Ejemplo n.º 1
0
        /// <summary>
        /// Exposes the commands which can be consumed.
        /// </summary>
        public void ExposeCommands()
        {
            WorkCommand ExposedWorkCommand = null;

            // =========================================================================================================
            SimpleElement ExposedArea  = new SimpleElement("Domain", "Domain");
            SimpleElement ExposedGroup = new SimpleElement("Definition", "Definition");

            this.CommandAreas_.Add(ExposedArea);
            this.CommandGroups_.PutIntoSublist(ExposedArea.TechName, ExposedGroup);

            // -------------------------------------------------------------------------------------
            ExposedWorkCommand       = new GenericCommand("EditDomain");
            ExposedWorkCommand.Apply =
                (par =>
            {
                var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine;
                if (Doc == null)
                {
                    return;
                }

                DomainServices.DomainEdit(Doc.TargetComposition.CompositeContentDomain);
            });
            ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null));

            this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Edit Domain...", ExposedWorkCommand.Name, "Edit the Domain of the current Composition", "book_edit.png",
                                                                                         EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand));

            // -------------------------------------------------------------------------------------
            /* this would confuse the user? */
            ExposedWorkCommand          = new GenericCommand("NewDomain");
            ExposedWorkCommand.Apply    = (par => ProductDirector.CompositionDirector.CreateComposition(true));
            ExposedWorkCommand.CanApply = (par => true);
            this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("New Domain", ExposedWorkCommand.Name, "Creates a new Domain (and its empty template Composition).", "book_star.png",
                                                                                         EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand));

            ExposedWorkCommand          = new GenericCommand("OpenDomain");
            ExposedWorkCommand.Apply    = (par => ProductDirector.CompositionDirector.OpenDomainAndCreateCompositionOfIt(true));
            ExposedWorkCommand.CanApply = (par => true);
            this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Open Domain", ExposedWorkCommand.Name, "Opens a Domain for editing (and creates its emtpy template Composition).", "folder_book.png",
                                                                                         EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand));

            // -------------------------------------------------------------------------------------
            ExposedWorkCommand       = new GenericCommand("SaveDomainAs");
            ExposedWorkCommand.Apply =
                (par =>
            {
                var Engine = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine;
                if (Engine == null)
                {
                    return;
                }

                var Confirmation = Display.DialogMessage("Confirmation", "Save also the current Composition as Domain's Template for create new ones?\n" +
                                                         "(Note: Later, it can be used or just start empty Compositions)",
                                                         EMessageType.Question, MessageBoxButton.YesNoCancel, MessageBoxResult.Yes);
                if (Confirmation == MessageBoxResult.Cancel || Confirmation == MessageBoxResult.None)
                {
                    return;
                }

                var SaveTemplate = (Confirmation == MessageBoxResult.Yes);

                //T Console.WriteLine("Saving Domain as...");

                var InitialRoute = (Engine.DomainLocation != null
                                        ? Engine.DomainLocation.LocalPath
                                        : (Engine.FullLocation == null
                                            ? Path.Combine(AppExec.UserDataDirectory,
                                                           Engine.TargetComposition.CompositeContentDomain.TechName)
                                            : Path.Combine(Path.GetDirectoryName(Engine.FullLocation.LocalPath),
                                                           Engine.TargetComposition.CompositeContentDomain.TechName)));

                var TargetRoute = Display.DialogGetSaveFile("Save Domain as",
                                                            FileDataType.FileTypeDomain.Extension,
                                                            FileDataType.FileTypeDomain.FilterForSave,
                                                            InitialRoute);
                if (TargetRoute == null)
                {
                    return;
                }

                var CurrentWindow = Display.GetCurrentWindow();
                CurrentWindow.Cursor = Cursors.Wait;

                var TargetDomain = Engine.TargetComposition.CompositeContentDomain;

                Visual Snapshot = null;

                if (SaveTemplate && TargetDomain.OwnerComposition.ActiveView != null)
                {
                    Snapshot = TargetDomain.OwnerComposition.ActiveView
                               .ToVisualSnapshot(DocumentEngine.PART_SNAPSHOT_WIDTH, DocumentEngine.PART_SNAPSHOT_HEIGHT);
                }

                TargetDomain.SetTemplateSaving(SaveTemplate);

                var Result = DocumentEngine.StoreToLocation <Domain>(TargetDomain, Domain.__ClassDefinitor.Name,
                                                                     TargetDomain.Classification.ContentTypeCode,
                                                                     TargetRoute, DomainDocumentUri, true, false,
                                                                     TargetDomain, Snapshot);

                if (!Result.IsAbsent())
                {
                    CurrentWindow.Cursor = Cursors.Arrow;
                    Display.DialogMessage("Error!", "Cannot save Domain.\n\nProblem: " + Result, EMessageType.Warning);
                    return;
                }
                Engine.DomainLocation = TargetRoute;

                this.WorkspaceDirector.ShellProvider.RefreshSelection();
                CurrentWindow.Cursor = Cursors.Arrow;
            });
            ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null));

            this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Save Domain As", ExposedWorkCommand.Name, "Saves the current Domain to the specified file.", "book_saveas.png",
                                                                                         EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand));

            // -------------------------------------------------------------------------------------
            // Ordered list of quick access commands
            this.QuickExposedCommands.Add(this.CommandExpositors["NewDomain"]);
            this.QuickExposedCommands.Add(this.CommandExpositors["OpenDomain"]);
            this.QuickExposedCommands.Add(this.CommandExpositors["EditDomain"]);
            this.QuickExposedCommands.Add(this.CommandExpositors["SaveDomainAs"]);

            // -------------------------------------------------------------------------------------
            ExposedWorkCommand       = new GenericCommand("Concept Definitions...");
            ExposedWorkCommand.Apply =
                (par =>
            {
                var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine;
                if (Doc == null)
                {
                    return;
                }

                DomainServices.DefineDomainConcepts(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain);
            });
            ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null));

            this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Concept Defs...", ExposedWorkCommand.Name, "Edit the Concept Definitions of the Domain", "imtc_concept.png",
                                                                                         EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand));

            // -------------------------------------------------------------------------------------
            ExposedWorkCommand       = new GenericCommand("Relationship Definitions...");
            ExposedWorkCommand.Apply =
                (par =>
            {
                var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine;
                if (Doc == null)
                {
                    return;
                }

                DomainServices.DefineDomainRelationships(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain);
            });
            ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null));

            this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Relationship Defs...", ExposedWorkCommand.Name, "Edit the Relationship Definitions of the Domain", "imtc_relationship.png",
                                                                                         EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand));

            // -------------------------------------------------------------------------------------
            ExposedWorkCommand       = new GenericCommand("Link-Role Variant Definitions...");
            ExposedWorkCommand.Apply =
                (par =>
            {
                var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine;
                if (Doc == null)
                {
                    return;
                }

                DomainServices.DefineDomainLinkRoleVariants(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain);
            });
            ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null));

            this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Link-Role Variant Defs...", ExposedWorkCommand.Name, "Edit the Link-Role Variant Definitions of the Domain", "link_role_variants.png",
                                                                                         EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand));

            // -------------------------------------------------------------------------------------
            ExposedWorkCommand       = new GenericCommand("Marker Definitions...");
            ExposedWorkCommand.Apply =
                (par =>
            {
                var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine;
                if (Doc == null)
                {
                    return;
                }

                DomainServices.DefineDomainMarkers(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain);
            });
            ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null));

            this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Marker Defs...", ExposedWorkCommand.Name, "Edit the Marker Definitions of the Domain", "award_star_edit.png",
                                                                                         EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand));

            // -------------------------------------------------------------------------------------
            ExposedWorkCommand       = new GenericCommand("Table-Structure Definitions...");
            ExposedWorkCommand.Apply =
                (par =>
            {
                var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine;
                if (Doc == null)
                {
                    return;
                }

                DomainServices.EditDomainTableDefinitions(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain);
            });
            ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null));

            this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Table-Structure Defs...", ExposedWorkCommand.Name, "Edit the Table-Structure Definitions of the Domain", "table_alter.png",
                                                                                         EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand));

            ExposedWorkCommand       = new GenericCommand("Base Tables...");
            ExposedWorkCommand.Apply =
                (par =>
            {
                var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine;
                if (Doc == null)
                {
                    return;
                }

                DomainServices.EditDomainBaseTables(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain);
            });
            ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null));

            this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Base Tables...", ExposedWorkCommand.Name, "Edit the Base Tables of the Domain", "table_multiple.png",
                                                                                         EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand));

            // -------------------------------------------------------------------------------------
            ExposedWorkCommand       = new GenericCommand("External Languages...");
            ExposedWorkCommand.Apply =
                (par =>
            {
                var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine;
                if (Doc == null)
                {
                    return;
                }

                DomainServices.DefineDomainExternalLanguages(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain);
            });
            ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null));

            this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("External Languages...", ExposedWorkCommand.Name, "Edit the External Languages declared for the Domain", "page_white_code_red.png",
                                                                                         EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand));

            // -------------------------------------------------------------------------------------
            ExposedWorkCommand       = new GenericCommand("Idea-Def Clusters...");
            ExposedWorkCommand.Apply =
                (par =>
            {
                var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine;
                if (Doc == null)
                {
                    return;
                }

                DomainServices.DefineDomainIdeaDefClusters(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain);
            });
            ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null));

            this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Idea-Def Clusters...", ExposedWorkCommand.Name, "Edit the Idea-Definition Clusters of the Domain", "def_clusters.png",
                                                                                         EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand));

            // -------------------------------------------------------------------------------------
        }
