Exemplo n.º 1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            KeyValuePair <IVertex, SimpleVisualiserWrapper> kvp = DisplayedVertexesUIElements.Where(x => ((SimpleVisualiserWrapper)x.Value).Child == e.Source).FirstOrDefault();

            if (kvp.Value != null && ((SimpleVisualiserWrapper)kvp.Value).IsHighlighted == false)
            {
                SimpleVisualiserWrapper wrapper = (SimpleVisualiserWrapper)kvp.Value;

                if (Highlighted != null)
                {
                    Highlighted.UnhighlightThisAndDescendants();
                }

                wrapper.HighlightThisAndDescendants();

                Highlighted = wrapper;
            }

            base.OnMouseEnter(e);
        }
Exemplo n.º 2
0
        protected SimpleVisualiserWrapper Add(double x, double y, FrameworkElement _e, IVertex baseVertex)
        {
            SimpleVisualiserWrapper e = new SimpleVisualiserWrapper(_e, baseVertex, this);

            Children.Add(e);

            e.UpdateLayout();

            Panel.SetZIndex(e, 1);
            Canvas.SetLeft(e, x - e.ActualWidth / 2);
            Canvas.SetTop(e, y - e.ActualHeight / 2);

            if (!DisplayedVertexesUIElements.ContainsKey(baseVertex))
            {
                DisplayedVertexesUIElements.Add(baseVertex, e);
            }
            else
            {
                DisplayedVertexesUIElements[baseVertex] = e;
            }

            return(e);
        }
Exemplo n.º 3
0
        protected void AddCircle(int level, IList <IVertex> InnerCircleVertexes)
        {
            //MinusZero.Instance.Log(1,"AddCircle", level.ToString());

            IList <IVertex> CircleVertexes = new List <IVertex>();

            if (level == 0)
            {
                IVertex b = Vertex.Get(@"BaseEdge:\To:");

                double x = this.Width / 2;
                double y = this.Height / 2;

                Add(x, y, (FrameworkElement)GetVisualiser(b), b).UpdateLayout();

                CircleVertexes.Add(b);

                AddCircle(1, CircleVertexes);

                return;
            }

            int OutAndInEdgesCount = 0;

            SimpleVisualiserWrapper dummyPointIn  = new SimpleVisualiserWrapper(null, null, this);
            SimpleVisualiserWrapper dummyPointOut = new SimpleVisualiserWrapper(null, null, this);

            foreach (IVertex v in InnerCircleVertexes)
            {
                foreach (IEdge e in v)
                {
                    if (!DisplayedVertexesUIElements.ContainsKey(e.To))
                    {
                        DisplayedVertexesUIElements.Add(e.To, dummyPointOut);
                        OutAndInEdgesCount++;
                    }
                }

                if (ShowInEdges)
                {
                    foreach (IEdge e in v.InEdges)
                    {
                        if (!DisplayedVertexesUIElements.ContainsKey(e.From))
                        {
                            DisplayedVertexesUIElements.Add(e.From, dummyPointIn);
                            OutAndInEdgesCount++;
                        }
                    }
                }
            }

            double cnt = 0;

            int CircleSize = GraphUtil.GetIntegerValue(Vertex.Get("VisualiserCircleSize:"));

            //IVertex DisplayedEdges = Vertex.Get("DisplayedEdges:");

            if (OutAndInEdgesCount > 0)
            {
                foreach (IVertex v in InnerCircleVertexes)
                {
                    SimpleVisualiserWrapper vPoint = DisplayedVertexesUIElements[v];

                    foreach (IEdge e in v)
                    {
                        if (!DisplayedVertexesUIElements.ContainsKey(e.To) || DisplayedVertexesUIElements[e.To] == dummyPointOut)
                        {
                            double x = (this.Width / 2) + Math.Cos(cnt / OutAndInEdgesCount * Math.PI * 2) * CircleSize * level;
                            double y = (this.Height / 2) + Math.Sin(cnt / OutAndInEdgesCount * Math.PI * 2) * CircleSize * level;

                            SimpleVisualiserWrapper toWrapper = Add(x, y, (FrameworkElement)GetVisualiser(e.To), e.To);

                            CircleVertexes.Add(e.To);

                            AddLine(vPoint, toWrapper, e.Meta);

                            cnt++;
                        }
                        else
                        {
                            SimpleVisualiserWrapper eToPoint = DisplayedVertexesUIElements[e.To];

                            AddLine(vPoint, eToPoint, e.Meta);
                        }
                    }

                    if (ShowInEdges)
                    {
                        foreach (IEdge e in v.InEdges)
                        {
                            if (!DisplayedVertexesUIElements.ContainsKey(e.From) || DisplayedVertexesUIElements[e.From] == dummyPointIn)
                            {
                                double x = (this.Width / 2) + Math.Cos(cnt / OutAndInEdgesCount * Math.PI * 2) * CircleSize * level;
                                double y = (this.Height / 2) + Math.Sin(cnt / OutAndInEdgesCount * Math.PI * 2) * CircleSize * level;

                                SimpleVisualiserWrapper fromWrapper = Add(x, y, (FrameworkElement)GetVisualiser(e.From), e.From);

                                CircleVertexes.Add(e.From);

                                cnt++;
                            }
                        }
                    }
                }
            }

            if (level < GraphUtil.GetIntegerValue(Vertex.Get("NumberOfCircles:")))
            {
                AddCircle(level + 1, CircleVertexes);
            }
            else // lines from last circle
            {
                foreach (IVertex v in CircleVertexes)
                {
                    SimpleVisualiserWrapper vPoint = DisplayedVertexesUIElements[v];

                    foreach (IEdge e in v)
                    {
                        if (DisplayedVertexesUIElements.ContainsKey(e.To)) // if vertex is allready displayed, connect it
                        {
                            SimpleVisualiserWrapper eToPoint = DisplayedVertexesUIElements[e.To];

                            AddLine(vPoint, eToPoint, e.Meta);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
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;
            }
        }