Esempio n. 1
0
        private bool Save(CompositionEngine Engine)
        {
            var Location = Engine.FullLocation;

            if (Location == null)
            {
                Location = Display.DialogGetSaveFile("Save Composition",
                                                     FileDataType.FileTypeComposition.Extension,
                                                     FileDataType.FileTypeComposition.FilterForSave,
                                                     Engine.TargetComposition.TechName);
            }
            if (Location == null)
            {
                return(false);
            }

            var CurrentWindow = Display.GetCurrentWindow();

            CurrentWindow.Cursor = Cursors.Wait;

            var Result = Engine.Store(Location);

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

            CurrentWindow.Cursor = Cursors.Arrow;

            return(true);
        }
Esempio n. 2
0
        public static Composition OpenComposition(Uri Location = null, bool CanEditPropertiesOfNewCompo = true)
        {
            var CurrentWindow = Display.GetCurrentWindow();

            if (Location == null)
            {
                Location = Display.DialogGetOpenFile("Open Composition",
                                                     FileDataType.FileTypeComposition.Extension,
                                                     FileDataType.FileTypeComposition.FilterForOpen);
            }
            if (Location == null)
            {
                return(null);
            }

            //-? DEPRECATE?:
            // Switch to document if already opened
            var CurrentlyOpenedDoc = ProductDirector.WorkspaceDirector.Documents
                                     .FirstOrDefault(doc => doc.DocumentEditEngine.Location != null && !doc.DocumentEditEngine.Location.LocalPath.IsAbsent() &&
                                                     doc.DocumentEditEngine.Location.LocalPath == Location.LocalPath);

            if (CurrentlyOpenedDoc != null)
            {
                ProductDirector.WorkspaceDirector.ActivateDocument(CurrentlyOpenedDoc);
                return(CurrentlyOpenedDoc as Composition);
            }

            CurrentWindow.Cursor = Cursors.Wait;

            var PreviousActiveDoc = ProductDirector.WorkspaceDirector.ActiveDocument;

            ProductDirector.WorkspaceDirector.ActiveDocument = null;   // Must deactive previous to create+activate the opening Composition.

            CompositionEngine.CreateActiveCompositionEngine(ProductDirector.CompositionDirector, ProductDirector.CompositionDirector.Visualizer, false);
            var Result = CompositionEngine.Materialize(Location);

            if (Result.Item1 == null)
            {
                CurrentWindow.Cursor = Cursors.Arrow;
                Display.DialogMessage("Error!", "Cannot open Composition.\n\nProblem: " + Result.Item2, EMessageType.Warning);
                ProductDirector.WorkspaceDirector.ActiveDocument = PreviousActiveDoc;
                return(null);
            }

            // Start visual interactive editing and show document view.
            ProductDirector.WorkspaceDirector.LoadDocument(Result.Item1.TargetComposition);
            Result.Item1.Start();

            /* Only for Creation, not opening.
             * if (CanEditPropertiesOfNewCompo)
             * {
             *  var EditOnOpenComposition = AppExec.GetConfiguration<bool>("Composition", "EditOnOpenComposition", true);
             *  if (EditOnOpenComposition)
             *      Result.Item1.EditCompositionProperties();
             * } */

            CurrentWindow.Cursor = Cursors.Arrow;

            return(Result.Item1.TargetComposition);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates, activates and returns a new Comopsition Engine, using the supplied Manager and Visualizer.
        /// From this point in time onwards, every editing change will be stored by this Entity Edit-Engine.
        /// </summary>
        public static CompositionEngine CreateActiveCompositionEngine(CompositionsManager Manager, IDocumentVisualizer Visualizer, bool IsForEditDomain)
        {
            var NewEngine = new CompositionEngine(Manager, Visualizer);

            NewEngine.IsForEditDomain = IsForEditDomain;

            EntityEditEngine.ActiveEntityEditor = NewEngine;

            return(NewEngine);
        }
Esempio n. 4
0
        /// <summary>
        /// Tries to close any pending resources still open (such as temporal Attachment files)
        /// </summary>
        public bool CloseRelatedResources(CompositionEngine Engine)
        {
            var Failure = DetailAttachmentEditor.TryLoadPendingAttachmentsFor(Engine);

            if (Failure == null)
            {
                return(true);
            }

            var Result = Display.DialogMessage("Error!",
                                               Failure.Message + "\n\nProblem: " + Failure.InnerException.Message + "\n\n" +
                                               "Do you want to ignore that problem and continue (potentially lossing information)?",
                                               EMessageType.Question,
                                               System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxResult.Cancel);

            return(Result == MessageBoxResult.OK);
        }
Esempio n. 5
0
        public void CreateComposition(bool IsForDomainCreation = false)
        {
            var CurrentWindow = Display.GetCurrentWindow();

            CurrentWindow.Cursor = Cursors.Wait;

            var PreviousActiveDoc = this.WorkspaceDirector.ActiveDocument;

            this.WorkspaceDirector.ActiveDocument = null;   // Must deactive previous to create+activate the opening Composition.

            CompositionEngine.CreateActiveCompositionEngine(this, this.Visualizer, IsForDomainCreation);
            var Result = CompositionEngine.Materialize();

            if (Result.Item1 == null)
            {
                CurrentWindow.Cursor = Cursors.Arrow;
                Display.DialogMessage("Error!", "Cannot create new Composition.\n\nProblem: " + Result.Item2, EMessageType.Warning);
                this.WorkspaceDirector.ActiveDocument = PreviousActiveDoc;
                return;
            }

            // Start visual interactive editing and show document view.
            this.WorkspaceDirector.LoadDocument(Result.Item1.TargetComposition);
            Result.Item1.Start();

            if (IsForDomainCreation)
            {
                Display.DialogMessage("Attention!",
                                      "Domains are created with a base Composition.\n" +
                                      "So, later it can be saved as the Domain's template.");

                DomainServices.DomainEdit(Result.Item1.TargetComposition.CompositeContentDomain);
            }
            else
            {
                var EditOnNewComposition = AppExec.GetConfiguration <bool>("Composition", "EditOnNewComposition", true);
                if (EditOnNewComposition)
                {
                    Result.Item1.EditCompositionProperties();
                }
            }

            CurrentWindow.Cursor = Cursors.Arrow;
        }
        // ---------------------------------------------------------------------------------------------------------------------------------------------------------
        private static void DefineContextMenuOptions()
        {
            // Views....................................................................................................
            ContextMenuOptionsForViews.Add(new Tuple <SimplePresentationElement, Func <View, FrameworkElement, bool?>, Action <View> >
                                               (new SimplePresentationElement("Go to Parent", "GoToParent", "Goes back to the parent Composite-Content View.", Display.GetAppImage("page_view_back.png")),
                                               (target, vexpo) => target.OwnerCompositeContainer.OwnerContainer != null,
                                               (target) => target.Engine.ShowCompositeAsView(target.OwnerCompositeContainer.OwnerContainer)));

            ContextMenuOptionsForViews.Add(new Tuple <SimplePresentationElement, Func <View, FrameworkElement, bool?>, Action <View> >
                                               (new SimplePresentationElement("Go to View", "GoToView", "Goes to the pointed Composite-Content View.", Display.GetAppImage("page_view.png")),
                                               (target, vexpo) => (target == target.Engine.CurrentView ? (bool?)null : true),
                                               (target) => target.Engine.ShowView(target)));

            ContextMenuOptionsForViews.Add(null);   // Separator

            ContextMenuOptionsForViews.Add(new Tuple <SimplePresentationElement, Func <View, FrameworkElement, bool?>, Action <View> >
                                               (new SimplePresentationElement("Paste", "Paste", "Paste Clipboard content.", Display.GetAppImage("paste_plain.png")),
                                               (target, vexpo) => (vexpo != target.Presenter) ? (bool?)null : target.Engine.ClipboardHasPasteableContent(),
                                               (target) => target.Engine.ClipboardPaste(target, false, CurrentMousePosition)));

            ContextMenuOptionsForViews.Add(new Tuple <SimplePresentationElement, Func <View, FrameworkElement, bool?>, Action <View> >
                                               (new SimplePresentationElement("Paste Shortcut", "PasteShortcut", "Paste copied Ideas as Shortcut.", Display.GetAppImage("paste_shortcut.png")),
                                               (target, vexpo) => (vexpo != target.Presenter) ? (bool?)null : General.Execute(() => Clipboard.ContainsData(CompositionEngine.IdeaTransferFormat.Name),
                                                                                                                              "Cannot access Windows Clipboard!").Result,
                                               (target) => target.Engine.ClipboardPaste(target, true)));

            ContextMenuOptionsForViews.Add(new Tuple <SimplePresentationElement, Func <View, FrameworkElement, bool?>, Action <View> >
                                               (new SimplePresentationElement("Select All", "SelectAll", "Sellect all visual objects of the View.", Display.GetAppImage("view_select_all.png")),
                                               (target, vexpo) => (vexpo != target.Presenter) ? (bool?)null : true,
                                               (target) => target.SelectMultipleObjects()));

            ContextMenuOptionsForViews.Add(null);   // Separator

            ContextMenuOptionsForViews.Add(new Tuple <SimplePresentationElement, Func <View, FrameworkElement, bool?>, Action <View> >
                                               (new SimplePresentationElement("Remove", "RemoveView", "Removes the entire View.", Display.GetAppImage("delete.png")),
                                               (target, vexpo) => (!ProductDirector.DocumentVisualizerControl.GetAllViews(target.Engine.TargetComposition).CountsAtLeast(2)
                                                 ? (bool?)null : target.OwnerCompositeContainer != target.OwnerCompositeContainer.OwnerComposition),
                                               (target) => target.Engine.RemoveCompositeView(target)));

            ContextMenuOptionsForViews.Add(new Tuple <SimplePresentationElement, Func <View, FrameworkElement, bool?>, Action <View> >
                                               (new SimplePresentationElement("View Properties", "ViewProperties", "Edits the properties of the View.", Display.GetAppImage("page_white_edit.png")),
                                               (target, vexpo) => true,
                                               (target) => CompositionEngine.EditViewProperties(target)));

            // Symbols...................................................................................................
            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Show/Hide Details", "ShowHideDetails", "Open/Close the symbol Details poster.", Display.GetAppImage("detail_poster.png")),
                                                       (target, vexpo) => (vexpo != target.GetDisplayingView().Presenter) ? (bool?)null : true,
                                                       (target) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.Manager.CommandSwitchDetails_Execution(null); }));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Convert", "Convert", "Converts the Idea, as based on other Idea Definition type.", Display.GetAppImage("wand_convert.png")),
                                                       (target, vexpo) => true,
                                                       (target) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.ConvertIdeasToAlternateDefinition(Eng.CurrentView.SelectedRepresentations.Select(vrep => vrep.RepresentedIdea)); }));

            ContextMenuOptionsForVisualSymbols.Add(null);   // Separator

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Expand/Collapse Related Origin Ideas", "ExpandCollapseRelatedOriginIdeas", "Expand/Collapse the Symbol supertree of Related Originating Ideas.", Display.GetAppImage("rel_sources.png")),
                                                       (target, vexpo) => ((vexpo != target.GetDisplayingView().Presenter) ? (bool?)null : target.OwnerRepresentation.OriginRepresentations.Any()),
                                                       (target) => target.GetDisplayingView().Manipulator.SwitchRelated(target, false)));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Expand/Collapse Related Target Ideas", "ExpandCollapseRelatedTargetIdeas", "Expand/Collapse the Symbol subtree of Related Targeted Ideas.", Display.GetAppImage("rel_targets.png")),
                                                       (target, vexpo) => ((vexpo != target.GetDisplayingView().Presenter) ? (bool?)null : target.OwnerRepresentation.TargetRepresentations.Any()),
                                                       (target) => target.GetDisplayingView().Manipulator.SwitchRelated(target, true)));

            //- ContextMenuOptionsForVisualSymbols.Add(null);   // Separator

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Show Composite-Content [F3]", "ShowCompositeContent", "Show the Idea Composite-Content as View.", Display.GetAppImage("show_composite.png")),
                                                       (target, vexpo) => (vexpo != target.GetDisplayingView().Presenter) ? (bool?)null : target.OwnerRepresentation.RepresentedIdea.IdeaDefinitor.IsComposable || target.OwnerRepresentation.RepresentedIdea.CompositeIdeas.Count > 0,
                                                       (target) => target.GetDisplayingView().Engine.ShowCompositeAsView(target)));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Display/Hide Composite-Content as Detail", "ShowCompositeContentAsDetail", "Display/Hide the Composite-Content View instead of Details.", Display.GetAppImage("composite_view.png")),
                                                       (target, vexpo) => ((vexpo != target.GetDisplayingView().Presenter) ? (bool?)null : target.OwnerRepresentation.RepresentedIdea.CompositeViews.Count > 0),
                                                       (target) => target.GetDisplayingView().Manipulator.ShowCompositeAsDetail(target)));

            ContextMenuOptionsForVisualSymbols.Add(null);   // Separator

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Add Attachment Detail", "AddAttachmentDetail", "Add an Attachment Detail to the Idea.", AttachmentDetailDesignator.KindPictogram),
                                                       (target, vexpo) => true,
                                                       (target) => target.GetDisplayingView().AppendDetailToVisualRepresentation(target.OwnerRepresentation, AttachmentDetailDesignator.KindName)));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Add Link Detail", "AddLinkDetail", "Add a Link Detail to the Idea.", LinkDetailDesignator.KindPictogram),
                                                       (target, vexpo) => true,
                                                       (target) => target.GetDisplayingView().AppendDetailToVisualRepresentation(target.OwnerRepresentation, LinkDetailDesignator.KindName)));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Add Table Detail", "AddTableDetail", "Add a Table Detail to the Idea.", TableDetailDesignator.KindPictogram),
                                                       (target, vexpo) => true,
                                                       (target) => target.GetDisplayingView().AppendDetailToVisualRepresentation(target.OwnerRepresentation, TableDetailDesignator.KindName)));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Edit Details [F6]", "EditDetails", "Opens the tab for edit the details of this Idea", Display.GetAppImage("detail_edit.png")),
                                                       (target, vexpo) => true,
                                                       (target) => target.GetDisplayingView().EditPropertiesOfVisualRepresentation(target.OwnerRepresentation, Display.TABKEY_DETAILS)));

            ContextMenuOptionsForVisualSymbols.Add(null);   // Separator

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Delete", "Delete", "Delete the selected objects.", Display.GetAppImage("lightbulb_delete.png")),
                                                       (target, vexpo) => true,
                                                       (target) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.DeleteObjects(Eng.CurrentView.SelectedObjects); }));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Cut", "Cut", "Cut the selected objects and let a copy in the Clipboard.", Display.GetAppImage("cut.png")),
                                                       (target, vexpo) => true,
                                                       (target) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.ClipboardCut(Eng.CurrentView); }));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Copy", "Copy", "Copy the selected objects to the Clipboard.", Display.GetAppImage("page_white_copy.png")),
                                                       (target, vexpo) => true,
                                                       (target) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.ClipboardCopy(Eng.CurrentView); }));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Paste", "Paste", "Paste Clipboard content into current View.", Display.GetAppImage("paste_plain.png")),
                                                       (target, vexpo) => target.GetDisplayingView().Engine.ClipboardHasPasteableContent(),
                                                       (target) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.ClipboardPaste(Eng.CurrentView); }));

            ContextMenuOptionsForVisualSymbols.Add(null);   // Separator

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Edit Markers [F7]", "EditMarkers", "Opens the tab for edit the markers of this Idea", Display.GetAppImage("award_star_gold_1.png")),
                                                       (target, vexpo) => true,
                                                       (target) => target.GetDisplayingView().EditPropertiesOfVisualRepresentation(target.OwnerRepresentation, Display.TABKEY_MARKINGS)));

            ContextMenuOptionsForVisualSymbols.Add(new Tuple <SimplePresentationElement, Func <VisualSymbol, FrameworkElement, bool?>, Action <VisualSymbol> >
                                                       (new SimplePresentationElement("Properties [F4]", "IdeaProperties", "Edit the Properties of this Idea", Display.GetAppImage("page_white_edit.png")),
                                                       (target, vexpo) => true,
                                                       (target) => target.GetDisplayingView().EditPropertiesOfVisualRepresentation(target.OwnerRepresentation)));

            // Connectors................................................................................................
            ContextMenuOptionsForVisualConnectors.Add(new Tuple <SimplePresentationElement, Func <VisualConnector, FrameworkElement, bool?>, Action <VisualConnector> >
                                                          (new SimplePresentationElement("Link Descriptor", "LinkDescriptor", "Edit the Descriptor of this Link", Display.GetAppImage("page_white_edit.png")),
                                                          (target, vexpo) => true,
                                                          (target) => target.DoEditDescriptor()));
            ContextMenuOptionsForVisualConnectors.Add(new Tuple <SimplePresentationElement, Func <VisualConnector, FrameworkElement, bool?>, Action <VisualConnector> >
                                                          (new SimplePresentationElement("Relationship Properties", "RelationshipProperties", "Edit the Descriptor of this Relationship", Display.GetAppImage("page_edit.png")),
                                                          (target, vexpo) => true,
                                                          (target) => target.GetDisplayingView().EditPropertiesOfVisualRepresentation(target.OwnerRepresentation)));

            // Complements...............................................................................................
            ContextMenuOptionsForVisualComplements.Add(new Tuple <SimplePresentationElement, Func <VisualComplement, FrameworkElement, bool?>, Action <VisualComplement, SimplePresentationElement>, List <SimplePresentationElement> >
                                                           (new SimplePresentationElement("Delete", "Delete", "Delete the selected objects.", Display.GetAppImage("lightbulb_delete.png")),
                                                           (target, vexpo) => true,
                                                           (target, selection) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.DeleteObjects(Eng.CurrentView.SelectedObjects); },
                                                           null));

            ContextMenuOptionsForVisualComplements.Add(new Tuple <SimplePresentationElement, Func <VisualComplement, FrameworkElement, bool?>, Action <VisualComplement, SimplePresentationElement>, List <SimplePresentationElement> >
                                                           (new SimplePresentationElement("Cut", "Cut", "Cut the selected objects and let a copy in the Clipboard.", Display.GetAppImage("cut.png")),
                                                           (target, vexpo) => true,
                                                           (target, selection) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.ClipboardCut(Eng.CurrentView); },
                                                           null));

            ContextMenuOptionsForVisualComplements.Add(new Tuple <SimplePresentationElement, Func <VisualComplement, FrameworkElement, bool?>, Action <VisualComplement, SimplePresentationElement>, List <SimplePresentationElement> >
                                                           (new SimplePresentationElement("Copy", "Copy", "Copy the selected objects to the Clipboard.", Display.GetAppImage("page_white_copy.png")),
                                                           (target, vexpo) => true,
                                                           (target, selection) => { var Eng = target.GetDisplayingView().Engine; Eng.CurrentView.SelectObject(target); Eng.ClipboardCopy(Eng.CurrentView); },
                                                           null));

            ContextMenuOptionsForVisualComplements.Add(null);   // Separator

            ContextMenuOptionsForVisualComplements.Add(new Tuple <SimplePresentationElement, Func <VisualComplement, FrameworkElement, bool?>, Action <VisualComplement, SimplePresentationElement>, List <SimplePresentationElement> >
                                                           (new SimplePresentationElement("Edit Content", "EditContent", "Edits the Content of this Complement or its owner Idea.", Display.GetAppImage("image_edit.png")),
                                                           (target, vexpo) => true,
                                                           (target, selection) => VisualComplement.Edit(target),
                                                           null));

            ContextMenuOptionsForVisualComplements.Add(null);   // Separator

            /*? Superseded by appropriate controls in line/connector brush (now format) selector.
             * ContextMenuOptionsForVisualComplements.Add(new Tuple<SimplePresentationElement, Func<VisualComplement, bool>, Action<VisualComplement, SimplePresentationElement>, List<SimplePresentationElement>>
             *              (new SimplePresentationElement("Line Thickness", "LineThickness", "Changes the thickness of the Complement lines.", Display.GetAppImage("line_thickness.png")),
             *               (target) => true,
             *               (target, selection) => VisualComplement.ChangeLineThickness(target, double.Parse(selection.TechName)),
             *               General.CreateList(new SimplePresentationElement("0.5", "0.5"),
             *                                  new SimplePresentationElement("1.0", "1"),
             *                                  new SimplePresentationElement("1.5", "1.5"),
             *                                  new SimplePresentationElement("2.0", "2"),
             *                                  new SimplePresentationElement("3.0", "3"),
             *                                  new SimplePresentationElement("4.0", "4"),
             *                                  new SimplePresentationElement("5.0", "5"),
             *                                  new SimplePresentationElement("6.0", "6"),
             *                                  new SimplePresentationElement("7.0", "7"),
             *                                  new SimplePresentationElement("8.0", "8"),
             *                                  new SimplePresentationElement("9.0", "9"),
             *                                  new SimplePresentationElement("10.0", "10"))));
             *
             * ContextMenuOptionsForVisualComplements.Add(new Tuple<SimplePresentationElement, Func<VisualComplement, bool>, Action<VisualComplement, SimplePresentationElement>, List<SimplePresentationElement>>
             *              (new SimplePresentationElement("Line Dash-Style", "LineDashStyle", "Changes the dash-style of the Complement lines.", Display.GetAppImage("line_dashstyle.png")),
             *               (target) => true,
             *               (target, selection) => VisualComplement.ChangeLineDashStyle(target, Display.DeclaredDashStyles[int.Parse(selection.TechName)].Item1),
             *               Display.DeclaredDashStyles.Select(dds =>
             *                   new SimplePresentationElement(dds.Item2, Display.DeclaredDashStyles.IndexOfMatch(d => d.Item1.IsEqual(dds.Item1)).ToString())).ToList())); */

            ContextMenuOptionsForVisualComplements.Add(new Tuple <SimplePresentationElement, Func <VisualComplement, FrameworkElement, bool?>, Action <VisualComplement, SimplePresentationElement>, List <SimplePresentationElement> >
                                                           (new SimplePresentationElement("Change Axis", "ChangeAxis", "Changes the axis (vertical/horizontal) of this Group Line Complement.", Display.GetAppImage("rod_change_axis.png")),
                                                           (target, vexpo) => target.IsComplementGroupLine,
                                                           (target, selection) => VisualComplement.ChangeAxis(target),
                                                           null));
        }
