Example #1
0
 public ObjectsConnector(VirtualControl host, ObjectPort sPort, ObjectPort ePort) : base(host, sPort, ePort)
 {
     Wire.Background = sPort.StrokeBrush;
     Host            = host;
     Type            = ConnectorTypes.Object;
     StartPort       = sPort;
     ePort.Linked    = true;
     sPort.Linked    = true;
     EndPort         = ePort;
     StartPort.CalcOrigin();
     EndPort.CalcOrigin();
     Sp = PointsCalculator.PortOrigin(StartPort);
     Ep = PointsCalculator.PortOrigin(EndPort);
     Wire.StartPoint = Sp;
     Wire.EndPoint   = Ep;
     ePort.Linked    = true;
     sPort.Linked    = true;
     Host.Children.Add(Wire);
     sPort.ParentNode.PropertyChanged += ParentNodeOnPropertyChanged;
     ePort.ParentNode.PropertyChanged += ParentNodeOnPropertyChanged;
     ePort.Data.Value = sPort.Data.Value;
     StartPort        = sPort;
     EndPort          = ePort;
     Wire.ContextMenu = wireMenu();
 }
Example #2
0
        public VirtualControlData(VirtualControl vc)
        {
            for (var index = vc.Nodes.Count - 1; index >= 0; index--)
            {
                var node = vc.Nodes[index];
                if (node.Types != NodeTypes.Root && node.Types != NodeTypes.SpaghettiDivider)
                {
                    Nodes.Add(new NodeProperties(node));
                }
                else if (node.Types == NodeTypes.SpaghettiDivider)
                {
                    SpaghettiDividers.Add(new SpaghDividerProperties(node));
                    VolatileConnectors.Add(new VolatileConnector
                    {
                        X         = node.X,
                        Y         = node.Y,
                        Connector = ((SpaghettiDivider)node).ObjectConnector
                    });
                    (node as SpaghettiDivider).Delete();
                }
            }
            foreach (var conn in vc.ObjectConnectors)
            {
                ObjectConnectors.Add(new ObjectConnectorProperties(conn));
            }
            foreach (var conn in vc.ExecutionConnectors)
            {
                ExecutionConnectors.Add(new ExecutionConnectorProperties(conn));
            }

            foreach (var conn in VolatileConnectors)
            {
                var divider = new SpaghettiDivider(vc, conn.Connector, false);
                for (var index = 0; index < vc.ObjectConnectors.Count; index++)
                {
                    var c = vc.ObjectConnectors[index];
                    if (c == conn.Connector)
                    {
                        c.Delete();
                    }
                }
                conn.Connector.EndPort.ConnectedConnectors.ClearConnectors();
                vc.AddNode(divider, conn.X, conn.Y);
            }
        }
Example #3
0
 public ExecutionConnector(VirtualControl host, ExecPort sPort, ExecPort ePort) : base(host, sPort, ePort)
 {
     Host         = host;
     Type         = ConnectorTypes.Execution;
     StartPort    = sPort;
     ePort.Linked = true;
     sPort.Linked = true;
     EndPort      = ePort;
     StartPort.CalcOrigin();
     EndPort.CalcOrigin();
     Sp = PointsCalculator.PortOrigin(StartPort);
     Ep = PointsCalculator.PortOrigin(EndPort);
     Wire.StartPoint = Sp;
     Wire.EndPoint   = Ep;
     Host.Children.Add(Wire);
     sPort.ParentNode.PropertyChanged += ParentNodeOnPropertyChanged;
     ePort.ParentNode.PropertyChanged += ParentNodeOnPropertyChanged;
     Interlocked.Increment(ref StartPort.CountOutConnectors);
     Interlocked.Increment(ref EndPort.CountOutConnectors);
     Wire.ContextMenu = wireMenu();
 }
Example #4
0
 public ExecPort(VirtualControl host, string name, PortTypes portType, string text, bool multipleConnectors)
 {
     Focusable   = false;
     Text        = text;
     Host        = host;
     StrokeBrush = Brushes.AliceBlue;
     MultipleConnectionsAllowed = multipleConnectors;
     if (portType == PortTypes.Input)
     {
         Style     = FindResource("InExecPortStyle") as Style;
         PortTypes = PortTypes.Input;
     }
     else
     {
         Style     = FindResource("OutExecPortStyle") as Style;
         PortTypes = PortTypes.Output;
     }
     PreviewMouseDown += OnMouseLeftButtonDown;
     PreviewMouseUp   += OnPreviewMouseUp;
     PreviewMouseMove += OnPreviewMouseMove;
     MouseLeave       += (sender, args) => Host.HideLinkingPossiblity();
 }
