Changeset 15 for Common/RecentFiles.cs
- Timestamp:
- Jun 18, 2024, 12:15:33 PM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/RecentFiles.cs
r14 r15 11 11 public int MaxCount = 10; 12 12 public event EventHandler Change; 13 public EventArgs e = null;14 13 15 14 public void AddItem(string fileName) … … 24 23 public void LimitMaxCount() 25 24 { 26 while(Items.Count > MaxCount)27 Items.Remove At(Items.Count - 1);25 if (Items.Count > MaxCount) 26 Items.RemoveRange(MaxCount, Items.Count - MaxCount); 28 27 } 29 28 … … 36 35 private void DoChange() 37 36 { 38 Change?.Invoke(this, new EventArgs());37 Change?.Invoke(this, EventArgs.Empty); 39 38 } 40 39 41 40 public void LoadFromRegistry(string regSubKey) 42 41 { 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); 45 44 46 45 int count = (int)regKey.GetValue("Count", 0); … … 55 54 public void SaveToRegistry(string regSubKey) 56 55 { 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); 59 58 60 59 regKey.SetValue("Count", Items.Count); … … 75 74 } 76 75 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); 78 78 for (int i = 0; i < Items.Count; i++) 79 79 {
Note:
See TracChangeset
for help on using the changeset viewer.