Пример #1
0
        private void ExpandAnimation(Node children, OrgNodeViewModel source, Connector org)
        {
            Node sourcenode = null;

            foreach (Node node in sfdiagram.Page.Children.OfType <Node>())
            {
                if (node.DataContext == source)
                {
                    sourcenode = node;
                }
            }
            OpacityAnimation(children);
            if (sourcenode != null)
            {
                DateTime dt = DateTime.Now;
                sb1            = new Storyboard();
                sb1.Completed += (s, e) =>
                {
                    if (ChartViewModel.SelectedObject != null)
                    {
                        if (((ChartViewModel.SelectedObject as OrgNodeViewModel).Content as Employee).IsExpand == State.Expand)
                        {
                            Update((ChartViewModel.SelectedObject as OrgNodeViewModel));
                        }
                    }
                };
            }
        }
Пример #2
0
        //Expands the Child Nodes
        private void Show(OrgNodeViewModel n)
        {
            if ((n.Content as Employee).IsExpand == State.Expand)
            {
                foreach (OrgConnectorViewModel con in (n.Info as INodeInfo).OutConnectors)
                {
                    foreach (Connector line in sfdiagram.Page.Children.OfType <Connector>())
                    {
                        if (line.DataContext == con)
                        {
                            ExpandAnimation(line);
                        }
                    }
                    con.Visible = true;

                    foreach (Node n1 in sfdiagram.Page.Children.OfType <Node>())
                    {
                        if ((con.TargetNode as OrgNodeViewModel) == n1.DataContext)
                        {
                            ExpandAnimation(n1);
                        }
                    }
                    (con.TargetNode as OrgNodeViewModel).Visible = true;
                    Show((con.TargetNode as OrgNodeViewModel));
                }
            }
        }
Пример #3
0
        //Expands the Child Nodes
        private void ApplyAnimation(OrgNodeViewModel n)
        {
            Connector con = null;

            if ((n.Content as Employee).IsExpand == State.Expand)
            {
                foreach (OrgConnectorViewModel con1 in (n.Info as INodeInfo).OutConnectors)
                {
                    foreach (Connector line in sfdiagram.Page.Children.OfType <Connector>()
                             .Where(connector => connector.TargetNode == con1.TargetNode || connector.SourceNode == con1.TargetNode))
                    {
                        if (line.SourceNode == n || line.TargetNode == n)
                        {
                            con = line;
                        }
                    }

                    foreach (Node v in sfdiagram.Page.Children.OfType <Node>())
                    {
                        if (v.DataContext == con1.TargetNode)
                        {
                            ExpandAnimation(v, n as OrgNodeViewModel, con);
                        }
                    }

                    ApplyAnimation(con1.TargetNode as OrgNodeViewModel);
                }
            }
        }
Пример #4
0
 private void HidePopup(OrgNodeViewModel node)
 {
     if (node != null)
     {
         if (((node as OrgNodeViewModel).CustomToolTip as Popup) != null)
         {
             ((node as OrgNodeViewModel).CustomToolTip as Popup).IsOpen = false;
         }
     }
 }
