public DecisionNode(Node owner, SerialNode serial)
        {
            InitializeComponent();

            this.owner = owner;
            left       = new Point(0, MDesigner.Instance.NodeSize / 2);
            right      = new Point(0, MDesigner.Instance.NodeSize / 2);
            top        = new Point(0, MDesigner.Instance.NodeSize / 2);
            bottom     = new Point(0, MDesigner.Instance.NodeSize / 2);

            this.TryUnbundling.IsEnabled = false;
            this.LayoutUpdated          += DecisionNode_LayoutUpdated;
            definitions = owner.Definitions;
            Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => { Name = serial.Name; }));
        }
Exemplo n.º 2
0
        public ValueNode(Node owner, SerialNode serial)
        {
            InitializeComponent();

            this.owner = owner;
            left       = new Point(0, MDesigner.Instance.NodeSize / 2);
            right      = new Point(0, MDesigner.Instance.NodeSize / 2);
            top        = new Point(0, MDesigner.Instance.NodeSize / 2);
            bottom     = new Point(0, MDesigner.Instance.NodeSize / 2);

            this.LayoutUpdated += DecisionNode_LayoutUpdated;
            better              = serial.Better;
            outcomes            = DeserializeOutcomes(serial.Outcomes);
            Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => { Name = serial.Name; }));
        }
Exemplo n.º 3
0
        public Node(SerialNode serial)
        {
            type        = serial.Type;
            definitions = serial.Definitions;
            id          = serial.Id;
            name        = serial.Name;
            switch (type)
            {
            case NodeType.Decision:
                control           = new DecisionNode(this, serial);
                definitionControl = new NodeDefinition(this);
                control.PreviewMouseLeftButtonUp += Control_MouseLeftButtonUp;
                break;

            case NodeType.Event:
                control            = new EventNode(this, serial);
                definitionControl  = new NodeDefinition(this);
                probabilityControl = new PropertyEvent(control as EventNode);
                control.PreviewMouseLeftButtonUp += Control_MouseLeftButtonUp;
                break;

            case NodeType.Value:
                control           = new ValueNode(this, serial);
                definitionControl = new ValueDefinition(this);
                outcomeControl    = new PropertyValue(control as ValueNode);
                control.PreviewMouseLeftButtonUp += Control_MouseLeftButtonUp;
                break;
            }

            Point pos = serial.Position;

            MainWindow.GetCanvas.Children.Add(control);
            Canvas.SetLeft(control, pos.X - MDesigner.Instance.NodeSize / 2);
            Canvas.SetTop(control, pos.Y - MDesigner.Instance.NodeSize / 2);

            n       = new Anchor(this, "North", Node.AnchorTopXProperty, Node.AnchorTopYProperty);
            s       = new Anchor(this, "South", Node.AnchorBottomXProperty, Node.AnchorBottomYProperty);
            w       = new Anchor(this, "West", Node.AnchorLeftXProperty, Node.AnchorLeftYProperty);
            e       = new Anchor(this, "East", Node.AnchorRightXProperty, Node.AnchorRightYProperty);
            anchors = new Anchor[] { n, s, w, e };
            MDiagram.AddNode(this);
        }
Exemplo n.º 4
0
        public SerialNode Serialize()
        {
            SerialNode serial = new SerialNode
            {
                Type        = Type,
                Name        = Name,
                Id          = ID,
                Definitions = Definitions,
            };

            serial.Position = new Point(LeftXProperty, TopYProperty);
            if (Type == NodeType.Event)
            {
                serial.Probabilities = (Control as EventNode).SerializeProbabilities();
            }
            else if (Type == NodeType.Value)
            {
                serial.Better   = (Control as ValueNode).Better;
                serial.Outcomes = (Control as ValueNode).SerializeOutcomes();
            }
            return(serial);
        }