public void SetCaret(int line, int col)
        {
            editor.Focus();
            TextAreaControl ctl = editor.ActiveTextAreaControl;

            if (ctl != null)
            {
                ctl.Caret.Position = new Point(col - 1, line - 1);
            }
        }
Exemple #2
0
 //------------------------------------------------------------------------
 //Common Contstructor Helper
 private void _initPost(string content)
 {
     //LF w/o CR causes issues with ics.te's fold marks (doubles onto following lines)
     if (content.IndexOf('\u000D') == -1)
     {
         content = content.Replace("\u000A", "\u000D\u000A");
     }
     icsEditor.Text = content;
     SetModified(false, true);
     Config.RegisterUpdateHandler(UpdateSyntax);
     UpdateSyntax();
     icsEditor.Focus();
 }
        protected void ShowCompletionWindow()
        {
            Enabled = true;
            // only this.Show() works when running inside a non-interactive Windows Service (e.g. unit tests),
            // so only use the Show(owner) overload when there is an owner.
            if (parentWindow != null)
            {
                this.Show(parentWindow);
            }
            else
            {
                this.Show();
            }

            control.Focus();

            if (parentForm != null)
            {
                parentForm.LocationChanged += new EventHandler(this.ParentFormLocationChanged);
            }

            control.ActiveTextAreaControl.VScrollBar.ValueChanged     += new EventHandler(ParentFormLocationChanged);
            control.ActiveTextAreaControl.HScrollBar.ValueChanged     += new EventHandler(ParentFormLocationChanged);
            control.ActiveTextAreaControl.TextArea.DoProcessDialogKey += new DialogKeyProcessor(ProcessTextAreaKey);
            control.ActiveTextAreaControl.Caret.PositionChanged       += new EventHandler(CaretOffsetChanged);
            control.ActiveTextAreaControl.TextArea.LostFocus          += new EventHandler(this.TextEditorLostFocus);
            control.Resize += new EventHandler(ParentFormLocationChanged);

            foreach (Control c in Controls)
            {
                c.MouseMove += ControlMouseMove;
            }
        }
        protected void ShowCompletionWindow()
        {
            Owner   = parentForm;
            Enabled = true;
            this.Show();

            control.Focus();

            if (parentForm != null)
            {
                parentForm.LocationChanged += new EventHandler(this.ParentFormLocationChanged);
            }

            control.ActiveTextAreaControl.VScrollBar.ValueChanged     += new EventHandler(ParentFormLocationChanged);
            control.ActiveTextAreaControl.HScrollBar.ValueChanged     += new EventHandler(ParentFormLocationChanged);
            control.ActiveTextAreaControl.TextArea.DoProcessDialogKey += new DialogKeyProcessor(ProcessTextAreaKey);
            control.ActiveTextAreaControl.Caret.PositionChanged       += new EventHandler(CaretOffsetChanged);
            control.ActiveTextAreaControl.TextArea.LostFocus          += new EventHandler(this.TextEditorLostFocus);
            control.Resize += new EventHandler(ParentFormLocationChanged);

            foreach (Control c in Controls)
            {
                c.MouseMove += ControlMouseMove;
            }
        }
Exemple #5
0
        private void InitializeTextEditor()
        {
            if (_textEditor != null)
            {
                return;
            }

            _textEditor = new TextEditorControl();
            panEditor.Controls.Add(_textEditor);
            _textEditor.Dock = DockStyle.Fill;
            _textEditor.BringToFront();
            _textEditor.Document.HighlightingStrategy               = ICSharpCode.TextEditor.Document.HighlightingStrategyFactory.CreateHighlightingStrategy("SQL");
            ActiveTextArea.TextEditorProperties.EnableFolding       = false;
            ActiveTextArea.TextEditorProperties.AllowCaretBeyondEOL = true;

            if (ConfigHelper.Current != null && ConfigHelper.Current.TextEditorOptions != null)
            {
                ActiveTextArea.MotherTextEditorControl.Encoding = ConfigHelper.Current.TextEditorOptions.Encoding;
            }
            else
            {
                ActiveTextArea.MotherTextEditorControl.Encoding = Encoding.Default;
            }

            ConfigHelper.Current.TextEditorOptions.ApplyToControl(_textEditor);
            ActiveDocument.ReadOnly = true;

            _textEditor.Focus();
        }
