コード例 #1
0
        internal static void ClearHighlightsResults(Form1 form)
        {
            XtraTabControl pagesTabControl = form.pagesTabControl;

            if (form.IsOpening)
            {
                return;
            }

            RichTextBox tempRichTextBox = new RichTextBox(); //Temporary RichTextBox to avoid too much undo/redo into buffer

            try
            {
                foreach (XtraTabPage tabPage in pagesTabControl.TabPages)
                {
                    CustomRichTextBox textBox = ProgramUtil.GetPageTextBox(tabPage);
                    textBox.SuspendPainting();

                    tempRichTextBox.Rtf = textBox.Rtf;
                    tempRichTextBox.SelectAll();
                    tempRichTextBox.Font = new Font(textBox.Font, FontStyle.Regular);
                    tempRichTextBox.SelectionBackColor = tempRichTextBox.BackColor;

                    RichTextBoxUtil.ReplaceRTFContent(textBox, tempRichTextBox);
                    textBox.ResumePainting();
                }
            }
            finally
            {
                tempRichTextBox.Dispose();
            }

            TextManager.RefreshUndoRedoExternal(form);
        }
コード例 #2
0
        internal static void SetPageTextBoxContextMenu(Form1 form, IEnumerable <ToolStripMenuItem> items)
        {
            XtraTabControl    pagesTabControl = form.pagesTabControl;
            CustomRichTextBox pageTextBox     = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);

            foreach (ToolStripMenuItem item in items)
            {
                item.Enabled = !String.IsNullOrEmpty(pageTextBox.SelectedText);
            }
        }
コード例 #3
0
        internal static Encoding GetTabTextEncoding(XtraTabPage tabPage)
        {
            CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(tabPage);

            Encoding fileEncoding;
            bool     encodingForced = Convert.ToBoolean(pageTextBox.CustomEncodingForced);

            if ((encodingForced && !String.IsNullOrEmpty(pageTextBox.CustomEncoding)) || (EncodingUtil.IsEncodingDefaultEnabled() && !String.IsNullOrEmpty(pageTextBox.CustomEncoding)))
            {
                fileEncoding = Encoding.GetEncoding(Convert.ToInt32(pageTextBox.CustomEncoding));
            }
            else
            {
                fileEncoding = EncodingUtil.GetDefaultEncoding();
            }

            return(fileEncoding);
        }
コード例 #4
0
        internal static int SearchCountOccurency(Form1 form, bool searchInAllFiles, bool forceDisableHighlight = false, String specificTextToSearch = null)
        {
            XtraTabControl pagesTabControl = form.pagesTabControl;
            CheckBox       caseCheckBox    = form.searchPanel.caseCheckBox;
            TextBox        searchTextBox   = form.searchPanel.searchTextBox;
            CheckBox       useRegularExpressionsCheckBox = form.searchPanel.regularExpressionsCheckBox;

            int    counter        = 0;
            String stringToSearch = !String.IsNullOrEmpty(specificTextToSearch) ? specificTextToSearch : searchTextBox.Text.Replace(ConstantUtil.newLineNotCompatible, ConstantUtil.newLine);

            if (searchInAllFiles)
            {
                foreach (XtraTabPage tabPage in pagesTabControl.TabPages)
                {
                    CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(tabPage);
                    String            text        = pageTextBox.Text;

                    if (!caseCheckBox.Checked)
                    {
                        stringToSearch = stringToSearch.ToLower();
                        text           = text.ToLower();
                    }

                    counter += StringUtil.SearchCountOccurences(text, stringToSearch, form, pageTextBox, forceDisableHighlight, useRegularExpressionsCheckBox.Checked);
                }
            }
            else
            {
                CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage);
                String            text        = pageTextBox.Text;

                if (!caseCheckBox.Checked)
                {
                    stringToSearch = stringToSearch.ToLower();
                    text           = text.ToLower();
                }

                counter = StringUtil.SearchCountOccurences(text, stringToSearch, form, pageTextBox, forceDisableHighlight, useRegularExpressionsCheckBox.Checked);
            }

            return(counter);
        }
コード例 #5
0
        internal static bool IsTabPageModified(XtraTabPage tabPage)
        {
            CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(tabPage);

            return(pageTextBox.CustomModified);
        }
コード例 #6
0
        internal static void SetTabTextEncoding(XtraTabPage tabPage, Encoding tabEncoding)
        {
            CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(tabPage);

            pageTextBox.CustomEncoding = tabEncoding.CodePage.ToString();
        }