예제 #1
0
        /// <summary>
        ///     Attempts to save a given workspace.  Shows a save as dialog if the 
        ///     workspace does not already have a path associated with it
        /// </summary>
        /// <param name="workspace">The workspace for which to show the dialog</param>
        /// <returns>true if save was successful, false otherwise</returns>
        internal bool ShowSaveDialogIfNeededAndSave(WorkspaceModel workspace)
        {
            // crash sould always allow save as
            if (!String.IsNullOrEmpty(workspace.FileName) && !DynamoModel.IsCrashing)
            {
                workspace.Save(EngineController.LiveRunnerRuntimeCore);
                return true;
            }
            else
            {
                //TODO(ben): We still add a cancel button to the save dialog if we're crashing
                // sadly it's not usually possible to cancel a crash

                var fd = this.GetSaveDialog(workspace);
                if (fd.ShowDialog() == DialogResult.OK)
                {
                    workspace.SaveAs(fd.FileName, EngineController.LiveRunnerRuntimeCore);
                    return true;
                }
            }

            return false;
        }
예제 #2
0
        /// <summary>
        ///     Attempts to save a given workspace.  Shows a save as dialog if the 
        ///     workspace does not already have a path associated with it
        /// </summary>
        /// <param name="workspace">The workspace for which to show the dialog</param>
        /// <returns>true if save was successful, false otherwise</returns>
        internal bool ShowSaveDialogIfNeededAndSave(WorkspaceModel workspace)
        {
            // crash sould always allow save as
            if (!String.IsNullOrEmpty(workspace.FileName) && !DynamoModel.IsCrashing)
            {
                workspace.Save(EngineController.LiveRunnerRuntimeCore);
                return true;
            }
            else
            {
                //TODO(ben): We still add a cancel button to the save dialog if we're crashing
                // sadly it's not usually possible to cancel a crash

                var fd = this.GetSaveDialog(workspace);
                // since the workspace file directory is null, we set the initial directory
                // for the file to be MyDocument folder in the local computer. 
                fd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                if (fd.ShowDialog() == DialogResult.OK)
                {
                    workspace.SaveAs(fd.FileName, EngineController.LiveRunnerRuntimeCore);
                    return true;
                }
            }

            return false;
        }