Ejemplo n.º 1
0
        public bool CloseSolution(bool allowCancel = true)
        {
            SD.MainThread.VerifyAccess();
            var solution = this.CurrentSolution;

            if (solution == null)
            {
                return(true);
            }

            var cancelEventArgs = new SolutionClosingEventArgs(solution, allowCancel);

            SolutionClosing(this, cancelEventArgs);
            if (allowCancel && cancelEventArgs.Cancel)
            {
                return(false);
            }

            foreach (var project in solution.Projects)
            {
                project.SavePreferences();
            }
            solution.SavePreferences();

            if (!SD.Workbench.CloseAllSolutionViews(force: !allowCancel))
            {
                return(false);
            }

            // If a build is running, cancel it.
            // If we would let a build run but unload the MSBuild projects, the next project.StartBuild call
            // could cause an exception.
            SD.BuildService.CancelBuild();

            CurrentProject = null;

            this.CurrentSolution = null;             // this will fire the CurrentSolutionChanged event
            SolutionClosed(this, new SolutionEventArgs(solution));
            solution.Dispose();
            return(true);
        }
Ejemplo n.º 2
0
		public bool CloseSolution(bool allowCancel)
		{
			SD.MainThread.VerifyAccess();
			var solution = this.CurrentSolution;
			if (solution == null)
				return true;
			
			var cancelEventArgs = new SolutionClosingEventArgs(solution, allowCancel);
			SolutionClosing(this, cancelEventArgs);
			if (allowCancel && cancelEventArgs.Cancel)
				return false;
			
			foreach (var project in solution.Projects)
				project.SavePreferences();
			solution.SavePreferences();
			
			if (!SD.Workbench.CloseAllSolutionViews(force: !allowCancel))
				return false;
			
			// If a build is running, cancel it.
			// If we would let a build run but unload the MSBuild projects, the next project.StartBuild call
			// could cause an exception.
			SD.BuildService.CancelBuild();
			
			CurrentProject = null;
			
			this.CurrentSolution = null; // this will fire the CurrentSolutionChanged event
			SolutionClosed(this, new SolutionEventArgs(solution));
			solution.Dispose();
			return true;
		}
Ejemplo n.º 3
0
 void OnSolutionClosing(object sender, SolutionClosingEventArgs e)
 {
     if (IsDebugging) {
         if (!e.AllowCancel) {
             Stop();
             return;
         }
         string caption = StringParser.Parse("${res:XML.MainMenu.DebugMenu.Stop}");
         string message = StringParser.Parse("${res:MainWindow.Windows.Debug.StopDebugging.Message}");
         string[] buttonLabels = new string[] {
             StringParser.Parse("${res:Global.Yes}"),
             StringParser.Parse("${res:Global.No}")
         };
         int result = MessageService.ShowCustomDialog(caption, message, 0, // yes
         1, // no
         buttonLabels);
         if (result == 0) {
             Stop();
         } else {
             e.Cancel = true;
         }
     }
 }