From 57157318940446bc0f5fa49307cd43d7c16042a8 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 30 Aug 2016 17:54:21 +0200 Subject: [PATCH] Prompt to add if an env var is being edited when the dialog is closed --- .../Dialogs/EnvironmentEditor.Designer.cs | 8 +++-- .../Windows/Dialogs/EnvironmentEditor.cs | 34 +++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/renderdocui/Windows/Dialogs/EnvironmentEditor.Designer.cs b/renderdocui/Windows/Dialogs/EnvironmentEditor.Designer.cs index 0c968da7d..691d476a6 100644 --- a/renderdocui/Windows/Dialogs/EnvironmentEditor.Designer.cs +++ b/renderdocui/Windows/Dialogs/EnvironmentEditor.Designer.cs @@ -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(); diff --git a/renderdocui/Windows/Dialogs/EnvironmentEditor.cs b/renderdocui/Windows/Dialogs/EnvironmentEditor.cs index d079486d0..7714310e9 100644 --- a/renderdocui/Windows/Dialogs/EnvironmentEditor.cs +++ b/renderdocui/Windows/Dialogs/EnvironmentEditor.cs @@ -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(); + } } }