Example #1
0
        public void HighlightThisAndDescendants()
        {
            IsHighlighted = true;

            HighlightThis();

            foreach (Shape e in Lines)
            {
                e.Stroke = (Brush)FindResource("0LightHighlightBrush");
                e.Fill   = (Brush)FindResource("0LightHighlightBrush");

                Panel.SetZIndex(e, 99998);

                if (e.Tag != null)
                {
                    LineTagStore lineTag = (LineTagStore)e.Tag;

                    if (lineTag.MetaLabel != null)
                    {
                        lineTag.MetaLabel.Foreground = (Brush)FindResource("0HighlightBrush");
                        Panel.SetZIndex(lineTag.MetaLabel, 99998);
                    }

                    lineTag.ToWrapper.HighlightThis();

                    if (lineTag.FromWrapper != this)
                    {
                        lineTag.FromWrapper.HighlightThis();
                    }
                }
            }
        }
Example #2
0
        protected void AddLine(SimpleVisualiserWrapper FromWrapper, SimpleVisualiserWrapper ToWrapper, IVertex meta)
        {
            LineTagStore lineTag = new LineTagStore();

            lineTag.ToWrapper   = ToWrapper;
            lineTag.FromWrapper = FromWrapper;

            ArrowLine l = new ArrowLine();

            l.Tag = lineTag;

            FromWrapper.Lines.Add(l);
            ToWrapper.Lines.Add(l);

            l.X1 = Canvas.GetLeft(FromWrapper) + FromWrapper.ActualWidth / 2;
            l.Y1 = Canvas.GetTop(FromWrapper) + FromWrapper.ActualHeight / 2;

            double tX = Canvas.GetLeft(ToWrapper) + ToWrapper.ActualWidth / 2;
            double tY = Canvas.GetTop(ToWrapper) + ToWrapper.ActualHeight / 2;

            double testX = l.X1 - tX;
            double testY = l.Y1 - tY;

            if (testX == 0)
            {
                testX = 0.001;
            }
            if (testY == 0)
            {
                testY = 0.001;
            }

            if (testY <= 0 && Math.Abs(testX * ToWrapper.ActualHeight) <= Math.Abs(testY * ToWrapper.ActualWidth))
            {
                l.X2 = tX - (ToWrapper.ActualHeight / 2 * testX / testY);
                l.Y2 = tY - ToWrapper.ActualHeight / 2;
            }

            if (testY > 0 && Math.Abs(testX * ToWrapper.ActualHeight) <= Math.Abs(testY * ToWrapper.ActualWidth))
            {
                l.X2 = tX + (ToWrapper.ActualHeight / 2 * testX / testY);
                l.Y2 = tY + ToWrapper.ActualHeight / 2;
            }

            if (testX >= 0 && Math.Abs(testX * ToWrapper.ActualHeight) >= Math.Abs(testY * ToWrapper.ActualWidth))
            {
                l.X2 = tX + ToWrapper.ActualWidth / 2;
                l.Y2 = tY + (ToWrapper.ActualWidth / 2 * testY / testX);
            }

            if (testX <= 0 && Math.Abs(testX * ToWrapper.ActualHeight) >= Math.Abs(testY * ToWrapper.ActualWidth))
            {
                l.X2 = tX - ToWrapper.ActualWidth / 2;
                l.Y2 = tY - (ToWrapper.ActualWidth / 2 * testY / testX);
            }

            l.Stroke = (Brush)FindResource("0LightGrayBrush");

            l.EndEnding = LineEndEnum.FilledTriangle;
            l.Fill      = (Brush)FindResource("0LightGrayBrush");

            Panel.SetZIndex(l, 0);

            Children.Add(l);

            if (MetaLabels && meta.Value != null && !GeneralUtil.CompareStrings(meta.Value, "$Empty"))
            {
                TextBlock b = new TextBlock();
                b.Text = meta.Value.ToString();

                Canvas.SetLeft(b, l.X1 + ((l.X2 - l.X1) / 2));
                Canvas.SetTop(b, l.Y1 + ((l.Y2 - l.Y1) / 2));

                b.Foreground = (Brush)FindResource("0LightGrayBrush");

                Children.Add(b);

                lineTag.MetaLabel = b;
            }
        }