示例#1
0
        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonUp(e);

            if (null == ViewModel)
            {
                return;
            }

            FlowChart flowChart = ViewModel.Model;

            NodeGraphManager.EndConnection();
            NodeGraphManager.EndDragNode();

            if (NodeGraphManager.IsSelecting)
            {
                bool bChanged = false;
                flowChart.History.BeginTransaction("Selecting");
                {
                    bChanged = NodeGraphManager.EndDragSelection(false);
                }

                Point mousePos = e.GetPosition(this);

                if ((0 != ( int )(mousePos.X - _LeftButtonDownPos.X)) ||
                    (0 != ( int )(mousePos.Y - _LeftButtonDownPos.Y)))
                {
                    flowChart.History.AddCommand(new History.ZoomAndPanCommand(
                                                     "ZoomAndPan", ViewModel.Model, _ZoomAndPanStartMatrix, ZoomAndPan.Matrix));
                    bChanged = true;
                }

                flowChart.History.EndTransaction(!bChanged);
            }
        }
 public FinishNode(NodeGraphManager ngm, Guid guid, FlowChart flowChart) : base(ngm, guid, flowChart)
 {
     //
     Header                = "Return";
     HeaderFontColor       = Brushes.White;
     HeaderBackgroundColor = new SolidColorBrush(Color.FromRgb(51, 20, 30));
 }
示例#3
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);

            FlowChart     flowChart     = ViewModel.Model.Owner;
            FlowChartView flowChartView = flowChart.ViewModel.View;

            Keyboard.Focus(flowChartView);

            NodeGraphManager.EndConnection();
            NodeGraphManager.EndDragNode();
            NodeGraphManager.EndDragSelection(false);

            NodeGraphManager.MouseLeftDownNode = ViewModel.Model;

            NodeGraphManager.BeginDragNode(flowChart);

            Node node = ViewModel.Model;

            _DraggingStartPos = new Point(node.X, node.Y);

            flowChart.History.BeginTransaction("Moving node");

            _ZoomAndPanStartMatrix = flowChartView.ZoomAndPan.Matrix;

            e.Handled = true;
        }
示例#4
0
        public override void RaisePropertyChanged(string propertyName)
        {
            base.RaisePropertyChanged(propertyName);

            NodePropertyPort port = NodeGraphManager.FindNodePropertyPort(this, propertyName);

            if (null != port)
            {
                Type nodeType = GetType();

                PropertyInfo propertyInfo = nodeType.GetProperty(propertyName);
                if (null != propertyInfo)
                {
                    port.Value = propertyInfo.GetValue(this);
                }
                else
                {
                    FieldInfo fieldInfo = nodeType.GetField(propertyName);
                    if (null != fieldInfo)
                    {
                        port.Value = fieldInfo.GetValue(this);
                    }
                }
            }
        }
示例#5
0
        private void UpdateDragging(Point mousePos, Point delta)
        {
            if (NodeGraphManager.IsConnecting)
            {
                NodeGraphManager.UpdateConnection(mousePos);
            }
            else if (NodeGraphManager.IsNodeDragging)
            {
                double invScale = 1.0f / _ZoomAndPan.Scale;
                NodeGraphManager.DragNode(new Point(delta.X * invScale, delta.Y * invScale));
            }
            else if (NodeGraphManager.IsSelecting)
            {
                // gather nodes in area.

                bool bCtrl  = Keyboard.IsKeyDown(Key.LeftCtrl);
                bool bShift = Keyboard.IsKeyDown(Key.LeftShift);
                bool bAlt   = Keyboard.IsKeyDown(Key.LeftAlt);

                NodeGraphManager.UpdateDragSelection(ViewModel.Model,
                                                     _ZoomAndPan.MatrixInv.Transform(mousePos), bCtrl, bShift, bAlt);

                Point startPos = _ZoomAndPan.Matrix.Transform(NodeGraphManager.SelectingStartPoint);

                Point selectionStart = new Point(Math.Min(startPos.X, mousePos.X), Math.Min(startPos.Y, mousePos.Y));
                Point selectionEnd   = new Point(Math.Max(startPos.X, mousePos.X), Math.Max(startPos.Y, mousePos.Y));

                ViewModel.SelectionStartX = selectionStart.X;
                ViewModel.SelectionStartY = selectionStart.Y;
                ViewModel.SelectionWidth  = selectionEnd.X - selectionStart.X;
                ViewModel.SelectionHeight = selectionEnd.Y - selectionStart.Y;
            }
        }
        public VarConstantIntegerNode(NodeGraphManager ngm, Guid guid, FlowChart flowChart) : base(ngm, guid, flowChart, CNodeType.VarConstantInteger)
        {
#endif
            //
            //HeaderBackgroundColor = new SolidColorBrush(Color.FromRgb(157, 248, 67));
            HeaderBackgroundColor = new SolidColorBrush(Color.FromRgb(71, 146, 0));
        }
