Exemplo n.º 1
0
        public GSPresentation(GStatement statement)
        {
            StatementID = statement.GetBoundProperty().ID;

            Statement = statement.GetBoundProperty() as Statement;
            Type      = statement.StatementType;
        }
Exemplo n.º 2
0
        // --------

        private void AddStatementPanel(Point point, StatementType statementType, bool editConversation = true, Statement statement = null)
        {
            GStatement gStatement = new GStatement(statementType, statement);

            gStatement.CreateConnectionItem.Click += CreateConnectionItem_Click;

            gStatement.StartItem.Click  += StartStatementItem_Click;
            gStatement.DeleteItem.Click += DeleteItem_Click;

            if (editConversation)
            {
                if (statementType == StatementType.Player)
                {
                    conversation.PlayerStatements.Add(gStatement.GetBoundProperty() as Statement);
                }
                else
                {
                    conversation.NPCStatements.Add(gStatement.GetBoundProperty() as Statement);
                }
            }

            if (statementType == StatementType.NPC)
            {
                gStatement.StartPosition.LostFocus += StartPosition_LostFocus;

                if (statement != null && conversation.StartStatements.Contains(statement))
                {
                    gStatement.SetBorderBrush     = Brushes.Orange;
                    gStatement.Border.BorderBrush = Brushes.Orange;

                    gStatement.StartItem.Header         = "Remove from start statements";
                    gStatement.StartPosition.Visibility = Visibility.Visible;
                }
            }

            Panel.SetZIndex(gStatement, 10);

            gStatement.MouseDown += Control_MouseDown;
            gStatement.MouseDown += Control_Connection_MouseDown;

            gStatement.MouseMove += Control_MouseMove;
            gStatement.MouseUp   += Control_MouseUp;

            Canvas.SetTop(gStatement, point.Y);
            Canvas.SetLeft(gStatement, point.X);

            Workspace.Children.Add(gStatement);
        }
Exemplo n.º 3
0
        // -------- Start Statements --------

        private void StartStatementItem_Click(object sender, RoutedEventArgs e)
        {
            if (!((sender as MenuItem).Tag is GStatement))
            {
                return;
            }

            GStatement gStatement = (sender as MenuItem).Tag as GStatement;

            if (conversation.StartStatements.Contains(gStatement.GetBoundProperty()))
            {
                Console.WriteLine("Is start!");

                gStatement.StartItem.Header         = "Add to start statements";
                gStatement.StartPosition.Visibility = Visibility.Collapsed;

                gStatement.SetBorderBrush     = Brushes.Transparent;
                gStatement.Border.BorderBrush = Brushes.Transparent;

                conversation.StartStatements.Remove(gStatement.GetBoundProperty() as Statement);

                UpdateStartStatementsSequence();
            }
            else
            {
                Console.WriteLine("Is not!");

                gStatement.StartItem.Header         = "Remove from start statements";
                gStatement.StartPosition.Visibility = Visibility.Visible;

                gStatement.SetBorderBrush     = Brushes.Orange;
                gStatement.Border.BorderBrush = Brushes.Orange;

                conversation.StartStatements.Add(gStatement.GetBoundProperty() as Statement);

                UpdateStartStatementsSequence();
            }
        }
Exemplo n.º 4
0
        // --------

        public GStatement GetGStatement(Statement statement)
        {
            foreach (UIElement control in Workspace.Children)
            {
                if (control is GStatement)
                {
                    GStatement gStatement = control as GStatement;

                    if (gStatement.GetBoundProperty() == statement)
                    {
                        return(gStatement);
                    }
                }
            }
            return(null);
        }
Exemplo n.º 5
0
        // -------- Creating connections --------

        private void CreateConnectionItem_Click(object sender, RoutedEventArgs e)
        {
            if (creatingConnection)
            {
                return;
            }
            creatingConnection = true;

            Control control = (sender as MenuItem).Tag as Control;

            if (!(control is GStatement))
            {
                Console.WriteLine("Cannot create connection from object other than GStatement!");
                return;
            }

            selected = control as GStatement;
            ShowInformation("Creating connection with element: " + selected.GetBoundProperty().ID, "Cancel", CancelConnection_Button_Click);
        }
Exemplo n.º 6
0
        private void Control_Connection_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!creatingConnection || selected == null)
            {
                return;
            }

            Control connecting = sender as Control;

            IPanel selectedPanel   = sender as IPanel;
            IPanel connectingPanel = connecting as IPanel;

            PanelConnection panelConnection = null;

            if (connecting is GStatement)
            {
                GStatement connectingGStatement = connecting as GStatement;
                panelConnection = new PanelConnection(selected, connecting, true, BreakConnectionItem_Click);

                if (selected.StatementType == connectingGStatement.StatementType)
                {
                    Console.WriteLine("Cannot connect two statements with same type!");

                    creatingConnection = false;
                    selected           = null;

                    return;
                }

                (selected.GetBoundProperty() as Statement).NextStatements.Add(connectingGStatement.GetBoundProperty() as Statement);
            }
            else if (connecting is GProperty)
            {
                GProperty connectingGProperty = connecting as GProperty;

                if (connectingGProperty.GetBoundProperty() == null)
                {
                    Console.WriteLine("GProperty property is not defined!");

                    creatingConnection = false;
                    selected           = null;

                    return;
                }

                panelConnection = new PanelConnection(selected, connecting, false, BreakConnectionItem_Click);
                Statement statement = selected.GetBoundProperty() as Statement;
                Property  property  = connectingGProperty.GetBoundProperty() as Property;

                if (connectingGProperty.Type == PropertyType.Condition)
                {
                    statement.Conditions.Add(property);
                    if (connectingGProperty.Negated)
                    {
                        statement.NegatedConditions.Add(property.ID);
                    }
                }
                else if (connectingGProperty.Type == PropertyType.Event)
                {
                    statement.Events.Add(property);
                }
            }
            Connections.Add(panelConnection);

            creatingConnection = false;
            selected           = null;

            HideTopInformationBar();
        }