From 8ac9d2b1cb0675b1161c1cb76fdb3136c5ba09d4 Mon Sep 17 00:00:00 2001 From: Hosch250 Date: Tue, 16 Jun 2015 23:39:00 -0500 Subject: [PATCH 1/7] Disable button and close #637 --- RetailCoder.VBE/UI/Settings/ITodoSettingsView.cs | 5 +++++ RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.cs | 6 ++++++ RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs | 5 ++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/RetailCoder.VBE/UI/Settings/ITodoSettingsView.cs b/RetailCoder.VBE/UI/Settings/ITodoSettingsView.cs index 6af4174693..aa57ceea72 100644 --- a/RetailCoder.VBE/UI/Settings/ITodoSettingsView.cs +++ b/RetailCoder.VBE/UI/Settings/ITodoSettingsView.cs @@ -31,6 +31,11 @@ public interface ITodoSettingsView /// bool SaveEnabled { get; set; } + /// + /// Boolean value representing the enables/disabled state of the UI element the user needs to interact with to add a new marker. + /// + bool AddEnabled { get; set; } + /// /// Request to remove the marker at the SelectedIndex. /// diff --git a/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.cs b/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.cs index 61af22e931..b6e5c57f1d 100644 --- a/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.cs +++ b/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.cs @@ -57,6 +57,12 @@ public bool SaveEnabled set { this.saveChangesButton.Enabled = value; } } + public bool AddEnabled + { + get { return addButton.Enabled; } + set { addButton.Enabled = value; } + } + public TodoPriority ActiveMarkerPriority { get { return (TodoPriority)this.priorityComboBox.SelectedIndex; } diff --git a/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs b/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs index 7915e2104c..2cda022175 100644 --- a/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs +++ b/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs @@ -60,7 +60,10 @@ private void AddMarker(object sender, EventArgs e) private void TextChanged(object sender, EventArgs e) { - _view.SaveEnabled = true; + var markerExists = _view.TodoMarkers.Where((t, i) => i != _view.SelectedIndex && t.Text == _view.ActiveMarkerText).Any(); + + _view.SaveEnabled = !markerExists; + _view.AddEnabled = !markerExists; } private void PriorityChanged(object sender, EventArgs e) From bda0cf11ae55136099f77f72d29d2cf38f7e978d Mon Sep 17 00:00:00 2001 From: Hosch250 Date: Wed, 17 Jun 2015 00:05:48 -0500 Subject: [PATCH 2/7] Better disabling --- .../TodoListSettingsUserControl.Designer.cs | 69 +++++++++++++------ .../Settings/TodoListSettingsUserControl.cs | 3 + .../UI/Settings/TodoSettingPresenter.cs | 13 ++-- RubberduckTests/Mocks/MockTodoSettingsView.cs | 1 + 4 files changed, 60 insertions(+), 26 deletions(-) diff --git a/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.Designer.cs b/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.Designer.cs index a26a501006..a99f0fdf05 100644 --- a/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.Designer.cs +++ b/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.Designer.cs @@ -40,6 +40,8 @@ private void InitializeComponent() this.saveChangesButton = new System.Windows.Forms.Button(); this.removeButton = new System.Windows.Forms.Button(); this.tokenListLabel = new System.Windows.Forms.Label(); + this.InvalidNameValidationIcon = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.InvalidNameValidationIcon)).BeginInit(); this.SuspendLayout(); // // tokenListBox @@ -47,52 +49,59 @@ private void InitializeComponent() this.tokenListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.tokenListBox.FormattingEnabled = true; - this.tokenListBox.Location = new System.Drawing.Point(12, 26); + this.tokenListBox.ItemHeight = 16; + this.tokenListBox.Location = new System.Drawing.Point(16, 32); + this.tokenListBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.tokenListBox.Name = "tokenListBox"; - this.tokenListBox.Size = new System.Drawing.Size(134, 238); + this.tokenListBox.Size = new System.Drawing.Size(177, 292); this.tokenListBox.TabIndex = 0; this.tokenListBox.SelectedIndexChanged += new System.EventHandler(this.tokenListBox_SelectedIndexChanged); // // tokenTextBox // - this.tokenTextBox.Location = new System.Drawing.Point(152, 100); + this.tokenTextBox.Location = new System.Drawing.Point(203, 123); + this.tokenTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.tokenTextBox.Name = "tokenTextBox"; - this.tokenTextBox.Size = new System.Drawing.Size(152, 20); + this.tokenTextBox.Size = new System.Drawing.Size(201, 22); this.tokenTextBox.TabIndex = 1; this.tokenTextBox.TextChanged += new System.EventHandler(this.tokenTextBox_TextChanged); // // priorityComboBox // this.priorityComboBox.FormattingEnabled = true; - this.priorityComboBox.Location = new System.Drawing.Point(152, 42); + this.priorityComboBox.Location = new System.Drawing.Point(203, 52); + this.priorityComboBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.priorityComboBox.Name = "priorityComboBox"; - this.priorityComboBox.Size = new System.Drawing.Size(152, 21); + this.priorityComboBox.Size = new System.Drawing.Size(201, 24); this.priorityComboBox.TabIndex = 2; this.priorityComboBox.SelectedIndexChanged += new System.EventHandler(this.priorityComboBox_SelectedIndexChanged); // // priorityLabel // this.priorityLabel.AutoSize = true; - this.priorityLabel.Location = new System.Drawing.Point(149, 25); + this.priorityLabel.Location = new System.Drawing.Point(199, 31); + this.priorityLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.priorityLabel.Name = "priorityLabel"; - this.priorityLabel.Size = new System.Drawing.Size(41, 13); + this.priorityLabel.Size = new System.Drawing.Size(56, 17); this.priorityLabel.TabIndex = 3; this.priorityLabel.Text = "Priority:"; // // tokenLabel // this.tokenLabel.AutoSize = true; - this.tokenLabel.Location = new System.Drawing.Point(149, 83); + this.tokenLabel.Location = new System.Drawing.Point(199, 102); + this.tokenLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.tokenLabel.Name = "tokenLabel"; - this.tokenLabel.Size = new System.Drawing.Size(68, 13); + this.tokenLabel.Size = new System.Drawing.Size(87, 17); this.tokenLabel.TabIndex = 4; this.tokenLabel.Text = "Token Text: "; // // addButton // - this.addButton.Location = new System.Drawing.Point(152, 145); + this.addButton.Location = new System.Drawing.Point(203, 178); + this.addButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.addButton.Name = "addButton"; - this.addButton.Size = new System.Drawing.Size(152, 31); + this.addButton.Size = new System.Drawing.Size(203, 38); this.addButton.TabIndex = 5; this.addButton.Text = "Add"; this.addButton.UseVisualStyleBackColor = true; @@ -100,9 +109,10 @@ private void InitializeComponent() // // saveChangesButton // - this.saveChangesButton.Location = new System.Drawing.Point(152, 189); + this.saveChangesButton.Location = new System.Drawing.Point(203, 233); + this.saveChangesButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.saveChangesButton.Name = "saveChangesButton"; - this.saveChangesButton.Size = new System.Drawing.Size(152, 31); + this.saveChangesButton.Size = new System.Drawing.Size(203, 38); this.saveChangesButton.TabIndex = 6; this.saveChangesButton.Text = "Change"; this.saveChangesButton.UseVisualStyleBackColor = true; @@ -110,9 +120,10 @@ private void InitializeComponent() // // removeButton // - this.removeButton.Location = new System.Drawing.Point(152, 235); + this.removeButton.Location = new System.Drawing.Point(203, 289); + this.removeButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.removeButton.Name = "removeButton"; - this.removeButton.Size = new System.Drawing.Size(152, 31); + this.removeButton.Size = new System.Drawing.Size(203, 38); this.removeButton.TabIndex = 7; this.removeButton.Text = "Remove"; this.removeButton.UseVisualStyleBackColor = true; @@ -121,16 +132,29 @@ private void InitializeComponent() // tokenListLabel // this.tokenListLabel.AutoSize = true; - this.tokenListLabel.Location = new System.Drawing.Point(12, 4); + this.tokenListLabel.Location = new System.Drawing.Point(16, 5); + this.tokenListLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.tokenListLabel.Name = "tokenListLabel"; - this.tokenListLabel.Size = new System.Drawing.Size(60, 13); + this.tokenListLabel.Size = new System.Drawing.Size(78, 17); this.tokenListLabel.TabIndex = 8; this.tokenListLabel.Text = "Token List:"; // + // InvalidNameValidationIcon + // + this.InvalidNameValidationIcon.Image = global::Rubberduck.Properties.Resources.cross_circle; + this.InvalidNameValidationIcon.Location = new System.Drawing.Point(395, 115); + this.InvalidNameValidationIcon.Margin = new System.Windows.Forms.Padding(4); + this.InvalidNameValidationIcon.Name = "InvalidNameValidationIcon"; + this.InvalidNameValidationIcon.Size = new System.Drawing.Size(16, 16); + this.InvalidNameValidationIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.InvalidNameValidationIcon.TabIndex = 14; + this.InvalidNameValidationIcon.TabStop = false; + // // TodoListSettingsUserControl // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.InvalidNameValidationIcon); this.Controls.Add(this.tokenListLabel); this.Controls.Add(this.removeButton); this.Controls.Add(this.saveChangesButton); @@ -140,9 +164,11 @@ private void InitializeComponent() this.Controls.Add(this.priorityComboBox); this.Controls.Add(this.tokenTextBox); this.Controls.Add(this.tokenListBox); - this.MinimumSize = new System.Drawing.Size(314, 294); + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.MinimumSize = new System.Drawing.Size(419, 362); this.Name = "TodoListSettingsUserControl"; - this.Size = new System.Drawing.Size(314, 294); + this.Size = new System.Drawing.Size(419, 362); + ((System.ComponentModel.ISupportInitialize)(this.InvalidNameValidationIcon)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -159,5 +185,6 @@ private void InitializeComponent() private Button saveChangesButton; private Button removeButton; private Label tokenListLabel; + private PictureBox InvalidNameValidationIcon; } } diff --git a/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.cs b/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.cs index b6e5c57f1d..bef0e2c85b 100644 --- a/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.cs +++ b/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.cs @@ -20,6 +20,9 @@ public TodoListSettingsUserControl() private void InitControl() { + AddEnabled = false; + SaveEnabled = false; + tokenListLabel.Text = RubberduckUI.TodoSettings_TokenListLabel; priorityLabel.Text = RubberduckUI.TodoSettings_PriorityLabel; tokenLabel.Text = RubberduckUI.TodoSettings_TokenLabel; diff --git a/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs b/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs index 2cda022175..880d58111c 100644 --- a/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs +++ b/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs @@ -58,17 +58,20 @@ private void AddMarker(object sender, EventArgs e) _view.SelectedIndex = _view.TodoMarkers.Count - 1; } - private void TextChanged(object sender, EventArgs e) + private void UpdateButtonsClickability() { - var markerExists = _view.TodoMarkers.Where((t, i) => i != _view.SelectedIndex && t.Text == _view.ActiveMarkerText).Any(); + _view.SaveEnabled = _view.ActiveMarkerText != ActiveMarker.Text || _view.ActiveMarkerPriority != ActiveMarker.Priority; + _view.AddEnabled = _view.TodoMarkers.All(t => t.Text != _view.ActiveMarkerText); + } - _view.SaveEnabled = !markerExists; - _view.AddEnabled = !markerExists; + private void TextChanged(object sender, EventArgs e) + { + UpdateButtonsClickability(); } private void PriorityChanged(object sender, EventArgs e) { - _view.SaveEnabled = true; + UpdateButtonsClickability(); } private void SelectionChanged(object sender, EventArgs e) diff --git a/RubberduckTests/Mocks/MockTodoSettingsView.cs b/RubberduckTests/Mocks/MockTodoSettingsView.cs index ca1c78f458..c74fb0a3a5 100644 --- a/RubberduckTests/Mocks/MockTodoSettingsView.cs +++ b/RubberduckTests/Mocks/MockTodoSettingsView.cs @@ -9,6 +9,7 @@ namespace RubberduckTests.Mocks class MockTodoSettingsView : ITodoSettingsView { public bool SaveEnabled { get; set; } + public bool AddEnabled { get; set; } private TodoPriority activeMarkerPriority; public TodoPriority ActiveMarkerPriority From 363fcd3308e96f6be2b40628f0be15bcc87d50b9 Mon Sep 17 00:00:00 2001 From: Hosch250 Date: Wed, 17 Jun 2015 15:18:47 -0500 Subject: [PATCH 3/7] Everything is working except the Add button --- .../Settings/ConfigurationLoader.cs | 2 +- RetailCoder.VBE/Settings/ToDoMarkers.cs | 23 +- .../UI/Settings/ITodoSettingsView.cs | 22 +- .../TodoListSettingsUserControl.Designer.cs | 200 ++++++------------ .../Settings/TodoListSettingsUserControl.cs | 96 ++++----- .../Settings/TodoListSettingsUserControl.resx | 3 + .../UI/Settings/TodoSettingPresenter.cs | 36 +--- 7 files changed, 128 insertions(+), 254 deletions(-) diff --git a/RetailCoder.VBE/Settings/ConfigurationLoader.cs b/RetailCoder.VBE/Settings/ConfigurationLoader.cs index 132299aa21..78b23ca816 100644 --- a/RetailCoder.VBE/Settings/ConfigurationLoader.cs +++ b/RetailCoder.VBE/Settings/ConfigurationLoader.cs @@ -113,7 +113,7 @@ public Configuration GetDefaultConfiguration() public ToDoMarker[] GetDefaultTodoMarkers() { var note = new ToDoMarker(RubberduckUI.ToDoMarkerNote, TodoPriority.Low); - var todo = new ToDoMarker(RubberduckUI.ToDoMarkerToDo, TodoPriority.Normal); + var todo = new ToDoMarker(RubberduckUI.ToDoMarkerToDo, TodoPriority.Medium); var bug = new ToDoMarker(RubberduckUI.ToDoMarkerBug, TodoPriority.High); return new[] { note, todo, bug }; diff --git a/RetailCoder.VBE/Settings/ToDoMarkers.cs b/RetailCoder.VBE/Settings/ToDoMarkers.cs index 13df11b018..b4767d542a 100644 --- a/RetailCoder.VBE/Settings/ToDoMarkers.cs +++ b/RetailCoder.VBE/Settings/ToDoMarkers.cs @@ -1,11 +1,13 @@ -using System.Xml.Serialization; +using System; +using System.Xml.Serialization; +using Rubberduck.UI; namespace Rubberduck.Settings { public enum TodoPriority { Low, - Normal, + Medium, High } @@ -25,6 +27,23 @@ public class ToDoMarker : IToDoMarker [XmlAttribute] public TodoPriority Priority { get; set; } + [XmlIgnore] + public string PriorityLabel + { + get { return RubberduckUI.ResourceManager.GetString("ToDoPriority_" + Priority, RubberduckUI.Culture); } + set + { + foreach (var priority in Enum.GetValues(typeof(TodoPriority))) + { + if (value == RubberduckUI.ResourceManager.GetString("ToDoPriority_" + priority, RubberduckUI.Culture)) + { + Priority = (TodoPriority)priority; + return; + } + } + } + } + /// Default constructor is required for serialization. DO NOT USE. public ToDoMarker() { diff --git a/RetailCoder.VBE/UI/Settings/ITodoSettingsView.cs b/RetailCoder.VBE/UI/Settings/ITodoSettingsView.cs index aa57ceea72..dd0eaa9531 100644 --- a/RetailCoder.VBE/UI/Settings/ITodoSettingsView.cs +++ b/RetailCoder.VBE/UI/Settings/ITodoSettingsView.cs @@ -26,16 +26,6 @@ public interface ITodoSettingsView /// int SelectedIndex { get; set; } - /// - /// Boolean value representing the enables/disabled state of the UI element the user needs to interact with to save the currently active marker. - /// - bool SaveEnabled { get; set; } - - /// - /// Boolean value representing the enables/disabled state of the UI element the user needs to interact with to add a new marker. - /// - bool AddEnabled { get; set; } - /// /// Request to remove the marker at the SelectedIndex. /// @@ -45,17 +35,7 @@ public interface ITodoSettingsView /// Request to add the currently active marker to BindingList{TodoMarker}. /// event EventHandler AddMarker; - - /// - /// Request to save changes made to the currently active marker back to the marker at the SelectedIndex. - /// - event EventHandler SaveMarker; - - /// - /// Raised whenever SelectedIndex is changed. - /// - event EventHandler SelectionChanged; - + /// /// Raised whenever ActiveMarkerText is changed. /// diff --git a/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.Designer.cs b/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.Designer.cs index a99f0fdf05..a95859d3a0 100644 --- a/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.Designer.cs +++ b/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.Designer.cs @@ -31,144 +31,73 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.tokenListBox = new System.Windows.Forms.ListBox(); - this.tokenTextBox = new System.Windows.Forms.TextBox(); - this.priorityComboBox = new System.Windows.Forms.ComboBox(); - this.priorityLabel = new System.Windows.Forms.Label(); - this.tokenLabel = new System.Windows.Forms.Label(); - this.addButton = new System.Windows.Forms.Button(); - this.saveChangesButton = new System.Windows.Forms.Button(); - this.removeButton = new System.Windows.Forms.Button(); - this.tokenListLabel = new System.Windows.Forms.Label(); - this.InvalidNameValidationIcon = new System.Windows.Forms.PictureBox(); - ((System.ComponentModel.ISupportInitialize)(this.InvalidNameValidationIcon)).BeginInit(); + this.toolStrip1 = new System.Windows.Forms.ToolStrip(); + this.AddButton = new System.Windows.Forms.ToolStripButton(); + this.RemoveButton = new System.Windows.Forms.ToolStripButton(); + this.TodoMarkersGridView = new System.Windows.Forms.DataGridView(); + this.toolStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.TodoMarkersGridView)).BeginInit(); this.SuspendLayout(); // - // tokenListBox - // - this.tokenListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.tokenListBox.FormattingEnabled = true; - this.tokenListBox.ItemHeight = 16; - this.tokenListBox.Location = new System.Drawing.Point(16, 32); - this.tokenListBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.tokenListBox.Name = "tokenListBox"; - this.tokenListBox.Size = new System.Drawing.Size(177, 292); - this.tokenListBox.TabIndex = 0; - this.tokenListBox.SelectedIndexChanged += new System.EventHandler(this.tokenListBox_SelectedIndexChanged); - // - // tokenTextBox - // - this.tokenTextBox.Location = new System.Drawing.Point(203, 123); - this.tokenTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.tokenTextBox.Name = "tokenTextBox"; - this.tokenTextBox.Size = new System.Drawing.Size(201, 22); - this.tokenTextBox.TabIndex = 1; - this.tokenTextBox.TextChanged += new System.EventHandler(this.tokenTextBox_TextChanged); - // - // priorityComboBox - // - this.priorityComboBox.FormattingEnabled = true; - this.priorityComboBox.Location = new System.Drawing.Point(203, 52); - this.priorityComboBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.priorityComboBox.Name = "priorityComboBox"; - this.priorityComboBox.Size = new System.Drawing.Size(201, 24); - this.priorityComboBox.TabIndex = 2; - this.priorityComboBox.SelectedIndexChanged += new System.EventHandler(this.priorityComboBox_SelectedIndexChanged); - // - // priorityLabel - // - this.priorityLabel.AutoSize = true; - this.priorityLabel.Location = new System.Drawing.Point(199, 31); - this.priorityLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.priorityLabel.Name = "priorityLabel"; - this.priorityLabel.Size = new System.Drawing.Size(56, 17); - this.priorityLabel.TabIndex = 3; - this.priorityLabel.Text = "Priority:"; - // - // tokenLabel - // - this.tokenLabel.AutoSize = true; - this.tokenLabel.Location = new System.Drawing.Point(199, 102); - this.tokenLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.tokenLabel.Name = "tokenLabel"; - this.tokenLabel.Size = new System.Drawing.Size(87, 17); - this.tokenLabel.TabIndex = 4; - this.tokenLabel.Text = "Token Text: "; - // - // addButton - // - this.addButton.Location = new System.Drawing.Point(203, 178); - this.addButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.addButton.Name = "addButton"; - this.addButton.Size = new System.Drawing.Size(203, 38); - this.addButton.TabIndex = 5; - this.addButton.Text = "Add"; - this.addButton.UseVisualStyleBackColor = true; - this.addButton.Click += new System.EventHandler(this.addButton_Click); - // - // saveChangesButton - // - this.saveChangesButton.Location = new System.Drawing.Point(203, 233); - this.saveChangesButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.saveChangesButton.Name = "saveChangesButton"; - this.saveChangesButton.Size = new System.Drawing.Size(203, 38); - this.saveChangesButton.TabIndex = 6; - this.saveChangesButton.Text = "Change"; - this.saveChangesButton.UseVisualStyleBackColor = true; - this.saveChangesButton.Click += new System.EventHandler(this.saveChangesButton_Click); - // - // removeButton - // - this.removeButton.Location = new System.Drawing.Point(203, 289); - this.removeButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.removeButton.Name = "removeButton"; - this.removeButton.Size = new System.Drawing.Size(203, 38); - this.removeButton.TabIndex = 7; - this.removeButton.Text = "Remove"; - this.removeButton.UseVisualStyleBackColor = true; - this.removeButton.Click += new System.EventHandler(this.removeButton_Click); - // - // tokenListLabel - // - this.tokenListLabel.AutoSize = true; - this.tokenListLabel.Location = new System.Drawing.Point(16, 5); - this.tokenListLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.tokenListLabel.Name = "tokenListLabel"; - this.tokenListLabel.Size = new System.Drawing.Size(78, 17); - this.tokenListLabel.TabIndex = 8; - this.tokenListLabel.Text = "Token List:"; - // - // InvalidNameValidationIcon - // - this.InvalidNameValidationIcon.Image = global::Rubberduck.Properties.Resources.cross_circle; - this.InvalidNameValidationIcon.Location = new System.Drawing.Point(395, 115); - this.InvalidNameValidationIcon.Margin = new System.Windows.Forms.Padding(4); - this.InvalidNameValidationIcon.Name = "InvalidNameValidationIcon"; - this.InvalidNameValidationIcon.Size = new System.Drawing.Size(16, 16); - this.InvalidNameValidationIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.InvalidNameValidationIcon.TabIndex = 14; - this.InvalidNameValidationIcon.TabStop = false; + // toolStrip1 + // + this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; + this.toolStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); + this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.AddButton, + this.RemoveButton}); + this.toolStrip1.Location = new System.Drawing.Point(0, 0); + this.toolStrip1.Name = "toolStrip1"; + this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; + this.toolStrip1.Size = new System.Drawing.Size(419, 27); + this.toolStrip1.TabIndex = 0; + this.toolStrip1.Text = "toolStrip1"; + // + // AddButton + // + this.AddButton.Image = global::Rubberduck.Properties.Resources.plus_circle; + this.AddButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.AddButton.Name = "AddButton"; + this.AddButton.Size = new System.Drawing.Size(61, 24); + this.AddButton.Text = "Add"; + this.AddButton.ToolTipText = "Add todo marker"; + this.AddButton.Click += new System.EventHandler(this.addButton_Click); + // + // RemoveButton + // + this.RemoveButton.Image = global::Rubberduck.Properties.Resources.minus_circle; + this.RemoveButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.RemoveButton.Margin = new System.Windows.Forms.Padding(5, 1, 0, 2); + this.RemoveButton.Name = "RemoveButton"; + this.RemoveButton.Size = new System.Drawing.Size(87, 24); + this.RemoveButton.Text = "Remove"; + this.RemoveButton.ToolTipText = "Remove todo marker"; + this.RemoveButton.Click += new System.EventHandler(this.removeButton_Click); + // + // TodoMarkersGridView + // + this.TodoMarkersGridView.AllowUserToAddRows = false; + this.TodoMarkersGridView.AllowUserToDeleteRows = false; + this.TodoMarkersGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.TodoMarkersGridView.Location = new System.Drawing.Point(0, 28); + this.TodoMarkersGridView.Name = "TodoMarkersGridView"; + this.TodoMarkersGridView.RowTemplate.Height = 24; + this.TodoMarkersGridView.Size = new System.Drawing.Size(419, 331); + this.TodoMarkersGridView.TabIndex = 1; // // TodoListSettingsUserControl // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.InvalidNameValidationIcon); - this.Controls.Add(this.tokenListLabel); - this.Controls.Add(this.removeButton); - this.Controls.Add(this.saveChangesButton); - this.Controls.Add(this.addButton); - this.Controls.Add(this.tokenLabel); - this.Controls.Add(this.priorityLabel); - this.Controls.Add(this.priorityComboBox); - this.Controls.Add(this.tokenTextBox); - this.Controls.Add(this.tokenListBox); - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.Controls.Add(this.TodoMarkersGridView); + this.Controls.Add(this.toolStrip1); + this.Margin = new System.Windows.Forms.Padding(4); this.MinimumSize = new System.Drawing.Size(419, 362); this.Name = "TodoListSettingsUserControl"; this.Size = new System.Drawing.Size(419, 362); - ((System.ComponentModel.ISupportInitialize)(this.InvalidNameValidationIcon)).EndInit(); + this.toolStrip1.ResumeLayout(false); + this.toolStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.TodoMarkersGridView)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -176,15 +105,10 @@ private void InitializeComponent() #endregion - private ListBox tokenListBox; - private TextBox tokenTextBox; - private ComboBox priorityComboBox; - private Label priorityLabel; - private Label tokenLabel; - private Button addButton; - private Button saveChangesButton; - private Button removeButton; - private Label tokenListLabel; - private PictureBox InvalidNameValidationIcon; + private ToolStrip toolStrip1; + private DataGridView TodoMarkersGridView; + private ToolStripButton AddButton; + private ToolStripButton RemoveButton; + } } diff --git a/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.cs b/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.cs index bef0e2c85b..7d5b5556c2 100644 --- a/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.cs +++ b/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Drawing; using System.Linq; using System.Windows.Forms; using Rubberduck.Settings; @@ -14,35 +15,46 @@ public partial class TodoListSettingsUserControl : UserControl, ITodoSettingsVie public TodoListSettingsUserControl() { InitializeComponent(); + } - InitControl(); + public TodoListSettingsUserControl(IList markers) + : this() + { + InitTodoMarkersGridView(markers); } - private void InitControl() + private void InitTodoMarkersGridView(IList markers) { - AddEnabled = false; - SaveEnabled = false; + TodoMarkersGridView.AutoGenerateColumns = false; + TodoMarkersGridView.Columns.Clear(); + TodoMarkersGridView.DataSource = new BindingList(markers); + TodoMarkersGridView.AlternatingRowsDefaultCellStyle.BackColor = Color.Lavender; + TodoMarkersGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + TodoMarkersGridView.CellValueChanged += SelectedPriorityChanged; - tokenListLabel.Text = RubberduckUI.TodoSettings_TokenListLabel; - priorityLabel.Text = RubberduckUI.TodoSettings_PriorityLabel; - tokenLabel.Text = RubberduckUI.TodoSettings_TokenLabel; + var markerTextColumn = new DataGridViewTextBoxColumn + { + Name = "Text", + DataPropertyName = "Text", + HeaderText = "Text", + ReadOnly = true + }; - addButton.Text = RubberduckUI.Add; - saveChangesButton.Text = RubberduckUI.Change; - removeButton.Text = RubberduckUI.Remove; - } + var markerPriorityColumn = new DataGridViewComboBoxColumn + { + Name = "Priority", + DataSource = TodoLabels(), + AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, + HeaderText = "Priority", + DataPropertyName = "PriorityLabel", + }; - public TodoListSettingsUserControl(IList markers) - : this() - { - this.tokenListBox.DataSource = new BindingList(markers); - this.tokenListBox.SelectedIndex = 0; - this.priorityComboBox.DataSource = TodoLabels(); + TodoMarkersGridView.Columns.AddRange(markerTextColumn, markerPriorityColumn); } private List TodoLabels() { - return (from object priority in Enum.GetValues(typeof(TaskPriority)) + return (from object priority in Enum.GetValues(typeof(TodoPriority)) select RubberduckUI.ResourceManager.GetString("ToDoPriority_" + priority, RubberduckUI.Culture)) .ToList(); @@ -50,60 +62,30 @@ private List TodoLabels() public int SelectedIndex { - get { return this.tokenListBox.SelectedIndex; } - set { this.tokenListBox.SelectedIndex = value; } - } - - public bool SaveEnabled - { - get { return this.saveChangesButton.Enabled; } - set { this.saveChangesButton.Enabled = value; } - } - - public bool AddEnabled - { - get { return addButton.Enabled; } - set { addButton.Enabled = value; } + get { return TodoMarkersGridView.SelectedRows[0].Index; } + set { TodoMarkersGridView.Rows[value].Selected = true; } } public TodoPriority ActiveMarkerPriority { - get { return (TodoPriority)this.priorityComboBox.SelectedIndex; } - set { this.priorityComboBox.SelectedIndex = (int)value; } + get { return TodoMarkers[SelectedIndex].Priority; } + set { TodoMarkersGridView.SelectedRows[0].Cells[1].Value = (int)value; } } public string ActiveMarkerText { - get { return this.tokenTextBox.Text; } - set { this.tokenTextBox.Text = value; } + get { return TodoMarkers[SelectedIndex].Text; } + set { TodoMarkersGridView.SelectedRows[0].Cells[0].Value = value; } } public BindingList TodoMarkers { - get { return (BindingList)this.tokenListBox.DataSource; } - set { this.tokenListBox.DataSource = value; } - } - - public event EventHandler SelectionChanged; - private void tokenListBox_SelectedIndexChanged(object sender, EventArgs e) - { - RaiseEvent(this, e, SelectionChanged); - } - - public event EventHandler SaveMarker; - private void saveChangesButton_Click(object sender, EventArgs e) - { - RaiseEvent(this, e, SaveMarker); - } - - public event EventHandler TextChanged; - private void tokenTextBox_TextChanged(object sender, EventArgs e) - { - RaiseEvent(this, e, TextChanged); + get { return (BindingList)TodoMarkersGridView.DataSource; } + set { TodoMarkersGridView.DataSource = value; } } public event EventHandler PriorityChanged; - private void priorityComboBox_SelectedIndexChanged(object sender, EventArgs e) + private void SelectedPriorityChanged(object sender, DataGridViewCellEventArgs e) { RaiseEvent(this, e, PriorityChanged); } diff --git a/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.resx b/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.resx index 1af7de150c..5da7a24dcf 100644 --- a/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.resx +++ b/RetailCoder.VBE/UI/Settings/TodoListSettingsUserControl.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs b/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs index 880d58111c..13e804707a 100644 --- a/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs +++ b/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs @@ -18,25 +18,15 @@ public TodoSettingPresenter(ITodoSettingsView view) { _view = view; - if (_view.TodoMarkers != null) - { - _view.ActiveMarkerText = _view.TodoMarkers[0].Text; - _view.ActiveMarkerPriority = _view.TodoMarkers[0].Priority; - } - - _view.SelectionChanged += SelectionChanged; - _view.TextChanged += TextChanged; _view.AddMarker += AddMarker; _view.RemoveMarker += RemoveMarker; - _view.SaveMarker += SaveMarker; - _view.PriorityChanged += PriorityChanged; + _view.PriorityChanged += SaveMarker; } private void SaveMarker(object sender, EventArgs e) { //todo: add test; How? I can't click the save button. Code smell here. var index = _view.SelectedIndex; - _view.TodoMarkers[index].Text = _view.ActiveMarkerText; _view.TodoMarkers[index].Priority = _view.ActiveMarkerPriority; } @@ -58,30 +48,6 @@ private void AddMarker(object sender, EventArgs e) _view.SelectedIndex = _view.TodoMarkers.Count - 1; } - private void UpdateButtonsClickability() - { - _view.SaveEnabled = _view.ActiveMarkerText != ActiveMarker.Text || _view.ActiveMarkerPriority != ActiveMarker.Priority; - _view.AddEnabled = _view.TodoMarkers.All(t => t.Text != _view.ActiveMarkerText); - } - - private void TextChanged(object sender, EventArgs e) - { - UpdateButtonsClickability(); - } - - private void PriorityChanged(object sender, EventArgs e) - { - UpdateButtonsClickability(); - } - - private void SelectionChanged(object sender, EventArgs e) - { - _view.ActiveMarkerPriority = this.ActiveMarker.Priority; - _view.ActiveMarkerText = this.ActiveMarker.Text; - - _view.SaveEnabled = false; - } - public void SetActiveItem(int index) { _view.SelectedIndex = index; From d4f5e1a1d0c2e07f098a3ca92037549ce580aa0d Mon Sep 17 00:00:00 2001 From: Hosch250 Date: Wed, 17 Jun 2015 16:03:00 -0500 Subject: [PATCH 4/7] Got popup working --- RetailCoder.VBE/Rubberduck.csproj | 11 ++ .../UI/Settings/AddMarkerForm.Designer.cs | 158 ++++++++++++++++++ RetailCoder.VBE/UI/Settings/AddMarkerForm.cs | 65 +++++++ .../UI/Settings/AddMarkerFormPresenter.cs | 22 +++ .../UI/Settings/IAddTodoSettingsView.cs | 43 +++++ .../UI/Settings/ITodoSettingsView.cs | 5 - .../UI/Settings/SettingsDialog.Designer.cs | 50 +++--- RetailCoder.VBE/UI/Settings/SettingsDialog.cs | 2 +- .../UI/Settings/SettingsDialog.resx | 22 --- .../UI/Settings/TodoSettingPresenter.cs | 28 +++- .../DeleteBranchForm.Designer.cs | 2 + .../UI/SourceControl/DeleteBranchForm.resx | 22 +++ 12 files changed, 375 insertions(+), 55 deletions(-) create mode 100644 RetailCoder.VBE/UI/Settings/AddMarkerForm.Designer.cs create mode 100644 RetailCoder.VBE/UI/Settings/AddMarkerForm.cs create mode 100644 RetailCoder.VBE/UI/Settings/AddMarkerFormPresenter.cs create mode 100644 RetailCoder.VBE/UI/Settings/IAddTodoSettingsView.cs diff --git a/RetailCoder.VBE/Rubberduck.csproj b/RetailCoder.VBE/Rubberduck.csproj index 039a7bb36d..f51d5bcde4 100644 --- a/RetailCoder.VBE/Rubberduck.csproj +++ b/RetailCoder.VBE/Rubberduck.csproj @@ -283,6 +283,14 @@ + + Form + + + AddMarkerForm.cs + + + @@ -591,6 +599,9 @@ FindSymbolDialog.cs + + AddMarkerForm.cs + SimpleListControl.cs diff --git a/RetailCoder.VBE/UI/Settings/AddMarkerForm.Designer.cs b/RetailCoder.VBE/UI/Settings/AddMarkerForm.Designer.cs new file mode 100644 index 0000000000..49b97e4180 --- /dev/null +++ b/RetailCoder.VBE/UI/Settings/AddMarkerForm.Designer.cs @@ -0,0 +1,158 @@ +namespace Rubberduck.UI.Settings +{ + partial class AddMarkerForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddMarkerForm)); + this.TodoMarkerPriorityComboBox = new System.Windows.Forms.ComboBox(); + this.TodoMarkerTextBox = new System.Windows.Forms.TextBox(); + this.TodoMarkerTextBoxLabel = new System.Windows.Forms.Label(); + this.TodoMarkerPriorityComboBoxLabel = new System.Windows.Forms.Label(); + this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel(); + this.CancelButton = new System.Windows.Forms.Button(); + this.OkButton = new System.Windows.Forms.Button(); + this.InvalidNameValidationIcon = new System.Windows.Forms.PictureBox(); + this.flowLayoutPanel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.InvalidNameValidationIcon)).BeginInit(); + this.SuspendLayout(); + // + // TodoMarkerPriorityComboBox + // + this.TodoMarkerPriorityComboBox.FormattingEnabled = true; + this.TodoMarkerPriorityComboBox.Location = new System.Drawing.Point(12, 88); + this.TodoMarkerPriorityComboBox.Name = "TodoMarkerPriorityComboBox"; + this.TodoMarkerPriorityComboBox.Size = new System.Drawing.Size(353, 24); + this.TodoMarkerPriorityComboBox.TabIndex = 0; + // + // TodoMarkerTextBox + // + this.TodoMarkerTextBox.Location = new System.Drawing.Point(12, 29); + this.TodoMarkerTextBox.Name = "TodoMarkerTextBox"; + this.TodoMarkerTextBox.Size = new System.Drawing.Size(353, 22); + this.TodoMarkerTextBox.TabIndex = 1; + // + // TodoMarkerTextBoxLabel + // + this.TodoMarkerTextBoxLabel.AutoSize = true; + this.TodoMarkerTextBoxLabel.Location = new System.Drawing.Point(12, 9); + this.TodoMarkerTextBoxLabel.Name = "TodoMarkerTextBoxLabel"; + this.TodoMarkerTextBoxLabel.Size = new System.Drawing.Size(35, 17); + this.TodoMarkerTextBoxLabel.TabIndex = 2; + this.TodoMarkerTextBoxLabel.Text = "Text"; + // + // TodoMarkerPriorityComboBoxLabel + // + this.TodoMarkerPriorityComboBoxLabel.AutoSize = true; + this.TodoMarkerPriorityComboBoxLabel.Location = new System.Drawing.Point(12, 68); + this.TodoMarkerPriorityComboBoxLabel.Name = "TodoMarkerPriorityComboBoxLabel"; + this.TodoMarkerPriorityComboBoxLabel.Size = new System.Drawing.Size(52, 17); + this.TodoMarkerPriorityComboBoxLabel.TabIndex = 3; + this.TodoMarkerPriorityComboBoxLabel.Text = "Priority"; + // + // flowLayoutPanel2 + // + this.flowLayoutPanel2.BackColor = System.Drawing.SystemColors.ControlDark; + this.flowLayoutPanel2.Controls.Add(this.CancelButton); + this.flowLayoutPanel2.Controls.Add(this.OkButton); + this.flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Bottom; + this.flowLayoutPanel2.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; + this.flowLayoutPanel2.Location = new System.Drawing.Point(0, 150); + this.flowLayoutPanel2.Margin = new System.Windows.Forms.Padding(4); + this.flowLayoutPanel2.Name = "flowLayoutPanel2"; + this.flowLayoutPanel2.Padding = new System.Windows.Forms.Padding(11, 10, 0, 10); + this.flowLayoutPanel2.Size = new System.Drawing.Size(380, 53); + this.flowLayoutPanel2.TabIndex = 4; + // + // CancelButton + // + this.CancelButton.BackColor = System.Drawing.SystemColors.ButtonFace; + this.CancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.CancelButton.Location = new System.Drawing.Point(265, 14); + this.CancelButton.Margin = new System.Windows.Forms.Padding(4); + this.CancelButton.Name = "CancelButton"; + this.CancelButton.Size = new System.Drawing.Size(100, 28); + this.CancelButton.TabIndex = 0; + this.CancelButton.Text = "Cancel"; + this.CancelButton.UseVisualStyleBackColor = false; + // + // OkButton + // + this.OkButton.BackColor = System.Drawing.SystemColors.ButtonFace; + this.OkButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.OkButton.Location = new System.Drawing.Point(157, 14); + this.OkButton.Margin = new System.Windows.Forms.Padding(4); + this.OkButton.Name = "OkButton"; + this.OkButton.Size = new System.Drawing.Size(100, 28); + this.OkButton.TabIndex = 1; + this.OkButton.Text = "Ok"; + this.OkButton.UseVisualStyleBackColor = false; + // + // InvalidNameValidationIcon + // + this.InvalidNameValidationIcon.Image = global::Rubberduck.Properties.Resources.cross_circle; + this.InvalidNameValidationIcon.Location = new System.Drawing.Point(356, 22); + this.InvalidNameValidationIcon.Margin = new System.Windows.Forms.Padding(4); + this.InvalidNameValidationIcon.Name = "InvalidNameValidationIcon"; + this.InvalidNameValidationIcon.Size = new System.Drawing.Size(16, 16); + this.InvalidNameValidationIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.InvalidNameValidationIcon.TabIndex = 14; + this.InvalidNameValidationIcon.TabStop = false; + // + // AddMarkerForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(380, 203); + this.Controls.Add(this.InvalidNameValidationIcon); + this.Controls.Add(this.flowLayoutPanel2); + this.Controls.Add(this.TodoMarkerPriorityComboBoxLabel); + this.Controls.Add(this.TodoMarkerTextBoxLabel); + this.Controls.Add(this.TodoMarkerTextBox); + this.Controls.Add(this.TodoMarkerPriorityComboBox); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "AddMarkerForm"; + this.Text = "AddMarkerForm"; + this.flowLayoutPanel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.InvalidNameValidationIcon)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ComboBox TodoMarkerPriorityComboBox; + private System.Windows.Forms.TextBox TodoMarkerTextBox; + private System.Windows.Forms.Label TodoMarkerTextBoxLabel; + private System.Windows.Forms.Label TodoMarkerPriorityComboBoxLabel; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2; + private System.Windows.Forms.Button CancelButton; + private System.Windows.Forms.Button OkButton; + private System.Windows.Forms.PictureBox InvalidNameValidationIcon; + } +} \ No newline at end of file diff --git a/RetailCoder.VBE/UI/Settings/AddMarkerForm.cs b/RetailCoder.VBE/UI/Settings/AddMarkerForm.cs new file mode 100644 index 0000000000..9e18dd5340 --- /dev/null +++ b/RetailCoder.VBE/UI/Settings/AddMarkerForm.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using Rubberduck.Settings; + +namespace Rubberduck.UI.Settings +{ + public partial class AddMarkerForm : Form, IAddTodoMarkerView + { + public AddMarkerForm() + { + InitializeComponent(); + + OkButton.Click += OKButtonClick; + CancelButton.Click += CancelButtonClick; + TodoMarkerTextBox.TextChanged += MarkerTextChanged; + } + + public List TodoMarkers { get; set; } + public string MarkerText { get; set; } + + private bool _isValidMarker = false; + public bool IsValidMarker + { + get { return _isValidMarker; } + set + { + _isValidMarker = value; + + InvalidNameValidationIcon.Visible = !_isValidMarker; + OkButton.Enabled = !_isValidMarker; + } + } + + public event EventHandler AddMarker; + private void OKButtonClick(object sender, EventArgs e) + { + var handler = AddMarker; + if (handler != null) + { + handler(sender, e); + } + } + + public event EventHandler Cancel; + private void CancelButtonClick(object sender, EventArgs e) + { + var handler = Cancel; + if (handler != null) + { + handler(sender, e); + } + } + + public event EventHandler TextChanged; + private void MarkerTextChanged(object sender, EventArgs e) + { + var handler = TextChanged; + if (handler != null) + { + handler(sender, e); + } + } + } +} diff --git a/RetailCoder.VBE/UI/Settings/AddMarkerFormPresenter.cs b/RetailCoder.VBE/UI/Settings/AddMarkerFormPresenter.cs new file mode 100644 index 0000000000..e35417fe6c --- /dev/null +++ b/RetailCoder.VBE/UI/Settings/AddMarkerFormPresenter.cs @@ -0,0 +1,22 @@ +using System; +using System.Linq; + +namespace Rubberduck.UI.Settings +{ + public class AddMarkerFormPresenter + { + private readonly IAddTodoMarkerView _view; + + public AddMarkerFormPresenter(IAddTodoMarkerView view) + { + _view = view; + + _view.TextChanged += TextChanged; + } + + private void TextChanged(object sender, EventArgs e) + { + _view.IsValidMarker = _view.TodoMarkers.All(t => t.Text != _view.MarkerText) && _view.MarkerText != string.Empty; + } + } +} diff --git a/RetailCoder.VBE/UI/Settings/IAddTodoSettingsView.cs b/RetailCoder.VBE/UI/Settings/IAddTodoSettingsView.cs new file mode 100644 index 0000000000..d2d2f32a26 --- /dev/null +++ b/RetailCoder.VBE/UI/Settings/IAddTodoSettingsView.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using Rubberduck.Settings; + +namespace Rubberduck.UI.Settings +{ + public interface IAddTodoMarkerView + { + /// + /// List of all current TodoMarkers. + /// + List TodoMarkers { get; set; } + + /// + /// Current text of new marker. + /// + string MarkerText { get; set; } + + /// + /// Sets UI display based on validity of marker. + /// + bool IsValidMarker { get; set; } + + /// + /// Request to add the currently active marker to BindingList{TodoMarker}. + /// + event EventHandler AddMarker; + + /// + /// Cancel adding marker. + /// + event EventHandler Cancel; + + /// + /// Cancel adding marker. + /// + event EventHandler TextChanged; + + void Show(); + void Hide(); + void Close(); + } +} diff --git a/RetailCoder.VBE/UI/Settings/ITodoSettingsView.cs b/RetailCoder.VBE/UI/Settings/ITodoSettingsView.cs index dd0eaa9531..5b907e0aea 100644 --- a/RetailCoder.VBE/UI/Settings/ITodoSettingsView.cs +++ b/RetailCoder.VBE/UI/Settings/ITodoSettingsView.cs @@ -35,11 +35,6 @@ public interface ITodoSettingsView /// Request to add the currently active marker to BindingList{TodoMarker}. /// event EventHandler AddMarker; - - /// - /// Raised whenever ActiveMarkerText is changed. - /// - event EventHandler TextChanged; /// /// Raised whenver ActiveMarkerPriority is changed. diff --git a/RetailCoder.VBE/UI/Settings/SettingsDialog.Designer.cs b/RetailCoder.VBE/UI/Settings/SettingsDialog.Designer.cs index 8840c04c5a..ea2ffc446c 100644 --- a/RetailCoder.VBE/UI/Settings/SettingsDialog.Designer.cs +++ b/RetailCoder.VBE/UI/Settings/SettingsDialog.Designer.cs @@ -31,7 +31,6 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(_SettingsDialog)); this.panel2 = new System.Windows.Forms.Panel(); this.TitleLabel = new System.Windows.Forms.Label(); this.InstructionsLabel = new System.Windows.Forms.Label(); @@ -52,28 +51,31 @@ private void InitializeComponent() this.panel2.Controls.Add(this.InstructionsLabel); this.panel2.Dock = System.Windows.Forms.DockStyle.Top; this.panel2.Location = new System.Drawing.Point(0, 0); + this.panel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(717, 68); + this.panel2.Size = new System.Drawing.Size(956, 84); this.panel2.TabIndex = 14; // // TitleLabel // this.TitleLabel.AutoSize = true; this.TitleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.TitleLabel.Location = new System.Drawing.Point(15, 9); + this.TitleLabel.Location = new System.Drawing.Point(20, 11); + this.TitleLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.TitleLabel.Name = "TitleLabel"; - this.TitleLabel.Padding = new System.Windows.Forms.Padding(2); - this.TitleLabel.Size = new System.Drawing.Size(118, 19); + this.TitleLabel.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.TitleLabel.Size = new System.Drawing.Size(139, 22); this.TitleLabel.TabIndex = 2; this.TitleLabel.Text = "General Settings"; // // InstructionsLabel // this.InstructionsLabel.AutoSize = true; - this.InstructionsLabel.Location = new System.Drawing.Point(12, 30); + this.InstructionsLabel.Location = new System.Drawing.Point(16, 37); + this.InstructionsLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.InstructionsLabel.Name = "InstructionsLabel"; - this.InstructionsLabel.Padding = new System.Windows.Forms.Padding(4); - this.InstructionsLabel.Size = new System.Drawing.Size(269, 21); + this.InstructionsLabel.Padding = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.InstructionsLabel.Size = new System.Drawing.Size(358, 27); this.InstructionsLabel.TabIndex = 3; this.InstructionsLabel.Text = "Changes will be applied after Rubberduck is reloaded."; // @@ -84,19 +86,21 @@ private void InitializeComponent() this.flowLayoutPanel2.Controls.Add(this.OkButton); this.flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Bottom; this.flowLayoutPanel2.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.flowLayoutPanel2.Location = new System.Drawing.Point(0, 364); + this.flowLayoutPanel2.Location = new System.Drawing.Point(0, 448); + this.flowLayoutPanel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.flowLayoutPanel2.Name = "flowLayoutPanel2"; - this.flowLayoutPanel2.Padding = new System.Windows.Forms.Padding(8, 8, 0, 8); - this.flowLayoutPanel2.Size = new System.Drawing.Size(717, 43); + this.flowLayoutPanel2.Padding = new System.Windows.Forms.Padding(11, 10, 0, 10); + this.flowLayoutPanel2.Size = new System.Drawing.Size(956, 53); this.flowLayoutPanel2.TabIndex = 15; // // CancelButton // this.CancelButton.BackColor = System.Drawing.SystemColors.ButtonFace; this.CancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.CancelButton.Location = new System.Drawing.Point(631, 11); + this.CancelButton.Location = new System.Drawing.Point(841, 14); + this.CancelButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.CancelButton.Name = "CancelButton"; - this.CancelButton.Size = new System.Drawing.Size(75, 23); + this.CancelButton.Size = new System.Drawing.Size(100, 28); this.CancelButton.TabIndex = 0; this.CancelButton.Text = "Cancel"; this.CancelButton.UseVisualStyleBackColor = false; @@ -105,9 +109,10 @@ private void InitializeComponent() // this.OkButton.BackColor = System.Drawing.SystemColors.ButtonFace; this.OkButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.OkButton.Location = new System.Drawing.Point(550, 11); + this.OkButton.Location = new System.Drawing.Point(733, 14); + this.OkButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.OkButton.Name = "OkButton"; - this.OkButton.Size = new System.Drawing.Size(75, 23); + this.OkButton.Size = new System.Drawing.Size(100, 28); this.OkButton.TabIndex = 1; this.OkButton.Text = "Ok"; this.OkButton.UseVisualStyleBackColor = false; @@ -116,29 +121,32 @@ private void InitializeComponent() // this.splitContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.Location = new System.Drawing.Point(0, 68); + this.splitContainer1.Location = new System.Drawing.Point(0, 84); + this.splitContainer1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.splitContainer1.Name = "splitContainer1"; // // splitContainer1.Panel1 // this.splitContainer1.Panel1.BackColor = System.Drawing.Color.White; this.splitContainer1.Panel1MinSize = 100; - this.splitContainer1.Size = new System.Drawing.Size(717, 296); - this.splitContainer1.SplitterDistance = 256; + this.splitContainer1.Size = new System.Drawing.Size(956, 364); + this.splitContainer1.SplitterDistance = 341; this.splitContainer1.SplitterWidth = 1; this.splitContainer1.TabIndex = 16; // // _SettingsDialog // this.AcceptButton = this.OkButton; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(717, 407); + this.AutoValidate = System.Windows.Forms.AutoValidate.EnablePreventFocusChange; + this.ClientSize = new System.Drawing.Size(956, 501); this.Controls.Add(this.splitContainer1); this.Controls.Add(this.flowLayoutPanel2); this.Controls.Add(this.panel2); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Icon = (System.Drawing.Icon)RubberduckUI.Ducky; + this.Icon = global::Rubberduck.UI.RubberduckUI.Ducky; + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "_SettingsDialog"; diff --git a/RetailCoder.VBE/UI/Settings/SettingsDialog.cs b/RetailCoder.VBE/UI/Settings/SettingsDialog.cs index 11a6120837..140717e0b8 100644 --- a/RetailCoder.VBE/UI/Settings/SettingsDialog.cs +++ b/RetailCoder.VBE/UI/Settings/SettingsDialog.cs @@ -82,7 +82,7 @@ private void LoadWindow() var markers = _config.UserSettings.ToDoListSettings.ToDoMarkers; _todoView = new TodoListSettingsUserControl(markers); - _todoController = new TodoSettingPresenter(_todoView); + _todoController = new TodoSettingPresenter(_todoView, new AddMarkerForm()); ActivateControl(_generalSettingsView); } diff --git a/RetailCoder.VBE/UI/Settings/SettingsDialog.resx b/RetailCoder.VBE/UI/Settings/SettingsDialog.resx index d3a1a2980d..1af7de150c 100644 --- a/RetailCoder.VBE/UI/Settings/SettingsDialog.resx +++ b/RetailCoder.VBE/UI/Settings/SettingsDialog.resx @@ -117,26 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - AAABAAEAEA4AAAEAIADgAwAAFgAAACgAAAAQAAAAHAAAAAEAIAAAAAAAuAMAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAB4AAABxAAEBtQEYGOMCLCz3AzEx/AIhIewABwfFAAAAiQAAADYAAAABAAAAAAAA - AAAAAAAAAAAAAQAAAJIDODj5CJqa/wzh4f8O/f3/Dv///w7///8O////De/v/wq0tP8ES0v/AAAAewAA - AAAAAAAAAAAAAAAAAEcFWlr/Dv///w7///8O////Dv///w7///8O////Dv///w7///8O////Dvv7/wMw - MPkAAAAgAAAAAAAAAAAAAQGpC8zM/w7///8O////Dv///w7///8O////Dv///w7///8O////Dv///w7/ - //8JoKD/AAAAfAAAAAAAAAAAARMT4g78/P8O////Dv///w7///8O////Dv///w7///8O////Dv///w7/ - //8O////DNzc/wAAALAAAAAAAAAAAAImJvcO////Dv///w7///8O////Dv///w7///8O////Dv///w7/ - //8O////Dv///w3o6P8AAAC8AAAAAAAAAAACHh7vDv///w7///8O////Dv///w7///8O////Dv///w7/ - //8O////Dv///w7///8LxMT/AAAAngAAAAAAAAAAAAQExg3o6P8O////Dv///wmnp/8GZ2f/B3l5/wZ1 - df8Kr6//Dv///w7///8O////Bmxs/wAAAFIAAAAAAAAAAAAAAGwHgoL/Dv///wq+vv8BDAzTAAAAOQAA - AE8BDQ3yDNLS/w7///8O////Dv///wZlZf8AABS4AAAPgQAAAA0AAAAIAQwM1AVjY/8ABwfEAAAAGAAA - AAAAAABNBnJy/w7///8O////Dv///w7///8N5ub/AAM+/wAA4P8AAC62AAAAAAAAACAAAABLAAAAAgAA - AAAAAAAAAAAAaAiUlP8O////Dv///wvKyv8Lvr7/Dvv7/wEQMf8AAP//AACF/wAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAADkFV1f/Dv///w7///8HdHT/Blxc/wvMzP8AAAXWAAAoogAAF58AAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAEBrwiQkP8O+/v/Dv///wzY2P8CLCz1AAAAMQAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAACHARkZ4wIpKfQABga8AAAANgAAAAAAAAAAAAAAAMAH - AAAABwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAQAAACMAAAA/AAAAP4DAAD+BwAA - - \ No newline at end of file diff --git a/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs b/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs index 13e804707a..efa07d9925 100644 --- a/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs +++ b/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs @@ -8,19 +8,29 @@ namespace Rubberduck.UI.Settings public class TodoSettingPresenter { private readonly ITodoSettingsView _view; + private readonly IAddTodoMarkerView _addTodoMarkerView; public ToDoMarker ActiveMarker { get { return _view.TodoMarkers[_view.SelectedIndex]; } } - public TodoSettingPresenter(ITodoSettingsView view) + public TodoSettingPresenter(ITodoSettingsView view, IAddTodoMarkerView addTodoMarkerView) { _view = view; + _addTodoMarkerView = addTodoMarkerView; _view.AddMarker += AddMarker; _view.RemoveMarker += RemoveMarker; _view.PriorityChanged += SaveMarker; + + _addTodoMarkerView.AddMarker += ConfirmAddMarker; + _addTodoMarkerView.Cancel += CancelAddMarker; + } + + ~TodoSettingPresenter() + { + _addTodoMarkerView.Close(); } private void SaveMarker(object sender, EventArgs e) @@ -39,13 +49,19 @@ private void RemoveMarker(object sender, EventArgs e) private void AddMarker(object sender, EventArgs e) { - var oldList = _view.TodoMarkers.ToList(); - var marker = new ToDoMarker(_view.ActiveMarkerText, _view.ActiveMarkerPriority); - oldList.Add(marker); + _addTodoMarkerView.TodoMarkers = _view.TodoMarkers.ToList(); + _addTodoMarkerView.Show(); + } - _view.TodoMarkers = new BindingList(oldList); + private void ConfirmAddMarker(object sender, EventArgs e) + { + _addTodoMarkerView.Hide(); + _view.TodoMarkers = new BindingList(_addTodoMarkerView.TodoMarkers); + } - _view.SelectedIndex = _view.TodoMarkers.Count - 1; + private void CancelAddMarker(object sender, EventArgs e) + { + _addTodoMarkerView.Hide(); } public void SetActiveItem(int index) diff --git a/RetailCoder.VBE/UI/SourceControl/DeleteBranchForm.Designer.cs b/RetailCoder.VBE/UI/SourceControl/DeleteBranchForm.Designer.cs index a36ba55192..66b4fbca95 100644 --- a/RetailCoder.VBE/UI/SourceControl/DeleteBranchForm.Designer.cs +++ b/RetailCoder.VBE/UI/SourceControl/DeleteBranchForm.Designer.cs @@ -28,6 +28,7 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DeleteBranchForm)); this.CancelButton = new System.Windows.Forms.Button(); this.OkButton = new System.Windows.Forms.Button(); this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel(); @@ -129,6 +130,7 @@ private void InitializeComponent() this.Controls.Add(this.BranchList); this.Controls.Add(this.flowLayoutPanel2); this.Controls.Add(this.panel1); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "DeleteBranchForm"; this.Text = "DeleteBranchForm"; this.flowLayoutPanel2.ResumeLayout(false); diff --git a/RetailCoder.VBE/UI/SourceControl/DeleteBranchForm.resx b/RetailCoder.VBE/UI/SourceControl/DeleteBranchForm.resx index 1af7de150c..d3a1a2980d 100644 --- a/RetailCoder.VBE/UI/SourceControl/DeleteBranchForm.resx +++ b/RetailCoder.VBE/UI/SourceControl/DeleteBranchForm.resx @@ -117,4 +117,26 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + AAABAAEAEA4AAAEAIADgAwAAFgAAACgAAAAQAAAAHAAAAAEAIAAAAAAAuAMAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAB4AAABxAAEBtQEYGOMCLCz3AzEx/AIhIewABwfFAAAAiQAAADYAAAABAAAAAAAA + AAAAAAAAAAAAAQAAAJIDODj5CJqa/wzh4f8O/f3/Dv///w7///8O////De/v/wq0tP8ES0v/AAAAewAA + AAAAAAAAAAAAAAAAAEcFWlr/Dv///w7///8O////Dv///w7///8O////Dv///w7///8O////Dvv7/wMw + MPkAAAAgAAAAAAAAAAAAAQGpC8zM/w7///8O////Dv///w7///8O////Dv///w7///8O////Dv///w7/ + //8JoKD/AAAAfAAAAAAAAAAAARMT4g78/P8O////Dv///w7///8O////Dv///w7///8O////Dv///w7/ + //8O////DNzc/wAAALAAAAAAAAAAAAImJvcO////Dv///w7///8O////Dv///w7///8O////Dv///w7/ + //8O////Dv///w3o6P8AAAC8AAAAAAAAAAACHh7vDv///w7///8O////Dv///w7///8O////Dv///w7/ + //8O////Dv///w7///8LxMT/AAAAngAAAAAAAAAAAAQExg3o6P8O////Dv///wmnp/8GZ2f/B3l5/wZ1 + df8Kr6//Dv///w7///8O////Bmxs/wAAAFIAAAAAAAAAAAAAAGwHgoL/Dv///wq+vv8BDAzTAAAAOQAA + AE8BDQ3yDNLS/w7///8O////Dv///wZlZf8AABS4AAAPgQAAAA0AAAAIAQwM1AVjY/8ABwfEAAAAGAAA + AAAAAABNBnJy/w7///8O////Dv///w7///8N5ub/AAM+/wAA4P8AAC62AAAAAAAAACAAAABLAAAAAgAA + AAAAAAAAAAAAaAiUlP8O////Dv///wvKyv8Lvr7/Dvv7/wEQMf8AAP//AACF/wAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAADkFV1f/Dv///w7///8HdHT/Blxc/wvMzP8AAAXWAAAoogAAF58AAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAEBrwiQkP8O+/v/Dv///wzY2P8CLCz1AAAAMQAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAACHARkZ4wIpKfQABga8AAAANgAAAAAAAAAAAAAAAMAH + AAAABwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAQAAACMAAAA/AAAAP4DAAD+BwAA + + \ No newline at end of file From bdb677d9f1789289787dbf0712fc998d53f937e5 Mon Sep 17 00:00:00 2001 From: Hosch250 Date: Wed, 17 Jun 2015 16:18:45 -0500 Subject: [PATCH 5/7] Just to have it... --- RetailCoder.VBE/Rubberduck.csproj | 1 - RetailCoder.VBE/UI/Settings/AddMarkerForm.cs | 7 +++++- .../UI/Settings/AddMarkerFormPresenter.cs | 22 ------------------- .../UI/Settings/TodoSettingPresenter.cs | 7 ++++++ 4 files changed, 13 insertions(+), 24 deletions(-) delete mode 100644 RetailCoder.VBE/UI/Settings/AddMarkerFormPresenter.cs diff --git a/RetailCoder.VBE/Rubberduck.csproj b/RetailCoder.VBE/Rubberduck.csproj index f51d5bcde4..e9e90bd154 100644 --- a/RetailCoder.VBE/Rubberduck.csproj +++ b/RetailCoder.VBE/Rubberduck.csproj @@ -289,7 +289,6 @@ AddMarkerForm.cs - diff --git a/RetailCoder.VBE/UI/Settings/AddMarkerForm.cs b/RetailCoder.VBE/UI/Settings/AddMarkerForm.cs index 9e18dd5340..724f977038 100644 --- a/RetailCoder.VBE/UI/Settings/AddMarkerForm.cs +++ b/RetailCoder.VBE/UI/Settings/AddMarkerForm.cs @@ -17,7 +17,12 @@ public AddMarkerForm() } public List TodoMarkers { get; set; } - public string MarkerText { get; set; } + + public string MarkerText + { + get { return TodoMarkerTextBox.Text; } + set { TodoMarkerTextBox.Text = value; } + } private bool _isValidMarker = false; public bool IsValidMarker diff --git a/RetailCoder.VBE/UI/Settings/AddMarkerFormPresenter.cs b/RetailCoder.VBE/UI/Settings/AddMarkerFormPresenter.cs deleted file mode 100644 index e35417fe6c..0000000000 --- a/RetailCoder.VBE/UI/Settings/AddMarkerFormPresenter.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Linq; - -namespace Rubberduck.UI.Settings -{ - public class AddMarkerFormPresenter - { - private readonly IAddTodoMarkerView _view; - - public AddMarkerFormPresenter(IAddTodoMarkerView view) - { - _view = view; - - _view.TextChanged += TextChanged; - } - - private void TextChanged(object sender, EventArgs e) - { - _view.IsValidMarker = _view.TodoMarkers.All(t => t.Text != _view.MarkerText) && _view.MarkerText != string.Empty; - } - } -} diff --git a/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs b/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs index efa07d9925..4f983bfd8f 100644 --- a/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs +++ b/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs @@ -26,6 +26,7 @@ public TodoSettingPresenter(ITodoSettingsView view, IAddTodoMarkerView addTodoMa _addTodoMarkerView.AddMarker += ConfirmAddMarker; _addTodoMarkerView.Cancel += CancelAddMarker; + _addTodoMarkerView.TextChanged += AddMarkerTextChanged; } ~TodoSettingPresenter() @@ -53,6 +54,12 @@ private void AddMarker(object sender, EventArgs e) _addTodoMarkerView.Show(); } + private void AddMarkerTextChanged(object sender, EventArgs e) + { + _addTodoMarkerView.IsValidMarker = _view.TodoMarkers.All(t => t.Text != _addTodoMarkerView.MarkerText.ToUpper()) && + _addTodoMarkerView.MarkerText != string.Empty; + } + private void ConfirmAddMarker(object sender, EventArgs e) { _addTodoMarkerView.Hide(); From 62b4500e421a80203157619b5a52dc70e53d63db Mon Sep 17 00:00:00 2001 From: Hosch250 Date: Wed, 17 Jun 2015 16:48:35 -0500 Subject: [PATCH 6/7] More commits --- RetailCoder.VBE/UI/Settings/AddMarkerForm.cs | 33 +++++++++++++++++-- .../UI/Settings/IAddTodoSettingsView.cs | 5 +++ .../UI/Settings/TodoSettingPresenter.cs | 9 ++++- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/RetailCoder.VBE/UI/Settings/AddMarkerForm.cs b/RetailCoder.VBE/UI/Settings/AddMarkerForm.cs index 724f977038..4cef47602c 100644 --- a/RetailCoder.VBE/UI/Settings/AddMarkerForm.cs +++ b/RetailCoder.VBE/UI/Settings/AddMarkerForm.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; using Rubberduck.Settings; @@ -11,9 +12,12 @@ public AddMarkerForm() { InitializeComponent(); + IsValidMarker = false; + OkButton.Click += OKButtonClick; CancelButton.Click += CancelButtonClick; TodoMarkerTextBox.TextChanged += MarkerTextChanged; + TodoMarkerPriorityComboBox.DataSource = TodoLabels(); } public List TodoMarkers { get; set; } @@ -24,7 +28,7 @@ public string MarkerText set { TodoMarkerTextBox.Text = value; } } - private bool _isValidMarker = false; + private bool _isValidMarker; public bool IsValidMarker { get { return _isValidMarker; } @@ -33,7 +37,32 @@ public bool IsValidMarker _isValidMarker = value; InvalidNameValidationIcon.Visible = !_isValidMarker; - OkButton.Enabled = !_isValidMarker; + OkButton.Enabled = _isValidMarker; + } + } + + private List TodoLabels() + { + return (from object priority in Enum.GetValues(typeof(TodoPriority)) + select + RubberduckUI.ResourceManager.GetString("ToDoPriority_" + priority, RubberduckUI.Culture)) + .ToList(); + } + + public TodoPriority MarkerPriority + { + get + { + return Enum.GetValues(typeof (TodoPriority)) + .Cast() + .FirstOrDefault( + p => + Equals(TodoMarkerPriorityComboBox.SelectedItem, RubberduckUI.ResourceManager.GetString("ToDoPriority_" + p, RubberduckUI.Culture))); + } + set + { + TodoMarkerPriorityComboBox.SelectedItem = RubberduckUI.ResourceManager.GetString("ToDoPriority_" + value, RubberduckUI.Culture); + } } diff --git a/RetailCoder.VBE/UI/Settings/IAddTodoSettingsView.cs b/RetailCoder.VBE/UI/Settings/IAddTodoSettingsView.cs index d2d2f32a26..a95e13b607 100644 --- a/RetailCoder.VBE/UI/Settings/IAddTodoSettingsView.cs +++ b/RetailCoder.VBE/UI/Settings/IAddTodoSettingsView.cs @@ -16,6 +16,11 @@ public interface IAddTodoMarkerView /// string MarkerText { get; set; } + /// + /// Current priority of new marker. + /// + TodoPriority MarkerPriority { get; set; } + /// /// Sets UI display based on validity of marker. /// diff --git a/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs b/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs index 4f983bfd8f..d4ae3c007a 100644 --- a/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs +++ b/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs @@ -62,13 +62,20 @@ private void AddMarkerTextChanged(object sender, EventArgs e) private void ConfirmAddMarker(object sender, EventArgs e) { - _addTodoMarkerView.Hide(); + HideAddMarkerForm(); _view.TodoMarkers = new BindingList(_addTodoMarkerView.TodoMarkers); } private void CancelAddMarker(object sender, EventArgs e) + { + HideAddMarkerForm(); + } + + private void HideAddMarkerForm() { _addTodoMarkerView.Hide(); + _addTodoMarkerView.MarkerText = string.Empty; + _addTodoMarkerView.MarkerPriority = default(TodoPriority); } public void SetActiveItem(int index) From 67c05e9d6e4d9b8e41f291d2d3c04de9895ec62f Mon Sep 17 00:00:00 2001 From: Hosch250 Date: Wed, 17 Jun 2015 17:01:47 -0500 Subject: [PATCH 7/7] Actually add marker on OK --- .../UI/Settings/AddMarkerForm.Designer.cs | 15 +++++++++++---- .../UI/Settings/TodoSettingPresenter.cs | 4 +++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/RetailCoder.VBE/UI/Settings/AddMarkerForm.Designer.cs b/RetailCoder.VBE/UI/Settings/AddMarkerForm.Designer.cs index 49b97e4180..ed8debc00e 100644 --- a/RetailCoder.VBE/UI/Settings/AddMarkerForm.Designer.cs +++ b/RetailCoder.VBE/UI/Settings/AddMarkerForm.Designer.cs @@ -61,18 +61,18 @@ private void InitializeComponent() this.TodoMarkerTextBoxLabel.AutoSize = true; this.TodoMarkerTextBoxLabel.Location = new System.Drawing.Point(12, 9); this.TodoMarkerTextBoxLabel.Name = "TodoMarkerTextBoxLabel"; - this.TodoMarkerTextBoxLabel.Size = new System.Drawing.Size(35, 17); + this.TodoMarkerTextBoxLabel.Size = new System.Drawing.Size(39, 17); this.TodoMarkerTextBoxLabel.TabIndex = 2; - this.TodoMarkerTextBoxLabel.Text = "Text"; + this.TodoMarkerTextBoxLabel.Text = "Text:"; // // TodoMarkerPriorityComboBoxLabel // this.TodoMarkerPriorityComboBoxLabel.AutoSize = true; this.TodoMarkerPriorityComboBoxLabel.Location = new System.Drawing.Point(12, 68); this.TodoMarkerPriorityComboBoxLabel.Name = "TodoMarkerPriorityComboBoxLabel"; - this.TodoMarkerPriorityComboBoxLabel.Size = new System.Drawing.Size(52, 17); + this.TodoMarkerPriorityComboBoxLabel.Size = new System.Drawing.Size(56, 17); this.TodoMarkerPriorityComboBoxLabel.TabIndex = 3; - this.TodoMarkerPriorityComboBoxLabel.Text = "Priority"; + this.TodoMarkerPriorityComboBoxLabel.Text = "Priority:"; // // flowLayoutPanel2 // @@ -125,8 +125,10 @@ private void InitializeComponent() // // AddMarkerForm // + this.AcceptButton = this.OkButton; this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.CancelButton; this.ClientSize = new System.Drawing.Size(380, 203); this.Controls.Add(this.InvalidNameValidationIcon); this.Controls.Add(this.flowLayoutPanel2); @@ -134,9 +136,14 @@ private void InitializeComponent() this.Controls.Add(this.TodoMarkerTextBoxLabel); this.Controls.Add(this.TodoMarkerTextBox); this.Controls.Add(this.TodoMarkerPriorityComboBox); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; this.Name = "AddMarkerForm"; + this.ShowInTaskbar = false; this.Text = "AddMarkerForm"; + this.TopMost = true; this.flowLayoutPanel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.InvalidNameValidationIcon)).EndInit(); this.ResumeLayout(false); diff --git a/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs b/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs index d4ae3c007a..2d3dc334d5 100644 --- a/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs +++ b/RetailCoder.VBE/UI/Settings/TodoSettingPresenter.cs @@ -62,8 +62,10 @@ private void AddMarkerTextChanged(object sender, EventArgs e) private void ConfirmAddMarker(object sender, EventArgs e) { - HideAddMarkerForm(); + _addTodoMarkerView.TodoMarkers.Add(new ToDoMarker(_addTodoMarkerView.MarkerText, + _addTodoMarkerView.MarkerPriority)); _view.TodoMarkers = new BindingList(_addTodoMarkerView.TodoMarkers); + HideAddMarkerForm(); } private void CancelAddMarker(object sender, EventArgs e)