Пример #5
0
        void OrgDiagram_Unloaded(object sender, RoutedEventArgs e)
        {
            sfdiagram.LayoutManager = null;
            //sfdiagram.ViewDictionary = null;
            this.Unloaded -= OrgDiagram_Unloaded;
            IGraphInfo graphInfo = sfdiagram.Info as IGraphInfo;

            ;
            foreach (IConnector connector in (IEnumerable <object>)sfdiagram.Connectors)
            {
                connector.SourceNode = null;
                connector.TargetNode = null;
            }

            foreach (FrameworkElement child in sfdiagram.Page.Children)
            {
                if (child is Node)
                {
                    OrgNodeViewModel vm = child.DataContext as OrgNodeViewModel;
                    if (vm != null)
                    {
                        vm.CustomToolTip = null;
                    }
                    child.MouseEnter          -= Node_PointerEntered_1;
                    child.MouseLeave          -= Node_PointerExited_1;
                    child.MouseLeftButtonDown -= Node_PointerPressed_1;
                }
                child.DataContext = null;
            }

            sfdiagram.Nodes      = null;
            sfdiagram.Connectors = null;

            SelectorViewModel selec = sfdiagram.SelectedItems as SelectorViewModel;

            if (selec != null)
            {
                selec.Connectors = null;
                selec.Nodes      = null;
                selec.Groups     = null;
            }
            sfdiagram.DataContext   = null;
            sfdiagram.SFSelector    = null;
            sfdiagram.SelectedItems = null;
            this.DataContext        = null;
            DiagramCommand.SetCommand(sfdiagram, null);

            this.Loaded   -= OrgDiagram_Loaded;
            this.Unloaded -= OrgDiagram_Unloaded;
            if (sfdiagram != null)
            {
                sfdiagram.Loaded    -= sfdiagram_Loaded;
                sfdiagram.MouseMove -= sfdiagram_PointerMoved;
            }
        }
Пример #6
0
        private void MovePrevious()
        {
            previous.MoveNext();
            OrgNodeViewModel org = previous.Current;

            if (org != null)
            {
                ((org as OrgNodeViewModel).Content as Employee).IsSearched = true;
                ((org as OrgNodeViewModel).Content as Employee).IsFocus    = NodeFocusState.Focused;
                (ChartViewModel.ScrollViewer as ScrollViewer).BringIntoCenter(((org as OrgNodeViewModel).Info as INodeInfo).Bounds);
            }
        }
Пример #7
0
 private void OnPrevious(object obj)
 {
     if ((ChartViewModel.Searchview as SearchViewModel).SearchResult.Count > 0)
     {
         if (ChartViewModel.ScrollViewer != null)
         {
             if (click < 0 || click >= (ChartViewModel.Searchview as SearchViewModel).SearchResult.Count - 1)
             {
                 click = 0;
             }
             CheckSearcheItem();
             if (click >= 0)
             {
                 OrgNodeViewModel org = ((ChartViewModel.Searchview as SearchViewModel).SearchResult[click] as OrgNodeViewModel);
                 (ChartViewModel.ScrollViewer as ScrollViewer).BringIntoCenter((org.Info as INodeInfo).Bounds);
                 (org.Content as Employee).IsSearched = true;
             }
         }
     }
 }
Пример #8
0
 private void Update(OrgNodeViewModel n)
 {
     if ((n.Content as Employee).IsExpand == State.Expand)
     {
         foreach (OrgConnectorViewModel con in (n.Info as INodeInfo).OutConnectors)
         {
             (con.TargetNode as OrgNodeViewModel).Visible = true;
             foreach (Connector line in sfdiagram.Page.Children.OfType <Connector>()
                      .Where(connector => connector.TargetNode == con.TargetNode || connector.SourceNode == con.TargetNode))
             {
                 if (line.SourceNode == n || line.TargetNode == n)
                 {
                     (line.DataContext as OrgConnectorViewModel).Visible = true;
                     OpacityAnimation(line);
                 }
             }
             Update((con.TargetNode as OrgNodeViewModel));
         }
     }
 }
Пример #9
0
 //Collapses the Child Nodes
 private static void Hide(OrgNodeViewModel n)
 {
     foreach (OrgNodeViewModel node in diagram.Page.Children.OfType <Connector>()
              .Where(connector => (connector.SourceNode as OrgNodeViewModel) == n)
              .Select(connector => (connector.TargetNode as OrgNodeViewModel)))
     {
         foreach (Connector line in diagram.Page.Children.OfType <Connector>()
                  .Where(connector => connector.TargetNode == node || connector.SourceNode == node))
         {
             (line.DataContext as OrgConnectorViewModel).Visible = false;
             CollapseAnimation(line);
         }
         foreach (Node v in diagram.Page.Children.OfType <Node>())
         {
             if (v.DataContext == node)
             {
                 CollapseAnimation(v);
                 (v.DataContext as OrgNodeViewModel).Visible = false;
             }
         }
         Hide(node);
     }
 }