Exemple #6
0
        private void InitializeTextEditor( )
        {
            if (_textEditor != null)
            {
                return;
            }

            _textEditor = new TextEditorControl();
            panEditor.Controls.Add(_textEditor);
            _textEditor.Dock = DockStyle.Fill;
            _textEditor.BringToFront();
            _textEditor.Document.HighlightingStrategy = ICSharpCode.TextEditor.Document.HighlightingStrategyFactory.CreateHighlightingStrategy("SQL");
            _textEditor.Document.DocumentChanged     += new DocumentEventHandler(Document_DocumentChanged);

            ActiveTextEditorProps.AllowCaretBeyondEOL = false;
            ActiveTextEditorProps.ConvertTabsToSpaces = false;
            ActiveTextEditorProps.EnableFolding       = false;
            ActiveTextEditorProps.IndentStyle         = IndentStyle.Smart;
            ActiveTextEditorProps.ShowEOLMarker       = false;
            ActiveTextEditorProps.ShowInvalidLines    = false;
            ActiveTextEditorProps.ShowLineNumbers     = true;
            ActiveTextEditorProps.ShowSpaces          = false;
            ActiveTextEditorProps.ShowTabs            = false;
            ActiveTextEditorProps.ShowVerticalRuler   = true;
            ActiveTextEditorProps.TabIndent           = 2;
            ActiveTextEditorProps.VerticalRulerRow    = 120;

            _textEditor.Focus();
        }
		CodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth) : base(parentForm, control)
		{
			this.dataProvider = completionDataProvider;
			this.completionData = completionData;
			this.document = control.Document;
			this.showDeclarationWindow = showDeclarationWindow;
			this.fixedListViewWidth = fixedListViewWidth;

			workingScreen = Screen.GetWorkingArea(Location);
			startOffset = control.ActiveTextAreaControl.Caret.Offset + 1;
			endOffset   = startOffset;
			if (completionDataProvider.PreSelection != null) {
				startOffset -= completionDataProvider.PreSelection.Length + 1;
				endOffset--;
			}
			
			codeCompletionListView = new CodeCompletionListView(completionData);
            codeCompletionListView.Font = new System.Drawing.Font(FontFamily.GenericMonospace, codeCompletionListView.Font.Size);
			codeCompletionListView.ImageList = completionDataProvider.ImageList;
			codeCompletionListView.Dock = DockStyle.Fill;
			codeCompletionListView.SelectedItemChanged += new EventHandler(CodeCompletionListViewSelectedItemChanged);
			codeCompletionListView.DoubleClick += new EventHandler(CodeCompletionListViewDoubleClick);
			codeCompletionListView.Click  += new EventHandler(CodeCompletionListViewClick);
			Controls.Add(codeCompletionListView);
			
			if (completionData.Length > MaxListLength) {
				vScrollBar.Dock = DockStyle.Right;
				vScrollBar.Minimum = 0;
				vScrollBar.Maximum = completionData.Length - 1;
				vScrollBar.SmallChange = 1;
				vScrollBar.LargeChange = MaxListLength;
				codeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged);
				Controls.Add(vScrollBar);
			}
			
			this.drawingSize = GetListViewSize();
			SetLocation();
			
			if (declarationViewWindow == null) {
				declarationViewWindow = new DeclarationViewWindow(parentForm);
			}
			SetDeclarationViewLocation();
			declarationViewWindow.ShowDeclarationViewWindow();
			declarationViewWindow.MouseMove += ControlMouseMove;
			control.Focus();
			CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);
			
			if (completionDataProvider.DefaultIndex >= 0) {
				codeCompletionListView.SelectIndex(completionDataProvider.DefaultIndex);
			}
			
			if (completionDataProvider.PreSelection != null) {
				CaretOffsetChanged(this, EventArgs.Empty);
			}
			
			vScrollBar.ValueChanged += VScrollBarValueChanged;
			document.DocumentAboutToBeChanged += DocumentAboutToBeChanged;
		}
        CodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control)
            : base(parentForm, control)
        {
            this.dataProvider = completionDataProvider;
            this.completionData = completionData;
            this.document = control.Document;

            workingScreen = Screen.GetWorkingArea(Location);
            startOffset = control.ActiveTextAreaControl.Caret.Offset + 1;
            endOffset   = startOffset;
            if (completionDataProvider.PreSelection != null) {
                startOffset -= completionDataProvider.PreSelection.Length + 1;
                endOffset--;
            }

            codeCompletionListView = new CodeCompletionListView(completionData);
            codeCompletionListView.ImageList = completionDataProvider.ImageList;
            codeCompletionListView.Dock = DockStyle.Fill;
            codeCompletionListView.SelectedItemChanged += new EventHandler(CodeCompletionListViewSelectedItemChanged);
            codeCompletionListView.DoubleClick += new EventHandler(CodeCompletionListViewDoubleClick);
            codeCompletionListView.Click  += new EventHandler(CodeCompletionListViewClick);
            Controls.Add(codeCompletionListView);

            const int MaxListLength = 10;
            if (completionData.Length > MaxListLength) {
                vScrollBar.Dock = DockStyle.Right;
                vScrollBar.Minimum = 0;
                vScrollBar.Maximum = completionData.Length - 1;
                vScrollBar.SmallChange = 1;
                vScrollBar.LargeChange = MaxListLength;
                codeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged);
                Controls.Add(vScrollBar);
            }

            this.drawingSize = new Size(codeCompletionListView.ItemHeight * 10,
                                        codeCompletionListView.ItemHeight * Math.Min(MaxListLength, completionData.Length));
            SetLocation();

            if (declarationViewWindow == null) {
                declarationViewWindow = new DeclarationViewWindow(parentForm);
            }
            SetDeclarationViewLocation();
            declarationViewWindow.ShowDeclarationViewWindow();
            declarationViewWindow.MouseMove += ControlMouseMove;
            control.Focus();
            CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);

            if (completionDataProvider.DefaultIndex >= 0) {
                codeCompletionListView.SelectIndex(completionDataProvider.DefaultIndex);
            }

            if (completionDataProvider.PreSelection != null) {
                CaretOffsetChanged(this, EventArgs.Empty);
            }

            vScrollBar.ValueChanged += VScrollBarValueChanged;
            document.DocumentAboutToBeChanged += DocumentAboutToBeChanged;
        }
        public TextRange FindNext(bool viaF3, bool searchBackward, string messageIfNotFound)
        {
            _lblStatus.Text      = string.Empty;
            _lblStatus.ForeColor = Color.Blue;

            RemoveHighlighting();
            if (string.IsNullOrEmpty(_tbSearchTerm.Text))
            {
                _lblStatus.ForeColor = Color.Red;
                _lblStatus.Text      = "Nothing specified to look for.";
                return(null);
            }

            _lastSearchWasBackward     = searchBackward;
            _search.LookFor            = _tbSearchTerm.Text;
            _search.MatchCase          = chkMatchCase.Checked;
            _search.MatchWholeWordOnly = chkMatchWholeWord.Checked;

            _editor.Focus();
            var caret = _editor.ActiveTextAreaControl.Caret;

            if (viaF3 && _search.HasScanRegion && !caret.Offset.
                IsInRange(_search.BeginOffset, _search.EndOffset))
            {
                // user moved outside of the originally selected region
                _search.ClearScanRegion();
                UpdateTitleBar();
            }

            var startFrom = caret.Offset - (searchBackward ? 1 : 0);
            var range     = _search.FindNext(startFrom, searchBackward, out _lastSearchLoopedAround);

            if (range != null)
            {
                SelectResult(range);
            }
            else if (messageIfNotFound != null)
            {
                //Dialog.ShowDialog(Application.ProductName, messageIfNotFound, string.Empty);
                _lblStatus.ForeColor = Color.Red;
                _lblStatus.Text      = messageIfNotFound;
            }
            Focus();
            return(range);
        }
