Inheritance: System.Windows.Controls.UserControl, ISelectableNode, ICutableNode, IPolymorphicShape, IDisposable
Exemplo n.º 1
0
        public NodeControl CreateNode(ViewModel.Node viewModelNode, SuperGraphControl parentSurface)
        {
            NodeControl nodeControl = null;

            /// TODO: We will need to consider being able to have the same viewModelNode present here twice.
            if (!Nodes.ContainsKey(viewModelNode.Id))
            {
                nodeControl = new NodeControl();
                Canvas.SetZIndex(nodeControl, 50);
                nodeControl.ParentSurface = parentSurface;
                nodeControl.DataContext = viewModelNode;
                nodeControl.VideoRemoteControl.DataContext = viewModelNode.VideoInfo;
                //nodeControl.NodeCornerControl.DataContext = viewModelNode;
                NodeControlFactorySet set = new NodeControlFactorySet();
                set.Node = viewModelNode;
                set.Control = nodeControl;

                Nodes.Add(viewModelNode.Id, set);
            }
            else
            {
                nodeControl = Nodes[viewModelNode.Id].Control;
            }

            return nodeControl;
        }
Exemplo n.º 2
0
 public RealignNode(NodeControl nodeControl)
 {
     RootDepth = 0;
     StackNumber = 0;
     NodeControl = nodeControl;
     Left = nodeControl.Centre.X;
     Top = nodeControl.Centre.Y;
 }
 public ChildrenControlCollection(NodeControl nodeControl, bool isParentIncluded = false, bool checkOneLevel = false)
 {
     _nodeControl = nodeControl;
     _isParentIncluded = isParentIncluded;
     _checkOneLevel = checkOneLevel;
     FindChildrenNodeControls();
     FindChildrenArrowControls();
 }
Exemplo n.º 4
0
 public FacadeNodeMotionHandler(NodeControl userControl)
 {
     _parent = userControl.ParentSurface;
     _parent.MapMoved += OnMapMoved;
     UserControl = userControl;
     MouseManagingControl = userControl.NodeImage;
     _selector = _parent.NodesSelector;
 }
Exemplo n.º 5
0
 public ArrowCreationSet(NodeControl nodeControl, Point location)
 {
     IsAdded = false;
     NodeControl = nodeControl;
     ArrowControl = new ArrowControl(nodeControl, null);
     From = new ArrowNodeSurrogate {Centre = location};
     To = new ArrowNodeSurrogate {Centre = location};
     Controller = new ArrowController(null, From, To);
     ArrowControl.DataContext = Controller.ViewModel;
 }
 public void ShowContextMenuForNodeControl(Point location, NodeControl nodeControl)
 {
     ParentNode = nodeControl;
     Canvas.SetLeft(this, location.X);
     Canvas.SetTop(this, location.Y);
     Visibility = Visibility.Visible;
     if (App.UserStyle == UserStyle.Author)
     {
         AuthorContextMenu.Visibility = Visibility.Visible;
         AuthorContextMenu.Focus();
         
     }
     else
     {
         ViewerContextMenu.Visibility = Visibility.Visible;
         ViewerContextMenu.Focus();
         ViewerContextMenu.Rating.DataContext = ParentNode.ViewModelNode.NodeProperties;
     }
 }
Exemplo n.º 7
0
        private ArrowControlFactorySet CreateSet(ViewModel.Relationship viewModelRelationship, NodeControl fromControl, NodeControl toControl)
        {
            ArrowController arrowController = new ArrowController(viewModelRelationship, fromControl, toControl);
            
            arrowController.ViewModel.Id = viewModelRelationship.Id;
            if (toControl != null)
            {
                toControl.LinkFromNode(fromControl);
            }
            ArrowControl arrowControl = new ArrowControl(fromControl, toControl);
            Canvas.SetZIndex(arrowControl, 40);
            arrowControl.DataContext = arrowController.ViewModel;
            if (toControl != null && toControl.ViewModelNode.State == CollapseState.None)
            {
                toControl.ViewModelNode.State = CollapseState.Expanded;
            }
            ArrowControlFactorySet set = new ArrowControlFactorySet();
            set.Relationship = viewModelRelationship;
            set.Control = arrowControl;
            set.Controller = arrowController;

            return set;
        }
Exemplo n.º 8
0
 public bool IsArrowExist(NodeControl from, NodeControl to)
 {
     var exist =
         GetRelationships()
             .FirstOrDefault(q => q != null && q.From == from.ViewModelNode.Id && q.To == to.ViewModelNode.Id);
     return exist != null;
 }
 public override void Show(NodeControl node = null)
 {
     Video.Disabled = !((MainPage)Application.Current.RootVisual).SuperGraphController.VideoController.HasVideo;
     base.Show(node);
 }
