public void SelectItem(CompletionListItem item) { if (selectedItem != null) { selectedItem.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)246, (byte)246, (byte)246)); } this.selectedItem = item; this.selectedItem.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)112, (byte)183, (byte)255)); //this.selectedItem.Corner //this.toolTip.Content = item.original.Descripti on; this.border2.Child = (UIElement)item.original.Description; this.scroller.ScrollToVerticalOffset(this.selectedItem.ActualHeight * items.IndexOf(item) - this.Height / 2); }
public CompletionWindow() { StackPanel outerPanel = new StackPanel(); outerPanel.Orientation = Orientation.Horizontal; Border border = new Border(); this.scroller = new ScrollViewer(); StackPanel panel = new StackPanel(); Main main = Main.Get(); items = panel.Children; panel.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)246, (byte)246, (byte)246)); this.Width = 600; this.Height = 230; //this.Topmost = true; foreach (ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData item in main.completionData) { CompletionListItem element = new CompletionListItem(); element.Text = item.Text; element.original = item; element.Image = item.Image; element.PreviewMouseUp += delegate(object o, System.Windows.Input.MouseButtonEventArgs args) { if (args.ChangedButton == System.Windows.Input.MouseButton.Left) { if (o == this.selectedItem) { Main.Get().AcceptCompletion(); return; } SelectItem((CompletionListItem)o); } main.editor.Focus(); }; panel.Children.Add(element); } this.scroller.Content = panel; border.BorderThickness = new System.Windows.Thickness(1, 1, 1, 1); border.BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)118, (byte)118, (byte)118)); border.CornerRadius = new System.Windows.CornerRadius(2, 2, 2, 2); border.Width = 180; border.Child = this.scroller; outerPanel.Children.Add(border); border2.BorderThickness = new System.Windows.Thickness(0, 1, 1, 1); border2.BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)118, (byte)118, (byte)118)); border2.CornerRadius = new System.Windows.CornerRadius(2, 2, 2, 2); border2.Width = 420; border2.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)246, (byte)246, (byte)246)); outerPanel.Children.Add(border2); outerPanel.Background = System.Windows.Media.Brushes.White; //border2. this.BackColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.White); this.Child = outerPanel; this.SelectFirstVisible(); }