Beispiel #1
0
        internal static void ResetTab(Form1 form)
        {
            XtraTabControl    pagesTabControl   = form.pagesTabControl;
            CustomRichTextBox pageTextBox       = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);
            CustomLineNumbers customLineNumbers = ProgramUtil.GetCustomLineNumbers(pagesTabControl.SelectedTabPage);

            if (ColumnRulerManager.IsPanelOpen(form))
            {
                ColumnRulerManager.TogglePanel(form);
            }

            String newTabTitle = LanguageUtil.GetCurrentLanguageString("tabPage1", form.Name);

            SetTabColor(pagesTabControl.SelectedTabPage, Color.Black); //pagesTabControl.SelectedTabPage.Appearance.Header.ForeColor = Color.Black;
            pagesTabControl.SelectedTabPage.Appearance.Header.Reset();
            pageTextBox.Text = String.Empty;
            pagesTabControl.SelectedTabPage.ImageIndex = 0;
            pagesTabControl.SelectedTabPage.Text       = newTabTitle;
            pagesTabControl.SelectedTabPage.Tooltip    = newTabTitle;
            form.Text = String.Format("DtPad - {0}", newTabTitle);
            ProgramUtil.SetFilenameTabPage(pagesTabControl.SelectedTabPage, String.Empty);
            pageTextBox.CustomZoom           = 100;
            pageTextBox.CustomModified       = false;
            pageTextBox.CustomOriginal       = String.Empty.GetHashCode().ToString();
            pageTextBox.CustomEncoding       = String.Empty;
            pageTextBox.CustomEncodingForced = false;
            customLineNumbers.Width          = customLineNumbers.MinimumSize.Width;
            ZoomSelect(form, 100);
            pageTextBox.ClearUndo();

            TextManager.RefreshUndoRedoExternal(form);

            if (String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage)))
            {
                ToggleTabFileTools(form, false);
            }
            OtherManager.FocusOnEditor(form);
        }
Beispiel #2
0
        internal static int AddNewPage(Form1 form, int tabIdentity)
        {
            XtraTabControl    pagesTabControl              = form.pagesTabControl;
            ToolStripMenuItem wordWrapToolStripMenuItem    = form.wordWrapToolStripMenuItem;
            ToolStripMenuItem lineNumbersToolStripMenuItem = form.lineNumbersToolStripMenuItem;
            ContextMenuStrip  textBoxContextMenuStrip      = form.textBoxContextMenuStrip;

            bool rowNumbersVisibile = lineNumbersToolStripMenuItem.Checked;
            bool wordWrapEnabled    = wordWrapToolStripMenuItem.Checked;

            if (form.WindowMode == CustomForm.WindowModeEnum.Note)
            {
                rowNumbersVisibile = false;
                wordWrapEnabled    = true;
            }

            String newTabTitle = LanguageUtil.GetCurrentLanguageString("tabPage1", form.Name);

            tabIdentity++;
            String newTabPageName = String.Format("tabPage{0}", tabIdentity);

            XtraTabPage newTabPageControl = new XtraTabPage
            {
                ImageIndex = 0,
                Name       = newTabPageName,
                Padding    = new Padding(3),
                Text       = newTabTitle,
                Tooltip    = newTabTitle
            };

            //newTabPageControl.Appearance.Header.ForeColor = Color.Black;
            //newTabPageControl.Appearance.PageClient.BackColor = Color.White;
            newTabPageControl.TextChanged += form.tabPage_TextChanged;

            CustomRichTextBox newTabPageTextBox = new CustomRichTextBox
            {
                AcceptsTab           = true,
                AllowDrop            = true,
                AutoWordSelection    = false,
                BackColor            = form.TextBackgroundColor,
                BorderStyle          = BorderStyle.None,
                ContextMenuStrip     = textBoxContextMenuStrip,
                CustomEncodingForced = false,
                CustomInsertMode     = "INS",
                CustomModified       = false,
                CustomOriginal       = String.Empty.GetHashCode().ToString(),
                CustomZoom           = 100,
                DetectUrls           = ConfigUtil.GetBoolParameter("HighlightURL"),
                Dock          = DockStyle.Fill,
                Font          = form.TextFont,
                ForeColor     = form.TextFontColor,
                HideSelection = false,
                //Multiline = true,
                Name = "pageTextBox",
                //ScrollBars = RichTextBoxScrollBars.Both,
                Text     = String.Empty,
                WordWrap = wordWrapEnabled
            };

            newTabPageControl.Controls.Add(newTabPageTextBox);

            CustomLineNumbers customLineNumbers = new CustomLineNumbers
            {
                AutoSizing = true,
                BackColor  = form.TextBackgroundColor,
                BackgroundGradient_AlphaColor = Color.FromArgb(0, 0, 0, 0),
                BackgroundGradient_BetaColor  = SystemColors.Window,
                BackgroundGradient_Direction  = LinearGradientMode.Horizontal,
                BorderLines_Color             = Color.DeepSkyBlue,
                BorderLines_Style             = DashStyle.Solid,
                BorderLines_Thickness         = 1F,
                Dock                           = DockStyle.Left,
                DockSide                       = CustomLineNumbers.LineNumberDockSide.Left,
                Font                           = form.TextFont,
                ForeColor                      = SystemColors.AppWorkspace,
                GridLines_Color                = Color.DeepSkyBlue,
                GridLines_Style                = DashStyle.Solid,
                GridLines_Thickness            = 1F,
                LineNrs_Alignment              = ContentAlignment.TopRight,
                LineNrs_AntiAlias              = false,
                LineNrs_ClippedByItemRectangle = true,
                LineNrs_Offset                 = new Size(0, 0),
                Location                       = new Point(3, 3),
                Margin                         = new Padding(0),
                MarginLines_Color              = Color.DeepSkyBlue,
                MarginLines_Side               = CustomLineNumbers.LineNumberDockSide.Right,
                MarginLines_Style              = DashStyle.Dash,
                MarginLines_Thickness          = 1F,
                MinimumSize                    = new Size(47, 0),
                Name                           = "customLineNumbers",
                Padding                        = new Padding(0, 0, 7, 0),
                ParentRichTextBox              = newTabPageTextBox,
                Show_LineNrs                   = true,
                Show_MarginLines               = true,
                Size                           = new Size(47, 308),
                TabIndex                       = 2,
                Visible                        = rowNumbersVisibile
            };

            newTabPageControl.Controls.Add(customLineNumbers);

            Label newTabPageLabel = new Label
            {
                AutoSize = true,
                Location = new Point(3, 3),
                Name     = "filenameTabPage",
                Size     = new Size(0, 13),
                Visible  = false
            };

            newTabPageLabel.TextChanged += form.filenameTabPage_TextChanged;
            newTabPageControl.Controls.Add(newTabPageLabel);

            pagesTabControl.TabPages.Add(newTabPageControl);
            pagesTabControl.SelectedTabPage = newTabPageControl;

            ExplorerManager.AddNodeToTabExplorer(form, newTabPageControl.Text, newTabPageControl.Name, 0, 0);
            OtherManager.FocusOnEditor(form);
            WindowModeManager.AddRelaxModeMargins(form);

            return(tabIdentity);
        }