Exemple #10
0
        CodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, string fileName) : base(parentForm, control, fileName)
        {
            this.dataProvider   = completionDataProvider;
            this.completionData = completionData;

            workingScreen = Screen.GetWorkingArea(Location);
            startOffset   = control.ActiveTextAreaControl.Caret.Offset + 1;
            endOffset     = startOffset;
            if (completionDataProvider.PreSelection != null)
            {
                startOffset -= completionDataProvider.PreSelection.Length + 1;
                endOffset--;
            }

            codeCompletionListView                      = new CodeCompletionListView(completionData);
            codeCompletionListView.ImageList            = completionDataProvider.ImageList;
            codeCompletionListView.Dock                 = DockStyle.Fill;
            codeCompletionListView.SelectedItemChanged += new EventHandler(CodeCompletionListViewSelectedItemChanged);
            codeCompletionListView.DoubleClick         += new EventHandler(CodeCompletionListViewDoubleClick);
            codeCompletionListView.Click               += new EventHandler(CodeCompletionListViewClick);
            Controls.Add(codeCompletionListView);

            if (completionData.Length > 10)
            {
                vScrollBar.Dock        = DockStyle.Right;
                vScrollBar.Minimum     = 0;
                vScrollBar.Maximum     = completionData.Length - 8;
                vScrollBar.SmallChange = 1;
                vScrollBar.LargeChange = 3;
                codeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged);
                Controls.Add(vScrollBar);
            }

            this.drawingSize = new Size(codeCompletionListView.ItemHeight * 10, codeCompletionListView.ItemHeight * Math.Min(10, completionData.Length));
            SetLocation();

            if (declarationViewWindow == null)
            {
                declarationViewWindow = new DeclarationViewWindow(parentForm);
            }
            SetDeclarationViewLocation();
            declarationViewWindow.ShowDeclarationViewWindow();
            control.Focus();
            CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);

            if (completionDataProvider.DefaultIndex >= 0)
            {
                codeCompletionListView.SelectIndex(completionDataProvider.DefaultIndex);
            }

            if (completionDataProvider.PreSelection != null)
            {
                CaretOffsetChanged(this, EventArgs.Empty);
            }

            vScrollBar.Scroll += new ScrollEventHandler(DoScroll);
        }
 private CodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth) : base(parentForm, control)
 {
     this.dataProvider          = completionDataProvider;
     this.completionData        = completionData;
     this.document              = control.Document;
     this.showDeclarationWindow = showDeclarationWindow;
     this.fixedListViewWidth    = fixedListViewWidth;
     this.workingScreen         = Screen.GetWorkingArea(base.Location);
     this.startOffset           = control.ActiveTextAreaControl.Caret.Offset + 1;
     this.endOffset             = this.startOffset;
     if (completionDataProvider.PreSelection != null)
     {
         CodeCompletionWindow length = this;
         length.startOffset = length.startOffset - (completionDataProvider.PreSelection.Length + 1);
         this.endOffset--;
     }
     this.codeCompletionListView = new CodeCompletionListView(completionData)
     {
         ImageList = completionDataProvider.ImageList,
         Dock      = DockStyle.Fill
     };
     this.codeCompletionListView.SelectedItemChanged += new EventHandler(this.CodeCompletionListViewSelectedItemChanged);
     this.codeCompletionListView.DoubleClick         += new EventHandler(this.CodeCompletionListViewDoubleClick);
     this.codeCompletionListView.Click += new EventHandler(this.CodeCompletionListViewClick);
     base.Controls.Add(this.codeCompletionListView);
     if ((int)completionData.Length > 10)
     {
         this.vScrollBar.Dock        = DockStyle.Right;
         this.vScrollBar.Minimum     = 0;
         this.vScrollBar.Maximum     = (int)completionData.Length - 1;
         this.vScrollBar.SmallChange = 1;
         this.vScrollBar.LargeChange = 10;
         this.codeCompletionListView.FirstItemChanged += new EventHandler(this.CodeCompletionListViewFirstItemChanged);
         base.Controls.Add(this.vScrollBar);
     }
     this.drawingSize = this.GetListViewSize();
     this.SetLocation();
     if (this.declarationViewWindow == null)
     {
         this.declarationViewWindow = new DeclarationViewWindow(parentForm);
     }
     this.SetDeclarationViewLocation();
     this.declarationViewWindow.ShowDeclarationViewWindow();
     this.declarationViewWindow.MouseMove += new MouseEventHandler(this.ControlMouseMove);
     control.Focus();
     this.CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);
     if (completionDataProvider.DefaultIndex >= 0)
     {
         this.codeCompletionListView.SelectIndex(completionDataProvider.DefaultIndex);
     }
     if (completionDataProvider.PreSelection != null)
     {
         this.CaretOffsetChanged(this, EventArgs.Empty);
     }
     this.vScrollBar.ValueChanged           += new EventHandler(this.VScrollBarValueChanged);
     this.document.DocumentAboutToBeChanged += new DocumentEventHandler(this.DocumentAboutToBeChanged);
 }