示例#7
0
        protected override void OnMouseEnter(MouseEventArgs e)
        {
            base.OnMouseEnter(e);

            if (MouseButtonState.Pressed == e.LeftButton)
            {
                if (NodeGraphManager.IsConnecting)
                {
                    string error;
                    bool   connectable = NodeGraphManager.CheckIfConnectable(ViewModel.Model, out error);
                    if (connectable)
                    {
                        NodeGraphManager.SetOtherConnectionPort(ViewModel.Model);
                        ToolTipVisibility = false;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(error))
                        {
                            ToolTipVisibility = false;
                        }
                        else
                        {
                            ToolTipText       = error;
                            ToolTipVisibility = true;
                        }
                    }
                }
            }
        }
		private void UpdateSelection( bool isSelected )
		{
			Node node = NodeGraphManager.FindNode( Guid );

			ObservableCollection<Guid> selectionList = NodeGraphManager.GetSelectionList( node.Owner );

			node.ViewModel.IsSelected = isSelected;

			if( node.ViewModel.IsSelected )
			{
				System.Diagnostics.Debug.WriteLine( "True" );
				if( !selectionList.Contains( Guid ) )
				{
					selectionList.Add( Guid );
				}
			}
			else
			{
				System.Diagnostics.Debug.WriteLine( "False" );
				if( selectionList.Contains( Guid ) )
				{
					selectionList.Remove( Guid );
				}
			}
		}
 public NodeGraphCommand(NodeGraphManager manager, string name, object undoParams, object redoParams)
 {
     NodeGraphManager = manager;
     Name             = name;
     UndoParams       = undoParams;
     RedoParams       = redoParams;
 }
        public OpStringConcat(NodeGraphManager ngm, Guid guid, FlowChart flowChart) : base(ngm, guid, flowChart, CNodeType.OpIntegerAdd)
        {
            var color    = Color.FromRgb(0x64, 0xDD, 0x17);
            var gradient = new LinearGradientBrush();

            gradient.GradientStops.Add(new GradientStop()
            {
                Color = color, Offset = 0
            });
            gradient.GradientStops.Add(new GradientStop()
            {
                Color = Color.FromArgb(255, color.R, color.G, color.B), Offset = 0.8
            });
            gradient.GradientStops.Add(new GradientStop()
            {
                Color = Color.FromArgb(80, color.R, color.G, color.B), Offset = 0.96
            });
            gradient.GradientStops.Add(new GradientStop()
            {
                Color = Color.FromArgb(40, color.R, color.G, color.B), Offset = 1.0
            });

            Header = "Op: String + String";
            HeaderBackgroundColor = gradient;
        }
示例#11
0
 public StartNode(NodeGraphManager ngm, Guid guid, FlowChart flowChart) : base(ngm, guid, flowChart)
 {
     //
     Header                = "Start Node";
     HeaderFontColor       = Brushes.White;
     HeaderBackgroundColor = new SolidColorBrush(Color.FromRgb(92, 20, 15));
 }
        public override void OnExecute(Connector prevConnector)
        {
            base.OnExecute(prevConnector);

            NodePropertyPort portObject = NodeGraphManager.FindNodePropertyPort(this, "Objects");

            List <NodePort> connectedPorts;

            NodeGraphManager.FindConnectedPorts(portObject, out connectedPorts);

            if (0 < connectedPorts.Count)
            {
                foreach (var connectedPort in connectedPorts)
                {
                    NodePropertyPort port   = connectedPort as NodePropertyPort;
                    string           result = string.Empty;
                    if (null != port.Value)
                    {
                        result = string.Format("{0}", port.Value.ToString());
                        NodeGraphManager.AddScreenLog(Owner, result);
                    }
                }
            }
            else
            {
                ExecutionState = NodeExecutionState.Failed;
            }
        }
        public override void OnCreate()
        {
            NodeGraphManager.CreateNodePropertyPort(false, Guid.NewGuid(), this, true, typeof(object), null,
                                                    "Objects", false, null, "Objects", true);

            base.OnCreate();
        }
示例#14
0
        public NodeGraphHistory(NodeGraphManager ngm, object owner, int numTransactions = 100)
        {
            NodeGraphManager = ngm;
            Owner            = owner;

            SetNumberOfTransactions(numTransactions);
        }
