Ejemplo n.º 1
0
        private Rectangle CreateDescription(Point origin, out Visual visual)
        {
            if (_vsGraphNodeInfo != null)
            {
                DrawingVisual  desc    = new DrawingVisual();
                DrawingContext context = desc.RenderOpen();

                string properties = "";
                foreach (KeyValuePair <GraphProperty, object> kvp in _vsGraphNodeInfo.Properties)
                {
                    string name  = kvp.Key.ToString();
                    bool   value = (kvp.Value is bool && ((bool)kvp.Value) == true);
                    if (name.StartsWith("CodeSchemaProperty_Is") && value)
                    {
                        properties += (properties.Length > 0 ? " : " : "") + name.Replace("CodeSchemaProperty_Is", "");
                    }
                }

                FormattedText fText = new FormattedText(properties, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Calibri"), _fontSize * 0.8, Brushes.Black);
                fText.SetFontStyle(FontStyles.Italic);
                fText.TextAlignment = TextAlignment.Center;

                context.DrawText(fText, CommonX.WpfPoint(origin));
                context.Close();

                _textMeasurer.FontSize = _fontSize * 0.8;
                _textMeasurer.Text     = properties;
                Size size = CommonX.Measure(_textMeasurer);

                visual = desc;
                return(new Rectangle(origin.X - size.Width / 2, origin.Y, origin.X + size.Width / 2, origin.Y + size.Height));
            }
            visual = null;
            return(new Rectangle());
        }
Ejemplo n.º 2
0
        private Rectangle CreateTitle(Point origin, out Visual visual)
        {
            DrawingVisual  title   = new DrawingVisual();
            DrawingContext context = title.RenderOpen();
            FormattedText  fText   = new FormattedText(Node.LabelText, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Calibri"), _fontSize, Brushes.Black);

            context.DrawText(fText, CommonX.WpfPoint(origin));
            context.Close();
            visual = title;

            _textMeasurer.FontSize = _fontSize;
            _textMeasurer.Text     = Node.LabelText;

            Size size = CommonX.Measure(_textMeasurer);

            return(new Rectangle(origin.X, origin.Y, origin.X + size.Width, origin.Y + size.Height));
        }
        public XLabel(Edge edge)
        {
            if (false)
            {
                TextBlock tb = null;
                if (edge.Label != null)
                {
                    tb = new TextBlock {
                        Text = edge.Label.Text
                    };
                    System.Windows.Size size = CommonX.Measure(tb);
                    tb.Width  = size.Width;
                    tb.Height = size.Height;
                    CommonX.PositionElement(tb, edge.Label.Center, 1);
                }

                _visualObject = tb;
            }

            DrawingObject = edge;
        }