Prompt to add if an env var is being edited when the dialog is closed

This commit is contained in:
baldurk
2016-08-30 17:54:21 +02:00
parent 1faf46ddc5
commit 5715731894
2 changed files with 39 additions and 3 deletions
+5 -3
View File
@@ -29,9 +29,9 @@
private void InitializeComponent()
{
System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
TreelistView.TreeListColumn treeListColumn1 = new TreelistView.TreeListColumn("Name", "Name");
TreelistView.TreeListColumn treeListColumn2 = new TreelistView.TreeListColumn("Modification", "Modification");
TreelistView.TreeListColumn treeListColumn3 = new TreelistView.TreeListColumn("Value", "Value");
TreelistView.TreeListColumn treeListColumn1 = ((TreelistView.TreeListColumn)(new TreelistView.TreeListColumn("Name", "Name")));
TreelistView.TreeListColumn treeListColumn2 = ((TreelistView.TreeListColumn)(new TreelistView.TreeListColumn("Modification", "Modification")));
TreelistView.TreeListColumn treeListColumn3 = ((TreelistView.TreeListColumn)(new TreelistView.TreeListColumn("Value", "Value")));
System.Windows.Forms.GroupBox groupBox2;
System.Windows.Forms.Label label2;
System.Windows.Forms.Label label1;
@@ -115,6 +115,7 @@
this.variables.ViewOptions.ShowLine = false;
this.variables.ViewOptions.ShowPlusMinus = false;
this.variables.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.variables_AfterSelect);
this.variables.KeyDown += new System.Windows.Forms.KeyEventHandler(this.variables_KeyDown);
//
// groupBox2
//
@@ -308,6 +309,7 @@
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Capture Environment Editor";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.EnvironmentEditor_FormClosing);
this.Load += new System.EventHandler(this.EnvironmentEditor_Load);
tableLayoutPanel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.variables)).EndInit();
@@ -112,6 +112,10 @@ namespace renderdocui.Windows.Dialogs
variables.Nodes.Remove(variables.SelectedNode);
variables.EndUpdate();
variables.NodesSelection.Clear();
string text = varName.Text;
varName.Text = "";
varName.Text = text;
}
}
@@ -130,6 +134,9 @@ namespace renderdocui.Windows.Dialogs
mod.type = EnvironmentModificationType.Set;
AddModification(mod, false);
varName.Text = "";
varName.Text = mod.variable;
}
public void AddModification(EnvironmentModification mod, bool silent)
@@ -175,5 +182,32 @@ namespace renderdocui.Windows.Dialogs
return ret;
}
}
private void EnvironmentEditor_FormClosing(object sender, FormClosingEventArgs e)
{
int idx = ExistingIndex();
if(idx >= 0)
return;
DialogResult res = MessageBox.Show(
"You did not add the variable modification you were editing. Add it now?",
"Variable not added", MessageBoxButtons.YesNoCancel);
if (res == DialogResult.Yes)
{
addUpdate_Click(addUpdate, new EventArgs());
}
else if (res == DialogResult.Cancel)
{
e.Cancel = true;
}
}
private void variables_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete && delete.Enabled)
delete.PerformClick();
}
}
}