示例#15
0
 public VariableNode(NodeGraphManager ngm, Guid guid, FlowChart flowChart, CalculatorNodeType nodeType) : base(ngm, guid, flowChart, nodeType)
 {
     Header = typeof(T).Name;
     HeaderBackgroundColor   = Brushes.Black;
     HeaderFontColor         = Brushes.White;
     AllowCircularConnection = false;
 }
        private NodePropertyPort createPort(string title, bool isInput, bool editor = true)
        {
            var ValuePort = NodeGraphManager.CreateNodePropertyPort(
                false, Guid.NewGuid(), this,
                isInput, typeof(int), Activator.CreateInstance(typeof(int)), title, editor, null, "");

            return(ValuePort);
        }
示例#17
0
        public ConnectorView(NodeGraphManager ngm)
        {
            NodeGraphManager = ngm;

            LayoutUpdated      += ConnectorView_LayoutUpdated;
            DataContextChanged += ConnectorView_DataContextChanged;
            Loaded             += ConnectorView_Loaded;
        }
示例#18
0
 void Start()
 {
     error.text = "";
     error.gameObject.SetActive(false);
     success.gameObject.SetActive(false);
     _nodeGraphManager = FindObjectOfType <NodeGraphManager>();
     _viewInputManager = FindObjectOfType <ViewInputManager>();
     editorPanel.SetActive(true);
 }
示例#19
0
        public void FitNodesToView(bool bOnlySelected)
        {
            double minX;
            double maxX;
            double minY;
            double maxY;

            NodeGraphManager.CalculateContentSize(ViewModel.Model, bOnlySelected, out minX, out maxX, out minY, out maxY);
            if ((minX == maxX) || (minY == maxY))
            {
                return;
            }

            FlowChart flowChart = ViewModel.Model;

            flowChart.History.BeginTransaction("Destroy Selected Nodes");
            {
                _ZoomAndPanStartMatrix = ZoomAndPan.Matrix;

                double vsWidth  = _ZoomAndPan.ViewWidth;
                double vsHeight = _ZoomAndPan.ViewHeight;

                Point margin = new Point(vsWidth * 0.05, vsHeight * 0.05);
                minX -= margin.X;
                minY -= margin.Y;
                maxX += margin.X;
                maxY += margin.Y;

                double contentWidth  = maxX - minX;
                double contentHeight = maxY - minY;

                _ZoomAndPan.StartX = (minX + maxX - vsWidth) * 0.5;
                _ZoomAndPan.StartY = (minY + maxY - vsHeight) * 0.5;
                _ZoomAndPan.Scale  = 1.0;

                Point vsZoomCenter = new Point(vsWidth * 0.5, vsHeight * 0.5);
                Point zoomCenter   = _ZoomAndPan.MatrixInv.Transform(vsZoomCenter);

                double newScale = Math.Min(vsWidth / contentWidth, vsHeight / contentHeight);
                _ZoomAndPan.Scale = Math.Max(0.1, Math.Min(1.0, newScale));

                Point vsNextZoomCenter = _ZoomAndPan.Matrix.Transform(zoomCenter);
                Point vsDelta          = new Point(vsZoomCenter.X - vsNextZoomCenter.X, vsZoomCenter.Y - vsNextZoomCenter.Y);

                _ZoomAndPan.StartX -= vsDelta.X;
                _ZoomAndPan.StartY -= vsDelta.Y;

                if (0 != ( int )(_ZoomAndPan.Matrix.OffsetX - _ZoomAndPanStartMatrix.OffsetX) ||
                    0 != ( int )(_ZoomAndPan.Matrix.OffsetX - _ZoomAndPanStartMatrix.OffsetX))
                {
                    flowChart.History.AddCommand(new History.ZoomAndPanCommand(
                                                     "ZoomAndPan", ViewModel.Model, _ZoomAndPanStartMatrix, ZoomAndPan.Matrix));
                }
            }
            flowChart.History.EndTransaction(false);
        }
        private NodePropertyPort createPort(string title, bool isInput, bool editor = true)
        {
            var ValuePort = NodeGraphManager.CreateNodePropertyPort(
                false, Guid.NewGuid(), this,
                isInput, typeof(string), "", title, editor, null, "");

            ValuePort.PropertyChanged += Port_PropertyChanged;

            return(ValuePort);
        }
        public override void OnCreate()
        {
            NodeGraphManager.CreateNodePropertyPort(false, Guid.NewGuid(), this, true, typeof(object), null,
                                                    "Objects", false, null, "Objects( multiple input )", true);

            NodeGraphManager.CreateNodePropertyPort(false, Guid.NewGuid(), this, false, typeof(ObservableCollection <object>), new ObservableCollection <object>(),
                                                    "Array", false, null, "Array");

            base.OnCreate();
        }
