Inheritance: System.Windows.Controls.UserControl
Exemplo n.º 1
0
 protected void OnSelected(DiagramNode sender, RoutedEventArgs eventArguments)
 {
     if (Selected != null)
     {
         Selected(sender, eventArguments);
     }
 }
Exemplo n.º 2
0
 protected void OnCollapsed(DiagramNode sender, RoutedEventArgs eventArguments)
 {
     OnSelected(sender, eventArguments);
     if (Collapsed != null)
     {
         Collapsed(this, eventArguments);
     }
 }
Exemplo n.º 3
0
 protected void OnExpanded(DiagramNode sender, RoutedEventArgs eventArguments)
 {
     OnSelected(sender, eventArguments);
     if (Expanded != null)
     {
         Expanded(this, eventArguments);
     }
 }
Exemplo n.º 4
0
 private void NodeSelected(DiagramNode sender, RoutedEventArgs eventArguments)
 {
     if (frictionScrollViewer != null)
     {
         frictionScrollViewer.AutoScrollTarget = sender.Location;
     }
     //throw new NotImplementedException();
 }
Exemplo n.º 5
0
        public void LoadDiagramNodes()
        {
            DiagramNode root = new DiagramNode("Root", null, "../Images/DiagramRootNode.png", "Dummy1View", "this is the root node");

            DiagramNode a = new DiagramNode("A", root, "../Images/DiagramNode.png", "Dummy1View", "this is node A");
            DiagramNode b = new DiagramNode("B", root, "../Images/DiagramNode.png", "Dummy1View", "this is node B");
            DiagramNode c = new DiagramNode("C", root, "../Images/DiagramNode.png", "Dummy1View", "this is node C");
            DiagramNode d = new DiagramNode("D", root, "../Images/DiagramNode.png", "Dummy1View", "this is node D");
            DiagramNode e = new DiagramNode("E", root, "../Images/DiagramNode.png", "Dummy1View", "this is node E");
            DiagramNode f = new DiagramNode("F", root, "../Images/DiagramNode.png", "Dummy1View", "this is node F");

            DiagramNode a1 = new DiagramNode("A.1", a, "../Images/DiagramNode.png", "Dummy1View", "this is node A.1");
            DiagramNode a2 = new DiagramNode("A.2", a, "../Images/DiagramNode.png", "Dummy1View", "this is node A.2");
            DiagramNode a3 = new DiagramNode("A.3", a, "../Images/DiagramNode.png", "Dummy1View", "this is node A.3");
            DiagramNode a4 = new DiagramNode("A.4", a, "../Images/DiagramNode.png", "Dummy1View", "this is node A.4");

            DiagramNode a1a = new DiagramNode("A.1.A", a1, "../Images/DiagramNode.png", "Dummy1View", "this is node A.1.A");
            DiagramNode a1b = new DiagramNode("A.1.B", a1, "../Images/DiagramNode.png", "Dummy1View", "this is node A.1.B");
            DiagramNode a1c = new DiagramNode("A.1.C", a1, "../Images/DiagramNode.png", "Dummy1View", "this is node A.1.C");
            DiagramNode a1d = new DiagramNode("A.1.D", a1, "../Images/DiagramNode.png", "Dummy1View", "this is node A.1.D");

            DiagramNode a1a1 = new DiagramNode("A.1.A.1", a1a, "../Images/DiagramNode.png", "Dummy1View", "this is node A.1.A.1");

            DiagramNode b1 = new DiagramNode("B.1", b, "../Images/DiagramNode.png", "Dummy1View", "this is node B.1");
            DiagramNode b2 = new DiagramNode("B.2", b, "../Images/DiagramNode.png", "Dummy1View", "this is node B.2");
            DiagramNode b3 = new DiagramNode("B.3", b, "../Images/DiagramNode.png", "Dummy1View", "this is node B.3");
            DiagramNode b4 = new DiagramNode("B.4", b, "../Images/DiagramNode.png", "Dummy1View", "this is node B.4");

            DiagramNode b1a = new DiagramNode("B.1.A", b1, "../Images/DiagramNode.png", "Dummy1View", "this is node B.1.A");
            DiagramNode b1b = new DiagramNode("B.1.B", b1, "../Images/DiagramNode.png", "Dummy1View", "this is node B.1.B");


            DiagramNode c1 = new DiagramNode("C.1", c, "../Images/DiagramNode.png", "Dummy1View", "this is node C.1");
            DiagramNode c2 = new DiagramNode("C.2", c, "../Images/DiagramNode.png", "Dummy1View", "this is node C.2");
            DiagramNode c3 = new DiagramNode("C.3", c, "../Images/DiagramNode.png", "Dummy1View", "this is node C.3");
            DiagramNode c4 = new DiagramNode("C.4", c, "../Images/DiagramNode.png", "Dummy1View", "this is node C.4");

            DiagramNode d1 = new DiagramNode("D.1", d, "../Images/DiagramNode.png", "Dummy1View", "this is node D.1");
            DiagramNode d2 = new DiagramNode("D.2", d, "../Images/DiagramNode.png", "Dummy1View", "this is node D.2");
            DiagramNode d3 = new DiagramNode("D.3", d, "../Images/DiagramNode.png", "Dummy1View", "this is node D.3");
            DiagramNode d4 = new DiagramNode("D.4", d, "../Images/DiagramNode.png", "Dummy1View", "this is node D.4");

            DiagramNode e1 = new DiagramNode("E.1", e, "../Images/DiagramNode.png", "Dummy1View", "this is node E.1");
            DiagramNode e2 = new DiagramNode("E.2", e, "../Images/DiagramNode.png", "Dummy1View", "this is node E.2");
            DiagramNode e3 = new DiagramNode("E.3", e, "../Images/DiagramNode.png", "Dummy1View", "this is node E.3");
            DiagramNode e4 = new DiagramNode("E.4", e, "../Images/DiagramNode.png", "Dummy1View", "this is node E.4");

            DiagramNode f1 = new DiagramNode("F.1", f, "../Images/DiagramNode.png", "Dummy1View", "this is node F.1");
            DiagramNode f2 = new DiagramNode("F.2", f, "../Images/DiagramNode.png", "Dummy1View", "this is node F.2");
            DiagramNode f3 = new DiagramNode("F.3", f, "../Images/DiagramNode.png", "Dummy1View", "this is node F.3");
            DiagramNode f4 = new DiagramNode("F.4", f, "../Images/DiagramNode.png", "Dummy1View", "this is node F.4");
            DiagramNode f5 = new DiagramNode("F.5", f, "../Images/DiagramNode.png", "Dummy1View", "this is node F.5");
            DiagramNode f6 = new DiagramNode("F.6", f, "../Images/DiagramNode.png", "Dummy1View", "this is node F.6");


            diagramViewer.RootNode             = root;
            diagramViewer.FrictionScrollViewer = this.sv;
        }
