public object Create() { var res = new StackPanel { Orientation = Orientation.Vertical, }; var sigGrid = new Grid(); sigGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); sigGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); res.Children.Add(sigGrid); for (int i = 1; i < writers.Count; i++) { var output = writers[i]; if (!output.IsEmpty) res.Children.Add(output.Create()); } if (Image != null) { var img = new DsImage { ImageReference = Image.Value, Margin = new Thickness(0, 0, 4, 0), VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, }; Grid.SetColumn(img, 0); sigGrid.Children.Add(img); } var sig = writers[0].Create(); Grid.SetColumn(sig, 1); sigGrid.Children.Add(sig); return res; }
void InitializeChildrens() { if (expander != null) return; ToolTip = toolTipDummy; expander = new ToggleButton { Style = (Style)FindResource("ExpandCollapseToggleStyle") }; icon = new DsImage { Width = 16, Height = 16, Margin = new Thickness(0, 0, 5, 1), VerticalAlignment = VerticalAlignment.Center, Focusable = false }; content = new ContentPresenter { Margin = new Thickness(2, 0, 6, 0), VerticalAlignment = VerticalAlignment.Center, Focusable = false }; expander.Checked += (sender, e) => { if (Node != null) Node.IsExpanded = true; }; expander.Unchecked += (sender, e) => { if (Node != null) Node.IsExpanded = false; }; AddVisualChild(expander); AddVisualChild(icon); AddVisualChild(content); UpdateChildren(Node); }
public override UIElement GenerateGlyph(WpfHexViewLine line, HexGlyphTag tag) { var glyphTag = tag as HexImageReferenceTag; if (glyphTag == null) return null; const double DEFAULT_IMAGE_LENGTH = 16; const double EXTRA_LENGTH = 2; double imageLength = Math.Min(DEFAULT_IMAGE_LENGTH, line.Height + EXTRA_LENGTH); var image = new DsImage { Width = imageLength, Height = imageLength, ImageReference = glyphTag.ImageReference, }; Panel.SetZIndex(image, glyphTag.ZIndex); return image; }
static object CreateImageUIObject(CompletionIcon icon, IImageMonikerService imageMonikerService) { var icon2 = icon as CompletionIcon2; if (icon2 == null) { var iconSource = icon.IconSource; if (iconSource == null) return null; return new Image { Width = 16, Height = 16, Source = iconSource, }; } var imageReference = imageMonikerService.ToImageReference(icon2.IconMoniker); if (imageReference.IsDefault) return null; var image = new DsImage { ImageReference = imageReference }; if (!((icon as IDsCompletionIcon)?.ThemeImage ?? false)) { DsImage.SetBackgroundColor(image, null); DsImage.SetBackgroundBrush(image, null); } return image; }
static void Add16x16Image(MenuItem menuItem, ImageReference imageReference, bool? enable = null) { var image = new DsImage { ImageReference = imageReference }; menuItem.Icon = image; if (enable == false) image.Opacity = 0.3; }
public UIElement GenerateGlyph(IWpfTextViewLine line, GlyphTextMarkerGlyphTag glyphTag) { if (line == null) throw new ArgumentNullException(nameof(line)); if (glyphTag == null) throw new ArgumentNullException(nameof(glyphTag)); Debug.Assert(!glyphTag.ImageReference.IsDefault); if (glyphTag.ImageReference.IsDefault) return null; const double DEFAULT_IMAGE_LENGTH = 16; const double EXTRA_LENGTH = 2; double imageLength = Math.Min(DEFAULT_IMAGE_LENGTH, line.Height + EXTRA_LENGTH); var image = new DsImage { Width = imageLength, Height = imageLength, ImageReference = glyphTag.ImageReference, }; Panel.SetZIndex(image, glyphTag.ZIndex); return image; }