Esempio n. 7
0
        // ---------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Goes to the specified object either in a diagram View and/or its maintenance editor.
        /// Returns indication of successful goto.
        /// </summary>
        public bool GoToObject(object Target)
        {
            if (Target is Idea)
            {
                var TargetIdea    = Target as Idea;
                var Representator = TargetIdea.VisualRepresentators.FirstOrDefault();

                if (Representator == null)
                {
                    return(false);
                }

                Representator.DisplayingView.Engine.ShowView(Representator.DisplayingView);

                Representator.DisplayingView.Presenter.PostCall(
                    vpres =>
                {
                    vpres.OwnerView.Manipulator.ApplySelection(Representator.MainSymbol);
                    vpres.OwnerView.Presenter.BringIntoView(Representator.MainSymbol.BaseArea);
                });

                return(true);
            }

            if (Target is VisualComplement)
            {
                var TargetComplement = Target as VisualComplement;

                var TargetView = TargetComplement.GetDisplayingView();
                TargetView.Engine.ShowView(TargetView);

                TargetView.Presenter.PostCall(
                    vpres =>
                {
                    vpres.OwnerView.Manipulator.ApplySelection(TargetComplement);
                    vpres.OwnerView.Presenter.BringIntoView(TargetComplement.BaseArea);
                });

                return(true);
            }

            if (Target is View)
            {
                var TargetView = Target as View;
                CompositionEngine.EditViewProperties(TargetView);
                return(true);
            }

            if (Target is Composition)
            {
                var TargetCompo = Target as Composition;
                TargetCompo.Engine.EditCompositionProperties();
                return(true);
            }

            if (Target is Domain)
            {
                var TargetDomain = Target as Domain;
                DomainServices.DomainEdit(TargetDomain);
                return(true);
            }

            if (Target is ConceptDefinition)
            {
                var TargetDef = Target as ConceptDefinition;
                DomainServices.DefineDomainConcepts(TargetDef.OwnerDomain, TargetDef);
                return(true);
            }

            if (Target is RelationshipDefinition)
            {
                var TargetDef = Target as RelationshipDefinition;
                DomainServices.DefineDomainRelationships(TargetDef.OwnerDomain, TargetDef);
                return(true);
            }

            if (Target is MarkerDefinition)
            {
                var TargetDef = Target as MarkerDefinition;
                DomainServices.DefineDomainMarkers(this.TargetComposition.CompositeContentDomain, TargetDef);
                return(true);
            }

            if (Target is TableDefinition)
            {
                var TargetDef = Target as TableDefinition;
                DomainServices.EditDomainTableDefinitions(TargetDef.OwnerDomain, TargetDef);
                return(true);
            }

            if (Target is SimplePresentationElement)    // Link-Role Variant
            {
                var TargetDef = Target as SimplePresentationElement;

                if (this.TargetComposition.CompositeContentDomain.LinkRoleVariants.Contains(TargetDef))
                {
                    DomainServices.DefineDomainLinkRoleVariants(this.TargetComposition.CompositeContentDomain, TargetDef);
                    return(true);
                }
            }

            // PENDING: Find "Base Tables" and "Descriptors"
            // (would require to have two target objects in the finding operation, one for the owner, other for the descriptor).

            return(false);
        }