Exemplo n.º 10
0
 private void CentraliseNodeVertically(NodeControl nodeControl)
 {
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         var moveY = ActualHeight/Zoom/2 - MoveGraphTransform.Y - nodeControl.Centre.Y;
         var moveX = - MoveGraphTransform.X - nodeControl.Centre.X +
                     (GlymaParameters.NodeTextWidth/2 + GlymaParameters.Margin);
         MoveMap(moveX, moveY);
     });
 }
Exemplo n.º 11
0
        private void CentraliseNode(NodeControl nodeControl)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (App.UserStyle == UserStyle.Reader && AllowAutoRealign)
                {
                    AutoRealign();
                }


                var oldLocation = nodeControl.Centre;

                var visibleNodes = GetVisibleNodeControls();

                var locationList = visibleNodes.Select(q => q.Centre).ToList();

                var leftMost = locationList.Min(q => q.X);
                var rightMost = locationList.Max(q => q.X);
                var topMost = locationList.Min(q => q.Y);
                var bottomMost = locationList.Max(q => q.Y);

                var newLocation = oldLocation;

                var widthOffset = GlymaParameters.NodeTextWidth/2 + GlymaParameters.Margin;
                var heightOffset = (nodeControl.TextArea.ActualHeight + 40)/2 + GlymaParameters.Margin;


                if (oldLocation.X <= ActualWidth/Zoom/2 + leftMost - widthOffset)
                {
                    newLocation.X = ActualWidth/Zoom/2 + leftMost - widthOffset;
                }
                else if (oldLocation.X >= rightMost - ActualWidth/Zoom/2 + widthOffset)
                {
                    newLocation.X = rightMost - ActualWidth/Zoom/2 + widthOffset;
                }

                //This make sure if the map is smaller than the display area, it will realign the map to the center
                if (bottomMost - topMost + 80 >= ActualHeight/Zoom)
                {
                    if (oldLocation.Y < ActualHeight/Zoom/2 + topMost - heightOffset &&
                        !oldLocation.Y.Equals(bottomMost))
                    {
                        newLocation.Y = ActualHeight/Zoom/2 + topMost - heightOffset;
                    }
                    else if (oldLocation.Y > bottomMost - ActualHeight/Zoom/2 + heightOffset &&
                             !oldLocation.Y.Equals(topMost))
                    {
                        newLocation.Y = bottomMost - ActualHeight/Zoom/2 + heightOffset;
                    }
                }


                //var leftMostMove = leftMost

                var moveX = ActualWidth/Zoom/2 - MoveGraphTransform.X - newLocation.X;
                var moveY = ActualHeight/Zoom/2 - MoveGraphTransform.Y - newLocation.Y;


                MoveMap(moveX, moveY);
            });
        }
Exemplo n.º 12
0
 public NodeMotionHandler(NodeControl userControl)
 {
     ParentSurface = userControl.ParentSurface.NodeContainer;
     UserControl = userControl;
     MouseManagingControl = userControl.NodeImage;
 }
Exemplo n.º 13
0
        /// <summary>
        ///     This method is for automatical realignment, it will realigns the map (horizontally or vertically)
        ///     based on last realign operation. If there is no realign action occurred, it will realign the map horizontally.
        /// </summary>
        /// <param name="focusedControl">
        ///     If focusedControl has been set, it will automatically moves the map to make sure the focused control not being
        ///     moved.
        /// </param>
        public void AutoRealign(NodeControl focusedControl = null)
        {
            var lastPosition = new Point();
            if (focusedControl != null)
            {
                lastPosition = focusedControl.ViewModelNode.Location;
            }
            if (RealignFactory.RealignStyle == RealignStyle.Horizontal)
            {
                HorizontalRealign();
            }
            else
            {
                VerticalRealign();
            }

            if (focusedControl != null)
            {
                var currentPosintion = focusedControl.ViewModelNode.Location;
                var difference = currentPosintion.Subtract(lastPosition);
                MoveMap(-difference.X, -difference.Y);
            }
        }
Exemplo n.º 14
0
 public void LinkFromNode(NodeControl node)
 {
     AddChild(node);
     node.AddParent(this);
 }
Exemplo n.º 15
0
 public virtual void Show(NodeControl node = null)
 {
     Visibility = Visibility.Visible;
     Focus();
 }
Exemplo n.º 16
0
 public ArrowControl(NodeControl from, NodeControl to)
 {
     InitializeComponent();
     From = from;
     To = to;
 }