示例#22
0
        private void FlowChartView_DragEnter(object sender, DragEventArgs args)
        {
            NodeGraphDragEventArgs eventArgs;
            ModelBase model = BuidNodeGraphDragEventArgs(args, out eventArgs);

            if (null != model)
            {
                NodeGraphManager.InvokeDragEnter(model, eventArgs);
            }
        }
示例#23
0
        public override void OnCreate()
        {
            NodePropertyPort port = NodeGraphManager.CreateNodePropertyPort(
                false, Guid.NewGuid(), this, false,
                typeof(ObservableCollection <T>), Array, "Array", true);

            port.DynamicPropertyPortValueChanged += ArrayPort_DynamicPropertyPortValueChanged;

            base.OnCreate();
        }
示例#24
0
        protected override void OnMouseLeave(MouseEventArgs e)
        {
            base.OnMouseLeave(e);

            if (NodeGraphManager.IsConnecting)
            {
                NodeGraphManager.SetOtherConnectionPort(null);
            }

            ToolTipVisibility = false;
        }
示例#25
0
        protected override void OnLostFocus(RoutedEventArgs e)
        {
            base.OnLostFocus(e);

            if (NodeGraphManager.IsConnecting)
            {
                NodeGraphManager.SetOtherConnectionPort(null);
            }

            ToolTipVisibility = false;
        }
示例#26
0
        public override void ReadXml(XmlReader reader)
        {
            base.ReadXml(reader);

            bool isNodesEnd      = false;
            bool isConnectorsEnd = false;

            while (reader.Read())
            {
                if (XmlNodeType.Element == reader.NodeType)
                {
                    if (("Node" == reader.Name) ||
                        ("Connector" == reader.Name))
                    {
                        string prevReaderName = reader.Name;

                        Guid      guid      = Guid.Parse(reader.GetAttribute("Guid"));
                        Type      type      = Type.GetType(reader.GetAttribute("Type"));
                        FlowChart flowChart = NodeGraphManager.FindFlowChart(
                            Guid.Parse(reader.GetAttribute("Owner")));

                        if ("Node" == prevReaderName)
                        {
                            Type vmType = Type.GetType(reader.GetAttribute("ViewModelType"));

                            Node node = NodeGraphManager.CreateNode(true, guid, flowChart, type, 0.0, 0.0, 0, vmType);
                            node.ReadXml(reader);
                        }
                        else
                        {
                            Connector connector = NodeGraphManager.CreateConnector(false, guid, flowChart, type);
                            connector.ReadXml(reader);
                        }
                    }
                }

                if (reader.IsEmptyElement || XmlNodeType.EndElement == reader.NodeType)
                {
                    if ("Nodes" == reader.Name)
                    {
                        isNodesEnd = true;
                    }
                    else if ("Connectors" == reader.Name)
                    {
                        isConnectorsEnd = true;
                    }
                }

                if (isNodesEnd && isConnectorsEnd)
                {
                    break;
                }
            }
        }
示例#27
0
        public override void OnCreate()
        {
            Type type = typeof(T);

            NodePropertyPort port = NodeGraphManager.CreateNodePropertyPort(
                false, Guid.NewGuid(), this, false, type, Activator.CreateInstance(type), "Value", true, null, "");

            port.DynamicPropertyPortValueChanged += ValuePort_PropertyPortValueChanged;

            base.OnCreate();
        }
示例#28
0
        public FnPrintString(NodeGraphManager ngm, Guid guid, FlowChart flowChart) : base(ngm, guid, flowChart, CNodeType.FunctionPrintString)
#endif
        {
            Header = "Function: Print String";
            HeaderBackgroundColor = new SolidColorBrush(Color.FromRgb(71, 116, 143));

            //var gradient = new LinearGradientBrush();
            //for(int x = 0; x < 10; x++)
            //	gradient.GradientStops.Add(new GradientStop(Rainbow(x), x / 10));

            //HeaderBackgroundColor = gradient;
        }
示例#29
0
        public virtual void OnDeserialize()
        {
            if (NodeGraphManager.OutputDebugInfo)
            {
                System.Diagnostics.Debug.WriteLine("Connector.OnDeserialize()");
            }

            NodeGraphManager.ConnectTo(StartPort, this);
            NodeGraphManager.ConnectTo(EndPort, this);
            IsInitialized = true;

            RaisePropertyChanged("Model");
        }
        public override void OnPostExecute(Connector prevConnector)
        {
            base.OnPostExecute(prevConnector);

            NodeFlowPort port = NodeGraphManager.FindNodeFlowPort(this, "Output");

            foreach (var connector in port.Connectors)
            {
                connector.OnPreExecute();
                connector.OnExecute();
                connector.OnPostExecute();
            }
        }