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

            Statement = statement.GetBoundProperty() as Statement;
            Type      = statement.StatementType;
        }
Ejemplo n.º 2
0
        public void LoadPresentation(GCEPresentation presentation)
        {
            Workspace.Children.Clear();
            Connections.Clear();

            Statement statement;
            Property  property;

            foreach (GSPresentation statementPresentation in presentation.Statements)
            {
                statement = Project.Quest.GetStatement(conversation, statementPresentation.Type, statementPresentation.StatementID);
                AddStatementPanel(statementPresentation.PointPresentation.ToPoint(), statementPresentation.Type, false, statement);
            }
            foreach (GPPresentation propertyPresentation in presentation.Properties)
            {
                property = Project.Quest.GetProperty(propertyPresentation.PropertyType, propertyPresentation.PropertyID);
                AddPropertyPanel(propertyPresentation.PointPresentation.ToPoint(), propertyPresentation.PropertyType, property);
            }

            foreach (PanelConnectionPresentation connection in presentation.PanelConnections)
            {
                GStatement first = presentation.GetGStatement(connection.First as GSPresentation);

                if (connection.Second is GSPresentation)
                {
                    Connections.Add(new PanelConnection(first, presentation.GetGStatement(connection.Second as GSPresentation), true, BreakConnectionItem_Click));
                }
                else
                {
                    Connections.Add(new PanelConnection(first, presentation.GetGProperty(connection.Second as GPPresentation), false, BreakConnectionItem_Click));
                }
            }
        }
Ejemplo n.º 3
0
        private void CancelConnection_Button_Click(object sender, RoutedEventArgs e)
        {
            if (!creatingConnection)
            {
                return;
            }

            selected           = null;
            creatingConnection = false;

            HideTopInformationBar();
        }
        public GSPresentation GetStatementPresentation(GStatement gStatement)
        {
            double gStatementX = Canvas.GetLeft(gStatement);
            double gStatementY = Canvas.GetTop(gStatement);

            foreach (GSPresentation presentation in Statements)
            {
                if (presentation.PointPresentation.X == gStatementX && presentation.PointPresentation.Y == gStatementY)
                {
                    return(presentation);
                }
            }

            return(null);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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();
            }
        }
        // -------- Access --------

        private void HookProperties()
        {
            foreach (UIElement element in Workspace.Children)
            {
                if (element is GStatement)
                {
                    GStatement gStatement = element as GStatement;

                    GSPresentation statement = new GSPresentation(gStatement);
                    statement.PointPresentation = new PointPresentation(Canvas.GetLeft(element as GStatement), Canvas.GetTop(element as GStatement));

                    Statements.Add(statement);
                }
                else if (element is GProperty)
                {
                    GProperty      gProperty = element as GProperty;
                    GPPresentation property  = new GPPresentation(gProperty);

                    property.PointPresentation = new PointPresentation(Canvas.GetLeft(element as GProperty), Canvas.GetTop(element as GProperty));

                    Properties.Add(property);
                }
            }
        }
Ejemplo n.º 10
0
 public void Append(GStatement statement)
 {
     Content.Add(statement);
 }
Ejemplo n.º 11
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();
        }
Ejemplo n.º 12
0
 public void AppendToElse(GStatement statement)
 {
     elseChild.Add(statement);
 }
Ejemplo n.º 13
0
 public void AppendToIf(GStatement statement)
 {
     ifChild.Add(statement);
 }
Ejemplo n.º 14
0
 public void Append(GStatement obj)
 {
     listStatement.Add(obj);
 }