Skip to content

Instantly share code, notes, and snippets.

@fushnisoft
Created August 11, 2012 18:29
Show Gist options
  • Save fushnisoft/3326211 to your computer and use it in GitHub Desktop.
Save fushnisoft/3326211 to your computer and use it in GitHub Desktop.
Close app view and then delete the app file
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