Exemplo n.º 6
0
        public void LoadDiagramNodes()
        {
            DiagramNode root = new DiagramNode("Root", null, "../Images/DiagramRootNode.png", "Dummy1View","this is the root node");

            DiagramNode a = new DiagramNode("A", root, "../Images/DiagramNode.png", "Dummy1View", "this is node A");
            DiagramNode b = new DiagramNode("B", root, "../Images/DiagramNode.png", "Dummy1View", "this is node B");
            DiagramNode c = new DiagramNode("C", root, "../Images/DiagramNode.png", "Dummy1View", "this is node C");
            DiagramNode d = new DiagramNode("D", root, "../Images/DiagramNode.png", "Dummy1View", "this is node D");
            DiagramNode e = new DiagramNode("E", root, "../Images/DiagramNode.png", "Dummy1View", "this is node E");
            DiagramNode f = new DiagramNode("F", root, "../Images/DiagramNode.png", "Dummy1View", "this is node F");

            DiagramNode a1 = new DiagramNode("A.1", a, "../Images/DiagramNode.png", "Dummy1View", "this is node A.1");
            DiagramNode a2 = new DiagramNode("A.2", a, "../Images/DiagramNode.png", "Dummy1View", "this is node A.2");
            DiagramNode a3 = new DiagramNode("A.3", a, "../Images/DiagramNode.png", "Dummy1View", "this is node A.3");
            DiagramNode a4 = new DiagramNode("A.4", a, "../Images/DiagramNode.png", "Dummy1View", "this is node A.4");

            DiagramNode a1a = new DiagramNode("A.1.A", a1, "../Images/DiagramNode.png", "Dummy1View", "this is node A.1.A");
            DiagramNode a1b = new DiagramNode("A.1.B", a1, "../Images/DiagramNode.png", "Dummy1View", "this is node A.1.B");
            DiagramNode a1c = new DiagramNode("A.1.C", a1, "../Images/DiagramNode.png", "Dummy1View", "this is node A.1.C");
            DiagramNode a1d = new DiagramNode("A.1.D", a1, "../Images/DiagramNode.png", "Dummy1View", "this is node A.1.D");

            DiagramNode a1a1 = new DiagramNode("A.1.A.1", a1a, "../Images/DiagramNode.png", "Dummy1View", "this is node A.1.A.1");

            DiagramNode b1 = new DiagramNode("B.1", b, "../Images/DiagramNode.png", "Dummy1View", "this is node B.1");
            DiagramNode b2 = new DiagramNode("B.2", b, "../Images/DiagramNode.png", "Dummy1View", "this is node B.2");
            DiagramNode b3 = new DiagramNode("B.3", b, "../Images/DiagramNode.png", "Dummy1View", "this is node B.3");
            DiagramNode b4 = new DiagramNode("B.4", b, "../Images/DiagramNode.png", "Dummy1View", "this is node B.4");

            DiagramNode b1a = new DiagramNode("B.1.A", b1, "../Images/DiagramNode.png", "Dummy1View", "this is node B.1.A");
            DiagramNode b1b = new DiagramNode("B.1.B", b1, "../Images/DiagramNode.png", "Dummy1View", "this is node B.1.B");

            DiagramNode c1 = new DiagramNode("C.1", c, "../Images/DiagramNode.png", "Dummy1View", "this is node C.1");
            DiagramNode c2 = new DiagramNode("C.2", c, "../Images/DiagramNode.png", "Dummy1View", "this is node C.2");
            DiagramNode c3 = new DiagramNode("C.3", c, "../Images/DiagramNode.png", "Dummy1View", "this is node C.3");
            DiagramNode c4 = new DiagramNode("C.4", c, "../Images/DiagramNode.png", "Dummy1View", "this is node C.4");

            DiagramNode d1 = new DiagramNode("D.1", d, "../Images/DiagramNode.png", "Dummy1View", "this is node D.1");
            DiagramNode d2 = new DiagramNode("D.2", d, "../Images/DiagramNode.png", "Dummy1View", "this is node D.2");
            DiagramNode d3 = new DiagramNode("D.3", d, "../Images/DiagramNode.png", "Dummy1View", "this is node D.3");
            DiagramNode d4 = new DiagramNode("D.4", d, "../Images/DiagramNode.png", "Dummy1View", "this is node D.4");

            DiagramNode e1 = new DiagramNode("E.1", e, "../Images/DiagramNode.png", "Dummy1View", "this is node E.1");
            DiagramNode e2 = new DiagramNode("E.2", e, "../Images/DiagramNode.png", "Dummy1View", "this is node E.2");
            DiagramNode e3 = new DiagramNode("E.3", e, "../Images/DiagramNode.png", "Dummy1View", "this is node E.3");
            DiagramNode e4 = new DiagramNode("E.4", e, "../Images/DiagramNode.png", "Dummy1View", "this is node E.4");

            DiagramNode f1 = new DiagramNode("F.1", f, "../Images/DiagramNode.png", "Dummy1View", "this is node F.1");
            DiagramNode f2 = new DiagramNode("F.2", f, "../Images/DiagramNode.png", "Dummy1View", "this is node F.2");
            DiagramNode f3 = new DiagramNode("F.3", f, "../Images/DiagramNode.png", "Dummy1View", "this is node F.3");
            DiagramNode f4 = new DiagramNode("F.4", f, "../Images/DiagramNode.png", "Dummy1View", "this is node F.4");
            DiagramNode f5 = new DiagramNode("F.5", f, "../Images/DiagramNode.png", "Dummy1View", "this is node F.5");
            DiagramNode f6 = new DiagramNode("F.6", f, "../Images/DiagramNode.png", "Dummy1View", "this is node F.6");

            diagramViewer.RootNode = root;
            diagramViewer.FrictionScrollViewer = this.sv;
        }
