Ejemplo n.º 1
0
 public override void OnMouseDown(MouseEvent e)
 {
     foreach (var a in PossibleConnections)
     {
         a.IsMouseOver = false;
     }
     e.Cancel();
 }
        public virtual void OnMouseMove(MouseEvent e)
        {
            ConnectorAtMouse = null;
            ViewModelAtMouse = null;
            foreach (var source in DiagramViewModel.GraphItems.Reverse())
            {
                if (source.Bounds.Contains(e.MousePosition))
                {
                    if (source is ConnectorViewModel) ConnectorAtMouse = (ConnectorViewModel) source;
                    else ViewModelAtMouse = ConnectorAtMouse;
                }
                if(ConnectorAtMouse != null) break;
            }

        }
Ejemplo n.º 3
0
        public void QueryContextMenu(ContextMenuUI ui, MouseEvent evt, params object[] obj)
        {
            var connector = obj.FirstOrDefault() as ConnectorViewModel;
            if (connector != null)
            {
                var connections =
                   InvertGraphEditor.CurrentDiagramViewModel.GraphItems.OfType<ConnectionViewModel>()
                       .Where(p => p.ConnectorA == connector || p.ConnectorB == connector).ToArray();

                foreach (var connection in connections)
                {
                    ConnectionViewModel connection1 = connection;
                     ui.AddCommand(new ContextMenuItem()
                        {
                            Title = string.Format("Remove {0}",connection1.Name),
                            Group="Remove",
                            Command = new LambdaCommand("Remove Connection", ()=> { connection1.Remove(connection1); })
                        });
             
                }
                
            }
        }
Ejemplo n.º 4
0
 public void QueryContextMenu(ContextMenuUI ui, MouseEvent evt, params object[] obj)
 {
 }
        public virtual void OnMouseUp(MouseEvent e)
        {

        }
        public virtual void OnMouseDown(MouseEvent e)
        {

        }
 public void CreateConnectionMenu(ConnectionHandler viewModel, DiagramViewModel diagramViewModel, MouseEvent mouseEvent)
 {
     
 }
Ejemplo n.º 8
0
 public virtual void OnRightClick(MouseEvent mouseEvent)
 {
     InvertApplication.SignalEvent<IOnRightClickEvent>(_ => _.OnRightClick(this, mouseEvent));
 }
Ejemplo n.º 9
0
 public virtual void OnMouseMove(MouseEvent e)
 {
 }
Ejemplo n.º 10
0
 public virtual void OnMouseExit(MouseEvent e)
 {
     InvertApplication.SignalEvent<IOnMouseExitEvent>(_ => _.OnMouseExit(this, e));
     ViewModelObject.IsMouseOver = false;
 }
Ejemplo n.º 11
0
 public override void OnMouseExit(MouseEvent e)
 {
     base.OnMouseExit(e);
     DiagramViewModel.LastMouseEvent = e;
     BubbleEvent(d => d.OnMouseExit(e), e);
 }
Ejemplo n.º 12
0
 public override void OnMouseEnter(MouseEvent e)
 {
     base.OnMouseEnter(e);
     BubbleEvent(d => d.OnMouseEnter(e), e);
 }
Ejemplo n.º 13
0
//        //TODO move this to platform specific operation
//#if UNITY_EDITOR
//        public bool HandleKeyEvent(Event evt, ModifierKeyState keyStates)
//        {
//            var bindings = InvertGraphEditor.KeyBindings;
//            foreach (var keyBinding in bindings)
//            {
//                if (keyBinding.Key != evt.keyCode)
//                {
//                    continue;
//                }
//                if (keyBinding.RequireAlt && !keyStates.Alt)
//                {
//                    continue;
//                }
//                if (keyBinding.RequireShift && !keyStates.Shift)
//                {
//                    continue;
//                }
//                if (keyBinding.RequireControl && !keyStates.Ctrl)
//                {
//                    continue;
//                }

//                var command = keyBinding.Command;
//                if (command != null)
//                {
//                    if (command.CanExecute(InvertGraphEditor.DesignerWindow) == null)
//                    {
//                        InvertGraphEditor.ExecuteCommand(command);
//                    }
//                    else
//                    {
//                        return false;
//                    }