Beispiel #3
0
        private static bool ClosePage(Form1 form, bool showMessages, bool moreTabs, out bool closeAll)
        {
            XtraTabControl pagesTabControl = form.pagesTabControl;

            closeAll = false;

            if (showMessages && TabUtil.IsTabPageModified(pagesTabControl.SelectedTabPage))
            {
                if (moreTabs)
                {
                    DialogResult dialogResult = WindowManager.ShowQuestionCancelNoAllBox(form, LanguageUtil.GetCurrentLanguageString("SaveUntitled", className));

                    if ((dialogResult == DialogResult.Cancel) || (dialogResult == DialogResult.Yes && !FileManager.SaveFile(form, false)))
                    {
                        return(false);
                    }
                    if (dialogResult == DialogResult.Retry)
                    {
                        closeAll = true;
                    }
                }
                else
                {
                    DialogResult dialogResult = WindowManager.ShowQuestionCancelBox(form, LanguageUtil.GetCurrentLanguageString("SaveUntitled", className));

                    if ((dialogResult == DialogResult.Cancel) || (dialogResult == DialogResult.Yes && !FileManager.SaveFile(form, false)))
                    {
                        return(false);
                    }
                }
            }
            else if (!showMessages)
            {
                closeAll = true;
            }

            CustomPanel sectionsPanel   = ProgramUtil.GetSectionsPanel(pagesTabControl.SelectedTabPage);
            CustomPanel annotationPanel = ProgramUtil.GetAnnotationPanel(pagesTabControl.SelectedTabPage);

            if (sectionsPanel != null)
            {
                pagesTabControl.SelectedTabPage.Controls.Remove(sectionsPanel);
            }
            if (annotationPanel != null)
            {
                pagesTabControl.SelectedTabPage.Controls.Remove(annotationPanel);
            }

            if (pagesTabControl.TabPages.Count > 1)
            {
                String selectedTabName  = pagesTabControl.SelectedTabPage.Name;
                int    selectedTabIndex = pagesTabControl.SelectedTabPageIndex;

                pagesTabControl.TabPages.Remove(pagesTabControl.SelectedTabPage);
                ExplorerManager.RemoveNodeToTabExplorer(form, selectedTabName);

                pagesTabControl.SelectedTabPage = selectedTabIndex < pagesTabControl.TabPages.Count ? pagesTabControl.TabPages[selectedTabIndex] : pagesTabControl.TabPages[pagesTabControl.TabPages.Count - 1];

                if (String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage)))
                {
                    ToggleTabFileTools(form, false);
                }
                OtherManager.FocusOnEditor(form);
            }
            else
            {
                ResetTab(form);
            }

            return(true);
        }