Beispiel #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);
        }
Beispiel #2
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);
        }