Exemplo n.º 7
0
        private void NodeExpanded(DiagramNode sender, RoutedEventArgs eventArguments)
        {
            rootNode.Location = new Point(
                (double)GetValue(Canvas.ActualWidthProperty) / 2.0,
                (double)GetValue(Canvas.ActualHeightProperty) / 2.0);


            MakeChildrenVisible(sender);

            if (sender.DiagramParent != null)
            {
                sender.DiagramParent.Visibility = Visibility.Visible;
                foreach (DiagramNode sibling in sender.DiagramParent.DiagramChildren)
                {
                    if (sibling != sender)
                    {
                        sibling.Visibility = Visibility.Collapsed;
                    }
                }
                if (sender.DiagramParent.DiagramParent != null)
                {
                    sender.DiagramParent.DiagramParent.Visibility = Visibility.Collapsed;
                }
            }

            if (sender.DiagramChildren.Count > 0)
            {
                double startAngle           = CalculateStartAngle(sender);
                double angleBetweenChildren = (sender == rootNode ? Math.PI * 2.0 : Math.PI) / ((double)sender.DiagramChildren.Count - 0);

                double legDistance = CalculateLegDistance(sender, angleBetweenChildren);

                for (int i = 0; i < sender.DiagramChildren.Count; ++i)
                {
                    DiagramNode child = sender.DiagramChildren[i];
                    child.Selected  += new NodeStateChangedHandler(NodeSelected);
                    child.Expanded  += new NodeStateChangedHandler(NodeExpanded);
                    child.Collapsed += new NodeStateChangedHandler(NodeCollapsed);

                    Point parentLocation = sender.Location;

                    child.Location = new Point(
                        parentLocation.X + Math.Cos(startAngle + angleBetweenChildren * (double)i) * legDistance,
                        parentLocation.Y + Math.Sin(startAngle + angleBetweenChildren * (double)i) * legDistance);

                    foreach (DiagramNode childsChild in child.DiagramChildren)
                    {
                        childsChild.Visibility = Visibility.Collapsed;
                    }
                }
            }

            BaseCanvas.InvalidateArrange();
            BaseCanvas.UpdateLayout();
            BaseCanvas.InvalidateVisual();
        }
