コード例 #1
0
ファイル: form1.cs プロジェクト: yashbajra/samples
        //************************************************************************************
        //
        // Remove the highlighted XML in the XML pane.
        //
        //************************************************************************************
        private void unHighlightXML()
        {
            // Set any previously selected text back to black.
            XmlTextBox.Select(_selectionStart, _selectionLength);
            Font tempFont = new Font(FontFamily.GenericSansSerif, 10F, FontStyle.Regular);

            XmlTextBox.SelectionFont  = tempFont;
            XmlTextBox.SelectionColor = Color.White;
        }
コード例 #2
0
ファイル: form1.cs プロジェクト: yashbajra/samples
        //************************************************************************************
        //
        // Highlight XML in the XML pane. Use the current selection in the TreeView node to
        // choose which element to highlight.
        //
        //************************************************************************************
        private bool highlightXML()
        {
            XmlNode selectedBookNode = _xmlHelperMethods.GetBook(_ISBNOfSelectedBookNode, _doc);

            if (selectedBookNode != null)
            {
                _currentlySelectedNode = selectedBookNode;

                // Use node to get search string.
                string stringToHighlight = selectedBookNode.OuterXml;

                // Cannot search RichTextBox with newlines so do some magic to get the highlight string.
                int numberOfCharactersBefore = stringToHighlight.Substring(0, stringToHighlight.IndexOf(_ISBNOfSelectedBookNode)).Length;
                int lengthOfSelection        = stringToHighlight.Length - Constants.lengthOfNamespaceDeclaration;

                // Highlight the new selected text.
                XmlTextBox.SelectionLength = _ISBNOfSelectedBookNode.Length;
                int tempSelectionIndex = XmlTextBox.Find(_ISBNOfSelectedBookNode);

                // Select the entire node in the RichTextBox. Not just the attribute value.
                XmlTextBox.SelectionStart  = tempSelectionIndex - numberOfCharactersBefore;
                XmlTextBox.SelectionLength = lengthOfSelection;

                // Store globally because user can manually select XML Text box and we need to know highlighted area later.
                _selectionStart  = XmlTextBox.SelectionStart;
                _selectionLength = XmlTextBox.SelectionLength;

                Font tempFont = new Font(FontFamily.GenericSansSerif, 9F, FontStyle.Bold);
                XmlTextBox.SelectionFont  = tempFont;
                XmlTextBox.SelectionColor = Color.Yellow;
                XmlTextBox.ScrollToCaret();

                populateEditBoxes();

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
ファイル: MetaForm.cs プロジェクト: smallo92/CodeWalker
        private void UpdateTextBoxFromData()
        {
            LoadingXml          = true;
            XmlTextBox.Text     = "";
            XmlTextBox.Language = Language.XML;
            DelayHighlight      = false;

            if (string.IsNullOrEmpty(xml))
            {
                LoadingXml = false;
                return;
            }
            //if (xml.Length > (1048576 * 5))
            //{
            //    XmlTextBox.Language = Language.Custom;
            //    XmlTextBox.Text = "[XML size > 10MB - Not shown due to performance limitations - Please use an external viewer for this file.]";
            //    return;
            //}
            //else
            if (xml.Length > (1024 * 512))
            {
                XmlTextBox.Language = Language.Custom;
                DelayHighlight      = true;
            }
            //else
            //{
            //    XmlTextBox.Language = Language.XML;
            //}


            Cursor = Cursors.WaitCursor;



            XmlTextBox.Text = xml;
            //XmlTextBox.IsChanged = false;
            XmlTextBox.ClearUndo();

            Cursor     = Cursors.Default;
            LoadingXml = false;
        }
コード例 #4
0
 private void LoadXML(string path)
 {
     XmlTextBox.Clear();
     XmlTextBox.Text = DecrtyptLoadXML(path);
 }