/// <summary>Add a filename to the list.</summary> /// <param name="file">File metadata.</param> public void AddMruFile(ApsimFileMetadata file) { if (file.FileName.Length > 0) // Do we really need this check? { if (MruList.Count > 0) { int index = MruList.FindIndex(f => f.FileName == file.FileName); if (index < 0) { // First time that filename has been added if (MruList.Count >= FilesInHistory) { MruList.RemoveAt(MruList.Count - 1); // Delete the last item } } else { // Item is in the history list => move to top file = MruList[index]; MruList.RemoveAt(index); } MruList.Insert(0, file); } else { MruList.Add(file); } } }
public SysTrayMenu() { InitializeComponent(); this.ClientSize = new System.Drawing.Size(FORM_WIDTH, Screen.PrimaryScreen.WorkingArea.Height); this.LostFocus += (object sender, EventArgs e) => MoveOutScreen(); MoveOutScreen(); trayMenu = new ContextMenu(); trayMenu.MenuItems.Add("Exit", OnExit); trayMenu.MenuItems.Add("Show", OnShow); trayIcon = new NotifyIcon(); trayIcon.Text = "eClipx"; trayIcon.Icon = new Icon(SystemIcons.Application, 40, 40); trayIcon.ContextMenu = trayMenu; trayIcon.Visible = true; KeyboardHook.CallWhen(true, true, Keys.X, GlobalHookKeyPress); Common.MyHandle = Handle; CurrentApp.StartWatcher(); clipboardItems = new MruList<int, ClipBoardElement>(CACHE_SIZE); controlItems = new List<ItemControl>(CACHE_SIZE); nextClipboardViewer = (IntPtr)User32.SetClipboardViewer((int)this.Handle); }
/// <summary>Add a filename to the list.</summary> /// <param name="filename">File path</param> public void AddMruFile(string filename) { if (filename.Length > 0) { if (MruList.Count > 0) { if (MruList.IndexOf(filename) < 0) { // First time that filename has been added if (MruList.Count >= FilesInHistory) { MruList.RemoveAt(MruList.Count - 1); // Delete the last item } } else { // Item is in the history list => move to top MruList.RemoveAt(MruList.IndexOf(filename)); } MruList.Insert(0, filename); } else { MruList.Add(filename); } } }
public MainFormInteractor(IServiceProvider services) { this.dlgFactory = services.RequireService <IDialogFactory>(); this.mru = new MruList(MaxMruItems); this.mru.Load(services.RequireService <IFileSystemService>(), MruListFile); this.sc = services.RequireService <IServiceContainer>(); }
internal void AddMruItem(string path) { if (path == null) { throw new ArgumentNullException("path"); } if (path.Length == 0) { throw new ArgumentOutOfRangeException("'path' is zero-length."); } // get... MruList list = this.GetMruItems(); if (list == null) { throw new InvalidOperationException("list is null."); } // add... list.Push(path); // save... string xml = list.ToXml(); if (xml == null) { throw new InvalidOperationException("'xml' is null."); } if (xml.Length == 0) { throw new InvalidOperationException("'xml' is zero-length."); } Runtime.Current.UserSettings.SetValue(ProjectMruListKey, xml); }
private void InitializeApplication() { m_tabPages = new List <IEditorTabPage> { new ImageEditorTabPage(m_definitions, m_resourcePackManager) { Dock = DockStyle.Fill }, new StringEditorTabPage { Dock = DockStyle.Fill }, new PatchesTabPage(m_patchManager) { Dock = DockStyle.Fill }, new ResourcePacksTabPage(m_resourcePackManager) { Dock = DockStyle.Fill } }; m_definitions = m_firmwareDefinitionManager.Load(); m_configuration = m_configurationManager.Load(); m_mruFirmwares = new MruList <string>(m_configuration.MostRecentlyUsed); m_patchManager.InitializeStorage(m_definitions); InitializeApplicationWindow(); InitializeOpenWithSpecifiedDefinitionMenu(); InitializeMruMenu(); InitializeTabPages(); InitializeUpdatesChecking(); }
public void AddToMruList(string val) { if (MruList.Count < MruMaxSize && !MruList.Contains(val)) { MruList.Add(val); } }
/// <summary> /// Gets the MRU items. /// </summary> /// <returns></returns> internal MruList GetMruItems() { // xml... string xml = Runtime.Current.UserSettings.GetStringValue(ProjectMruListKey, null, Cultures.System, OnNotFound.ReturnNull); // get... MruList list = null; if (!(string.IsNullOrEmpty(xml))) { list = MruList.LoadXml(xml); if (list == null) { throw new InvalidOperationException("'list' is null."); } } // dod we get it? if (list == null) { list = new MruList(5); } // return... return(list); }
AsEnumerable(this MruList mrulist) { for (uint i = 0; i < mrulist.ItemCount; i++) { yield return(mrulist.GetItem(i)); } }
public MainFormInteractor(IServiceProvider services) { this.dlgFactory = services.RequireService <IDialogFactory>(); this.mru = new MruList(MaxMruItems); this.mru.Load(MruListFile); this.sc = services.RequireService <IServiceContainer>(); this.nextPage = new Dictionary <IPhasePageInteractor, IPhasePageInteractor>(); }
public MainFormInteractor(IServiceProvider services) { this.dlgFactory = services.RequireService <IDialogFactory>(); this.mru = new MruList(MaxMruItems); this.mru.Load(MruListFile); this.sc = services.RequireService <IServiceContainer>(); this.CancellationTokenSource = new CancellationTokenSource(); }
public MainFormInteractor(IServiceProvider services) { this.dlgFactory = services.RequireService<IDialogFactory>(); this.mru = new MruList(MaxMruItems); this.mru.Load(MruListFile); this.sc = services.RequireService<IServiceContainer>(); this.nextPage = new Dictionary<IPhasePageInteractor, IPhasePageInteractor>(); }
public void Mru_Add() { MruList m = new MruList(2); m.Use("Hiz"); Assert.AreEqual(1, m.Items.Count); Assert.AreEqual("Hiz", m.Items[0]); }
public Jrfc.MruList GetRemoteMruList() { if (this.FileExtensionAssociations == null) { return(null); } return(MruList.CreateRemoteHostMruListByExtList(this.Hostname, this.FileExtensionAssociations)); }
private void RefreshMruList() { // mru... MruList list = ProjectStore.CurrentStore.GetMruItems(); if (list == null) { throw new InvalidOperationException("list is null."); } // set... const int maxItems = 5; for (int index = 0; index < maxItems; index++) { ProjectLinkLabel link = null; switch (index) { case 0: link = this.link1; break; case 1: link = this.link2; break; case 2: link = this.link3; break; case 3: link = this.link4; break; case 4: link = this.link5; break; default: throw new NotSupportedException(string.Format("Cannot handle '{0}' ({1}).", index, index.GetType())); } // set... if (list.Count > index) { link.FilePath = (string)((IList)list)[index]; link.Enabled = true; } else { link.Text = "(None available)"; link.Enabled = false; } } }
private void InitializeStorages() { m_configurationStorage.Initialize(); m_firmwareDefinitionStorage.Initialize(); m_resourcePackStorage.Initialize(); m_definitions = m_firmwareDefinitionStorage.LoadAll(); m_configuration = m_configurationStorage.TryLoad(Paths.SettingsFile) ?? new ApplicationConfiguration(); m_mruFirmwares = new MruList <string>(m_configuration.MostRecentlyUsed); m_patchManager.InitializeStorage(m_definitions); }
public void Add_New_Patient() { IMruList mrulist = new MruList { Limit = 5, RecentList = new List <string>() }; string newP = ObjectId.GenerateNewId().ToString(); mrulist.AddPatient(newP.ToString()); Assert.AreEqual(1, mrulist.RecentList.Count); }
static Settings() { Color = new ColorSettings(); Regions = new List<Region> { new Region {RegionName = Region.DefaultRegion, RColor = System.Drawing.Color.White} }; RecentProjects = new MruList(); Reset(); ResetApplicationSettings(); LoadApplicationSettings(); }
private void InitializeStorages() { m_configurationStorage.Initialize(); m_firmwareDefinitionStorage.Initialize(); m_resourcePackStorage.Initialize(); m_definitions = m_firmwareDefinitionStorage.LoadAll().ToList(); m_configuration = m_configurationStorage.TryLoad(NFEPaths.SettingsFile) ?? new ApplicationConfiguration(); m_mruFirmwares = new MruList <string>(m_configuration.MostRecentlyUsed); m_patchManager.InitializeStorage(m_definitions); //m_updatesManager.SetupInitialData(Consts.ApplicationVersion, m_definitions); }
/// <summary>Remove a specified file from the list</summary> /// <param name="filename">The file name to delete</param> public void DelMruFile(string filename) { if (filename.Length > 0) { if (MruList.Count > 0) { if (MruList.IndexOf(filename) >= 0) { MruList.RemoveAt(MruList.IndexOf(filename)); } } } }
/// <summary>Remove a specified file from the list</summary> /// <param name="fileName">The file name to delete</param> public void DelMruFile(string fileName) { if (string.IsNullOrEmpty(fileName) || MruList == null || MruList.Count < 1) { return; } int index = MruList.FindIndex(f => f.FileName == fileName); if (index >= 0) { MruList.RemoveAt(index); } }
/// <summary>Rename a specified file in the list</summary> /// <param name="filename">The file name to rename</param> /// <param name="newname">The new file name</param> public void RenameMruFile(string filename, string newname) { if (filename.Length > 0) { if (MruList.Count > 0) { int idx = MruList.IndexOf(filename); if (idx >= 0) { MruList.RemoveAt(idx); MruList.Insert(idx, newname); } } } }
/// <summary>Rename a specified file in the list</summary> /// <param name="fileName">The file name to rename</param> /// <param name="newName">The new file name</param> public void RenameMruFile(string fileName, string newName) { if (string.IsNullOrEmpty(fileName) || MruList == null || MruList.Count < 1) { return; } int index = MruList.FindIndex(f => f.FileName == fileName); if (index >= 0) { MruList.RemoveAt(index); MruList.Insert(index, new ApsimFileMetadata(newName)); } }
public void Dispose() { if (m_host != null) { MruList hostList = m_host.MainWindow.FileMruList; hostList.Clear(); // The list is actually a stack. foreach (KeyValuePair <string, object> item in m_list.Cast <KeyValuePair <string, object> >().Reverse()) { hostList.AddItem(item.Key, item.Value); } m_host = null; } }
private static IOConnectionInfo IOFromParameters(string strPath, string strUser, string strPassword) { IOConnectionInfo iocBase = IOConnectionInfo.FromPath(strPath); if (!string.IsNullOrEmpty(strUser)) { iocBase.UserName = strUser; } if (!string.IsNullOrEmpty(strPassword)) { iocBase.Password = strPassword; } if (!string.IsNullOrEmpty(iocBase.UserName)) { iocBase.CredSaveMode = IOCredSaveMode.UserNameOnly; } if (!string.IsNullOrEmpty(iocBase.Password)) { iocBase.CredSaveMode = IOCredSaveMode.SaveCred; } if (string.IsNullOrEmpty(iocBase.UserName) && string.IsNullOrEmpty(iocBase.Password)) { MruList mru = Program.MainForm.FileMruList; for (uint u = 0; u < mru.ItemCount; ++u) { IOConnectionInfo iocMru = (mru.GetItem(u).Value as IOConnectionInfo); if (iocMru == null) { Debug.Assert(false); continue; } if (iocMru.Path == iocBase.Path) { iocBase = iocMru.CloneDeep(); break; } } } return(MainForm.CompleteConnectionInfo(iocBase, false, true, true, false)); }
public void Add_Existing_Patient_to_Three_Top_Of_Stack() { IMruList mrulist = new MruList { Limit = 5, RecentList = new List <string>() }; ObjectId newP = ObjectId.GenerateNewId(); ObjectId newP2 = ObjectId.GenerateNewId(); ObjectId newP3 = ObjectId.GenerateNewId(); mrulist.AddPatient(newP.ToString()); mrulist.AddPatient(newP2.ToString()); mrulist.AddPatient(newP3.ToString()); mrulist.AddPatient(newP.ToString()); int result = mrulist.RecentList.IndexOf(newP.ToString()); Assert.AreEqual(0 + 1, result + 1); }
public void Add_Existing_Patient_to_Three() { IMruList mrulist = new MruList { Limit = 5, RecentList = new List <string>() }; ObjectId newP = ObjectId.GenerateNewId(); ObjectId newP2 = ObjectId.GenerateNewId(); ObjectId newP3 = ObjectId.GenerateNewId(); mrulist.AddPatient(newP.ToString()); mrulist.AddPatient(newP2.ToString()); mrulist.AddPatient(newP3.ToString()); int index = mrulist.RecentList.IndexOf(newP.ToString()) + 1; mrulist.AddPatient(newP.ToString()); int result = mrulist.RecentList.IndexOf(newP.ToString()) + 1; Assert.AreNotEqual(index, result); }
private void InitAutoCompletions() { Dictionary <string, bool> dUrls = new Dictionary <string, bool>(); Dictionary <string, bool> dUsers = new Dictionary <string, bool>(); MainForm mf = Program.MainForm; MruList l = ((mf != null) ? mf.FileMruList : null); if (l == null) { Debug.Assert(false); return; } for (uint u = 0; u < l.ItemCount; ++u) { IOConnectionInfo ioc = (l.GetItem(u).Value as IOConnectionInfo); if (ioc == null) { Debug.Assert(false); continue; } if (ioc.IsLocalFile()) { continue; } string str = ioc.Path; if (!string.IsNullOrEmpty(str)) { dUrls[str] = true; } str = ioc.UserName; if (!string.IsNullOrEmpty(str)) { dUsers[str] = true; } } InitAutoCompletion(m_tbUrl, dUrls); InitAutoCompletion(m_tbUserName, dUsers); }
public void Load(string filename) { try { XmlSerializer serializer = new XmlSerializer(typeof(PrefsData)); pd = (PrefsData)serializer.Deserialize(new StreamReader(filename)); if (MruList == null) { MruList = new ArrayList(); } if (MruList.Count > MruMaxSize) { MruList.RemoveRange(MruMaxSize, MruList.Count - MruMaxSize); } } catch (Exception) { // not found or corrupted, keep defaults } }
public void Add_Existing_6th_Patient_Not_There() { IMruList mrulist = new MruList { Limit = 5, RecentList = new List <string>() }; ObjectId newP = ObjectId.GenerateNewId(); ObjectId newP2 = ObjectId.GenerateNewId(); ObjectId newP3 = ObjectId.GenerateNewId(); ObjectId newP4 = ObjectId.GenerateNewId(); ObjectId newP5 = ObjectId.GenerateNewId(); ObjectId newP6 = ObjectId.GenerateNewId(); mrulist.AddPatient(newP.ToString()); mrulist.AddPatient(newP2.ToString()); mrulist.AddPatient(newP3.ToString()); mrulist.AddPatient(newP4.ToString()); mrulist.AddPatient(newP5.ToString()); mrulist.AddPatient(newP6.ToString()); string found = mrulist.RecentList.Find(o => o.Equals(newP.ToString())); Assert.IsNull(found); }
private void InitializeApplication() { m_tabPages = new List<IEditorTabPage> { new ImageEditorTabPage(m_definitions, m_resourcePackManager) { Dock = DockStyle.Fill }, new StringEditorTabPage { Dock = DockStyle.Fill }, new PatchesTabPage(m_patchManager) { Dock = DockStyle.Fill }, new ResourcePacksTabPage(m_resourcePackManager) { Dock = DockStyle.Fill } }; m_definitions = m_firmwareDefinitionManager.Load(); m_configuration = m_configurationManager.Load(); m_mruFirmwares = new MruList<string>(m_configuration.MostRecentlyUsed); m_patchManager.InitializeStorage(m_definitions); InitializeApplicationWindow(); InitializeOpenWithSpecifiedDefinitionMenu(); InitializeMruMenu(); InitializeTabPages(); InitializeUpdatesChecking(); }
public ApsimFileMetadata GetMruFile(string fileName) { return(MruList.Find(f => f.FileName == fileName)); }