Ejemplo n.º 2
0
        public static bool RelationshipDefinitionEdit(Domain SourceDomain, IList <RelationshipDefinition> EditedList, RelationshipDefinition RelationshipDef)
        {
            /*- if (!ProductDirector.ConfirmImmediateApply("Relationship Definition", "DomainEdit.RelationshipDefinition", "ApplyDialogChangesDirectly"))
             *  return false; */

            var CurrentWindow = Display.GetCurrentWindow();

            CurrentWindow.Cursor = Cursors.Wait;

            var InstanceController = EntityInstanceController.AssignInstanceController(RelationshipDef,
                                                                                       (current, previous, editpanels) =>
            {
                var CurrentDetailsEditor = (GlobalDetailsDefinitor)editpanels.First(editpanel => editpanel is GlobalDetailsDefinitor);

                // IMPORTANT: Ensure that at least one linking variant is available.
                if (current.OriginOrParticipantLinkRoleDef.AllowedVariants.Count < 1)
                {
                    current.OriginOrParticipantLinkRoleDef.AllowedVariants.Add(current.OwnerDomain.LinkRoleVariants.FirstOrDefault());
                }

                if (current.TargetLinkRoleDef != null && current.TargetLinkRoleDef.AllowedVariants.Count < 1)
                {
                    current.TargetLinkRoleDef.AllowedVariants.Add(current.OwnerDomain.LinkRoleVariants.FirstOrDefault());
                }

                return(CurrentDetailsEditor.UpdateRelatedDetailDefinitions(current));
            });

            var DetDefEd = GlobalDetailsDefinitor.CreateGlobalDetailsDefinitor(InstanceController.EntityEditor, RelationshipDef);

            InstanceController.StartEdit();

            var ExtraGeneralContentsPanel = new Grid();

            ExtraGeneralContentsPanel.ColumnDefinitions.Add(new ColumnDefinition());
            ExtraGeneralContentsPanel.ColumnDefinitions.Add(new ColumnDefinition());

            var ExtraGenContentPanelLeft = new StackPanel();

            Grid.SetColumn(ExtraGenContentPanelLeft, 0);
            ExtraGeneralContentsPanel.Children.Add(ExtraGenContentPanelLeft);

            var ExtraGenContentPanelRight = new StackPanel();

            Grid.SetColumn(ExtraGenContentPanelRight, 1);
            ExtraGeneralContentsPanel.Children.Add(ExtraGenContentPanelRight);

            var Expositor = new EntityPropertyExpositor(RelationshipDefinition.__IsComposable.TechName);

            Expositor.LabelMinWidth = 180;
            ExtraGenContentPanelLeft.Children.Add(Expositor);

            Expositor = new EntityPropertyExpositor(ConceptDefinition.__IsVersionable.TechName);
            Expositor.LabelMinWidth = 180;
            ExtraGenContentPanelLeft.Children.Add(Expositor);

            Expositor = new EntityPropertyExpositor(ConceptDefinition.__HasGroupRegion.TechName);
            Expositor.LabelMinWidth = 180;
            ExtraGenContentPanelLeft.Children.Add(Expositor);

            Expositor = new EntityPropertyExpositor(ConceptDefinition.__HasGroupLine.TechName);
            Expositor.LabelMinWidth = 180;
            ExtraGenContentPanelLeft.Children.Add(Expositor);

            Expositor = new EntityPropertyExpositor(RelationshipDefinition.__RepresentativeShape.TechName);
            Expositor.LabelMinWidth = 180;
            ExtraGenContentPanelLeft.Children.Add(Expositor);
            Expositor.PostCall(expo =>
            {
                var Combo = expo.ValueEditor as ComboBox;
                if (Combo != null)
                {
                    var Panel = new FrameworkElementFactory(typeof(WrapPanel));
                    Panel.SetValue(WrapPanel.WidthProperty, 810.0);
                    Panel.SetValue(WrapPanel.ItemWidthProperty, 200.0);
                    // Don't work as expected: Panel.SetValue(WrapPanel.OrientationProperty, Orientation.Vertical);
                    var Templ        = new ItemsPanelTemplate(Panel);
                    Combo.ItemsPanel = Templ;
                }
            }, true);

            Expositor = new EntityPropertyExpositor(ConceptDefinition.__PreciseConnectByDefault.TechName);
            Expositor.LabelMinWidth = 180;
            ExtraGenContentPanelLeft.Children.Add(Expositor);

            var ClosuredExpositor = new EntityPropertyExpositor(IdeaDefinition.__Cluster.TechName);

            ClosuredExpositor.LabelMinWidth = 210;
            ExtraGenContentPanelRight.Children.Add(ClosuredExpositor);
            var PropCtl = InstanceController.GetPropertyController(IdeaDefinition.__Cluster.TechName);

            PropCtl.ComplexOptionsProviders =
                Tuple.Create <IRecognizableElement, Action <object> >(
                    new SimplePresentationElement("Edit Clusters", "EditClusters", "Edit Clusters", Display.GetAppImage("def_clusters.png")),
                    obj =>
            {
                if (DomainServices.DefineDomainIdeaDefClusters(SourceDomain, DomainServices.TABKEY_IDEF_CLUSTER_RELATIONSHIP))
                {
                    ClosuredExpositor.RetrieveAvailableItems();
                }
            }).IntoArray();

            Expositor = new EntityPropertyExpositor(RelationshipDefinition.__CanAutomaticallyCreateRelatedConcepts.TechName);
            Expositor.LabelMinWidth = 210;
            ExtraGenContentPanelRight.Children.Add(Expositor);

            Expositor = new EntityPropertyExpositor(RelationshipDefinition.__IsSimple.TechName);
            Expositor.LabelMinWidth = 210;
            ExtraGenContentPanelRight.Children.Add(Expositor);

            Expositor = new EntityPropertyExpositor(RelationshipDefinition.__HideCentralSymbolWhenSimple.TechName);
            Expositor.LabelMinWidth = 210;
            ExtraGenContentPanelRight.Children.Add(Expositor);

            Expositor = new EntityPropertyExpositor(RelationshipDefinition.__ShowNameIfHidingCentralSymbol.TechName);
            Expositor.LabelMinWidth = 210;
            ExtraGenContentPanelRight.Children.Add(Expositor);

            var VisualSymbolFormatter     = new VisualSymbolFormatSubform("DefaultSymbolFormat");
            var VisualConnectorsFormatter = new VisualConnectorsFormatSubform("DefaultConnectorsFormat", RelationshipDef.DefaultConnectorsFormat);

            var TemplateEd = new TemplateEditor();

            TemplateEd.Initialize(SourceDomain, SourceDomain.CurrentExternalLanguage.TechName, typeof(Relationship), RelationshipDef,
                                  IdeaDefinition.__OutputTemplates, Domain.__OutputTemplatesForRelationships, false,
                                  Tuple.Create <string, ImageSource, string, Action <string> >("Insert predefined...", Display.GetAppImage("page_white_wrench.png"), "Inserts a system predefined Output-Template text, at the current selection.",
                                                                                               text => { var tpl = DomainServices.GetPredefinedOutputTemplate(); if (tpl != null)
                                                                                                         {
                                                                                                             TemplateEd.SteSyntaxEditor.ReplaceTextAtSelection(tpl);
                                                                                                         }
                                                                                               }),
                                  Tuple.Create <string, ImageSource, string, Action <string> >("Test", Display.GetAppImage("page_white_wrench.png"), "Test the Template against a source Relationship.",
                                                                                               text => RememberedTemplateTestRelationship[SourceDomain.OwnerComposition] =
                                                                                                   TemplateTester.TestTemplate(typeof(Relationship), RelationshipDef, IdeaDefinition.__OutputTemplates.Name,
                                                                                                                               RelationshipDef.GetGenerationFinalTemplate(TemplateEd.CurrentTemplate.Language, text, TemplateEd.ChbExtendsBaseTemplate.IsChecked.IsTrue()),
                                                                                                                               SourceDomain.OwnerComposition,
                                                                                                                               RememberedTemplateTestRelationship.GetValueOrDefault(SourceDomain.OwnerComposition)
                                                                                                                               .NullDefault(SourceDomain.OwnerComposition.CompositeIdeas.OrderBy(idea => idea.Name)
                                                                                                                                            .FirstOrDefault(idea => idea.IdeaDefinitor == RelationshipDef)
                                                                                                                                            .NullDefault(SourceDomain.OwnerComposition.DeclaredIdeas
                                                                                                                                                         .FirstOrDefault(idea => idea is Relationship))))));
            var TemplateTab = TabbedEditPanel.CreateTab(DomainServices.TABKEY_DEF_OUTTEMPLATE, "Output-Templates", "Definition of Output-Templates", TemplateEd);

            var SpecTabs = General.CreateList(
                TabbedEditPanel.CreateTab(DomainServices.TABKEY_DEF_ARRANGE, "Arrange", "Settings for relate and group ideas.",
                                          new ArrangeTabForRelationshipDef(RelationshipDef)),
                TabbedEditPanel.CreateTab(TABKEY_DEF_REL_LINKROLEDEF_ORIPAR, "Origin/Participant Link-Role Def.", "Definition of Link-Role for Origin or Participant.",
                                          new LinkRoleDefSpecSubform("OriginOrParticipantLinkRoleDef", false, RelationshipDef.OriginOrParticipantLinkRoleDef, RelationshipDef)),
                TabbedEditPanel.CreateTab(TABKEY_DEF_REL_LINKROLEDEF_TARGET, "Target Link-Role Def.", "Definition of Link-Role for Target.",
                                          new LinkRoleDefSpecSubform("TargetLinkRoleDef", true, RelationshipDef.TargetLinkRoleDef, RelationshipDef)),
                TabbedEditPanel.CreateTab(DomainServices.TABKEY_DEF_FORMAT, "Symbol format", "Definition for the Central/Main-Symbol format.",
                                          VisualSymbolFormatter),
                TabbedEditPanel.CreateTab(TABKEY_DEF_REL_CONNFORMAT, "Connectors format", "Definition for the Connectors format.",
                                          VisualConnectorsFormatter),
                TabbedEditPanel.CreateTab(DomainServices.TABKEY_DEF_DETAILS, "Details", "Details definition.", DetDefEd),
                TemplateTab);

            var EditPanel = Display.CreateEditPanel(RelationshipDef, SpecTabs, true, null, Display.TABKEY_TECHSPEC + General.STR_SEPARATOR + DomainServices.TABKEY_DEF_OUTTEMPLATE,
                                                    true, false, true, true, ExtraGeneralContentsPanel);

            EditPanel.Loaded +=
                ((sender, args) =>
            {
                var OwnerWindow = EditPanel.GetNearestVisualDominantOfType <Window>();
                OwnerWindow.MinWidth = 750;
                OwnerWindow.MinHeight = 550;
                OwnerWindow.PostCall(wnd => CurrentWindow.Cursor = Cursors.Arrow);
            });

            if (IdeaDefinition.__OutputTemplates.IsAdvanced)
            {
                EditPanel.ShowAdvancedMembersChanged +=
                    ((show) =>
                {
                    TemplateTab.SetVisible(show);
                    if (!show)
                    {
                        var OwnerTabControl = TemplateTab.GetNearestDominantOfType <TabControl>();
                        if (OwnerTabControl.SelectedItem == TemplateTab)
                        {
                            OwnerTabControl.SelectedIndex = 0;
                        }
                    }
                });
            }

            var Previewer = new VisualElementPreviewer(VisualSymbolFormatter.VisualElementFormatter.ExpoLineBrush,
                                                       VisualSymbolFormatter.VisualElementFormatter.ExpoLineThickness,
                                                       VisualSymbolFormatter.VisualElementFormatter.ExpoLineDash,
                                                       VisualSymbolFormatter.VisualElementFormatter.ExpoMainBackground,
                                                       VisualConnectorsFormatter.VisualElementFormatter.ExpoLineBrush,
                                                       VisualConnectorsFormatter.VisualElementFormatter.ExpoLineThickness,
                                                       VisualConnectorsFormatter.VisualElementFormatter.ExpoLineDash,
                                                       VisualConnectorsFormatter.VisualElementFormatter.ExpoMainBackground);

            Previewer.AttachSource(RelationshipDef);
            Previewer.Margin        = new Thickness(4);
            EditPanel.HeaderContent = Previewer;
            Previewer.PostCall(prv => prv.ShowPreview());   // Required because of initially unpopulated properties of old Domains.

            var Result = InstanceController.Edit(EditPanel, "Edit Relationship Definition - " + RelationshipDef.ToString(), true, null,
                                                 RELDEFWND_INI_WIDTH, RELDEFWND_INI_HEIGHT).IsTrue();

            return(Result);
        }