Created
August 11, 2012 18:29
-
-
Save fushnisoft/3326211 to your computer and use it in GitHub Desktop.
Close app view and then delete the app file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using ICSharpCode.Core; | |
using ICSharpCode.SharpDevelop.Gui; | |
using SoftVelocity.Generator.UI; | |
namespace ClarionAddins | |
{ | |
public class TestForRick : AbstractMenuCommand | |
{ | |
private string _fileToDelete; | |
public override void Run() | |
{ | |
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; | |
if (window != null && | |
window.ActiveViewContent is SoftVelocity.Generator.UI.ApplicationMainWindowControl_ViewContent) | |
{ | |
_fileToDelete = window.ViewContent.FileName; | |
if (MessageService.AskQuestion("Close and delete file?\r\nFile: " + _fileToDelete, "TestForRick")) | |
{ | |
((ApplicationMainWindowControl_ViewContent)window.ActiveViewContent).App.Closed += App_Closed; | |
window.CloseWindow(true); | |
} | |
} | |
} | |
void App_Closed(object sender, SoftVelocity.Generator.ApplicationEventArgs e) | |
{ | |
try | |
{ | |
File.Delete(_fileToDelete); | |
} | |
catch (Exception ex) | |
{ | |
MessageService.ShowMessage("An Exception occurred: " + ex.ToString()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment