コード例 #1
0
        public override object Create(HexToolTipContent content)
        {
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }

            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 < content.Text.Length; i++)
            {
                var text = content.Text[i];
                if (text.Count == 0)
                {
                    continue;
                }
                res.Children.Add(CreateTextElement(text));
            }
            var imgRef = content.Image as ImageReference?;

            if (imgRef != null)
            {
                var img = new DsImage {
                    ImageReference      = imgRef.Value,
                    Margin              = new Thickness(0, 0, 4, 0),
                    VerticalAlignment   = VerticalAlignment.Top,
                    HorizontalAlignment = HorizontalAlignment.Left,
                };
                Grid.SetColumn(img, 0);
                sigGrid.Children.Add(img);
            }
            if (content.Text.Length > 0)
            {
                var sig = CreateTextElement(content.Text[0]);
                Grid.SetColumn(sig, 1);
                sigGrid.Children.Add(sig);
            }
            return(res);
        }
コード例 #2
0
 /// <summary>
 /// Creates an object that can be shown in a tooltip
 /// </summary>
 /// <param name="content">Content</param>
 /// <returns></returns>
 public abstract object?Create(HexToolTipContent content);