示例#1
0
 public void Clear()
 {
     if (this.isOutput)
     {
         IORichTextBox box = richTextbox;
         box.Document.Blocks.Clear();
         box.Document.Blocks.Add(new Paragraph());
         box.MinPageWidth = 0.0f;
     }
     else
     {
         textEditor.Clear();
     }
 }
示例#2
0
        public void _AppendLine(string s, string color = null, string fonfamily = null, double fontsize = 0)
        {
            IORichTextBox richTextbox = this.richTextbox;
            Paragraph     lastBlock   = (Paragraph)this.richTextbox.Document.Blocks.LastBlock;
            Run           item        = new Run(s);

            if (color != null)
            {
                try
                {
                    item.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(color));
                }
                catch (FormatException)
                {
                    Console.WriteLine("错误的颜色字符串");
                }
            }
            if (fontsize == 0.0)
            {
                fontsize = richTextbox.FontSize;
            }
            item.FontSize = fontsize;
            if (fonfamily != null)
            {
                item.FontFamily = new FontFamily(fonfamily);
            }
            lastBlock.Inlines.Add(item);
            this.countLines++;
            if (this.countLines == maxLines)
            {
                this.richTextbox.Document.Blocks.Add(new Paragraph());
                this.countLines = 0;
                if (this.richTextbox.Document.Blocks.Count >= maxBuffer)
                {
                    this.richTextbox.Document.Blocks.Remove(this.richTextbox.Document.Blocks.FirstBlock);
                }
            }
            richTextbox.MinPageWidth = GetStringActuallyWidth(item) + fontsize;
            richTextbox.ScrollToEnd();
        }
示例#3
0
 public bool SetFontFamily(string s)
 {
     if (isOutput)
     {
         IORichTextBox temp = richTextbox;
         if (temp != null)
         {
             temp.FontFamily = new FontFamily(s);
             return(true);
         }
         return(false);
     }
     else
     {
         var temp = textEditor;
         if (temp != null)
         {
             temp.FontFamily = new FontFamily(s);
             return(true);
         }
         return(false);
     }
 }
示例#4
0
 public bool SetFontSize(double d)
 {
     if (isOutput)
     {
         IORichTextBox temp = richTextbox;
         if (temp != null)
         {
             temp.FontSize = d;
             return(true);
         }
         return(false);
     }
     else
     {
         var temp = textEditor;
         if (temp != null)
         {
             temp.FontSize = d;
             return(true);
         }
         return(false);
     }
 }
示例#5
0
        public IOTabItem(string name, string style, bool isOutput = true)
        {
            this.MinWidth = 20;

            this.isOutput = isOutput;

            // GRID
            Grid grid   = new Grid();
            var  topRow = new RowDefinition();

            topRow.Height = GridLength.Auto;
            grid.RowDefinitions.Add(topRow);
            grid.RowDefinitions.Add(new RowDefinition());
            var secRow = new RowDefinition();

            secRow.Height = GridLength.Auto;
            grid.RowDefinitions.Add(secRow);

            this.grid = grid;

            if (isOutput)
            {
                // RICHBOX
                IORichTextBox textBox = new IORichTextBox();
                textBox.Style          = (Style)Control.Resources[style];
                textBox.Document       = new FlowDocument(new Paragraph());
                textBox.Document.Style = (Style)Control.Resources["BoxFlowDocument"];
                this.richTextbox       = textBox;

                grid.Children.Add(textBox);
                Grid.SetRow(textBox, 1);
            }
            else
            {
                TextEditor textEditor = new TextEditor();
                textEditor.Style = (Style)Control.Resources[style];
                var temp = new TextEditorOptions();
                temp.ShowEndOfLine         = true;
                temp.ShowSpaces            = true;
                temp.ShowTabs              = true;
                temp.EnableEmailHyperlinks = false;
                temp.EnableHyperlinks      = false;
                temp.HighlightCurrentLine  = true;
                textEditor.TextArea.SelectionCornerRadius = 0;
                textEditor.Options                   = temp;
                textEditor.KeyUp                    += TextEditor_KeyUp;
                textEditor.PreviewKeyDown           += TextEditor_KeyDown;
                textEditor.PreviewMouseLeftButtonUp += TextEditor_MouseUp;
                textEditor.TextArea.TextEntered     += TextArea_TextEntered;
                //DataObject.AddPastingHandler(textEditor, TextArea_TextPasted);
                textEditor.ShowLineNumbers = true;
                this.textEditor            = textEditor;
                grid.Children.Add(textEditor);
                Grid.SetRow(textEditor, 1);
            }

            this.ClickCloseBtnCommand = new RelayCommand(collapseItem);
            DataContext = this;

            // WrapPanel
            WrapPanel panel = new WrapPanel();

            grid.Children.Add(panel);
            Grid.SetRow(panel, 0);
            this.wrapPanel = panel;

            // Tabitem
            this.Content  = grid;
            this.Header   = name;
            orignalHeader = name;
        }