Пример #1
0
        public void ShowToolTip(AutocompleteItem autocompleteItem, Control control = null)
        {
            string title = autocompleteItem.ToolTipTitle;
            string text  = autocompleteItem.ToolTipText;

            if (control == null)
            {
                control = this;
            }

            if (string.IsNullOrEmpty(title))
            {
                toolTip.ToolTipTitle = null;
                toolTip.SetToolTip(control, null);
                return;
            }

            if (string.IsNullOrEmpty(text))
            {
                toolTip.ToolTipTitle = null;
                toolTip.Show(title, control, Width + 3, 0, ToolTipDuration);
            }
            else
            {
                toolTip.ToolTipTitle = title;
                toolTip.Show(text, control, Width + 3, 0, ToolTipDuration);
            }
        }
Пример #2
0
        private void ApplyAutocomplete(Control control, AutocompleteItem item, Range fragment)
        {
            string newText = item.GetTextForReplace();

            //replace text of fragment
            fragment.Text = newText;
            control.Focus();
        }
Пример #3
0
        private void ApplyAutocomplete(AutocompleteItem item, Range fragment)
        {
            string newText = item.GetTextForReplace();

            //replace text of fragment
            fragment.Text = newText;
            fragment.TargetWrapper.TargetControl.Focus();
        }
Пример #4
0
        internal virtual void OnSelecting()
        {
            if (SelectedItemIndex < 0 || SelectedItemIndex >= VisibleItems.Count)
            {
                return;
            }

            AutocompleteItem item = VisibleItems[SelectedItemIndex];
            var args = new SelectingEventArgs
            {
                Item          = item,
                SelectedIndex = SelectedItemIndex
            };

            OnSelecting(args);

            if (args.Cancel)
            {
                SelectedItemIndex = args.SelectedIndex;
                (Host.ListView as Control).Invalidate(true);
                return;
            }

            if (!args.Handled)
            {
                Range fragment = Fragment;

                if (item is IAutoCompleteMenuItemCustomReplace customReplace)
                {
                    fragment       = new Range(TargetControlWrapper);
                    fragment.Start = TargetControlWrapper.SelectionStart + TargetControlWrapper.SelectionLength - customReplace.ReplaceLength;
                    fragment.End   = fragment.Start + customReplace.ReplaceLength;
                }

                ApplyAutocomplete(item, fragment);
            }

            Close();
            //
            var args2 = new SelectedEventArgs
            {
                Item    = item,
                Control = TargetControlWrapper.TargetControl
            };

            item.OnSelected(args2);
            OnSelected(args2);
        }
Пример #5
0
        public void AddItem(AutocompleteItem item)
        {
            if (sourceItems == null)
            {
                sourceItems = new List <AutocompleteItem>();
            }

            if (sourceItems is IList)
            {
                (sourceItems as IList).Add(item);
            }
            else
            {
                throw new Exception("Current autocomplete items does not support adding");
            }
        }
Пример #6
0
        public void ShowToolTip(AutocompleteItem autocompleteItem, Control control = null)
        {
            string title = autocompleteItem.ToolTipTitle;
            string text  = autocompleteItem.ToolTipText;

            if (control == null)
            {
                control = this;
            }

            if (string.IsNullOrEmpty(title))
            {
                toolTip.ToolTipTitle = null;
                toolTip.SetToolTip(control, null);
                return;
            }

            ScintillaControl = (Scintilla)targetControl;
            TextAreaPoint    = new Point(ScintillaControl.PointXFromPosition(ScintillaControl.CurrentPosition), ScintillaControl.PointYFromPosition(ScintillaControl.CurrentPosition));

            if (string.IsNullOrEmpty(text))
            {
                toolTip.ToolTipTitle = null;

                if (control == this)
                {
                    toolTip.Show(title, control, Width + 3, 0, ToolTipDuration);
                }
                else
                {
                    toolTip.Show(title, control, TextAreaPoint.X + Width + 9, TextAreaPoint.Y + 19, ToolTipDuration);
                }
            }
            else
            {
                toolTip.ToolTipTitle = title;

                if (control == this)
                {
                    toolTip.Show(text, control, Width + 3, 0, ToolTipDuration);
                }
                else
                {
                    toolTip.Show(text, control, TextAreaPoint.X + Width + 9, TextAreaPoint.Y + 19, ToolTipDuration);
                }
            }
        }