//                    return true;
//                }
//                return false;
//            }
//            return false;
//        }
//#endif
        public override void OnMouseDoubleClick(MouseEvent mouseEvent)
        {
           
            DiagramViewModel.LastMouseEvent = mouseEvent;
            if (DrawersAtMouse == null)
            {

                DrawersAtMouse = GetDrawersAtPosition(this, mouseEvent.MousePosition).ToArray();
            }
            base.OnMouseDoubleClick(mouseEvent);
            if (DrawersAtMouse.Length < 1)
            {
                if (mouseEvent.ModifierKeyStates.Alt)
                {
                   // DiagramViewModel.ShowContainerDebug();
                }
                else
                {
                    DiagramViewModel.ShowQuickAdd();
                }

                return;
            }
            if (!BubbleEvent(d => d.OnMouseDoubleClick(mouseEvent), mouseEvent))
            {

                return;
            }
            else
            {
               
            }

            DiagramViewModel.Navigate();

            Refresh((IPlatformDrawer)InvertGraphEditor.PlatformDrawer);
            //Refresh((IPlatformDrawer)InvertGraphEditor.PlatformDrawer);
     

        }
Ejemplo n.º 14
0
        public override void OnMouseMove(MouseEvent e)
        {
            base.OnMouseMove(e);
            _startPos = StartConnector.Bounds.center;

            _endPos = e.MousePosition;

            endViewModel = ConnectorAtMouse;
            color = Color.green;

            if (endViewModel == null)
            {
                var nodeAtMouse = ViewModelAtMouse as DiagramNodeViewModel;

                if (nodeAtMouse != null)
                {

                    foreach (var connector in nodeAtMouse.Connectors)
                    {
                        // Skip anything that might still be visible but not "visible"
                        if (nodeAtMouse.IsCollapsed)
                        {
                            if (connector != connector.InputConnector || connector != connector.OutputConnector)
                                continue;
                        }
                        ConnectionViewModel connection = null;
                        foreach (var strategy in InvertGraphEditor.ConnectionStrategies)
                        {

                            //try and connect them
                            connection = strategy.Connect(DiagramViewModel, StartConnector, connector);
                            if (connection != null)
                                break;

                        }
                        if (connection != null)
                        {
                            CurrentConnection = connection;
                            _endPos = connector.Bounds.center;
                            connector.HasConnections = true;
                            break;
                        }
                    }
                    if (CurrentConnection != null)
                    {
                        // Grab the default connector
                        var adjustedBounds = new Rect(nodeAtMouse.Bounds.x - 9, nodeAtMouse.Bounds.y + 1,
                            nodeAtMouse.Bounds.width + 19, nodeAtMouse.Bounds.height + 9);


                        //InvertGraphEditor.PlatformDrawer.DrawStretchBox(adjustedBounds.Scale(InvertGraphEditor.DesignerWindow.Scale),InvertStyles.NodeBackground,20);
                    }
                }
                else
                {

                    CurrentConnection = null;
                }




            }
            else
            {


                foreach (var strategy in InvertGraphEditor.ConnectionStrategies)
                {
                    //try and connect them
                    var connection = strategy.Connect(DiagramViewModel, StartConnector, endViewModel);
                    if (connection != null)
                    {
                        CurrentConnection = connection;
                        break;
                    }
                }
                if (CurrentConnection == null)
                {
                    color = Color.red;
                }
                else
                {
                    _endPos = endViewModel.Bounds.center;

                }
            }




        }
