Exemplo n.º 1
0
        /// <summary>
        /// Creates a new code completion window.
        /// </summary>
        public CompletionWindow(TextArea textArea) : base(textArea)
        {
            CompletionList = new CompletionList();
            // keep height automatic
            CloseAutomatically = true;
            MaxHeight          = 225;
            Width = 175;
            Child = CompletionList;
            // prevent user from resizing window to 0x0
            MinHeight = 15;
            MinWidth  = 30;

            _toolTipContent = new ContentControl();
            _toolTipContent.Classes.Add("ToolTip");

            _toolTip = new PopupWithCustomPosition
            {
                IsLightDismissEnabled = true,
                PlacementTarget       = this,
                PlacementMode         = PlacementMode.Right,
                Child = _toolTipContent,
            };

            LogicalChildren.Add(_toolTip);

            //_toolTip.Closed += (o, e) => ((Popup)o).Child = null;

            AttachEvents();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new code completion window.
        /// </summary>
        public CompletionWindow(TextArea textArea) : base(textArea, (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).MainWindow.PlatformImpl.CreatePopup())
        {
            CompletionList = new CompletionList();
            // keep height automatic
            CloseAutomatically = true;
            MaxHeight          = 225;
            Width   = 175;
            Content = CompletionList;
            // prevent user from resizing window to 0x0
            MinHeight = 15;
            MinWidth  = 30;

            _toolTipContent = new ContentControl();
            _toolTipContent.Classes.Add("ToolTip");

            _toolTip = new PopupWithCustomPosition
            {
                StaysOpen       = false,
                PlacementTarget = this,
                PlacementMode   = PlacementMode.Right,
                Child           = _toolTipContent,
            };

            LogicalChildren.Add(_toolTip);

            //_toolTip.Closed += (o, e) => ((Popup)o).Child = null;

            AttachEvents();
        }
Exemplo n.º 3
0
        private void CaretPositionChanged(object sender, EventArgs e)
        {
            var offset = TextArea.Caret.Offset;

            if (offset == StartOffset)
            {
                if (CloseAutomatically && CloseWhenCaretAtBeginning)
                {
                    Hide();
                }
                else
                {
                    CompletionList.SelectItem(string.Empty);
                }
                return;
            }
            if (offset < StartOffset || offset > EndOffset)
            {
                if (CloseAutomatically)
                {
                    Hide();
                }
            }
            else
            {
                var document = TextArea.Document;
                if (document != null)
                {
                    CompletionList.SelectItem(document.GetText(StartOffset, offset - StartOffset));
                }
            }
        }
Exemplo n.º 4
0
 public void Show(string e)
 {
     if (!string.IsNullOrEmpty(e))
     {
         CompletionList.SelectItem(e);
     }
     if (CompletionList.ListBox.ItemCount > 0)
     {
         Show();
     }
 }