Ejemplo n.º 1
0
        public void SettingNodeAsInputOrOutputMarksGraphAsModified()
        {
            Open(@"core\isInput_isOutput\IsInput.dyn");

            // Get the node view for a specific node in the graph
            NodeView nodeView = NodeViewWithGuid("c275ece0-2316-4e27-8d51-915257374c1e");

            // Get a reference to the current workspace
            NodeViewModel  nodeViewModel = (nodeView.DataContext as NodeViewModel);
            WorkspaceModel ws            = nodeViewModel.DynamoViewModel.CurrentSpace;

            // Verify IsSetAsInput is set to true
            Assert.AreEqual(nodeViewModel.IsSetAsInput, true);
            // Verify IsSetAsOutput is set to false
            Assert.AreEqual(nodeViewModel.IsSetAsOutput, false);
            // Verify the graph is not marked as modified
            Assert.AreEqual(ws.HasUnsavedChanges, false);

            // Set IsSetAsInput to false
            nodeViewModel.IsSetAsInput = false;
            // Verify graph is marked as modified
            Assert.AreEqual(nodeViewModel.IsSetAsInput, false);
            Assert.AreEqual(ws.HasUnsavedChanges, true);

            // Save the graph
            string tempPath = Path.Combine(Path.GetTempPath(), "IsInput.dyn");

            ws.Save(tempPath);

            // Verify graph is no longer marked as modified
            Assert.AreEqual(nodeViewModel.IsSetAsInput, false);
            Assert.AreEqual(ws.HasUnsavedChanges, false);

            // Repeat process for IsSetAsOutput //

            // Verify IsSetAsOutput is set to false
            Assert.AreEqual(nodeViewModel.IsSetAsOutput, false);
            // Set IsSetAsOutput to true
            nodeViewModel.IsSetAsOutput = true;

            // Verify graph is marked as modified
            Assert.AreEqual(nodeViewModel.IsSetAsOutput, true);
            Assert.AreEqual(ws.HasUnsavedChanges, true);

            // Save the graph
            ws.Save(tempPath);

            // Verify graph is no longer marked as modified
            Assert.AreEqual(nodeViewModel.IsSetAsOutput, true);
            Assert.AreEqual(ws.HasUnsavedChanges, false);

            // Delete temp file
            File.Delete(tempPath);
        }
Ejemplo n.º 2
0
 private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     _workspace.Save(_configService);
 }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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;
        }