示例#1
0
        // -------- Deleting and Breaking Connections --------

        private void DeleteItem_Click(object sender, RoutedEventArgs e)
        {
            IPanel iPanel = (sender as MenuItem).Tag as IPanel;

            bool removedIsStatement = iPanel is GStatement;

            GProperty gProperty = null;

            if (!removedIsStatement)
            {
                gProperty = iPanel as GProperty;

                for (int n = Connections.Count - 1; n >= 0; n--)
                {
                    if (gProperty.Type == PropertyType.Condition)
                    {
                        ((Connections[n].First as GStatement).GetBoundProperty() as Statement).Conditions.Remove(gProperty.GetBoundProperty());
                        ((Connections[n].First as GStatement).GetBoundProperty() as Statement).NegatedConditions.Remove(gProperty.GetBoundProperty().ID);
                    }
                    else
                    {
                        ((Connections[n].First as GStatement).GetBoundProperty() as Statement).Events.Remove(gProperty.GetBoundProperty());
                    }

                    if (Connections[n].First.Equals(iPanel) || Connections[n].Second.Equals(iPanel))
                    {
                        Connections[n].Delete();
                        Connections.RemoveAt(n);
                    }
                }
            }
            else
            {
                for (int n = Connections.Count - 1; n >= 0; n--)
                {
                    if (Connections[n].First.Equals(iPanel) || Connections[n].Second.Equals(iPanel))
                    {
                        Connections[n].Delete();
                        Connections.RemoveAt(n);
                    }
                }

                conversation.BreakConnectionsWithStatement((iPanel.GetBoundProperty() as Statement));
                conversation.RemoveStatement(iPanel.GetBoundProperty() as Statement);

                UpdateStartStatementsSequence();
            }

            Workspace.Children.Remove(iPanel as Control);
        }