Пример #7
0
        internal virtual void OnSelecting()
        {
            if (SelectedItemIndex < 0 || SelectedItemIndex >= VisibleItems.Count)
            {
                return;
            }

            AutocompleteItem item = VisibleItems[SelectedItemIndex];
            var args = new SelectingEventArgs
            {
                Item          = item,
                SelectedIndex = SelectedItemIndex
            };

            OnSelecting(args);

            if (args.Cancel)
            {
                SelectedItemIndex = args.SelectedIndex;
                (Host.ListView as Control).Invalidate(true);
                return;
            }

            if (!args.Handled)
            {
                Range fragment = Fragment;
                ApplyAutocomplete(TargetControl, item, fragment);
            }

            Close();
            //
            var args2 = new SelectedEventArgs
            {
                Item    = item,
                Control = TargetControl
            };

            item.OnSelected(args2);
            OnSelected(args2);
        }
Пример #8
0
        public void SetToolTip(AutocompleteItem autocompleteItem)
        {
            string title = VisibleItems[SelectedItemIndex].ToolTipTitle;
            string text  = VisibleItems[SelectedItemIndex].ToolTipText;

            if (string.IsNullOrEmpty(title))
            {
                toolTip.ToolTipTitle = null;
                toolTip.SetToolTip(this, null);
                return;
            }

            if (string.IsNullOrEmpty(text))
            {
                toolTip.ToolTipTitle = null;
                toolTip.Show(title, this, Width + 3, 0, 3000);
            }
            else
            {
                toolTip.ToolTipTitle = title;
                toolTip.Show(text, this, Width + 3, 0, 3000);
            }
        }
Пример #9
0
        private void ApplyAutocomplete(AutocompleteItem item, Range fragment)
        {
            var newText = item.GetTextForReplace();
            //replace text of fragment

            var expressionTextBox = (TargetControlWrapper.TargetControl as ExpressionTextBox);
            var scintillaEditor   =
                (TargetControlWrapper.TargetControl as ScintillaCodeEditorControl);

            var isExponent = false;

            if (expressionTextBox != null)
            {
                isExponent = expressionTextBox.ExponentMode;
            }
            else if (scintillaEditor != null)
            {
                isExponent = scintillaEditor.ExponentMode;
            }


            fragment.Text = isExponent ? SpecialSymbols.AsciiToSuperscript(newText) : newText;
            fragment.TargetWrapper.TargetControl.Focus();
        }
 public void ShowToolTip(AutocompleteItem autocompleteItem, Control control = null)
 {
 }
 private void ApplyAutocomplete(AutocompleteItem item, Range fragment)
 {
     string newText = item.GetTextForReplace();
     //replace text of fragment
     fragment.Text = newText;
     fragment.TargetWrapper.TargetControl.Focus();
 }
        public void AddItem(AutocompleteItem item)
        {
            if (sourceItems == null)
                sourceItems = new List<AutocompleteItem>();

            if (sourceItems is IList)
                (sourceItems as IList).Add(item);
            else
                throw new Exception("Current autocomplete items does not support adding");
        }
Пример #13
0
        public void ShowToolTip(AutocompleteItem autocompleteItem, Control control = null)
        {
            string title = autocompleteItem.ToolTipTitle;
            string text = autocompleteItem.ToolTipText;
            if (control == null)
                control = this;

            if (string.IsNullOrEmpty(title))
            {
                toolTip.ToolTipTitle = null;
                toolTip.SetToolTip(control, null);
                return;
            }

            if (string.IsNullOrEmpty(text))
            {
                toolTip.ToolTipTitle = null;
                toolTip.Show(title, control, Width + 3, 0, ToolTipDuration);
            }
            else
            {
                toolTip.ToolTipTitle = title;
                toolTip.Show(text, control, Width + 3, 0, ToolTipDuration);
            }
        }
        public void SetToolTip(AutocompleteItem autocompleteItem)
        {
            string title = VisibleItems[SelectedItemIndex].ToolTipTitle;
            string text = VisibleItems[SelectedItemIndex].ToolTipText;

            if (string.IsNullOrEmpty(title))
            {
                toolTip.ToolTipTitle = null;
                toolTip.SetToolTip(this, null);
                return;
            }

            if (string.IsNullOrEmpty(text))
            {
                toolTip.ToolTipTitle = null;
                toolTip.Show(title, this, Width + 3, 0, 3000);
            }
            else
            {
                toolTip.ToolTipTitle = title;
                toolTip.Show(text, this, Width + 3, 0, 3000);
            }
        }
Пример #15
0
        // A function that returns an autoCompleteMenuItem
        private static AutocompleteItem CreateOne(string text, string menuText, string tooltipText, string tooltipTitle, int imageIndex)
        {
            AutocompleteItem tempItm = new AutocompleteItem();

            tempItm.Text = text;
            tempItm.MenuText = menuText;
            tempItm.ToolTipText = tooltipText;
            tempItm.ToolTipTitle = tooltipTitle;
            tempItm.ImageIndex = imageIndex;
            return tempItm;
        }