Example #5
0
        public Comment(ObservableCollection <Node> nodes, VirtualControl host)
        {
            CalculateSize(nodes);
            Style = FindResource("Comment") as Style;
            host.AddChildren(this, X, Y);
            Panel.SetZIndex(this, ZIndexes.CommentIndex);
            _host      = host;
            MouseDown += Comment_MouseDown;
            MouseUp   += Comment_MouseUp;

            Loaded += (e, r) =>
            {
                {
                    _p = (StackPanel)Template.FindName("CornerImage_Resize", this);
                    Canvas.SetLeft(_p, Width - 15);
                    Canvas.SetTop(_p, Height - 15);
                    _p.PreviewMouseDown += P_MouseDown;
                    _p.MouseEnter       += (m, le) => { Cursor = Cursors.SizeNWSE; };
                    _p.MouseUp          += P_MouseUp;
                    ContextMenu          = DeleteComment();
                }
            };
            host.Comments.Add(this);
        }
Example #6
0
        public ObjectPort(VirtualControl host, PortTypes portType, string text, RTypes type)
        {
            Text = text;
            Data = new RVariable(type);
            Host = host;
            // Focusable = false;
            Data.ParentPort = this;


            if (portType == PortTypes.Input)
            {
                if (type == RTypes.ArrayOrFactorOrListOrMatrix)
                {
                    Style = (Style)FindResource("InArrayPortStyle");
                }
                else
                {
                    Style = (Style)FindResource("InObjectPortStyle");
                }
                PortTypes = PortTypes.Input;
            }
            else
            {
                if (type == RTypes.ArrayOrFactorOrListOrMatrix)
                {
                    Style = (Style)FindResource("OutArrayPortStyle");
                }
                else
                {
                    Style = (Style)FindResource("OutObjectPortStyle");
                }
                PortTypes = PortTypes.Output;
            }
            Loaded += (sender, args) =>
            {
                Host   = host;
                _panel = (StackPanel)Template.FindName("ControlsPanel", this);
                _pin   = (UIElement)Template.FindName("Pin", this);
                if (_pin != null)
                {
                    _pin.PreviewMouseDown += OnMouseDown;
                }
                if (_panel == null)
                {
                    return;
                }
                if (Control != null)
                {
                    try
                    {
                        _panel.Children.Remove(Control);
                        _panel.Children.Add(Control);
                    }
                    catch (Exception)
                    {
                        MagicLaboratory.unLinkChild(Control);
                        _panel.Children.Add(Control);
                    }
                }
            };

            PreviewMouseUp   += OnMouseUp;
            PreviewMouseMove += ObjectPort_PreviewMouseMove;
            MouseLeave       += (sender, args) =>
            {
                Host.HideLinkingPossiblity();
                ParentNode.Refresh();
                args.Handled = true;
            };

            Control.Loaded      += Control_Loaded;
            Control.SizeChanged += Control_SizeChanged;
        }
Example #7
0
        //private readonly DependencyPropertyDescriptor LeftTrigger
        //    = DependencyPropertyDescriptor.FromProperty(
        //        Canvas.LeftProperty, typeof(Node)
        //    );


        /// <summary>
        ///     The node that will contain the ports and data
        /// </summary>
        /// <param name="host"></param>
        /// <param name="type"></param>
        /// <param name="spontaneousAddition"></param>
        public Node(VirtualControl host, NodeTypes type, bool spontaneousAddition = true)
        {
            Types = type;
            Host  = host;
            Style = (Style)FindResource("NodeStyle");
            switch (type)
            {
            case NodeTypes.Event:
                Background = Brushes.Red;
                break;

            case NodeTypes.Basic:
                Background = Brushes.Transparent;
                break;

            case NodeTypes.Method:
                Background = Brushes.DeepSkyBlue;
                break;

            case NodeTypes.Function:
                Background = Brushes.LightGreen;
                break;

            case NodeTypes.VariableGet:
                Background = Brushes.Black;
                break;

            case NodeTypes.VariableSet:
                Background = Brushes.LightGray;
                break;

            case NodeTypes.Root:
                break;

            case NodeTypes.Code:
                break;

            case NodeTypes.SpaghettiDivider:
                break;

            case NodeTypes.CollapsedRegion:
                break;
            }
            var init = false;

            Loaded += (sender, args) =>
            {
                if (!init)
                {
                    FuncNodeInit();
                    init = true;
                }
            };
            Panel.SetZIndex(this, ZIndexes.NodeIndex);
            KeyboardNavigation.SetDirectionalNavigation(this, KeyboardNavigationMode.None);
            if (spontaneousAddition)
            {
                host.AddNode(this, Mouse.GetPosition(host).X - 5, Mouse.GetPosition(host).Y - 5,
                             type == NodeTypes.Root);
            }

            Id = Guid.NewGuid().ToString();
            Console.WriteLine(Id);
            IsVisibleChanged += Node_IsVisibleChanged;
            MouseDown        += Node_MouseDown;
        }
Example #8
0
 public Connector(VirtualControl host, Port sPort, Port ePort)
 {
     Wire.ParentConnector = this;
     ID = Guid.NewGuid().ToString();
 }