private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditorTabPage etb = GetActiveTab();

            if (etb != null)
            {
                etb.Delete();
            }
        }
        void etb_TextChanged(object sender, EventArgs e)
        {
            EditorTabPage etb = GetActiveTab();

            if (etb != null)
            {
                toolStripStatusLabel2.Text = string.Format("Line: {0}", (etb.Editor.ActiveTextAreaControl.TextArea.Caret.Line + 1).ToString());
                toolStripStatusLabel3.Text = string.Format("Col: {0}", etb.Editor.ActiveTextAreaControl.TextArea.Caret.Column.ToString());
            }
        }
        public TextEditorControl GetActiveEditor()
        {
            EditorTabPage etb = GetActiveTab();

            if (etb != null)
            {
                return(etb.Editor);
            }
            return(null);
        }
        private void cutLineToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditorTabPage etb = GetActiveTab();

            if (etb != null)
            {
                etb.SelectLine(etb.Editor.ActiveTextAreaControl.TextArea.Caret.Line);
                etb.Cut();
            }
        }
        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);
            }
        }
        protected override void OnClosing(CancelEventArgs e)
        {
            EditorConfigurationSection section = cfg.GetEditorConfiguration();

            section.MainWindowX.Value      = this.Location.X;
            section.MainWindowY.Value      = this.Location.Y;
            section.MainWindowWidth.Value  = this.Size.Width;
            section.MainWindowHeight.Value = this.Size.Height;

            cfg.SaveAll();

            unsavedDocumentsDialog.ClearDocuments();

            foreach (TabPage tb in tabControl1.TabPages)
            {
                if (tb is EditorTabPage)
                {
                    EditorTabPage etb = tb as EditorTabPage;
                    if (!etb.Saved)
                    {
                        unsavedDocumentsDialog.AddDocument(etb.GetFileFullPathAndName());
                    }
                }
            }

            if (unsavedDocumentsDialog.SelectedDocumentsCount > 0)
            {
                DialogResult dr = unsavedDocumentsDialog.ShowDialog();

                if (dr == DialogResult.Yes)
                {
                    IEnumerable <string> documents = unsavedDocumentsDialog.SelectedDocuments;

                    foreach (string document in documents)
                    {
                        string file = Path.GetFileName(document);

                        EditorTabPage etb = GetTabByTitle(file);

                        if (etb != null)
                        {
                            tabControl1.SelectedTab = etb;
                            saveToolStripMenuItem_Click(null, null);
                        }
                    }
                }
                else if (dr == DialogResult.Cancel)
                {
                    e.Cancel = true;
                }
            }

            base.OnClosing(e);
        }
        private void saveAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditorTabPage currentActiveTab = GetActiveTab();

            foreach (EditorTabPage etb in tabControl1.TabPages)
            {
                tabControl1.SelectedTab = etb;
                saveToolStripMenuItem_Click(null, null);
            }

            tabControl1.SelectedTab = currentActiveTab;
        }
 private void closeAllToolStripMenuItem_Click(object sender, EventArgs e)
 {
     foreach (TabPage tb in tabControl1.TabPages)
     {
         if (tb is EditorTabPage)
         {
             EditorTabPage etb = tb as EditorTabPage;
             tabControl1.SelectedTab = etb;
             closeToolStripMenuItem_Click(sender, e);
         }
     }
 }
示例#9
0
        private void clearSelectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return;
            }
            EditorTabPage etb = tb as EditorTabPage;

            etb.Editor.ActiveTextAreaControl.TextArea.SelectionManager.ClearSelection();
        }
示例#10
0
        private void insertNbspToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return;
            }
            EditorTabPage etb = tb as EditorTabPage;

            etb.InsertTextAtCursor("&nbsp;");
        }
        /*private void tabControl1_MouseClick (object sender, MouseEventArgs e)
         * {
         *  return;
         *  if (e.Button == MouseButtons.Right) {
         *      //Point pt = new Point(e.X, e.Y);
         *      Point pt = Cursor.Position;
         *      Point p = this.tabControl1.PointToClient (pt);
         *      for (int i = 0; i < this.tabControl1.TabCount; i++) {
         *          Rectangle r = this.tabControl1.GetTabRect (i);
         *          if (r.Contains (p)) {
         *              this.tabControl1.SelectedIndex = i; // i is the index of tab under cursor
         *              var menu = new ContextMenu ();
         *              menu.MenuItems.Add ("Закрыть", closeToolStripMenuItem_Click);
         *              if (tabControl1.SelectedTab as EditorTabPage != null) {
         *                  menu.MenuItems.Add ("-");
         *                  menu.MenuItems.Add ("Имя и путь файла скопировать", filepathnameToolStripMenuItem_Click);
         *                  menu.MenuItems.Add ("Директорию файла скопировать", foldernameToolStripMenuItem_Click);
         *              }
         *              menu.Show (this.tabControl1, p);
         *              SetupActiveTab ();
         *              return;
         *          }
         *      }
         *      //e.Cancel = true;
         *  }
         * }*/

        private void filepathnameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return;
            }
            EditorTabPage etb = tb as EditorTabPage;

            Globals.TextClipboard.CopyTextToClipboard(etb.GetFileFullPathAndName(), false);
        }