Exemple #12
0
        private void closeTabPage(TabPage tab_page)
        {
            TextEditorControl text_editor = ((TextEditorControl)tab_page.Controls.Find("textEditorControl1", true).FirstOrDefault());

            if (this.tabControl1.TabCount == 1 && !tab_page.Text.Contains("*"))
            {
                if (tab_page.Text.Contains("未命名"))
                {
                    return;
                }
                else
                {
                    this.tabControl1.TabPages.Remove(tab_page); // 移除所在邊框的分頁
                    addNewTabPage();
                }
            }

            if (this.tabControl1.TabCount == 1 && tab_page.Text.Contains("*"))
            {
                DialogResult myResult = MessageBox.Show("Save file '" + tab_page.Text.Replace("*", "").Trim() + "'?", "Save", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (myResult == DialogResult.Yes)
                {
                    SaveFile(tab_page);
                }
                else if (myResult == DialogResult.No)
                {
                    this.tabControl1.TabPages.Remove(tab_page); // 移除所在邊框的分頁
                    addNewTabPage();
                }

                return;
            }

            if (this.tabControl1.TabCount > 1 && !tab_page.Text.Contains("*"))
            {
                this.tabControl1.TabPages.Remove(tab_page);                     // 移除所在邊框的分頁
                this.tabControl1.SelectedIndex = this.tabControl1.TabCount - 1; // 將所在邊框指定為最後一個
                text_editor.Focus();
                return;
            }

            if (this.tabControl1.TabCount > 1 && tab_page.Text.Contains("*"))
            {
                DialogResult myResult = MessageBox.Show("Save file '" + tab_page.Text.Replace("*", "").Trim() + "'?", "Save", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (myResult == DialogResult.Yes)
                {
                    SaveFile(tab_page);
                }
                else if (myResult == DialogResult.No)
                {
                    this.tabControl1.TabPages.Remove(tab_page); // 移除所在邊框的分頁
                }

                return;
            }
        }
Exemple #13
0
        private void HandleCodeCompletionKeyPress_Ex(char c)
        {
            switch (c)
            {
            case (char)27: //ESC
                _codeCompWindowEx.DismissSelector();
                _textEditor.Focus();
                return;

            default:
                if (Char.IsControl(c))
                {
                    return;
                }
                ActiveTextArea.InsertChar(c);
                _codeCompWindowEx.JumpTo(GetPreviousNonWSLineParts);
                break;
            }
        }
Exemple #14
0
        protected virtual void InitializeOptions()
        {
            if (_panelIsHidden)
            {
                var searchBox = this.SearchBox;
                if (searchBox != null)
                {
                    searchBox.SelectAll();
                    searchBox.Focus();
                }
                else
                {
                    if (_editor != null)
                    {
                        _editor.Focus();
                    }
                }

                this.HighlightAll();
            }

            _isInitialized = true;
            _searchCount   = 0;
        }
Exemple #15
0
        public void SetEditorActive()
        {
            TabPage page = tabControl.Parent as TabPage;

            if (page != null)
            {
                TabControl main = page.Parent as TabControl;
                if (main != null)
                {
                    main.SelectedTab = page;
                }
            }
            tabControl.SelectedTab = tabPage;
            editor.Focus();
            editor.Refresh();
        }
Exemple #16
0
        protected void ShowCompletionWindow()
        {
            Enabled = true;
            AbstractCompletionWindow.ShowWindow(base.Handle, AbstractCompletionWindow.SW_SHOWNA);

            control.Focus();
            if (Owner != null)
            {
                Owner.LocationChanged += new EventHandler(this.ParentFormLocationChanged);
            }

            control.ActiveTextAreaControl.VScrollBar.ValueChanged     += new EventHandler(ParentFormLocationChanged);
            control.ActiveTextAreaControl.HScrollBar.ValueChanged     += new EventHandler(ParentFormLocationChanged);
            control.ActiveTextAreaControl.TextArea.DoProcessDialogKey += new DialogKeyProcessor(ProcessTextAreaKey);
            control.ActiveTextAreaControl.Caret.PositionChanged       += new EventHandler(CaretOffsetChanged);
            control.ActiveTextAreaControl.TextArea.LostFocus          += new EventHandler(this.TextEditorLostFocus);
            control.Resize += new EventHandler(ParentFormLocationChanged);
        }
Exemple #17
0
        private void InitializeTextEditor( )
        {
            if (_textEditor != null)
            {
                return;
            }


            _textEditor = new TextEditorControl();
            panEditor.Controls.Add(_textEditor);
            _textEditor.Dock = DockStyle.Fill;
            _textEditor.BringToFront();
            ConfigurationLoader.CurrentConfig.TextEditorOptions.ApplyToControl(_textEditor);
            _textEditor.Document.HighlightingStrategy = ICSharpCode.TextEditor.Document.HighlightingStrategyFactory.CreateHighlightingStrategy("SQL");
            _textEditor.ContextMenuStrip          = popUpEditor;
            ActiveTextArea.KeyDown               += new System.Windows.Forms.KeyEventHandler(OnTextEditorKeyDown);
            _textEditor.Document.DocumentChanged += new DocumentEventHandler(OnDocumentChanged);
            _textEditor.Focus();
        }
Exemple #18
0
    private void InitializeTextEditor()
    {
      if (_textEditor != null)
      {
        return;
      }


      _textEditor = new TextEditorControl();
      panScript.Controls.Add(_textEditor);
      _textEditor.Dock = DockStyle.Fill;
      _textEditor.BringToFront();
      Program.MainForm.ConfigContent.TextEditorOptions.ApplyToControl(_textEditor);
      _textEditor.Document.HighlightingStrategy = ICSharpCode.TextEditor.Document.HighlightingStrategyFactory.CreateHighlightingStrategy("SQL");
      _textEditor.ContextMenuStrip = popUpEditor;
      _textEditor.Focus();
      ActiveTextArea.TextEditorProperties.EnableFolding = false;
      ActiveDocument.ReadOnly = true;
    }
Exemple #19
0
 private CodeCompletionWindow(ICompletionDataProvider completionDataProvider, Form parentForm, TextEditorControl control, string fileName) : base(parentForm, control, fileName)
 {
     this.workingScreen = Screen.GetWorkingArea(base.Location);
     this.startOffset   = control.ActiveTextAreaControl.Caret.Offset + 1;
     this.endOffset     = this.startOffset;
     if (completionDataProvider.PreSelection != null)
     {
         this.startOffset -= completionDataProvider.PreSelection.Length + 1;
         this.endOffset--;
     }
     this.codeCompletionListView                      = new CodeCompletionListView(CodeCompletionWindow.completionData);
     this.codeCompletionListView.ImageList            = completionDataProvider.ImageList;
     this.codeCompletionListView.Dock                 = DockStyle.Fill;
     this.codeCompletionListView.SelectedItemChanged += new EventHandler(this.CodeCompletionListViewSelectedItemChanged);
     this.codeCompletionListView.DoubleClick         += new EventHandler(this.CodeCompletionListViewDoubleClick);
     this.codeCompletionListView.Click               += new EventHandler(this.CodeCompletionListViewClick);
     base.Controls.Add(this.codeCompletionListView);
     if (CodeCompletionWindow.completionData.Length > 10)
     {
         this.vScrollBar.Dock        = DockStyle.Right;
         this.vScrollBar.Minimum     = 0;
         this.vScrollBar.Maximum     = CodeCompletionWindow.completionData.Length - 8;
         this.vScrollBar.SmallChange = 1;
         this.vScrollBar.LargeChange = 3;
         this.codeCompletionListView.FirstItemChanged += new EventHandler(this.CodeCompletionListViewFirstItemChanged);
         base.Controls.Add(this.vScrollBar);
     }
     this.drawingSize = new Size(this.codeCompletionListView.ItemHeight * 10, this.codeCompletionListView.ItemHeight * Math.Min(10, CodeCompletionWindow.completionData.Length));
     this.SetLocation();
     this.declarationViewWindow = new DeclarationViewWindow(parentForm);
     this.SetDeclarationViewLocation();
     this.declarationViewWindow.ShowDeclarationViewWindow();
     control.Focus();
     this.CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);
     if (completionDataProvider.PreSelection != null)
     {
         this.CaretOffsetChanged(this, EventArgs.Empty);
     }
     this.vScrollBar.Scroll += new ScrollEventHandler(this.DoScroll);
 }
		PABCNETCodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control,bool visibleKeyPressed, bool is_by_dot) : base(parentForm, control)
		{
			this.dataProvider = completionDataProvider;
			this.completionData = completionData;
			this.document = control.Document;
			workingScreen = Screen.GetWorkingArea(Location);
            lastCursorScreenPosition = control.ActiveTextAreaControl.Caret.ScreenPosition;
            startOffset = control.ActiveTextAreaControl.Caret.Offset + (visibleKeyPressed ? 1 : 0);
			endOffset   = startOffset;
			if (completionDataProvider.PreSelection != null) {
				
				startOffset -= completionDataProvider.PreSelection.Length; //+ 1;
				if (visibleKeyPressed) endOffset--;
				//endOffset--;
				(completionDataProvider as VisualPascalABC.CodeCompletionProvider).preSelection = null;
			}
			
			codeCompletionListView = new PABCNETCodeCompletionListView(completionData, is_by_dot);
			codeCompletionListView.ImageList = completionDataProvider.ImageList;
			codeCompletionListView.Dock = DockStyle.Fill;
			codeCompletionListView.SelectedItemChanged += new EventHandler(CodeCompletionListViewSelectedItemChanged);
			codeCompletionListView.DoubleClick += new EventHandler(CodeCompletionListViewDoubleClick);
			codeCompletionListView.Click  += new EventHandler(CodeCompletionListViewClick);
            codeCompletionListView.Font = new Font(VisualPascalABC.Constants.CompletionWindowCodeCompletionListViewFontName,codeCompletionListView.Font.Size);
			Controls.Add(codeCompletionListView);
			
			int MaxListLength = VisualPascalABC.Constants.CompletionWindowMaxListLength;
			if (completionData.Length > MaxListLength) {
				vScrollBar.Dock = DockStyle.Right;
				vScrollBar.Minimum = 0;
				vScrollBar.Maximum = completionData.Length - 1;
				vScrollBar.SmallChange = 1;
				vScrollBar.LargeChange = MaxListLength;
				codeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged);
				Controls.Add(vScrollBar);
			}
            this.drawingSize = new Size(//codeCompletionListView.ItemHeight * 10,
                                        VisualPascalABC.Constants.CompletionWindowWidth,
                                        codeCompletionListView.ItemHeight * Math.Min(MaxListLength, completionData.Length) + 2);
			SetLocation();
			
			if (declarationViewWindow == null) {
				declarationViewWindow = new DeclarationWindow(parentForm);
				declarationViewWindow.in_completion_list = true;
                declarationViewWindow.Font = new Font(VisualPascalABC.Constants.CompletionWindowDeclarationViewWindowFontName, declarationViewWindow.Font.Size);
			}            
			SetDeclarationViewLocation();
            //DS закоментил, это желтый квадрат при старте
			//declarationViewWindow.ShowDeclarationViewWindow();
			declarationViewWindow.MouseMove += ControlMouseMove;
			control.Focus();
			CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);
			
			if ((completionDataProvider as VisualPascalABC.CodeCompletionProvider).DefaultCompletionElement != null) {
				if ((completionDataProvider as VisualPascalABC.CodeCompletionProvider).ByFirstChar)
				codeCompletionListView.FirstInsert = true;
				codeCompletionListView.SelectIndexByCompletionData((completionDataProvider as VisualPascalABC.CodeCompletionProvider).DefaultCompletionElement);
			}
			
			if (completionDataProvider.PreSelection != null) {
				CaretOffsetChanged(this, EventArgs.Empty);
			}
			
			vScrollBar.ValueChanged += VScrollBarValueChanged;
			document.DocumentAboutToBeChanged += DocumentAboutToBeChanged;
		}
    /// <summary>
    /// Initializes a new instance of the <see cref="CompletionWindow"/> class.
    /// </summary>
    /// <param name="completionDataProvider">The completion data provider.</param>
    /// <param name="completionData">The completion data.</param>
    /// <param name="parentForm">The parent form.</param>
    /// <param name="control">The text editor control.</param>
    /// <param name="showDeclarationWindow"><see langword="true"/> to show declaration window; otherwise <see langword="false"/>.</param>
    /// <param name="fixedListViewWidth"><see langword="true"/> to use a fixed width in the list view.</param>
    /// <param name="closeAutomatically"><see langword="true"/> to close the completion window automatically.</param>
    CompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth, bool closeAutomatically)
      : base(parentForm, control)
    {
      _dataProvider = completionDataProvider;
      _completionData = completionData;
      _document = control.Document;
      _showDeclarationWindow = showDeclarationWindow;
      _fixedListViewWidth = fixedListViewWidth;
      _closeAutomatically = closeAutomatically;

      int caretOffset = control.ActiveTextAreaControl.Caret.Offset;
      _startOffset = caretOffset;
      _endOffset = caretOffset;

      // Move start offset if something is pre-selected.
      if (!String.IsNullOrEmpty(completionDataProvider.PreSelection))
        _startOffset -= completionDataProvider.PreSelection.Length;

      _completionListView = new CompletionListView(completionData);
      _completionListView.Dock = DockStyle.Fill;
      _completionListView.FilterList = true;
      _completionListView.ImageList = completionDataProvider.ImageList;
      _completionListView.Click += CompletionListViewClick;
      _completionListView.DoubleClick += CompletionListViewDoubleClick;
      _completionListView.FirstItemChanged += CompletionListViewFirstItemChanged;
      _completionListView.ItemCountChanged += CompletionListViewItemCountChanged;
      _completionListView.SelectedItemChanged += CompletionListViewSelectedItemChanged;
      Controls.Add(_completionListView);

      _vScrollBar = new VScrollBar();
      _vScrollBar.SmallChange = 1;
      _vScrollBar.LargeChange = _maxListLength;
      _vScrollBar.Dock = DockStyle.Right;
      Controls.Add(_vScrollBar);
      UpdateScrollBar();

      _workingScreen = Screen.GetWorkingArea(Location);
      DrawingSize = GetListViewSize();
      _textLocation = TextEditorControl.ActiveTextAreaControl.TextArea.Caret.Position;
      SetLocation(_textLocation);

      if (_declarationViewWindow == null)
        _declarationViewWindow = new DeclarationViewWindow(parentForm);

      SetDeclarationViewLocation();
      _declarationViewWindow.Show();
      _declarationViewWindow.MouseMove += ControlMouseMove;
      control.Focus();
      CompletionListViewSelectedItemChanged(this, EventArgs.Empty);

      if (!String.IsNullOrEmpty(completionDataProvider.PreSelection))
      {
        // Select item based on pre-selection.
        CaretOffsetChanged(this, EventArgs.Empty);
      }
      else if (completionDataProvider.DefaultIndex >= 0)
      {
        // Select default item
        _completionListView.SelectItem(completionDataProvider.DefaultIndex);
      }

      _vScrollBar.ValueChanged += VScrollBarValueChanged;
      _document.DocumentAboutToBeChanged += DocumentAboutToBeChanged;
    }
