private void btnSelFile_Click(object sender, EventArgs e) { string path = SimpleDialog.OpenFile(null, "Key Files (*.snk)|*.snk|All Files (*.*)|*.*", ".snk", true, StrongKeyFile); if (!String.IsNullOrEmpty(path)) { txtKeyFile.Text = path; StrongKeyFile = path; } }
public void btnSaveLog_Click(object sender, EventArgs e) { try { using (new SimpleWaitCursor()) { TreeView treeView1 = _form.TreeView; AssemblyDefinition ad = _form.TreeViewHandler.GetCurrentAssembly(); if (ad == null) { SimpleMessage.ShowInfo("Cannot determine current assembly."); return; } string initFileName = String.Empty; for (int i = 0; i < treeView1.Nodes.Count; i++) { if (ad.Equals(treeView1.Nodes[i].Tag)) { initFileName = treeView1.Nodes[i].Text; break; } } initFileName = initFileName + ".log.txt"; string initDir = Config.ClassEditorSaveAsDir; if (!Directory.Exists(initDir)) { initDir = Environment.CurrentDirectory; } string path = SimpleDialog.OpenFile("Save Log", "Text files (*.txt)|*.txt", ".txt", false, initDir, initFileName); if (!String.IsNullOrEmpty(path)) { Config.ClassEditorSaveAsDir = Path.GetDirectoryName(path); } if (String.IsNullOrEmpty(path)) { return; } using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine(txtLog.Text); } } } catch (Exception ex) { SimpleMessage.ShowException(ex); } }
private void btnSelectApp_Click(object sender, EventArgs e) { string initDir = null; if (!String.IsNullOrEmpty(txtApp.Text) && File.Exists(txtApp.Text)) { initDir = Path.GetDirectoryName(txtApp.Text); } string path = SimpleDialog.OpenFile(this.Text, Consts.FilterExeFile, ".exe", true, initDir); if (!String.IsNullOrEmpty(path)) { txtApp.Text = path; } }
private void mnuOpenFile_Click(object sender, EventArgs e) { string initDir = null; if (!String.IsNullOrEmpty(_lastOpenDir)) { initDir = _lastOpenDir; } else { initDir = SourceDir; } string file = SimpleDialog.OpenFile("Open File", Consts.FilterAssemblyFile, "", false, initDir); if (File.Exists(file)) { _lastOpenDir = Path.GetDirectoryName(file); OpenFile(file); } }
private void SaveAssembly() { AssemblyDefinition ad = TreeViewHandler.GetCurrentAssembly(); if (ad == null) { SimpleMessage.ShowInfo("Cannot determine current assembly."); return; } string initDir = null; if (!String.IsNullOrEmpty(_lastSaveDir)) { initDir = _lastSaveDir; } else { initDir = SourceDir; } string initFileName = _lastSaveFileName; string origFileName = Path.GetFileName(ad.MainModule.FullyQualifiedName); if (String.IsNullOrEmpty(initFileName) || !Path.GetFileNameWithoutExtension(initFileName).StartsWith(Path.GetFileNameWithoutExtension(origFileName))) { initFileName = origFileName; } string file = SimpleDialog.OpenFile("Save As", Consts.FilterAssemblyFile, Path.GetExtension(initFileName), false, initDir, initFileName); if (!String.IsNullOrEmpty(file)) { if (File.Exists(file)) { File.Delete(file); } string adPath = Path.GetDirectoryName(ad.MainModule.FullyQualifiedName); bool resolveDirAdded = Host.AddAssemblyResolveDir(adPath); try { ad.Write(file); } finally { if (resolveDirAdded) { Host.RemoveAssemblyResolveDir(adPath); } } _lastSaveDir = Path.GetDirectoryName(file); _lastSaveFileName = Path.GetFileName(file); //Config.LastSaveDir = _lastSaveDir; SimpleMessage.ShowInfo(String.Format("Assembly saved to {0}", file)); if (file.Equals(initFileName, StringComparison.OrdinalIgnoreCase)) { TreeViewHandler.ClearRenamedObjects(); } } }