Example #1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         document.DocumentAboutToBeChanged -= DocumentAboutToBeChanged;
         if (codeCompletionListView != null)
         {
             codeCompletionListView.Dispose();
             codeCompletionListView = null;
         }
         if (declarationViewWindow != null)
         {
             declarationViewWindow.Dispose();
             declarationViewWindow = null;
         }
     }
     base.Dispose(disposing);
 }
Example #2
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;
        }
		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;
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing) {
				document.DocumentAboutToBeChanged -= DocumentAboutToBeChanged;
				if (codeCompletionListView != null) {
					codeCompletionListView.Dispose();
					codeCompletionListView = null;
				}
				if (declarationViewWindow != null) {
					declarationViewWindow.Dispose();
					declarationViewWindow = null;
				}
			}
			base.Dispose(disposing);
		}