Exemplo n.º 8
0
 private void NodeCollapsed(DiagramNode sender, RoutedEventArgs eventArguments)
 {
     foreach (DiagramNode child in sender.DiagramChildren)
     {
         child.Visibility = Visibility.Collapsed;
         foreach (DiagramNode grandChildren in child.DiagramChildren)
         {
             grandChildren.Visibility = Visibility.Collapsed;
         }
     }
     BaseCanvas.InvalidateArrange();
     BaseCanvas.UpdateLayout();
     BaseCanvas.InvalidateVisual();
 }
Exemplo n.º 9
0
        public DiagramNode(String nodeName, DiagramNode treeParent,
                           string imageUrl, string navigateTo, string itemDescription)
        {
            InitializeComponent();

            this.navigateTo       = navigateTo;
            this.ToolTip          = itemDescription;
            this.diagramParent    = treeParent;
            this.NodeName.Content = nodeName;
            if (treeParent != null)
            {
                this.diagramParent.diagramChildren.Add(this);
            }
            this.btnNavigate.Tag = imageUrl;
        }
Exemplo n.º 10
0
        public DiagramNode(String nodeName, DiagramNode treeParent,
            string imageUrl, string navigateTo, string itemDescription)
        {
            InitializeComponent();

            this.navigateTo = navigateTo;
            this.ToolTip = itemDescription;
            this.diagramParent = treeParent;
            this.NodeName.Content = nodeName;
            if (treeParent != null)
            {
                this.diagramParent.diagramChildren.Add(this);
            }
            this.btnNavigate.Tag = imageUrl;
        }
Exemplo n.º 11
0
        private void MakeChildrenVisible(DiagramNode sender)
        {
            foreach (DiagramNode child in sender.DiagramChildren)
            {
                if (!BaseCanvas.Children.Contains(child))
                {
                    BaseCanvas.Children.Add(child);
                }
                else
                {
                    child.Visibility = Visibility.Visible;
                }
            }

            BaseCanvas.InvalidateArrange();
            BaseCanvas.UpdateLayout();
            BaseCanvas.InvalidateVisual();
        }