Esempio n. 8
0
        /// <summary>
        /// Tries to close the supplied document engine and returns indication of action executed or cancelled by user.
        /// </summary>
        public bool CloseComposition(CompositionEngine Engine)
        {
            if (Engine.ExistenceStatus == EExistenceStatus.Modified)
            {
                var Result = Display.DialogMessage("Confirmation",
                                                   "The Composition \"" + Engine.TargetComposition.Name + "\" has been modified.\n" +
                                                   (Engine.FullLocation != null ? "\nLocation: " + Engine.FullLocation.LocalPath : "") + "\n\n" +
                                                   "Do you want to save changes?",
                                                   EMessageType.Question,
                                                   System.Windows.MessageBoxButton.YesNoCancel, System.Windows.MessageBoxResult.Yes);

                if (Result == System.Windows.MessageBoxResult.Cancel)
                {
                    return(false);
                }

                if (Result == System.Windows.MessageBoxResult.Yes)
                {
                    if (!CloseRelatedResources(Engine))
                    {
                        return(false);
                    }

                    var Location = Engine.FullLocation;

                    if (Location != null)
                    {
                        var StoreResult = Engine.Store();
                        if (!StoreResult.IsAbsent())
                        {
                            Display.DialogMessage("Error!", "Cannot save Composition.\n\nProblem: " + StoreResult, EMessageType.Warning);
                            return(false);
                        }
                    }
                    else
                    {
                        Location = Display.DialogGetSaveFile("Save Composition",
                                                             FileDataType.FileTypeComposition.Extension,
                                                             FileDataType.FileTypeComposition.FilterForSave,
                                                             Engine.TargetComposition.TechName);
                        if (Location == null)
                        {
                            return(false);
                        }

                        var StoreResult = Engine.Store(Location);
                        if (!StoreResult.IsAbsent())
                        {
                            Display.DialogMessage("Error!", "Cannot save Composition.\n\nProblem: " + StoreResult, EMessageType.Warning);
                            return(false);
                        }
                    }
                }
            }

            Engine.Stop();

            // Show the new activated engine
            this.WorkspaceDirector.RemoveDocument(Engine.TargetComposition);

            // Finally, clears the palettes if no document remains.
            Application.Current.MainWindow
            .PostCall(win =>
            {
                if (this.WorkspaceDirector.Documents.Count < 1)
                {
                    ProductDirector.UpdatePalettes(null);
                }
            }, true);

            return(true);
        }
