コード例 #1
0
ファイル: AddEntityCommand.cs プロジェクト: jeswin/AgileFx
        public override void InvokeHandler(CommandSetState state)
        {
            var store = state.CurrentDocView.CurrentDiagram.Store;

            var addEntityForm = new AddEntityForm(store);

            addEntityForm.ShowDialog();
        }
コード例 #2
0
ファイル: AgileModelerDocData.cs プロジェクト: jeswin/AgileFx
        public void HandleElementAdded(object sender, ElementAddedEventArgs e)
        {
            if (ModelerTransaction.IsInTransaction)
            {
                return;
            }

            ModelerTransaction.Enter(() =>
            {
                using (Transaction tx = (sender as Store).TransactionManager.BeginTransaction())
                {
                    if (e.ModelElement is ModelClass)
                    {
                        e.ModelElement.Delete();
                        var dlg = new AddEntityForm(sender as Store);
                        dlg.ShowDialog();
                    }
                    else if (e.ModelElement is Inheritance)
                    {
                        var inheritance      = e.ModelElement as Inheritance;
                        var baseClassName    = inheritance.Superclass.Name;
                        var derivedClassName = inheritance.Subclass.Name;
                        inheritance.Delete();
                        InheritanceUtil.AddInheritance(sender as Store, baseClassName, derivedClassName);
                    }
                    else if (e.ModelElement is Association)
                    {
                        var assoc = e.ModelElement as Association;
                        var dlg   = new AddAssociationForm(sender as Store);
                        dlg.SetSelectedClasses(assoc.Source, assoc.Target);
                        assoc.Delete();
                        dlg.ShowDialog();
                    }
                    else if (e.ModelElement is NavigationProperty)
                    {
                        var parentClass = (e.ModelElement as NavigationProperty).ModelClass;
                        e.ModelElement.Delete();
                        var addAssociationForm = new AddAssociationForm(sender as Store);
                        addAssociationForm.SetSelectedClasses(parentClass);
                        addAssociationForm.ShowDialog();
                    }

                    if (tx.HasPendingChanges)
                    {
                        tx.Commit();
                    }
                }
            });
        }