Esempio n. 1
0
        private void AppendToMRU(string filename)
        {
            MRUListConfigurationSection mruList = cfg.GetMRUList();

            if (!mruList.Contains(filename))
            {
                if (mruList.Instances.Count >= 15)
                {
                    mruList.RemoveAt(14);
                }
                mruList.InsertAt(0, filename);

                ToolStripMenuItem tsi = new ToolStripMenuItem(filename, null, new EventHandler(RecentFiles_Click));
                recentFilesToolStripMenuItem.DropDown.Items.Insert(0, tsi);
            }
            else
            {
                mruList.Remove(filename);
                mruList.InsertAt(0, filename);

                ToolStripMenuItem tsi = GetRecentMenuItem(filename);
                recentFilesToolStripMenuItem.DropDown.Items.Remove(tsi);
                recentFilesToolStripMenuItem.DropDown.Items.Insert(0, tsi);
            }
        }
Esempio n. 2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string file = openFileDialog1.FileName;

                InternalOpenFile(file);

                MRUListConfigurationSection mruList = cfg.GetMRUList();
                if (!mruList.Contains(file))
                {
                    if (mruList.Instances.Count >= 15)
                    {
                        mruList.RemoveAt(14);
                    }
                    mruList.InsertAt(0, file);

                    ToolStripMenuItem tsi = new ToolStripMenuItem(file, null, new EventHandler(RecentFiles_Click));
                    recentFilesToolStripMenuItem.DropDown.Items.Insert(0, tsi);
                }
                else
                {
                    mruList.Remove(file);
                    mruList.InsertAt(0, file);

                    ToolStripMenuItem tsi = GetRecentMenuItem(file);
                    recentFilesToolStripMenuItem.DropDown.Items.Remove(tsi);
                    recentFilesToolStripMenuItem.DropDown.Items.Insert(0, tsi);
                }
            }
        }
        internal void InternalOpenFile(string fileToLoad)
        {
            if (string.IsNullOrWhiteSpace(fileToLoad))
            {
                return;
            }
            if (this.WindowState != FormWindowState.Normal)
            {
                this.WindowState = FormWindowState.Normal;
            }
            this.BringToFront();

            var tab = FindTabByPath(fileToLoad);

            if (tab != null)
            {
                tabControl1.SelectedTab = tab;
                SetupActiveTab();
                return;
            }

            EditorTabPage etb = new EditorTabPage();

            etb.LoadFile(fileToLoad);
            etb.Editor.DragEnter           += new DragEventHandler(tabControl1_DragEnter);
            etb.Editor.DragDrop            += new DragEventHandler(tabControl1_DragDrop);
            etb.OnEditorTextChanged        += new EventHandler(etb_TextChanged);
            etb.OnEditorTabFilenameChanged += new EventHandler(TabControl_TabCaptionUpdate);
            etb.OnEditorTabStateChanged    += new EventHandler(TabControl_TabCaptionUpdate);
            tabControl1.TabPages.Add(etb);
            etb.Show();
            tabControl1.SelectedTab = etb;
            etb.Update();

            MRUListConfigurationSection mruList = cfg.GetMRUList();

            if (!mruList.Contains(fileToLoad))
            {
                if (mruList.Instances.Count >= 15)
                {
                    mruList.RemoveAt(14);
                }
                mruList.InsertAt(0, fileToLoad);
                ToolStripMenuItem tsi = new ToolStripMenuItem(fileToLoad, null, new EventHandler(RecentFiles_Click));
                recentFilesToolStripMenuItem.DropDown.Items.Insert(0, tsi);
            }
            else
            {
                mruList.Remove(fileToLoad);
                mruList.InsertAt(0, fileToLoad);
                ToolStripMenuItem tsi = GetRecentMenuItem(fileToLoad);
                recentFilesToolStripMenuItem.DropDown.Items.Remove(tsi);
                recentFilesToolStripMenuItem.DropDown.Items.Insert(0, tsi);
            }
        }
Esempio n. 4
0
        public static MRUListConfigurationSection GetMRUList(this Configuration cfg)
        {
            MRUListConfigurationSection section = cfg.GetSection("MRUList") as MRUListConfigurationSection;

            if (section == null)
            {
                section = new MRUListConfigurationSection();
                cfg.Sections.Add("MRUList", section);
            }
            //section.SectionInformation.ForceSave = true;
            return(section);
        }
        public MainForm()
        {
            cfg = Globals.LoadConfiguration();
            InitializeComponent();
            InitializeIndexedSearchTabPageMenuItem();
            InitializeTabContextMenu();

            MRUListConfigurationSection mruList = cfg.GetMRUList();

            if (mruList.Instances.Count > 0)
            {
                foreach (MRUListElement record in mruList.Instances)
                {
                    ToolStripItem tsi = new ToolStripMenuItem(record.FileName);
                    tsi.Click += new EventHandler(RecentFiles_Click);
                    recentFilesToolStripMenuItem.DropDown.Items.Add(tsi);
                }
            }

            unsavedDocumentsDialog = new UnsavedDocumentsDialog();
            optionsDialog          = new OptionsDialog();
            entriesListDialog      = new EntriesListDialog();
            aboutDialog            = new AboutDialog();

            tabControl1.DrawMode              = TabDrawMode.OwnerDrawFixed;
            tabControl1.DrawItem             += new System.Windows.Forms.DrawItemEventHandler(this.tabControl1_DrawItem);
            tabControl1.SelectedIndexChanged += new EventHandler(tabControl1_SelectedIndexChanged);
            tabControl1.DragEnter            += new DragEventHandler(tabControl1_DragEnter);
            tabControl1.DragDrop             += new DragEventHandler(tabControl1_DragDrop);

            var editorConfiguration = cfg.GetEditorConfiguration();
            int x     = editorConfiguration.MainWindowX.Value;
            int y     = editorConfiguration.MainWindowY.Value;
            int width = editorConfiguration.MainWindowWidth.Value;

            if (width < 100)
            {
                width = 800;
            }

            int height = editorConfiguration.MainWindowHeight.Value;

            if (height < 100)
            {
                height = 600;
            }

            this.StartPosition = FormStartPosition.Manual;
            this.Location      = new Point(x, y);
            this.Size          = new Size(width, height);
        }