void RichTextBoxEx_Loaded(object sender, RoutedEventArgs e) { if (IntellisenseList.Parent == null) { (this.Parent as Grid).Children.Add(IntellisenseList); //Create the style with Margin=0 for the Paragraph Style style = new Style { TargetType = typeof(Paragraph) }; style.Setters.Add(new Setter(Paragraph.MarginProperty, new Thickness(0))); //Add the style as resource. this.Resources.Add(typeof(Paragraph), style); } IntellisenseList.SetValue(Canvas.ZIndexProperty, 1000); if (this.Parent.GetType() != typeof(Grid)) { throw new Exception("This control must be inside Grid control."); } if (ContentAssistTriggers.Count == 0) { ContentAssistTriggers.Add('.'); } this.BorderThickness = new Thickness(1); this.BorderBrush = Brushes.Black; IntellisenseList.MaxHeight = 100; IntellisenseList.MinWidth = 100; IntellisenseList.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; IntellisenseList.VerticalAlignment = System.Windows.VerticalAlignment.Top; IntellisenseList.Visibility = System.Windows.Visibility.Collapsed; IntellisenseList.BorderThickness = new Thickness(1); IntellisenseList.MouseDoubleClick += new MouseButtonEventHandler(AssistListBox_MouseDoubleClick); IntellisenseList.PreviewKeyDown += new KeyEventHandler(AssistListBox_PreviewKeyDown); UpdateInfo(); }
public MacrosView() { InitializeComponent(); DataContext = this; foreach (var i in Variables) { ContentAssistSource.Add(i); ContentAssistTriggers.Add(i[0]); } ContentAssistSource.Add("off"); }
private void RichTextBoxEx_Loaded(object sender, RoutedEventArgs e) { //init the assist list box if (this.Parent.GetType() != typeof(Grid)) { throw new Exception("this control must be put in Grid control"); } if (AssistPopup.Child != null) { return; } if (ContentAssistTriggers.Count == 0) { ContentAssistTriggers.Add('@'); } AssistPopup.PopupAnimation = PopupAnimation.Fade; AssistPopup.MaxHeight = 100; AssistPopup.MinWidth = 140; AssistPopup.PlacementTarget = this.Parent as Grid; AssistPopup.Placement = PlacementMode.Left; AssistPopup.StaysOpen = false; AssistPopup.IsOpen = false; AssistPopup.AllowsTransparency = true; AssistPopup.Closed += AssistPopup_Closed; //(this.Parent as Grid).Children.Add(AssistListBox); Border border = new Border() { BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(2), BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E0E0E0")), Margin = new Thickness(0), Background = Brushes.White, }; AssistListBox.MaxHeight = 100; AssistListBox.MinWidth = 140; AssistListBox.Margin = new Thickness(0); AssistListBox.BorderThickness = new Thickness(0); AssistListBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; AssistListBox.VerticalAlignment = System.Windows.VerticalAlignment.Top; AssistListBox.SnapsToDevicePixels = true; //AssistListBox.Visibility = System.Windows.Visibility.Collapsed; AssistListBox.MouseDoubleClick += new MouseButtonEventHandler(AssistListBox_MouseDoubleClick); AssistListBox.PreviewKeyDown += new KeyEventHandler(AssistListBox_PreviewKeyDown); border.Child = AssistListBox; AssistPopup.Child = border; }
protected override void OnTextInput(System.Windows.Input.TextCompositionEventArgs e) { base.OnTextInput(e); if (IsAssistKeyPressed == false && e.Text.Length == 1) { if (ContentAssistTriggers.Contains(char.Parse(e.Text))) { ResetAssistListBoxLocation(); IsAssistKeyPressed = true; FilterAssistBoxItemsSource(); return; } } if (IsAssistKeyPressed) { sbLastWords.Append(e.Text); FilterAssistBoxItemsSource(); } }