public OptionsDialog(TextEditorControl textEditorControl)
    {
      InitializeComponent();

      // Show the properties of the TextEditorControl
      propertyGrid.SelectedObject = textEditorControl;
    }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextArea"/> class.
        /// </summary>
        /// <param name="motherTextEditorControl">The mother text editor control.</param>
        /// <param name="motherTextAreaControl">The mother text area control.</param>
        public TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl)
        {
            _motherTextAreaControl = motherTextAreaControl;
              _motherTextEditorControl = motherTextEditorControl;
              _caret = new Caret(this);
              _selectionManager = new SelectionManager(Document, this);
              _textAreaClipboardHandler = new TextAreaClipboardHandler(this);
              ResizeRedraw = true;

              SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
              SetStyle(ControlStyles.AllPaintingInWmPaint, true);
              SetStyle(ControlStyles.UserPaint, true);
              SetStyle(ControlStyles.Opaque, false);
              SetStyle(ControlStyles.ResizeRedraw, true);
              SetStyle(ControlStyles.Selectable, true);

              _lineNumberMargin = new LineNumberMargin(this);
              _foldMargin = new FoldMargin(this);
              _iconMargin = new IconMargin(this);
              _leftMargins.AddRange(new AbstractMargin[] { _iconMargin, _lineNumberMargin, _foldMargin });
              _textView = new TextView(this);
              OptionsChanged();

              new TextAreaMouseHandler(this).Attach();
              new TextAreaDragDropHandler().Attach(this);

              _bracketHighlightingSchemes.Add(new BracketHighlightingScheme('{', '}'));
              _bracketHighlightingSchemes.Add(new BracketHighlightingScheme('(', ')'));
              _bracketHighlightingSchemes.Add(new BracketHighlightingScheme('[', ']'));

              _caret.PositionChanged += SearchMatchingBracket;
              Document.TextContentChanged += TextContentChanged;
              Document.FoldingManager.FoldingChanged += DocumentFoldingsChanged;
        }
Esempio n. 3
0
        public static TextEditorControl Build(string highlighting, 
            IFoldingStrategy foldingStrategy, 
            AbstractInsightDataProvider insight)
        {
            var ret = new TextEditorControl();

            /*_completionProvider = completionProvider;
            _insight = insight;

            ret.Document.FormattingStrategy = new CSharpFormattingStrategy();
            ret.Document.FoldingManager.FoldingStrategy = foldingStrategy;

            ret.CompletionRequest += new EventHandler<CompletionEventArgs>(CompletionRequest);
            ret.InsightRequest += new EventHandler<InsightEventArgs>(InsightRequest);
            ret.ToolTipRequest += new EventHandler<ToolTipRequestEventArgs>(ToolTipRequest);
            */

            ret.Dock = DockStyle.Fill;

            Font consolasFont = new Font("Consolas", 9.75f);
            ret.Font = consolasFont;

            var timer = new Timer();
            timer.Enabled = true;
            timer.Interval = 2000;
            timer.Tick += new EventHandler(UpdateFoldings);
            timer.Tag = ret;

            ret.Document.HighlightingStrategy = HighlightingManager.Manager.FindHighlighterForFile(highlighting);

            return ret;
        }
