Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Ior/Forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 54 additions & 3 deletions Ior/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,25 @@ private void MainForm_Load(object sender, EventArgs e)
bindHistorySettings();
setUpFileDialogs();
ActiveControl = txtRequestUrl;

// If clone request, do it
string[] args = Environment.GetCommandLineArgs();

for (int aidx = 0; aidx < args.Length; aidx++)
{
if (args[aidx].Equals("-clone"))
{
try
{
string fileName = args[aidx + 1];
openRequestFileFromClone(fileName);
}
catch (Exception ex)
{
MessageBox.Show("Error processing clone request: " + ex.Message);
}
}
}
} catch(Exception ex) { //n.b. exceptions swallowed during main load since gui message pump not started
log.Fatal(ex, "Exception in main, shutting down");
showError("Error", "Unknown error, shutting down: " + Environment.NewLine + Environment.NewLine + ex.ToString());
Expand Down Expand Up @@ -484,7 +503,7 @@ private void aboutToolStripMenuItem_Click(object sender, EventArgs e) {
}
}

private void save(string fileName) {
private void save(string fileName, bool updateLastSaveFileName = true) {
if (fileName == null) {
requestSaveFileDialog.FileName = FilePathFormatter.Format(lastOpenedRequestFilePath, FilePathFormat.Short);
setUpFileDialogs();
Expand All @@ -503,7 +522,9 @@ private void save(string fileName) {

var requestVm = buildRequestViewModel();
requestVm.Save(fileName);
updateLastOpenedRequestFile(fileName);

if (updateLastSaveFileName )
updateLastOpenedRequestFile(fileName);
}

private void updateLastOpenedRequestFile(string fileName) {
Expand Down Expand Up @@ -540,7 +561,7 @@ private void openRequestFile(string fileName) {
requestVm = RequestViewModel.Load(fileName);
} catch(Exception ex) {
log.Warn(ex, "Error opening request file");
showWarning("File Open Error", "Error opening request file");
showWarning("File Open Error", "Error opening request file: " + ex.Message + "\r\n" + ex.StackTrace);
return;
}
bind(ResponseModel.Empty); // clear the response.
Expand Down Expand Up @@ -837,5 +858,35 @@ private void lblLogNotifications_Click(object sender, EventArgs e) {
resetLogStats();
showLogViewer();
}

private void duplicateToolStripMenuItem_Click(object sender, EventArgs e)
{

string tmpFile = Path.GetTempFileName();
save(tmpFile, false);

String args = String.Format("-clone {0}", tmpFile);

var info = new System.Diagnostics.ProcessStartInfo(Application.ExecutablePath, args);
System.Diagnostics.Process.Start(info);
}

private void openRequestFileFromClone(string fileName)
{
RequestViewModel requestVm;
try
{
requestVm = RequestViewModel.Load(fileName);
}
catch
{
showWarning("File Open Error", "Error opening request file");
return;
}
bind(ResponseModel.Empty); // clear the response.
bind(requestVm);

File.Delete(fileName);
}
}
}
3 changes: 3 additions & 0 deletions Ior/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ static void Main()
var args = Environment.GetCommandLineArgs();
var launchFilePath = args.Length >= 2 ? args[1] : null;

// If this is a "clone" request, we don't want to treat it as a normal file
if (launchFilePath != null && launchFilePath.ToLower().Equals("-clone")) launchFilePath = null;

//set default form icon to project exe icon
var defaultIcon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
typeof(Form).GetField("defaultIcon", BindingFlags.NonPublic | BindingFlags.Static).SetValue(null, defaultIcon);
Expand Down