Fixed behavior of FocusedTextBox (special characters and bell).

This commit is contained in:
Lorenz Cuno Klopfenstein 2010-05-26 20:31:03 +02:00
parent b459475cf0
commit d389573363
5 changed files with 308 additions and 269 deletions

View file

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OnTopReplica {
static class EnumerationExtensions {
public static bool Contains<T>(IEnumerable<T> collection, T value){
foreach (var v in collection)
if (v.Equals(value))
return true;
return false;
}
}
}

View file

@ -19,18 +19,48 @@ namespace OnTopReplica {
if (e.KeyCode == Keys.Return) {
OnConfirmInput();
e.Handled = true;
e.SuppressKeyPress = true;
}
else if (e.KeyCode == Keys.Escape) {
OnAbortInput();
e.Handled = true;
e.SuppressKeyPress = true;
}
base.OnKeyUp(e);
Console.WriteLine("{0} ({1})", e.KeyCode, e.KeyValue);
base.OnKeyUp(e);
}
//List of characters to ignore on KeyPress events (because they generate bell rings)
char[] _ignoreChars = new char[] {
(char)27, (char)13
};
protected override void OnKeyPress(KeyPressEventArgs e) {
if (EnumerationExtensions.Contains(_ignoreChars, e.KeyChar)) {
e.Handled = true;
}
base.OnKeyPress(e);
}
public event EventHandler ConfirmInput;
protected virtual void OnConfirmInput() {
if (ConfirmInput != null)
ConfirmInput(this, EventArgs.Empty);
var evt = ConfirmInput;
if (evt != null)
evt(this, EventArgs.Empty);
}
public event EventHandler AbortInput;
protected virtual void OnAbortInput() {
var evt = AbortInput;
if (evt != null)
evt(this, EventArgs.Empty);
}
}
}

View file

@ -105,6 +105,7 @@
</Compile>
<Compile Include="CloneClickEventArgs.cs" />
<Compile Include="CloseRequestEventArgs.cs" />
<Compile Include="EnumerationExtensions.cs" />
<Compile Include="FullscreenMode.cs" />
<Compile Include="Strings.it.Designer.cs">
<DependentUpon>Strings.it.resx</DependentUpon>

View file