Exemple #22
0
        private void tvDirectory_DoubleClick(object sender, EventArgs e)
        {
            TreeNode selectNode = tvDirectory.SelectedNode;

            if (selectNode != null && selectNode.Tag != null)
            {
                if (selectNode.ImageKey != folderKeyOfImageList)
                {
                    #region 打开文件

                    string dsoFramerExtensionString = ".doc,.docx,.rtf,.ppt,.odt,.docm,.dotx,.dotm,.dot,.xls,";
                    string generalExtensionString   = ".txt,.cs,.vb,.java,.cpp,.il,.xml,.config,";
                    string webBrowerExtensionString = ".htm,.html,.mht,.pdf,";

                    string[] generalExtensions   = generalExtensionString.Split(',');
                    string[] dsoFramerExtensions = dsoFramerExtensionString.Split(',');
                    string[] webBrowerExtensions = webBrowerExtensionString.Split(',');
                    string[] extensions          = (dsoFramerExtensionString + generalExtensionString + webBrowerExtensionString).TrimEnd(',').Split(',');
                    string   path = selectNode.Tag.ToString();
                    try
                    {
                        if (extensions.Contains(Path.GetExtension(path)))
                        {
                            if (dsoFramerExtensions.Contains(Path.GetExtension(path)))
                            {
                                this.editorContainer.Controls.Clear();
                                //dsoFramer必须先把控件Add上,再打开文件
                                this.editorContainer.Controls.Add(this.axFramerControl1);
                                this.axFramerControl1.Open(path);
                                //this.axFramerControl1.Focus();
                            }
                            else if (webBrowerExtensions.Contains(Path.GetExtension(path)))
                            {
                                this.editorContainer.Controls.Clear();
                                this.webBrower.Navigate(path);
                                this.editorContainer.Controls.Add(this.webBrower);
                                this.webBrower.Focus();
                            }
                            else
                            {
                                string content = File.ReadAllText(path);
                                this.editorContainer.Controls.Clear();
                                txtCode.LoadFile(path);
                                this.editorContainer.Controls.Add(this.txtCode);
                                txtCode.Focus();
                            }
                            txtFileName.Text = path.ToString();
                        }
                        else
                        {
                            OpenFileBySystem(path);
                        }
                    }
                    catch (Exception ex)
                    {
                        this.ShowMessage(ex);
                        OpenFileBySystem(path);
                    }
                    #endregion
                }
            }
        }
