protected override void ExecuteCore(SelectedItemCollection selection) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = false; dialog.Title = Messages.INSTALL_LICENSE_KEY; dialog.CheckFileExists = true; dialog.CheckPathExists = true; dialog.Filter = string.Format("{0} (*.tslic)|*.tslic|{1} (*.*)|*.*", Messages.XS_LICENSE_FILES, Messages.ALL_FILES); //dialog.ShowHelp = true; //dialog.HelpRequest += new EventHandler(this.dialog_HelpRequest); if ((dialog.ShowDialog(Program.MainWindow) == DialogResult.OK)) { Host hostAncestor = selection.HostAncestor; ApplyLicenseAction action = new ApplyLicenseAction(hostAncestor.Connection, hostAncestor, dialog.FileName); ActionProgressDialog progressDialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee); progressDialog.Text = Messages.INSTALL_LICENSE_KEY; progressDialog.ShowDialog(Program.MainWindow); } }
protected override void RunActions() { // Showing this dialog has the (undocumented) side effect of changing the working directory // to that of the file selected. This means a handle to the directory persists, making // it undeletable until the program exits, or the working dir moves on. So, save and // restore the working dir... string oldDir = String.Empty; try { oldDir = Directory.GetCurrentDirectory(); ApplyLicenseAction action = new ApplyLicenseAction(host.Connection, host, Dialog.FileName, activateFreeLicense); ActionProgressDialog actionProgress = new ActionProgressDialog(action, ProgressBarStyle.Marquee); actionProgress.Text = title; actionProgress.ShowDialog(parent); } finally { Directory.SetCurrentDirectory(oldDir); } }