示例#12
0
        private void moveLineDownToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return;
            }
            EditorTabPage etb = tb as EditorTabPage;

            etb.MoveLineDown(etb.Editor.ActiveTextAreaControl.TextArea.Caret.Line);
        }
示例#13
0
        private void convertTextToHtmlToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return;
            }
            EditorTabPage etb = tb as EditorTabPage;

            etb.ConvertTextToHtml();
        }
示例#14
0
        private void MakeH6ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return;
            }
            EditorTabPage etb = tb as EditorTabPage;

            etb.MakeH("6");
        }
示例#15
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return;
            }
            EditorTabPage etb = tb as EditorTabPage;

            SaveTabToDisk(etb);
        }
示例#16
0
        private void enchanceImagelinkToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return;
            }
            EditorTabPage etb = tb as EditorTabPage;

            etb.EnchanceImagelink();
        }
示例#17
0
        private void wrapInToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return;
            }
            EditorTabPage etb = tb as EditorTabPage;

            MessageBox.Show("not implemented yet");
        }
        private void findAndReplaceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditorTabPage etb = GetActiveTab();

            if (etb != null)
            {
                if (findReplaceDialog.ShowDialog() == DialogResult.OK)
                {
                    etb.FindAndReplace(findReplaceDialog.Search, findReplaceDialog.Replacement, findReplaceDialog.Options);
                }
            }
        }
示例#19
0
        void etb_TextChanged(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return;
            }
            EditorTabPage etb = tb as EditorTabPage;

            toolStripStatusLabel2.Text = string.Format("Line: {0}", (etb.Editor.ActiveTextAreaControl.TextArea.Caret.Line + 1).ToString());
            toolStripStatusLabel3.Text = string.Format("Col: {0}", etb.Editor.ActiveTextAreaControl.TextArea.Caret.Column.ToString());
        }
示例#20
0
        public void UpdateMainWindowTitle()
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb is EditorTabPage)
            {
                EditorTabPage etb = tb as EditorTabPage;
                if (etb != null)
                {
                    this.Text = string.Format("MyPad - {0} [{1}]", etb.Text, etb.GetFileFullPathAndName());
                }
            }
        }
        private void findNextToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditorTabPage etb = GetActiveTab();

            if (etb != null)
            {
                int index = etb.Find(findDialog.Search, findDialog.Options);
                if (index >= 0)
                {
                    etb.ScrollToOffset(index);
                }
            }
        }
示例#22
0
 private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (optionsDialog.ShowDialog() == DialogResult.OK)
     {
         foreach (TabPage tb in tabControl1.TabPages)
         {
             if (tb is EditorTabPage)
             {
                 EditorTabPage etb = tb as EditorTabPage;
                 etb.ReloadSettings();
             }
         }
     }
 }
示例#23
0
        private void copyLineToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return;
            }
            EditorTabPage etb = tb as EditorTabPage;

            etb.SelectLine(etb.Editor.ActiveTextAreaControl.TextArea.Caret.Line);
            etb.Copy();

            clearSelectionToolStripMenuItem_Click(null, null);
        }
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditorTabPage etb        = new EditorTabPage();
            string        newTabName = string.Format("Untitled{0}", GetUntitledTabCount());

            etb.SetTitle(newTabName);
            etb.Editor.DragEnter        += new DragEventHandler(tabControl1_DragEnter);
            etb.Editor.DragDrop         += new DragEventHandler(tabControl1_DragDrop);
            etb.OnEditorTextChanged     += new EventHandler(etb_TextChanged);
            etb.OnEditorFilenameChanged += new EventHandler(etb_FilenameChanged);
            etb.Show();

            tabControl1.TabPages.Add(etb);
            tabControl1.SelectedTab = etb;
        }