Ejemplo n.º 15
0
        public override void OnMouseUp(MouseEvent e)
        {
            base.OnMouseUp(e);
            if (CurrentConnection != null)
            {
                InvertApplication.Execute(new LambdaCommand("Create Connection",() =>
                {
                    CurrentConnection.Apply(CurrentConnection);
                }));
            }
            else
            {
                var mouseData = e;
                InvertApplication.SignalEvent<IShowConnectionMenu>(
                    _ => _.Show(DiagramViewModel, StartConnector, mouseData.MouseUpPosition));

                //var allowedFilterNodes = FilterExtensions.AllowedFilterNodes[this.DiagramViewModel.CurrentRepository.CurrentFilter.GetType()];
                //var menu = InvertGraphEditor.CreateCommandUI<ContextMenuUI>();
                //foreach (var item in allowedFilterNodes)
                //{
                //    if (item.IsInterface) continue;
                //    if (item.IsAbstract) continue;

                //    var node = Activator.CreateInstance(item) as IDiagramNode;
                //    node.Graph = this.DiagramViewModel.GraphData;
                //    var vm = InvertGraphEditor.Container.GetNodeViewModel(node, this.DiagramViewModel) as DiagramNodeViewModel;


                //    if (vm == null) continue;
                //    vm.IsCollapsed = false;
                //    var connectors = new List<ConnectorViewModel>();
                //    vm.GetConnectors(connectors);

                //    var config = InvertGraphEditor.Container.Resolve<NodeConfigBase>(item.Name);
                //    var name = config == null ? item.Name : config.Name;
                //    foreach (var connector in connectors)
                //    {
                //        foreach (var strategy in InvertGraphEditor.ConnectionStrategies)
                //        {
                //            var connection = strategy.Connect(this.DiagramViewModel, StartConnector, connector);
                //            if (connection == null) continue;
                //            var node1 = node;
                //            var message = string.Format("Create {0}", name);
                //            if (!string.IsNullOrEmpty(connector.Name))
                //            {
                //                message += string.Format(" and connect to {0}", connector.Name);
                //            }
                //            var value = new KeyValuePair<IDiagramNode, ConnectionViewModel>(node1, connection);
                //            menu.AddCommand(
                //             new SimpleEditorCommand<DiagramViewModel>(delegate(DiagramViewModel n)
                //             {


                //                 //UnityEditor.EditorWindow.FocusWindowIfItsOpen(typeof (ElementsDesigner));

                //                 InvertGraphEditor.ExecuteCommand(_ =>
                //                 {
                //                     this.DiagramViewModel.AddNode(value.Key,e.MouseUpPosition);
                //                     connection.Apply(value.Value as ConnectionViewModel);
                //                     value.Key.IsSelected = true;
                //                     value.Key.IsEditing = true;
                //                     value.Key.Name = "";
                //                 });
                //             },message));
                //        }

                //    }

                //}
                //menu.Go();

            }


            foreach (var a in PossibleConnections)
            {
                a.IsMouseOver = false;
                a.IsSelected = false;
            }
            e.Cancel();
        }
Ejemplo n.º 16
0
 public void ShowItemContextMenu(MouseEvent mouseEvent)
 {
     InvertApplication.SignalEvent<IShowContextMenu>(_ => _.Show(mouseEvent, DiagramViewModel.SelectedNodeItem));
 }
Ejemplo n.º 17
0
 public override void OnMouseDown(MouseEvent mouseEvent)
 {
     //base.OnMouseDown(mouseEvent);
     //InvertApplication.SignalEvent<IOnMouseDownEvent>(_ => _.OnMouseDown(this, mouseEvent));        
 }
Ejemplo n.º 18
0
 public override void OnMouseDown(MouseEvent mouseEvent)
 {
     base.OnMouseDown(mouseEvent);
     DiagramViewModel.LastMouseEvent = mouseEvent;
     if (DrawersAtMouse == null) return;
     if (!DrawersAtMouse.Any())
     {
         DiagramViewModel.NothingSelected();
         if (mouseEvent.ModifierKeyStates.Ctrl)
         {
             DiagramViewModel.ShowQuickAdd();
         }
         mouseEvent.Begin(SelectionRectHandler);
     }
     else
     {
         BubbleEvent(d => d.OnMouseDown(mouseEvent), mouseEvent);
     }
 }
Ejemplo n.º 19
0
 public virtual void OnMouseEnter(MouseEvent e)
 {
     ViewModelObject.IsMouseOver = true;
     InvertApplication.SignalEvent<IOnMouseEnterEvent>(_ => _.OnMouseEnter(this, e));
 }
Ejemplo n.º 20
0
        public bool BubbleEvent(Action<IDrawer> action, MouseEvent e)
        {
            if (DrawersAtMouse == null) return true;

            foreach (var item in DrawersAtMouse.OrderByDescending(p => p.ZOrder))
            {
               // if (!item.Enabled) continue;
                action(item);
                if (e.NoBubble)
                {
                    e.NoBubble = false;
                    return false;

                    break;
                }
            }
            return true;
        }
Ejemplo n.º 21
0
 public virtual void OnMouseUp(MouseEvent e)
 {
     InvertApplication.SignalEvent<IOnMouseUpEvent>(_ => _.OnMouseUp(this, e));
 }
