/// <summary>
        /// Override of <see cref="BehaviourBase"/> that handles a left mouse button press.
        /// This initiates the point move process allowing a user to alter the Y value of
        /// the selected point.
        /// </summary>
        /// <param name="position">The position on the mouse on click.</param>
        public override void MouseLeftButtonDown(Point position)
        {
            // Get the point that has been clicked on.
            GetSelectedPoint(position);

            // Check we can capture the mouse, otherwise the move is impossible.
            bool captured = BehaviourContainer.CaptureMouse();

            if (captured && _selectedPoint != null)
            {
                _leftMouseDown = true;

                SetZoomEnabled(false);

                foreach (var child in this.BehaviourContainer.Children)
                {
                    if (child is ZoomBehaviour)
                    {
                        (child as ZoomBehaviour).IsEnabled = false;
                        break;
                    }
                }

                // Change the point style by adding it to the Series SelectedItems list
                //((ChartSingleSeriesBase)Chart.Series[0]).SelectedItems.Add(_selectedPoint);

                // Change the cursor
                _currentCursor = Chart.Cursor;
                Chart.Cursor   = Cursors.Hand;
            }
        }
Example #2
0
        public override void MouseLeftButtonUp(Point position)
        {
            if (!_leftMouseDown)
            {
                return;
            }

            position = EnsurePointIsOnChart(position);

            //Mouse button is no longer down
            _leftMouseDown = false;
            //Reset the zoom rectangle to hidden
            _zoomRectangle.Visibility = Visibility.Collapsed;

            BehaviourContainer.ReleaseMouseCapture();

            //If we haven't really gone far enough to bother stop now
            if (Math.Abs(position.X - _firstPosition.X) < 2)
            {
                return;
            }
            if (Keyboard.Modifiers != ModifierKeys.Shift)
            {
                RequestZoom(_firstPosition, position);
            }
        }
Example #3
0
        public override void MouseLeftButtonUp(Point position)
        {
            if (Keyboard.Modifiers != ModifierKeys.Shift)
            {
                ResetSelection();
                _leftMouseDown = false;
                return;
            }

            if (!_leftMouseDown)
            {
                return;
            }

            position = EnsurePointIsOnChart(position);

            _leftMouseDown = false;

            BehaviourContainer.ReleaseMouseCapture();

            if (Math.Abs(position.X - _firstPosition.X) < 2)
            {
                ResetSelection();
            }

            MakeSelection(_firstPosition, position);
        }
Example #4
0
    private void LoadBehaviour(string behaviourName)
    {
        if (isBehaviourLoaded(behaviourName))
        {
            return;
        }

        BehaviourContainer tmpContainer = new BehaviourContainer();

        tmpContainer.BehaviourName = behaviourName;

        XmlSerializer serializer = new XmlSerializer(typeof(Node_Canvas_Object));

        StreamReader lecteur = new StreamReader("Assets/Resources/Behaviours/" + behaviourName + ".xml");

        Node_Canvas_Object nodeCanvas = (Node_Canvas_Object)serializer.Deserialize(lecteur);

        foreach (Node n1 in nodeCanvas.nodes)
        {
            if (n1.Linkers[0])
            {
                n1.Linkers[0].body = n1;
            }
            for (int i = 1; i < 4; ++i)
            {
                if (n1.Linkers[i])
                {
                    n1.Linkers[i].body = n1;
                    foreach (Node n2 in nodeCanvas.nodes)
                    {
                        if (n1.Linkers[i].connectionID == n2.ID)
                        {
                            n1.Linkers[i].connection = n2.Linkers[(int)Node.LinkType.From];
                            n2.Linkers[(int)Node.LinkType.From].connection = n1.Linkers[i];
                        }
                    }
                }
            }
        }

        lecteur.Close();

        Behaviours.Add(tmpContainer);

        tmpContainer.canvas = nodeCanvas;

        foreach (Node node in tmpContainer.canvas.nodes)
        {
            if (node.name == "Root")
            {
                tmpContainer.root        = node;
                tmpContainer.currentNode = tmpContainer.root.Linkers[(int)Node.LinkType.To].connection.body;
            }
        }

        Behaviours.Add(tmpContainer);
    }
