Changeset 15 for Common/RecentFiles.cs


Ignore:
Timestamp:
Jun 18, 2024, 12:15:33 PM (5 months ago)
Author:
chronos
Message:
  • Modified: Updated files.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/RecentFiles.cs

    r14 r15  
    1111        public int MaxCount = 10;
    1212        public event EventHandler Change;
    13         public EventArgs e = null;
    1413
    1514        public void AddItem(string fileName)
     
    2423        public void LimitMaxCount()
    2524        {
    26             while (Items.Count > MaxCount)
    27                 Items.RemoveAt(Items.Count - 1);
     25            if (Items.Count > MaxCount)
     26                Items.RemoveRange(MaxCount, Items.Count - MaxCount);
    2827        }
    2928
     
    3635        private void DoChange()
    3736        {
    38             Change?.Invoke(this, new EventArgs());
     37            Change?.Invoke(this, EventArgs.Empty);
    3938        }   
    4039
    4140        public void LoadFromRegistry(string regSubKey)
    4241        {
    43             RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(regSubKey);
    44             if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(regSubKey);
     42            RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(regSubKey) ??
     43                                Application.UserAppDataRegistry.CreateSubKey(regSubKey);
    4544
    4645            int count = (int)regKey.GetValue("Count", 0);
     
    5554        public void SaveToRegistry(string regSubKey)
    5655        {
    57             RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(regSubKey, true);
    58             if (regKey == null) regKey = Application.UserAppDataRegistry.CreateSubKey(regSubKey);
     56            RegistryKey regKey = Application.UserAppDataRegistry.OpenSubKey(regSubKey, true) ??
     57                                Application.UserAppDataRegistry.CreateSubKey(regSubKey);
    5958
    6059            regKey.SetValue("Count", Items.Count);
     
    7574            }
    7675
    77             while (menuItem.DropDownItems.Count > Items.Count) menuItem.DropDownItems.RemoveAt(menuItem.DropDownItems.Count - 1);
     76            while (menuItem.DropDownItems.Count > Items.Count)
     77                menuItem.DropDownItems.RemoveAt(menuItem.DropDownItems.Count - 1);
    7878            for (int i = 0; i < Items.Count; i++)
    7979            {
Note: See TracChangeset for help on using the changeset viewer.