Exemplo n.º 12
0
        private static double CalculateLegDistance(DiagramNode sender, double angleBetweenChildren)
        {
            double legDistance = 1.0;
            double childToChildMinDistance = 1.0;
            foreach (DiagramNode child in sender.DiagramChildren)
            {
                legDistance = Math.Max(legDistance, sender.BoundingCircle + child.BoundingCircle);
                foreach (DiagramNode otherChild in sender.DiagramChildren)
                {
                    if (otherChild != child)
                    {
                        childToChildMinDistance = Math.Max(childToChildMinDistance, child.BoundingCircle + otherChild.BoundingCircle);
                    }
                }
            }

            legDistance = Math.Max(
                legDistance,
                (childToChildMinDistance / 2.0) / Math.Sin(angleBetweenChildren / 2.0));
            return legDistance;
        }
Exemplo n.º 13
0
        protected override void OnRender(System.Windows.Media.DrawingContext dc)
        {
            base.OnRender(dc);
            foreach (UIElement uiElement in Children)
            {
                if (uiElement is DiagramNode)
                {
                    DiagramNode node = (DiagramNode)uiElement;

                    if (node.Visibility == Visibility.Visible)
                    {
                        if (node.DiagramParent != null &&
                            node.DiagramParent.Visibility == Visibility.Visible)
                        {
                            dc.DrawLine(new Pen(Brushes.Black, 2.0),
                                        node.Location, node.DiagramParent.Location);
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        private double CalculateStartAngle(DiagramNode node)
        {
            if (node == rootNode)
            {
                return(0.0);
            }
            else
            {
                Vector parentToNode = node.Location - node.DiagramParent.Location;
                parentToNode.Normalize();
                Vector leftToRight = new Vector(1.0, 0.0);
                double angle       = Vector.AngleBetween(parentToNode, leftToRight);
                if (angle < 0)
                {
                    angle = 360 - angle;
                }

                if (node.DiagramChildren.Count > 1)
                {
                    if (node.Location.Y < node.DiagramParent.Location.Y)
                    {
                        if (node.Location.X > node.DiagramParent.Location.X)
                        {
                            angle -= 180;
                        }
                        else
                        {
                            angle -= 270;
                        }
                    }
                    else
                    {
                        angle -= 90;
                    }
                }

                return(Math.PI * angle / 180.0);
            }
        }
Exemplo n.º 15
0
        private static double CalculateLegDistance(DiagramNode sender, double angleBetweenChildren)
        {
            double legDistance             = 1.0;
            double childToChildMinDistance = 1.0;

            foreach (DiagramNode child in sender.DiagramChildren)
            {
                legDistance = Math.Max(legDistance, sender.BoundingCircle + child.BoundingCircle);
                foreach (DiagramNode otherChild in sender.DiagramChildren)
                {
                    if (otherChild != child)
                    {
                        childToChildMinDistance = Math.Max(childToChildMinDistance, child.BoundingCircle + otherChild.BoundingCircle);
                    }
                }
            }

            legDistance = Math.Max(
                legDistance,
                (childToChildMinDistance / 2.0) / Math.Sin(angleBetweenChildren / 2.0));
            return(legDistance);
        }
Exemplo n.º 16
0
        private double CalculateStartAngle(DiagramNode node)
        {
            if (node == rootNode)
            {
                return 0.0;
            }
            else
            {
                Vector parentToNode = node.Location - node.DiagramParent.Location;
                parentToNode.Normalize();
                Vector leftToRight = new Vector(1.0, 0.0);
                double angle = Vector.AngleBetween(parentToNode, leftToRight);
                if (angle < 0)
                    angle = 360 - angle;

                if (node.DiagramChildren.Count > 1)
                {
                    if (node.Location.Y < node.DiagramParent.Location.Y)
                    {
                        if (node.Location.X > node.DiagramParent.Location.X)
                            angle -= 180;
                        else
                            angle -= 270;
                    }
                    else
                    {
                        angle -= 90;
                    }
                }

                return (Math.PI * angle / 180.0);
            }
        }
Exemplo n.º 17
0
 private void NodeSelected(DiagramNode sender, RoutedEventArgs eventArguments)
 {
     if (frictionScrollViewer != null)
         frictionScrollViewer.AutoScrollTarget = sender.Location;
     //throw new NotImplementedException();
 }
Exemplo n.º 18
0
 protected void OnCollapsed(DiagramNode sender, RoutedEventArgs eventArguments)
 {
     OnSelected(sender, eventArguments);
     if (Collapsed != null)
         Collapsed(this, eventArguments);
 }
Exemplo n.º 19
0
        private void NodeExpanded(DiagramNode sender, RoutedEventArgs eventArguments)
        {
            rootNode.Location = new Point(
                (double)GetValue(Canvas.ActualWidthProperty) / 2.0,
                (double)GetValue(Canvas.ActualHeightProperty) / 2.0);

            MakeChildrenVisible(sender);

            if (sender.DiagramParent != null)
            {
                sender.DiagramParent.Visibility = Visibility.Visible;
                foreach (DiagramNode sibling in sender.DiagramParent.DiagramChildren)
                {
                    if (sibling != sender)
                        sibling.Visibility = Visibility.Collapsed;
                }
                if (sender.DiagramParent.DiagramParent != null)
                    sender.DiagramParent.DiagramParent.Visibility = Visibility.Collapsed;
            }

            if (sender.DiagramChildren.Count > 0)
            {
                double startAngle = CalculateStartAngle(sender);
                double angleBetweenChildren = (sender == rootNode ? Math.PI * 2.0 : Math.PI) / ((double)sender.DiagramChildren.Count - 0);

                double legDistance = CalculateLegDistance(sender, angleBetweenChildren);

                for (int i = 0; i < sender.DiagramChildren.Count; ++i)
                {
                    DiagramNode child = sender.DiagramChildren[i];
                    child.Selected += new NodeStateChangedHandler(NodeSelected);
                    child.Expanded += new NodeStateChangedHandler(NodeExpanded);
                    child.Collapsed += new NodeStateChangedHandler(NodeCollapsed);

                    Point parentLocation = sender.Location;

                    child.Location = new Point(
                        parentLocation.X + Math.Cos(startAngle + angleBetweenChildren * (double)i) * legDistance,
                        parentLocation.Y + Math.Sin(startAngle + angleBetweenChildren * (double)i) * legDistance);

                    foreach (DiagramNode childsChild in child.DiagramChildren)
                    {
                        childsChild.Visibility = Visibility.Collapsed;
                    }
                }
            }

            BaseCanvas.InvalidateArrange();
            BaseCanvas.UpdateLayout();
            BaseCanvas.InvalidateVisual();
        }
Exemplo n.º 20
0
 private void NodeCollapsed(DiagramNode sender, RoutedEventArgs eventArguments)
 {
     foreach (DiagramNode child in sender.DiagramChildren)
     {
         child.Visibility = Visibility.Collapsed;
         foreach (DiagramNode grandChildren in child.DiagramChildren)
         {
             grandChildren.Visibility = Visibility.Collapsed;
         }
     }
     BaseCanvas.InvalidateArrange();
     BaseCanvas.UpdateLayout();
     BaseCanvas.InvalidateVisual();
 }
Exemplo n.º 21
0
        private void MakeChildrenVisible(DiagramNode sender)
        {
            foreach (DiagramNode child in sender.DiagramChildren)
            {
                if (!BaseCanvas.Children.Contains(child))
                    BaseCanvas.Children.Add(child);
                else
                    child.Visibility = Visibility.Visible;
            }

            BaseCanvas.InvalidateArrange();
            BaseCanvas.UpdateLayout();
            BaseCanvas.InvalidateVisual();
        }
Exemplo n.º 22
0
 protected void OnExpanded(DiagramNode sender, RoutedEventArgs eventArguments)
 {
     OnSelected(sender, eventArguments);
     if (Expanded != null)
         Expanded(this, eventArguments);
 }
Exemplo n.º 23
0
 protected void OnSelected(DiagramNode sender, RoutedEventArgs eventArguments)
 {
     if (Selected != null)
         Selected(sender, eventArguments);
 }