Example #5
0
    public void ExecuteNextStep()
    {
        BehaviourContainer ctn = Behaviours[currentBehaviour];

        if (ctn.currentNode.name == "Start Step")
        {
            inStep          = true;
            ctn.currentNode = ctn.currentNode.Linkers[(int)Node.LinkType.To].connection.body;
        }

        if (ctn.currentNode.name == "End Step")
        {
            inStep          = false;
            ctn.currentNode = ctn.currentNode.Linkers[(int)Node.LinkType.To].connection.body;
        }

        if (ctn.currentNode.name == "Action")
        {
            ActionNode n = ctn.currentNode as ActionNode;

            n.ActionFunction.DoAction(this.gameObject);
            ctn.currentNode = ctn.currentNode.Linkers[(int)Node.LinkType.To].connection.body;

            if (inStep)
            {
                ExecuteNextStep();
            }
        }
        else if (ctn.currentNode.name == "Condition")
        {
            ConditionNode n = ctn.currentNode as ConditionNode;

            if (n.ConditionFunction.DoCondition(this.gameObject))
            {
                ctn.currentNode = ctn.currentNode.Linkers[(int)Node.LinkType.ToOK].connection.body;
            }
            else
            {
                ctn.currentNode = ctn.currentNode.Linkers[(int)Node.LinkType.ToKO].connection.body;
            }

            ExecuteNextStep();
        }
        else if (ctn.currentNode.name == "End")
        {
            EndNode endNode = ctn.currentNode as EndNode;

            if (endNode.Restart)
            {
                ctn.currentNode = ctn.root.Linkers[(int)Node.LinkType.To].connection.body;
            }
        }
    }
        /// <summary>
        /// Override of <see cref="BehaviourBase"/> that handles the left mouse button being
        /// released. If the button was initially pressed on point, then this signifies the
        /// end of a move.
        /// </summary>
        /// <param name="position">The position the button was released at.</param>
        public override void MouseLeftButtonUp(Point position)
        {
            if (!_leftMouseDown)
            {
                return;
            }

            SetZoomEnabled(true);
            Chart.Cursor   = _currentCursor;
            _leftMouseDown = false;
            _selectedPoint = null;
            BehaviourContainer.ReleaseMouseCapture();
        }
Example #7
0
    private void ResetBehaviour()
    {
        BehaviourContainer ctn = Behaviours[currentBehaviour];

        ctn.currentNode = ctn.root.Linkers[(int)Node.LinkType.To].connection.body;
    }
Example #8
0
        public override void MouseLeftButtonDown(Point position)
        {
            if (Chart.XAxis.ActualRange == null || Chart.YAxis.ActualRange == null || !BehaviourContainer.CaptureMouse() || Keyboard.Modifiers == ModifierKeys.Shift)
            {
                return;
            }

            _leftMouseDown = true;
            _firstPosition = position;

            //Set the up the zoom rectangle
            _zoomRectangle.SetValue(Canvas.LeftProperty, position.X);
            _zoomRectangle.SetValue(Canvas.TopProperty, position.Y);
            _zoomRectangle.Width  = 0;
            _zoomRectangle.Height = 0;
            if (_zoomRectangle.Border != null)
            {
                _zoomRectangle.Border.Background  = _zoomRectangle.Background;
                _zoomRectangle.Border.BorderBrush = _zoomRectangle.Foreground;
            }

            //Make it visible
            _zoomRectangle.Visibility = Visibility.Visible;
        }
Example #9
0
        public override void MouseLeftButtonDown(Point position)
        {
            if (Chart.XAxis.ActualRange == null || Chart.YAxis.ActualRange == null || !BehaviourContainer.CaptureMouse())
            {
                return;
            }

            _leftMouseDown = true;
            _firstPosition = position;

            //Set the up the zoom rectangle
            _selectionRectangle.SetValue(Canvas.LeftProperty, position.X);
            _selectionRectangle.SetValue(Canvas.TopProperty, UseFullYAxis ? 0 : position.Y);
            _selectionRectangle.Width  = 0;
            _selectionRectangle.Height = UseFullYAxis ? BehaviourContainer.ActualHeight : 0;
            if (_selectionRectangle.Border != null)
            {
                _selectionRectangle.Border.Background = new SolidColorBrush(new Color {
                    A = 60, R = 255, B = 0, G = 0
                });
                _selectionRectangle.Border.BorderBrush = new SolidColorBrush(new Color {
                    A = 255, R = 255, B = 0, G = 0
                });
            }

            //Make it visible
            _selectionRectangle.Visibility = Visibility.Visible;
        }