public void Exit() { //Ensure that we leave the workspace marked as //not having changes. ViewModel.HomeSpace.HasUnsavedChanges = false; if (View.IsLoaded) { View.Close(); } if (ViewModel != null) { var shutdownParams = new DynamoViewModel.ShutdownParams( shutdownHost: false, allowCancellation: false); ViewModel.PerformShutdownSequence(shutdownParams); ViewModel = null; } View = null; Model = null; preloader = null; try { var directory = new DirectoryInfo(TempFolder); directory.Delete(true); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
public override void Cleanup() { try { preloader = null; DynamoSelection.Instance.ClearSelection(); if (ViewModel == null) { return; } var shutdownParams = new DynamoViewModel.ShutdownParams( shutdownHost: false, allowCancellation: false); ViewModel.PerformShutdownSequence(shutdownParams); ViewModel.RequestUserSaveWorkflow -= RequestUserSaveWorkflow; ViewModel = null; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } base.Cleanup(); }
private void WindowClosing(object sender, CancelEventArgs e) { // Test cases that make use of views (e.g. recorded tests) have // their own tear down logic as part of the test set-up (mainly // because DynamoModel should stay long enough for verification // code to verify data much later than the window closing). // if (DynamoModel.IsTestMode) { return; } var sp = new DynamoViewModel.ShutdownParams( shutdownHost: false, allowCancellation: true, closeDynamoView: false); if (dynamoViewModel.PerformShutdownSequence(sp)) { //Shutdown wasn't cancelled SizeChanged -= DynamoView_SizeChanged; LocationChanged -= DynamoView_LocationChanged; } else { //Shutdown was cancelled e.Cancel = true; } }
public void Exit() { //Ensure that we leave the workspace marked as //not having changes. Model.HomeSpace.HasUnsavedChanges = false; if (View.IsLoaded) { View.Close(); } if (ViewModel != null) { var shutdownParams = new DynamoViewModel.ShutdownParams( shutdownHost: false, allowCancellation: false); ViewModel.PerformShutdownSequence(shutdownParams); ViewModel = null; } View = null; Model = null; GC.Collect(); }
private void RestartTestSetupWithNewSettings(Dynamo.Models.DynamoModel.IStartConfiguration configuration, bool startInTestMode) { // Shutdown Dynamo and restart it View.Close(); View = null; if (ViewModel != null) { var shutdownParams = new DynamoViewModel.ShutdownParams( shutdownHost: false, allowCancellation: false); ViewModel.PerformShutdownSequence(shutdownParams); ViewModel = null; } Model = DynamoModel.Start(configuration); ViewModel = DynamoViewModel.Start( new DynamoViewModel.StartConfiguration() { DynamoModel = Model }); var expectedState = startInTestMode ? DynamoModel.DynamoModelState.StartedUIless : DynamoModel.DynamoModelState.StartedUI; Assert.AreEqual(ViewModel.Model.State, expectedState); //create the view View = new DynamoView(ViewModel); SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); }
protected void Exit() { if (this.ViewModel != null) { var shutdownParams = new DynamoViewModel.ShutdownParams( shutdownHost: false, allowCancellation: false); this.ViewModel.PerformShutdownSequence(shutdownParams); this.ViewModel = null; this.commandCallback = null; } }
private void RestartTestSetup(bool startInTestMode) { // Shutdown Dynamo and restart it View.Close(); View = null; if (ViewModel != null) { var shutdownParams = new DynamoViewModel.ShutdownParams( shutdownHost: false, allowCancellation: false); ViewModel.PerformShutdownSequence(shutdownParams); ViewModel = null; } // Setup Temp PreferenceSetting Location for testing PreferenceSettings.DynamoTestPath = Path.Combine(TempFolder, "UserPreferenceTest.xml"); Model = DynamoModel.Start( new DynamoModel.DefaultStartConfiguration() { StartInTestMode = startInTestMode, ProcessMode = startInTestMode ? TaskProcessMode.Synchronous : TaskProcessMode.Asynchronous }); ViewModel = DynamoViewModel.Start( new DynamoViewModel.StartConfiguration() { DynamoModel = Model }); var expectedState = startInTestMode ? DynamoModel.DynamoModelState.StartedUIless : DynamoModel.DynamoModelState.StartedUI; Assert.AreEqual(ViewModel.Model.State, expectedState); //create the view View = new DynamoView(ViewModel); SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); }
public virtual void TearDown() { //Ensure that we leave the workspace marked as //not having changes. ViewModel.HomeSpace.HasUnsavedChanges = false; if (null != View && View.IsLoaded) { View.Close(); } if (ViewModel != null) { var shutdownParams = new DynamoViewModel.ShutdownParams(false, false); ViewModel.PerformShutdownSequence(shutdownParams); ViewModel = null; } View = null; Model = null; preloader = null; pathResolver = null; if (assemblyResolver != null) { assemblyResolver.TearDown(); assemblyResolver = null; } PathManager.BuiltinPackagesDirectory = originalBuiltinPackagesDirectory; try { var directory = new DirectoryInfo(TempFolder); directory.Delete(true); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
public override void Cleanup() { try { var shutdownParams = new DynamoViewModel.ShutdownParams( shutdownHost: false, allowCancellation: false); ViewModel.PerformShutdownSequence(shutdownParams); this.ViewModel = null; EventArgs args = new ExcelCloseEventArgs(false); ExcelInterop.OnProcessExit(this, args); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } base.Cleanup(); GC.Collect(); }
public override void Cleanup() { try { var vm = ViewModel; ViewModel = null; DynamoSelection.Instance.ClearSelection(); var shutdownParams = new DynamoViewModel.ShutdownParams( shutdownHost: false, allowCancellation: false); vm.PerformShutdownSequence(shutdownParams); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } base.Cleanup(); GC.Collect(); }
private void RestartTestSetup(bool startInTestMode) { // Shutdown Dynamo and restart it View.Close(); View = null; if (ViewModel != null) { var shutdownParams = new DynamoViewModel.ShutdownParams( shutdownHost: false, allowCancellation: false); ViewModel.PerformShutdownSequence(shutdownParams); ViewModel = null; } // Setup Temp PreferenceSetting Location for testing PreferenceSettings.DynamoTestPath = Path.Combine(TempFolder, "UserPreferenceTest.xml"); Model = DynamoModel.Start( new DynamoModel.StartConfiguration() { StartInTestMode = startInTestMode }); ViewModel = DynamoViewModel.Start( new DynamoViewModel.StartConfiguration() { DynamoModel = Model }); //create the view View = new DynamoView(ViewModel); View.Show(); SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); }