Exemple #23
0
        PABCNETCodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool visibleKeyPressed, bool is_by_dot) : base(parentForm, control)
        {
            this.dataProvider        = completionDataProvider;
            this.completionData      = completionData;
            this.document            = control.Document;
            workingScreen            = Screen.GetWorkingArea(Location);
            lastCursorScreenPosition = control.ActiveTextAreaControl.Caret.ScreenPosition;
            startOffset = control.ActiveTextAreaControl.Caret.Offset + (visibleKeyPressed ? 1 : 0);
            endOffset   = startOffset;
            if (completionDataProvider.PreSelection != null)
            {
                startOffset -= completionDataProvider.PreSelection.Length;                 //+ 1;
                if (visibleKeyPressed)
                {
                    endOffset--;
                }
                //endOffset--;
                (completionDataProvider as VisualPascalABC.CodeCompletionProvider).preSelection = null;
            }

            codeCompletionListView                      = new PABCNETCodeCompletionListView(completionData, is_by_dot);
            codeCompletionListView.ImageList            = completionDataProvider.ImageList;
            codeCompletionListView.Dock                 = DockStyle.Fill;
            codeCompletionListView.SelectedItemChanged += new EventHandler(CodeCompletionListViewSelectedItemChanged);
            codeCompletionListView.DoubleClick         += new EventHandler(CodeCompletionListViewDoubleClick);
            codeCompletionListView.Click               += new EventHandler(CodeCompletionListViewClick);
            codeCompletionListView.Font                 = new Font(VisualPascalABC.Constants.CompletionWindowCodeCompletionListViewFontName, codeCompletionListView.Font.Size);
            Controls.Add(codeCompletionListView);

            int MaxListLength = VisualPascalABC.Constants.CompletionWindowMaxListLength;

            if (completionData.Length > MaxListLength)
            {
                vScrollBar.Dock        = DockStyle.Right;
                vScrollBar.Minimum     = 0;
                vScrollBar.Maximum     = completionData.Length - 1;
                vScrollBar.SmallChange = 1;
                vScrollBar.LargeChange = MaxListLength;
                codeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged);
                Controls.Add(vScrollBar);
            }
            this.drawingSize = new Size(//codeCompletionListView.ItemHeight * 10,
                VisualPascalABC.Constants.CompletionWindowWidth,
                codeCompletionListView.ItemHeight * Math.Min(MaxListLength, completionData.Length) + 2);
            SetLocation();

            if (declarationViewWindow == null)
            {
                declarationViewWindow = new DeclarationWindow(parentForm);
                declarationViewWindow.in_completion_list = true;
                declarationViewWindow.Font = new Font(VisualPascalABC.Constants.CompletionWindowDeclarationViewWindowFontName, declarationViewWindow.Font.Size);
            }
            SetDeclarationViewLocation();
            //DS закоментил, это желтый квадрат при старте
            //declarationViewWindow.ShowDeclarationViewWindow();
            declarationViewWindow.MouseMove += ControlMouseMove;
            control.Focus();
            CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty);

            if ((completionDataProvider as VisualPascalABC.CodeCompletionProvider).DefaultCompletionElement != null)
            {
                if ((completionDataProvider as VisualPascalABC.CodeCompletionProvider).ByFirstChar)
                {
                    codeCompletionListView.FirstInsert = true;
                }
                codeCompletionListView.SelectIndexByCompletionData((completionDataProvider as VisualPascalABC.CodeCompletionProvider).DefaultCompletionElement);
            }

            if (completionDataProvider.PreSelection != null)
            {
                CaretOffsetChanged(this, EventArgs.Empty);
            }

            vScrollBar.ValueChanged           += VScrollBarValueChanged;
            document.DocumentAboutToBeChanged += DocumentAboutToBeChanged;
        }