Esempio n. 4
0
        public MainForm()
        {
            InitializeComponent();

            // Hook events
            txtInput.Document.DocumentChanged += new EventHandler<DigitalRune.Windows.TextEditor.Document.DocumentEventArgs>(RegexDataChanged);
            txtPattern.Document.DocumentChanged += new EventHandler<DigitalRune.Windows.TextEditor.Document.DocumentEventArgs>(RegexDataChanged);

            // Default Cut/Paste operations to data box
            _activeControl = txtInput;

            // Pull up defaults
            _colors = new ProjectColorScheme();
            LoadInitSettings();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TextAreaControl"/> class.
        /// </summary>
        /// <param name="motherTextEditorControl">The mother text editor control.</param>
        public TextAreaControl(TextEditorControl motherTextEditorControl)
        {
            _motherTextEditorControl = motherTextEditorControl;
              _textArea = new TextArea(motherTextEditorControl, this);
              Controls.Add(_textArea);

              _vScrollBar.ValueChanged += VScrollBarValueChanged;
              _hScrollBar.ValueChanged += HScrollBarValueChanged;
              SetScrollBars();

              ResizeRedraw = true;

              Document.TextContentChanged += DocumentTextContentChanged;
              Document.DocumentChanged += AdjustScrollBarsOnDocumentChange;
              Document.UpdateCommited += DocumentUpdateCommitted;
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextAreaControl"/> class.
        /// </summary>
        /// <param name="motherTextEditorControl">The mother text editor control.</param>
        public TextAreaControl(TextEditorControl motherTextEditorControl)
        {
            _motherTextEditorControl = motherTextEditorControl;
            _textArea = new TextArea(motherTextEditorControl, this);
            Controls.Add(_textArea);

            _vScrollBar.ValueChanged += VScrollBarValueChanged;
            _hScrollBar.ValueChanged += HScrollBarValueChanged;
            SetScrollBars();

            ResizeRedraw = true;

            Document.TextContentChanged += DocumentTextContentChanged;
            Document.DocumentChanged    += AdjustScrollBarsOnDocumentChange;
            Document.UpdateCommited     += DocumentUpdateCommitted;
        }
Esempio n. 7
0
 /// <summary>
 /// Releases the unmanaged resources used by the <see cref="Control"></see> and its child controls and optionally releases the managed resources.
 /// </summary>
 /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
       {
     if (!_disposed)
     {
       _disposed = true;
       if (_caret != null)
       {
     _caret.PositionChanged -= SearchMatchingBracket;
     _caret.Dispose();
       }
       Document.TextContentChanged -= TextContentChanged;
       Document.FoldingManager.FoldingChanged -= DocumentFoldingsChanged;
       _motherTextAreaControl = null;
       _motherTextEditorControl = null;
       foreach (AbstractMargin margin in _leftMargins)
       {
     if (margin is IDisposable)
       (margin as IDisposable).Dispose();
       }
       _textView.Dispose();
     }
       }
       base.Dispose(disposing);
 }
 /// <summary>
 /// Releases the unmanaged resources used by the <see cref="Control"></see> and its child controls and optionally releases the managed resources.
 /// </summary>
 /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
       {
     if (!_disposed)
     {
       _disposed = true;
       Document.TextContentChanged -= DocumentTextContentChanged;
       Document.DocumentChanged -= AdjustScrollBarsOnDocumentChange;
       Document.UpdateCommited -= DocumentUpdateCommitted;
       _motherTextEditorControl = null;
       if (_vScrollBar != null)
       {
     _vScrollBar.Dispose();
     _vScrollBar = null;
       }
       if (_hScrollBar != null)
       {
     _hScrollBar.Dispose();
     _hScrollBar = null;
       }
       if (_hRuler != null)
       {
     _hRuler.Dispose();
     _hRuler = null;
       }
     }
       }
       base.Dispose(disposing);
 }
Esempio n. 9
0
        private void ImportDataFromFile(TextEditorControl target)
        {
            var dialog = new OpenFileDialog
            {
                Filter = "Text Files|*.txt;*.csv;*.xml|All Files|*.*"
            };

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                target.Text = File.ReadAllText(dialog.FileName);
            }
        }
Esempio n. 10
0
        private void ExportDataToFile(TextEditorControl target)
        {
            var dialog = new SaveFileDialog
            {
                Title = "Save File",
                Filter = "Text File|*.txt|XML File|*.xml|All Files|*.*",
                AddExtension = true
            };

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                File.WriteAllText(dialog.FileName, target.Text);
            }
        }
Esempio n. 11
0
 private void textEditorControl_Enter(object sender, EventArgs e)
 {
     _activeControl = (TextEditorControl)sender;
 }