Esempio n. 9
0
        public void OpenDomainAndCreateCompositionOfIt(bool IsForOpenDomain, Uri Location = null, bool CanEditPropertiesOfNewCompo = true)
        {
            bool OpenCompositionStoredWithDomain = true;

            if (IsForOpenDomain)
            {
                Console.WriteLine("Opening Domain (and creating its Composition)...");
            }
            else
            {
                Console.WriteLine("Creating new Composition of Domain...");
            }

            if (Location == null)
            {
                var Selection = DomainSelector.SelectDomain(AppExec.ApplicationSpecificDefinitionsDirectory,
                                                            (IsForOpenDomain ? null :
                                                             "Select Domain file to create Composition..."),
                                                            !IsForOpenDomain);
                if (Selection == null)
                {
                    return;
                }

                Location = Selection.Item1;
                OpenCompositionStoredWithDomain = (IsForOpenDomain || Selection.Item2);

                // If 'Basic Domain' was selected...
                if (Location == null)
                {
                    this.CreateComposition();
                    return;
                }

                /* Previously...
                 * Location = Display.DialogGetOpenFile("Select Domain",
                 *                                   FileDataType.FileTypeDomain.Extension,
                 *                                   FileDataType.FileTypeDomain.FilterForOpen); */
            }
            if (Location == null)
            {
                return;
            }

            /* NOT APPLICABLE FOR DOMAINS
             * // Switch to document if already opened
             * var CurrentlyOpenedDoc = this.WorkspaceDirector.Documents
             *  .FirstOrDefault(doc => doc.DocumentEditEngine.Location != null && !doc.DocumentEditEngine.Location.LocalPath.IsAbsent()
             *                         && doc.DocumentEditEngine.Location.LocalPath == Location.LocalPath);
             *
             * if (CurrentlyOpenedDoc != null)
             * {
             *  this.WorkspaceDirector.ActivateDocument(CurrentlyOpenedDoc);
             *  return;
             * }
             */

            /* unnecessary
             * if (IsForOpenDomain)
             *  Application.Current.MainWindow.PostCall(mainwin =>
             *      Display.DialogMessage("Attention!",
             *                            "Domains must are created with a base Composition.\n" +
             *                            "So, later it can be saved as the Domain's template."); */

            var CurrentWindow = Display.GetCurrentWindow();

            CurrentWindow.Cursor = Cursors.Wait;

            var PreviousActiveDoc = this.WorkspaceDirector.ActiveDocument;

            this.WorkspaceDirector.ActiveDocument = null;   // Must deactive previous to create+activate the opening Composition.

            CompositionEngine.CreateActiveCompositionEngine(this, this.Visualizer, IsForOpenDomain);
            var DomainLoad = CompositionEngine.MaterializeDomain(Location);

            if (DomainLoad.Item1 == null)
            {
                CurrentWindow.Cursor = Cursors.Arrow;
                Display.DialogMessage("Error!", "Cannot open Domain.\n\nProblem: " + DomainLoad.Item2, EMessageType.Warning);
                this.WorkspaceDirector.ActiveDocument = PreviousActiveDoc;
                return;
            }

            var Result = CompositionEngine.Materialize(null, DomainLoad.Item1, OpenCompositionStoredWithDomain);

            if (Result.Item1 == null)
            {
                CurrentWindow.Cursor = Cursors.Arrow;
                Display.DialogMessage("Error!", "Cannot create Composition of Domain.\n\nProblem: " + Result.Item2, EMessageType.Warning);
                this.WorkspaceDirector.ActiveDocument = PreviousActiveDoc;
                return;
            }

            // Start visual interactive editing and show document view.
            Result.Item1.DomainLocation = Location;
            this.WorkspaceDirector.LoadDocument(Result.Item1.TargetDocument);

            Result.Item1.Start();

            if (IsForOpenDomain)
            {
                DomainServices.DomainEdit(Result.Item1.TargetComposition.CompositeContentDomain);
            }
            else
            if (CanEditPropertiesOfNewCompo)
            {
                var EditOnNewComposition = AppExec.GetConfiguration <bool>("Composition", "EditOnNewComposition", true);
                if (EditOnNewComposition)
                {
                    Result.Item1.EditCompositionProperties();
                }
            }

            CurrentWindow.Cursor = Cursors.Arrow;
        }