Ejemplo n.º 22
0
        public override void OnMouseMove(MouseEvent e)
        {
            base.OnMouseMove(e);
            DiagramViewModel.LastMouseEvent = e;
            if (e.IsMouseDown && e.MouseButton == 0 && !e.ModifierKeyStates.Any)
            {
                foreach (var item in Children.OfType<DiagramNodeDrawer>())
                {
                    if (item.ViewModelObject.IsSelected)
                    {
#if UNITY_EDITOR
                        if (DiagramViewModel.Settings.Snap)
                        {
                            item.ViewModel.Position += e.MousePositionDeltaSnapped;
                            item.ViewModel.Position = item.ViewModel.Position.Snap(DiagramViewModel.Settings.SnapSize);
                        }
                        else
                        {
#endif
                            item.ViewModel.Position += e.MousePositionDelta;
#if UNITY_EDITOR
                        }
#endif
                        if (item.ViewModel.Position.x < 0)
                        {
                            item.ViewModel.Position = new Vector2(0f, item.ViewModel.Position.y);
                        }
                        if (item.ViewModel.Position.y < 0)
                        {
                            item.ViewModel.Position = new Vector2(item.ViewModel.Position.x, 0f);
                        }
                        item.Dirty = true;
                        //item.Refresh((IPlatformDrawer)InvertGraphEditor.PlatformDrawer,item.Bounds.position,false);
                    }
                }
            }
            else
            {

                var nodes = GetDrawersAtPosition(this, e.MousePosition).ToArray();

                //NodeDrawerAtMouse = nodes.FirstOrDefault();

                if (DrawersAtMouse != null)
                    foreach (var item in nodes)
                    {
                        var alreadyInside = DrawersAtMouse.Contains(item);
                        if (!alreadyInside)
                        {
                            item.OnMouseEnter(e);
                        }
                    }
                if (DrawersAtMouse != null)
                    foreach (var item in DrawersAtMouse)
                    {
                        if (!nodes.Contains(item))
                        {
                            item.OnMouseExit(e);
                        }
                    }

                DrawersAtMouse = nodes;
                foreach (var node in DrawersAtMouse)
                {
                    node.OnMouseMove(e);
                }
            }
        }
Ejemplo n.º 23
0
 public virtual void OnMouseDown(MouseEvent mouseEvent)
 {
     InvertApplication.SignalEvent<IOnMouseDownEvent>(_ => _.OnMouseDown(this, mouseEvent));
 }
Ejemplo n.º 24
0
        public override void OnMouseUp(MouseEvent mouseEvent)
        {
            DiagramViewModel.LastMouseEvent = mouseEvent;
            BubbleEvent(d => d.OnMouseUp(mouseEvent), mouseEvent);

        }
Ejemplo n.º 25
0
        public virtual void OnMouseDoubleClick(MouseEvent e)
        {

        }
Ejemplo n.º 26
0
        public override void OnRightClick(MouseEvent mouseEvent)
        {
            DiagramViewModel.LastMouseEvent = mouseEvent;
            BubbleEvent(d => d.OnRightClick(mouseEvent), mouseEvent);
            if (DrawersAtMouse == null)
            {
                ShowAddNewContextMenu(mouseEvent);
                return;

            }
            //var item = DrawersAtMouse.OrderByDescending(p=>p.ZOrder).FirstOrDefault();
            IDrawer item = DrawersAtMouse.OfType<ConnectorDrawer>().FirstOrDefault();
            if (item != null)
            {
                InvertApplication.SignalEvent<IShowContextMenu>(_=>_.Show(mouseEvent,item.ViewModelObject));
                return;
            }
            item = DrawersAtMouse.OfType<ItemDrawer>().FirstOrDefault();
            if (item != null)
            {
                if (item.Enabled)
                ShowItemContextMenu(mouseEvent);
                return;
            }
            item = DrawersAtMouse.OfType<DiagramNodeDrawer>().FirstOrDefault();
            if (item == null)
                item = DrawersAtMouse.OfType<HeaderDrawer>().FirstOrDefault();
            if (item != null)
            {
                if (!item.ViewModelObject.IsSelected)
                item.ViewModelObject.Select();
                ShowContextMenu(mouseEvent);
                return;
            }
            ShowAddNewContextMenu(mouseEvent);
        }
Ejemplo n.º 27
0
 public void ShowAddNewContextMenu(MouseEvent mouseEvent)
 {
     InvertApplication.SignalEvent<IShowContextMenu>(_ => _.Show(mouseEvent, DiagramViewModel));
 }
Ejemplo n.º 28
0
 public void ShowContextMenu(MouseEvent mouseEvent)
 {
     InvertApplication.SignalEvent<IShowContextMenu>(_ => _.Show(mouseEvent, DiagramViewModel.SelectedNodes.Cast<object>().ToArray()));
 }
Ejemplo n.º 29
0
        public void OnRightClick(MouseEvent mouseEvent)
        {

        }
Ejemplo n.º 30
0
 public override void OnMouseDown(MouseEvent mouseEvent)
 {
     base.OnMouseDown(mouseEvent);
     ViewModel.SaveImage = true;
 }