Exemplo n.º 17
0
 public bool ContainsNodeControl(NodeControl nodeControl)
 {
     return NodeControls.Contains(nodeControl);
 }
Exemplo n.º 18
0
 private void RemoveChild(NodeControl node)
 {
     if (ChildNodes.Contains(node))
     {
         ChildNodes.Remove(node);
     }
 }
Exemplo n.º 19
0
 private void AddChild(NodeControl node)
 {
     if (!ChildNodes.Contains(node))
     {
         ChildNodes.Add(node);
     }
 }
Exemplo n.º 20
0
 public void SelectAllChildsOfNode(NodeControl nodeControl)
 {
     foreach (var control in nodeControl.GetAllNodeControls())
     {
         AddNode(control, false);
     }
 }
Exemplo n.º 21
0
        public override void Show(NodeControl node = null)
        {
            _nodeControl = node;
            base.Show(node);
            if (node != null && !IsAdded)
            {
                if (ViewerNodeControlContextMenu != null)
                {
                    if (JavascriptCallbackRegister.Instance.HasViewerCustomContextMenuItem)
                    {
                        ViewerNodeControlContextMenu.CustomContextMenuItemSeparator.Visibility = Visibility.Visible;
                        var items = ViewerNodeControlContextMenu.PopupMenu.Items.Select(item => item as FrameworkElement).ToList();
                        var index = 0;
                        foreach (var item in items)
                        {
                            if (item.Name == "CustomContextMenuItemSeparator")
                            {
                                break;
                            }
                            index++;
                        }

                        foreach (var viewerItem in JavascriptCallbackRegister.Instance.ViewerItems)
                        {
                            var button = new SuperContextMenuItem();
                            button.IconPath = string.Empty;
                            button.Name = viewerItem;
                            button.Header = viewerItem;
                            button.MouseLeftButtonUp += ButtonOnMouseLeftButtonUp;
                            index++;
                            items.Insert(index, button);
                        }
                        IsAdded = true;
                        ViewerNodeControlContextMenu.PopupMenu.Items.Clear();
                        ViewerNodeControlContextMenu.PopupMenu.ItemsSource = items;
                    }
                    else
                    {
                        ViewerNodeControlContextMenu.CustomContextMenuItemSeparator.Visibility = Visibility.Collapsed;
                    }
                } 
                else if (AuthorNodeControlContextMenu != null)
                {
                    if (JavascriptCallbackRegister.Instance.HasAuthorCustomContextMenuItem)
                    {
                        AuthorNodeControlContextMenu.CustomContextMenuItemSeparator.Visibility = Visibility.Visible;
                        var items = AuthorNodeControlContextMenu.PopupMenu.Items.Select(item => item as FrameworkElement).ToList();
                        var index = 0;
                        foreach (var item in items)
                        {
                            if (item.Name == "CustomContextMenuItemSeparator")
                            {
                                break;
                            }
                            index ++;
                        }

                        foreach (var viewerItem in JavascriptCallbackRegister.Instance.AuthorItems)
                        {
                            var button = new SuperContextMenuItem();
                            button.IconPath = string.Empty;
                            button.Name = viewerItem;
                            button.Header = viewerItem;
                            button.MouseLeftButtonUp += ButtonOnMouseLeftButtonUp;
                            index ++;
                            items.Insert(index, button);
                        }
                        IsAdded = true;
                        AuthorNodeControlContextMenu.PopupMenu.Items.Clear();
                        AuthorNodeControlContextMenu.PopupMenu.ItemsSource = items;
                    }
                    else
                    {
                        AuthorNodeControlContextMenu.CustomContextMenuItemSeparator.Visibility = Visibility.Collapsed;
                    }
                }
            }
            
        }
Exemplo n.º 22
0
 public void UnLinkFromNode(NodeControl node)
 {
     RemoveChild(node);
     node.RemoveParent(this);
     if (ChildNodes.Count == 0)
     {
         CollapseControl.State = CollapseState.None;
     }
 }
Exemplo n.º 23
0
 private void AddParent(NodeControl node)
 {
     if (!ParentNodes.Contains(node))
     {
         ParentNodes.Add(node);
     }
 }
Exemplo n.º 24
0
 public void DeSelectAllChildsOfNode(NodeControl nodeControl)
 {
     foreach (var control in nodeControl.GetAllNodeControls())
     {
         RemoveNode(control);
     }
 }
Exemplo n.º 25
0
 private void RemoveParent(NodeControl node)
 {
     if (ParentNodes.Contains(node))
     {
         ParentNodes.Remove(node);
     }
 }
Exemplo n.º 26
0
 public void LinkFromNode(NodeControl node)
 {
     AddChild(node);
     node.AddParent(this);
 }