@ -23,302 +23,284 @@
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.panel1 = new System.Windows.Forms.Panel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.numH = new System.Windows.Forms.NumericUpDown();
this.numW = new System.Windows.Forms.NumericUpDown();
this.numY = new System.Windows.Forms.NumericUpDown();
this.numX = new System.Windows.Forms.NumericUpDown();
this.buttonDone = new System.Windows.Forms.Button();
this.buttonReset = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.comboBox1 = new VistaControls.ComboBox();
this.textRegionName = new OnTopReplica.FocusedTextBox();
this.panel1.SuspendLayout();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numH)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numW)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numY)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numX)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.Control;
this.panel1.Controls.Add(this.groupBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.panel1.Name = "panel1";
this.panel1.Padding = new System.Windows.Forms.Padding(5, 5, 5, 5);
this.panel1.Size = new System.Drawing.Size(233, 292);
this.panel1.TabIndex = 0;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.textRegionName);
this.groupBox1.Controls.Add(this.numH);
this.groupBox1.Controls.Add(this.numW);
this.groupBox1.Controls.Add(this.numY);
this.groupBox1.Controls.Add(this.numX);
this.groupBox1.Controls.Add(this.buttonDone);
this.groupBox1.Controls.Add(this.buttonReset);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.buttonDelete);
this.groupBox1.Controls.Add(this.buttonSave);
this.groupBox1.Controls.Add(this.comboBox1);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox1.Location = new System.Drawing.Point(5, 5);
this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.groupBox1.Size = new System.Drawing.Size(223, 282);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = Strings.RegionsTitle;
//
// numH
//
this.numH.Enabled = false;
this.numH.Location = new System.Drawing.Point(145, 150);
this.numH.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.numH.Maximum = new decimal(new int[] {
this.panel1 = new System.Windows.Forms.Panel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.numH = new System.Windows.Forms.NumericUpDown();
this.numW = new System.Windows.Forms.NumericUpDown();
this.numY = new System.Windows.Forms.NumericUpDown();
this.numX = new System.Windows.Forms.NumericUpDown();
this.buttonDone = new System.Windows.Forms.Button();
this.buttonReset = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.comboBox1 = new VistaControls.ComboBox();
this.textRegionName = new OnTopReplica.FocusedTextBox();
this.panel1.SuspendLayout();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numH)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numW)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numY)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numX)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.Control;
this.panel1.Controls.Add(this.groupBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.panel1.Size = new System.Drawing.Size(175, 237);
this.panel1.TabIndex = 0;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.textRegionName);
this.groupBox1.Controls.Add(this.numH);
this.groupBox1.Controls.Add(this.numW);
this.groupBox1.Controls.Add(this.numY);
this.groupBox1.Controls.Add(this.numX);
this.groupBox1.Controls.Add(this.buttonDone);
this.groupBox1.Controls.Add(this.buttonReset);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.buttonDelete);
this.groupBox1.Controls.Add(this.buttonSave);
this.groupBox1.Controls.Add(this.comboBox1);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox1.Location = new System.Drawing.Point(4, 4);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(167, 229);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Regions";
//
// numH
//
this.numH.Enabled = false;
this.numH.Location = new System.Drawing.Point(109, 122);
this.numH.Maximum = new decimal(new int[] {
100000,
0,
0,
0});
this.numH.Minimum = new decimal(new int[] {
this.numH.Minimum = new decimal(new int[] {
100000,
0,
0,
-2147483648});
this.numH.Name = "numH";
this.numH.Size = new System.Drawing.Size(57, 22);
this.numH.TabIndex = 7;
this.numH.ValueChanged += new System.EventHandler(this.RegionValueChanged);
//
// numW
//
this.numW.Enabled = false;
this.numW.Location = new System.Drawing.Point(145, 118);
this.numW.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.numW.Maximum = new decimal(new int[] {
this.numH.Name = "numH";
this.numH.Size = new System.Drawing.Size(43, 20);
this.numH.TabIndex = 7;
this.numH.ValueChanged += new System.EventHandler(this.RegionValueChanged);
//
// numW
//
this.numW.Enabled = false;
this.numW.Location = new System.Drawing.Point(109, 96);
this.numW.Maximum = new decimal(new int[] {
100000,
0,
0,
0});
this.numW.Minimum = new decimal(new int[] {
this.numW.Minimum = new decimal(new int[] {
100000,
0,
0,
-2147483648});
this.numW.Name = "numW";
this.numW.Size = new System.Drawing.Size(57, 22);
this.numW.TabIndex = 6;
this.numW.ValueChanged += new System.EventHandler(this.RegionValueChanged);
//
// numY
//
this.numY.Enabled = false;
this.numY.Location = new System.Drawing.Point(31, 150);
this.numY.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.numY.Maximum = new decimal(new int[] {
this.numW.Name = "numW";
this.numW.Size = new System.Drawing.Size(43, 20);
this.numW.TabIndex = 6;
this.numW.ValueChanged += new System.EventHandler(this.RegionValueChanged);
//
// numY
//
this.numY.Enabled = false;
this.numY.Location = new System.Drawing.Point(23, 122);
this.numY.Maximum = new decimal(new int[] {
100000,
0,
0,
0});
this.numY.Minimum = new decimal(new int[] {
this.numY.Minimum = new decimal(new int[] {
100000,
0,
0,
-2147483648});
this.numY.Name = "numY";
this.numY.Size = new System.Drawing.Size(57, 22);
this.numY.TabIndex = 5;
this.numY.ValueChanged += new System.EventHandler(this.RegionValueChanged);
//
// numX
//
this.numX.Enabled = false;
this.numX.Location = new System.Drawing.Point(31, 118);
this.numX.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.numX.Maximum = new decimal(new int[] {
this.numY.Name = "numY";
this.numY.Size = new System.Drawing.Size(43, 20);
this.numY.TabIndex = 5;
this.numY.ValueChanged += new System.EventHandler(this.RegionValueChanged);
//
// numX
//
this.numX.Enabled = false;
this.numX.Location = new System.Drawing.Point(23, 96);
this.numX.Maximum = new decimal(new int[] {
100000,
0,
0,
0});
this.numX.Minimum = new decimal(new int[] {
this.numX.Minimum = new decimal(new int[] {
100000,
0,
0,
-2147483648});
this.numX.Name = "numX";
this.numX.Size = new System.Drawing.Size(57, 22);
this.numX.TabIndex = 4;
this.numX.ValueChanged += new System.EventHandler(this.RegionValueChanged);
//
// buttonDone
//
this.buttonDone.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDone.Location = new System.Drawing.Point(135, 246);
this.buttonDone.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.buttonDone.Name = "buttonDone";
this.buttonDone.Size = new System.Drawing.Size(80, 28);
this.buttonDone.TabIndex = 9;
this.buttonDone.Text = global::OnTopReplica.Strings.RegionsDoneButton;
this.buttonDone.UseVisualStyleBackColor = true;
this.buttonDone.Click += new System.EventHandler(this.CloseClick);
//
// buttonReset
//
this.buttonReset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonReset.Location = new System.Drawing.Point(8, 246);
this.buttonReset.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.buttonReset.Name = "buttonReset";
this.buttonReset.Size = new System.Drawing.Size(80, 28);
this.buttonReset.TabIndex = 8;
this.buttonReset.Text = global::OnTopReplica.Strings.RegionsResetButton;
this.buttonReset.UseVisualStyleBackColor = true;
this.buttonReset.Click += new System.EventHandler(this.ResetClick);
//
// label6
//
this.label6.AutoSize = true;
this.label6.ForeColor = System.Drawing.SystemColors.ControlDark;
this.label6.Location = new System.Drawing.Point(95, 153);
this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(49, 17);
this.label6.TabIndex = 9;
this.label6.Text = Strings.RegionsHeight;
//
// label7
//
this.label7.AutoSize = true;
this.label7.ForeColor = System.Drawing.SystemColors.ControlDark;
this.label7.Location = new System.Drawing.Point(95, 121);
this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(44, 17);
this.label7.TabIndex = 8;
this.label7.Text = Strings.RegionsWidth;
//
// label3
//
this.label3.AutoSize = true;
this.label3.ForeColor = System.Drawing.SystemColors.ControlDark;
this.label3.Location = new System.Drawing.Point(8, 153);
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(17, 17);
this.label3.TabIndex = 5;
this.label3.Text = "Y";
//
// label2
//
this.label2.AutoSize = true;
this.label2.ForeColor = System.Drawing.SystemColors.ControlDark;
this.label2.Location = new System.Drawing.Point(8, 121);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(17, 17);
this.label2.TabIndex = 4;
this.label2.Text = "X";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(8, 94);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(103, 17);
this.label1.TabIndex = 3;
this.label1.Text = Strings.RegionsCurrentRegion;
//
// buttonDelete
//
this.buttonDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDelete.Enabled = false;
this.buttonDelete.Location = new System.Drawing.Point(135, 57);
this.buttonDelete.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(80, 28);
this.buttonDelete.TabIndex = 3;
this.buttonDelete.Text = global::OnTopReplica.Strings.RegionsDeleteButton;
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.DeleteClick);
//
// buttonSave
//
this.buttonSave.Enabled = false;
this.buttonSave.Location = new System.Drawing.Point(8, 57);
this.buttonSave.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(80, 28);
this.buttonSave.TabIndex = 1;
this.buttonSave.Text = global::OnTopReplica.Strings.RegionsSaveButton;
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.SaveClick);
//
// comboBox1
//
this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.comboBox1.CueBannerText = global::OnTopReplica.Strings.RegionsStoredRegions;
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(8, 23);
this.comboBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(206, 24);
this.comboBox1.TabIndex = 0;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.RegionCombo_index);
//
// textRegionName
//
this.textRegionName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textRegionName.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.textRegionName.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.textRegionName.Location = new System.Drawing.Point(8, 59);
this.textRegionName.Margin = new System.Windows.Forms.Padding(4);
this.textRegionName.Name = "textRegionName";
this.textRegionName.Size = new System.Drawing.Size(118, 22);
this.textRegionName.TabIndex = 2;
this.textRegionName.Visible = false;
this.textRegionName.Leave += new System.EventHandler(this.Save_lost);
this.textRegionName.ConfirmInput += new System.EventHandler(this.Save_confirm);
//
// RegionBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Black;
this.Controls.Add(this.panel1);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.MinimumSize = new System.Drawing.Size(213, 222);
this.Name = "RegionBox";
this.Size = new System.Drawing.Size(233, 292);
this.panel1.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numH)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numW)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numY)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numX)).EndInit();
this.ResumeLayout(false);
this.numX.Name = "numX";
this.numX.Size = new System.Drawing.Size(43, 20);
this.numX.TabIndex = 4;
this.numX.ValueChanged += new System.EventHandler(this.RegionValueChanged);
//
// buttonDone
//
this.buttonDone.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDone.Location = new System.Drawing.Point(101, 200);
this.buttonDone.Name = "buttonDone";
this.buttonDone.Size = new System.Drawing.Size(60, 23);
this.buttonDone.TabIndex = 9;
this.buttonDone.Text = global::OnTopReplica.Strings.RegionsDoneButton;
this.buttonDone.UseVisualStyleBackColor = true;
this.buttonDone.Click += new System.EventHandler(this.CloseClick);
//
// buttonReset
//
this.buttonReset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonReset.Location = new System.Drawing.Point(6, 200);
this.buttonReset.Name = "buttonReset";
this.buttonReset.Size = new System.Drawing.Size(60, 23);
this.buttonReset.TabIndex = 8;
this.buttonReset.Text = global::OnTopReplica.Strings.RegionsResetButton;
this.buttonReset.UseVisualStyleBackColor = true;
this.buttonReset.Click += new System.EventHandler(this.ResetClick);
//
// label6
//
this.label6.AutoSize = true;
this.label6.ForeColor = System.Drawing.SystemColors.ControlDark;
this.label6.Location = new System.Drawing.Point(71, 124);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(38, 13);
this.label6.TabIndex = 9;
this.label6.Text = "Height";
//
// label7
//
this.label7.AutoSize = true;
this.label7.ForeColor = System.Drawing.SystemColors.ControlDark;
this.label7.Location = new System.Drawing.Point(71, 98);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(35, 13);
this.label7.TabIndex = 8;
this.label7.Text = "Width";
//
// label3
//
this.label3.AutoSize = true;
this.label3.ForeColor = System.Drawing.SystemColors.ControlDark;
this.label3.Location = new System.Drawing.Point(6, 124);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(14, 13);
this.label3.TabIndex = 5;
this.label3.Text = "Y";
//
// label2
//
this.label2.AutoSize = true;
this.label2.ForeColor = System.Drawing.SystemColors.ControlDark;
this.label2.Location = new System.Drawing.Point(6, 98);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(14, 13);
this.label2.TabIndex = 4;
this.label2.Text = "X";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(6, 76);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(76, 13);
this.label1.TabIndex = 3;
this.label1.Text = "Current region:";
//
// buttonDelete
//
this.buttonDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDelete.Enabled = false;
this.buttonDelete.Location = new System.Drawing.Point(101, 46);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(60, 23);
this.buttonDelete.TabIndex = 3;
this.buttonDelete.Text = global::OnTopReplica.Strings.RegionsDeleteButton;
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.DeleteClick);
//
// buttonSave
//
this.buttonSave.Enabled = false;
this.buttonSave.Location = new System.Drawing.Point(6, 46);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(60, 23);
this.buttonSave.TabIndex = 1;
this.buttonSave.Text = global::OnTopReplica.Strings.RegionsSaveButton;
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.SaveClick);
//
// comboBox1
//
this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.comboBox1.CueBannerText = global::OnTopReplica.Strings.RegionsStoredRegions;
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(6, 19);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(156, 21);
this.comboBox1.TabIndex = 0;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.RegionCombo_index);
//
// textRegionName
//
this.textRegionName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textRegionName.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.textRegionName.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.textRegionName.Location = new System.Drawing.Point(6, 48);
this.textRegionName.Name = "textRegionName";
this.textRegionName.Size = new System.Drawing.Size(90, 20);
this.textRegionName.TabIndex = 2;
this.textRegionName.Visible = false;
this.textRegionName.ConfirmInput += new System.EventHandler(this.Save_confirm);
this.textRegionName.AbortInput += new System.EventHandler(this.Save_lost);
this.textRegionName.Leave += new System.EventHandler(this.Save_lost);
//
// RegionBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Black;
this.Controls.Add(this.panel1);
this.MinimumSize = new System.Drawing.Size(160, 180);
this.Name = "RegionBox";
this.Size = new System.Drawing.Size(175, 237);
this.panel1.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numH)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numW)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numY)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numX)).EndInit();
this.ResumeLayout(false);
}

View file

@ -104,8 +104,15 @@ namespace OnTopReplica {
}
private void DeleteClick(object sender, EventArgs e) {
Settings.Default.SavedRegions.RemoveAt(comboBox1.SelectedIndex);
comboBox1.Items.RemoveAt(comboBox1.SelectedIndex);
if (comboBox1.SelectedIndex < 0)
return;
var origIndex = comboBox1.SelectedIndex;
Settings.Default.SavedRegions.RemoveAt(origIndex);
comboBox1.Items.RemoveAt(origIndex);
if (comboBox1.Items.Count > 0)
comboBox1.SelectedIndex = 0;
}
private void SaveClick(object sender, EventArgs e) {