コード例 #1
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);
        }
コード例 #2
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;
        }
コード例 #3
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;
        }