Пример #1
0
 /// <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);
         }
     }
 }
Пример #2
0
        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);
        }
Пример #3
0
 /// <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);
         }
     }
 }
Пример #4
0
 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>();
 }
Пример #5
0
        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);
        }
Пример #6
0
        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();
        }
Пример #7
0
 public void AddToMruList(string val)
 {
     if (MruList.Count < MruMaxSize && !MruList.Contains(val))
     {
         MruList.Add(val);
     }
 }
Пример #8
0
        /// <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);
        }
Пример #9
0
 AsEnumerable(this MruList mrulist)
 {
     for (uint i = 0; i < mrulist.ItemCount; i++)
     {
         yield return(mrulist.GetItem(i));
     }
 }
Пример #10
0
 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>();
 }
Пример #11
0
 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();
 }
Пример #12
0
 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>();
 }
Пример #13
0
        public void Mru_Add()
        {
            MruList m = new MruList(2);

            m.Use("Hiz");
            Assert.AreEqual(1, m.Items.Count);
            Assert.AreEqual("Hiz", m.Items[0]);
        }
Пример #14
0
        public Jrfc.MruList GetRemoteMruList()
        {
            if (this.FileExtensionAssociations == null)
            {
                return(null);
            }

            return(MruList.CreateRemoteHostMruListByExtList(this.Hostname, this.FileExtensionAssociations));
        }
Пример #15
0
        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;
                }
            }
        }
Пример #16
0
        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);
        }
Пример #17
0
            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);
            }
Пример #18
0
 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();
 }
Пример #19
0
        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);
        }
Пример #20
0
 /// <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));
             }
         }
     }
 }
Пример #21
0
        /// <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);
            }
        }
Пример #22
0
 /// <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);
             }
         }
     }
 }
Пример #23
0
        /// <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));
            }
        }
Пример #24
0
        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));
        }
Пример #26
0
            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);
            }
Пример #27
0
            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);
            }
Пример #28
0
        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);
        }
Пример #29
0
        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
            }
        }
Пример #30
0
            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);
            }
Пример #31
0
        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();
        }
Пример #32
0
 public ApsimFileMetadata GetMruFile(string fileName)
 {
     return(MruList.Find(f => f.FileName == fileName));
 }