示例#25
0
 public EditorTabPage GetTabByTitle(string title)
 {
     foreach (TabPage tb in tabControl1.TabPages)
     {
         if (tb is EditorTabPage)
         {
             EditorTabPage etb = tb as EditorTabPage;
             if (etb.Text == title || etb.Text.StartsWith(title))
             {
                 return(etb);
             }
         }
     }
     return(null);
 }
        private void Highlighting_Click(object sender, EventArgs e)
        {
            EditorTabPage     etb = GetActiveTab();
            ToolStripMenuItem tsi = (ToolStripMenuItem)sender;

            if (etb != null)
            {
                etb.SetHighlighting(tsi.Text);
                string name = etb.GetHighlighting();

                if (tsi.Text.Equals(name))
                {
                    tsi.Checked = true;
                }
            }
        }
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditorTabPage currentActiveTab = tabControl1.SelectedTab as EditorTabPage;

            bool          bSavingNecessary = true;
            EditorTabPage etb        = new EditorTabPage();
            string        newTabName = null;

            string nearestInternalLink = GetNearestInternalLink(etb.Editor);

            if (string.IsNullOrWhiteSpace(nearestInternalLink))
            {
                newTabName       = string.Format("Untitled{0}", tabControl1.GetUntitledTabCount());
                bSavingNecessary = false; // это совершенно новый файл и его можно не сохранять
            }
            else
            {
                string name = newTabName = string.Format("Untitled{0}", tabControl1.GetUntitledTabCount());
                // name = nearestInternalLink;
                string fullPath = Path.Combine(etb.GetFileFullPathAndName(), name);
                if (File.Exists(fullPath))
                {
                    InternalOpenFile(fullPath);
                    return;
                }
                newTabName = fullPath;
                // А здесь уже есть полезная информация от пользователя - имя файла,
                // поэтому не сохранять молча уже нельзя
            }

            var oldName = currentActiveTab == null ? String.Empty : currentActiveTab.GetFileFullPathAndName();

            etb.Editor.Text       = Globals.GetDefaultTemplateText(newTabName, oldName, newTabName);
            etb.IsSavingNecessary = bSavingNecessary;
            etb.SetFileName(newTabName);


            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);
            etb.Show();

            tabControl1.TabPages.Add(etb);
            tabControl1.SelectedTab = etb;
        }
        void InternalOpenFile(string fileToLoad)
        {
            if (string.IsNullOrWhiteSpace(fileToLoad))
            {
                return;
            }
            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.OnEditorFilenameChanged += new EventHandler(etb_FilenameChanged);
            tabControl1.TabPages.Add(etb);
            etb.Show();
            tabControl1.SelectedTab = etb;
            etb.Update();

            if (!SettingsManager.MRUList.Contains(fileToLoad))
            {
                if (SettingsManager.MRUList.Count >= 15)
                {
                    SettingsManager.MRUList.RemoveAt(14);
                }
                SettingsManager.MRUList.Insert(0, fileToLoad);
                ToolStripMenuItem tsi = new ToolStripMenuItem(fileToLoad, null, new EventHandler(RecentFiles_Click));
                recentFilesToolStripMenuItem.DropDown.Items.Insert(0, tsi);
            }
            else
            {
                SettingsManager.MRUList.Remove(fileToLoad);
                SettingsManager.MRUList.Insert(0, fileToLoad);
                ToolStripMenuItem tsi = GetRecentMenuItem(fileToLoad);
                recentFilesToolStripMenuItem.DropDown.Items.Remove(tsi);
                recentFilesToolStripMenuItem.DropDown.Items.Insert(0, tsi);
            }
        }
示例#29
0
        private void findAndReplaceRawToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return;
            }
            EditorTabPage etb = tb as EditorTabPage;

            findReplaceDialog.SetFocusOnSearchTextField();
            findReplaceDialog.Text += " Raw";
            if (findReplaceDialog.ShowDialog() == DialogResult.OK)
            {
                etb.FindAndReplaceRaw(findReplaceDialog.Search, findReplaceDialog.Replacement, findReplaceDialog.Options);
            }
        }
示例#30
0
        private void findNextToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return;
            }
            EditorTabPage etb = tb as EditorTabPage;

            int index = etb.Find(findDialog.Search, findDialog.Options);

            if (index >= 0)
            {
                etb.ScrollToOffset(index);
            }
        }