Exemple #24
0
 public override void SelectView()
 {
     textEditorControl.Focus();
     OnViewSelected(null);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CompletionWindow"/> class.
        /// </summary>
        /// <param name="completionDataProvider">The completion data provider.</param>
        /// <param name="completionData">The completion data.</param>
        /// <param name="parentForm">The parent form.</param>
        /// <param name="control">The text editor control.</param>
        /// <param name="showDeclarationWindow"><c>true</c> to show declaration window; otherwise <c>false</c>.</param>
        /// <param name="fixedListViewWidth"><c>true</c> to use a fixed width in the list view.</param>
        /// <param name="closeAutomatically"><c>true</c> to close the completion window automatically.</param>
        CompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth, bool closeAutomatically)
            : base(parentForm, control)
        {
            _dataProvider          = completionDataProvider;
            _completionData        = completionData;
            _document              = control.Document;
            _showDeclarationWindow = showDeclarationWindow;
            _fixedListViewWidth    = fixedListViewWidth;
            _closeAutomatically    = closeAutomatically;

            int caretOffset = control.ActiveTextAreaControl.Caret.Offset;

            _startOffset = caretOffset;
            _endOffset   = caretOffset;

            // Move start offset if something is pre-selected.
            if (!String.IsNullOrEmpty(completionDataProvider.PreSelection))
            {
                _startOffset -= completionDataProvider.PreSelection.Length;
            }

            _completionListView                      = new CompletionListView(completionData);
            _completionListView.Dock                 = DockStyle.Fill;
            _completionListView.FilterList           = true;
            _completionListView.ImageList            = completionDataProvider.ImageList;
            _completionListView.Click               += CompletionListViewClick;
            _completionListView.DoubleClick         += CompletionListViewDoubleClick;
            _completionListView.FirstItemChanged    += CompletionListViewFirstItemChanged;
            _completionListView.ItemCountChanged    += CompletionListViewItemCountChanged;
            _completionListView.SelectedItemChanged += CompletionListViewSelectedItemChanged;
            Controls.Add(_completionListView);

            _vScrollBar             = new VScrollBar();
            _vScrollBar.SmallChange = 1;
            _vScrollBar.LargeChange = _maxListLength;
            _vScrollBar.Dock        = DockStyle.Right;
            Controls.Add(_vScrollBar);
            UpdateScrollBar();

            _workingScreen = Screen.GetWorkingArea(Location);
            DrawingSize    = GetListViewSize();
            _textLocation  = TextEditorControl.ActiveTextAreaControl.TextArea.Caret.Position;
            SetLocation(_textLocation);

            if (_declarationViewWindow == null)
            {
                _declarationViewWindow = new DeclarationViewWindow(parentForm);
            }

            SetDeclarationViewLocation();
            _declarationViewWindow.Show();
            _declarationViewWindow.MouseMove += ControlMouseMove;
            control.Focus();
            CompletionListViewSelectedItemChanged(this, EventArgs.Empty);

            if (!String.IsNullOrEmpty(completionDataProvider.PreSelection))
            {
                // Select item based on pre-selection.
                CaretOffsetChanged(this, EventArgs.Empty);
            }
            else if (completionDataProvider.DefaultIndex >= 0)
            {
                // Select default item
                _completionListView.SelectItem(completionDataProvider.DefaultIndex);
            }

            _vScrollBar.ValueChanged           += VScrollBarValueChanged;
            _document.DocumentAboutToBeChanged += DocumentAboutToBeChanged;
        }