From 0c2d21ee0a44c5b0f527b1ba701e745d994a5fce Mon Sep 17 00:00:00 2001 From: gamosoft_cp Date: Wed, 24 Jul 2013 17:09:24 +0000 Subject: [PATCH] Issue with split container race condition in progress --- .../AppointmentsControl.Designer.cs | 84 +++++++++---------- Outlook2013TodoAddIn/AppointmentsControl.cs | 7 +- 2 files changed, 48 insertions(+), 43 deletions(-) diff --git a/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs b/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs index c3e9b61..46a9a3c 100644 --- a/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs +++ b/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs @@ -32,13 +32,13 @@ this.ctxMenuAppointments = new System.Windows.Forms.ContextMenuStrip(this.components); this.mnuItemReplyAllEmail = new System.Windows.Forms.ToolStripMenuItem(); this.panel1 = new System.Windows.Forms.Panel(); - this.lstTasks = new System.Windows.Forms.ListView(); - this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.lstAppointments = new System.Windows.Forms.ListView(); this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.lstTasks = new System.Windows.Forms.ListView(); + this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.apptCalendar = new Outlook2013TodoAddIn.CustomCalendar(); this.ctxMenuAppointments.SuspendLayout(); this.panel1.SuspendLayout(); @@ -72,36 +72,24 @@ this.panel1.Size = new System.Drawing.Size(258, 767); this.panel1.TabIndex = 8; // - // lstTasks + // splitContainer1 // - this.lstTasks.Activation = System.Windows.Forms.ItemActivation.OneClick; - this.lstTasks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader3, - this.columnHeader4}); - this.lstTasks.ContextMenuStrip = this.ctxMenuAppointments; - this.lstTasks.Dock = System.Windows.Forms.DockStyle.Fill; - this.lstTasks.FullRowSelect = true; - this.lstTasks.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.lstTasks.Location = new System.Drawing.Point(0, 0); - this.lstTasks.MultiSelect = false; - this.lstTasks.Name = "lstTasks"; - this.lstTasks.OwnerDraw = true; - this.lstTasks.ShowItemToolTips = true; - this.lstTasks.Size = new System.Drawing.Size(258, 266); - this.lstTasks.TabIndex = 5; - this.lstTasks.TileSize = new System.Drawing.Size(300, 38); - this.lstTasks.UseCompatibleStateImageBehavior = false; - this.lstTasks.View = System.Windows.Forms.View.Tile; + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 228); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; // - // columnHeader3 + // splitContainer1.Panel1 // - this.columnHeader3.Text = "Date"; - this.columnHeader3.Width = 200; + this.splitContainer1.Panel1.Controls.Add(this.lstAppointments); // - // columnHeader4 + // splitContainer1.Panel2 // - this.columnHeader4.Text = "Subject"; - this.columnHeader4.Width = 200; + this.splitContainer1.Panel2.Controls.Add(this.lstTasks); + this.splitContainer1.Size = new System.Drawing.Size(258, 539); + this.splitContainer1.SplitterDistance = 269; + this.splitContainer1.TabIndex = 6; + this.splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitContainer1_SplitterMoved); // // lstAppointments // @@ -136,24 +124,36 @@ this.columnHeader2.Text = "Subject"; this.columnHeader2.Width = 200; // - // splitContainer1 + // lstTasks // - this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.Location = new System.Drawing.Point(0, 228); - this.splitContainer1.Name = "splitContainer1"; - this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + this.lstTasks.Activation = System.Windows.Forms.ItemActivation.OneClick; + this.lstTasks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader3, + this.columnHeader4}); + this.lstTasks.ContextMenuStrip = this.ctxMenuAppointments; + this.lstTasks.Dock = System.Windows.Forms.DockStyle.Fill; + this.lstTasks.FullRowSelect = true; + this.lstTasks.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.lstTasks.Location = new System.Drawing.Point(0, 0); + this.lstTasks.MultiSelect = false; + this.lstTasks.Name = "lstTasks"; + this.lstTasks.OwnerDraw = true; + this.lstTasks.ShowItemToolTips = true; + this.lstTasks.Size = new System.Drawing.Size(258, 266); + this.lstTasks.TabIndex = 5; + this.lstTasks.TileSize = new System.Drawing.Size(300, 38); + this.lstTasks.UseCompatibleStateImageBehavior = false; + this.lstTasks.View = System.Windows.Forms.View.Tile; // - // splitContainer1.Panel1 + // columnHeader3 // - this.splitContainer1.Panel1.Controls.Add(this.lstAppointments); + this.columnHeader3.Text = "Date"; + this.columnHeader3.Width = 200; // - // splitContainer1.Panel2 + // columnHeader4 // - this.splitContainer1.Panel2.Controls.Add(this.lstTasks); - this.splitContainer1.Size = new System.Drawing.Size(258, 539); - this.splitContainer1.SplitterDistance = 269; - this.splitContainer1.TabIndex = 6; - this.splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitContainer1_SplitterMoved); + this.columnHeader4.Text = "Subject"; + this.columnHeader4.Width = 200; // // apptCalendar // diff --git a/Outlook2013TodoAddIn/AppointmentsControl.cs b/Outlook2013TodoAddIn/AppointmentsControl.cs index caa8a86..36eab1b 100644 --- a/Outlook2013TodoAddIn/AppointmentsControl.cs +++ b/Outlook2013TodoAddIn/AppointmentsControl.cs @@ -92,7 +92,12 @@ namespace Outlook2013TodoAddIn if (this.ShowTasks) { this.splitContainer1.Panel2Collapsed = false; - this.splitContainer1.SplitterDistance = Properties.Settings.Default.SplitterDistance; + if (Properties.Settings.Default.SplitterDistance >= this.splitContainer1.Panel1MinSize && Properties.Settings.Default.SplitterDistance <= this.splitContainer1.Height - this.splitContainer1.Panel2MinSize) + { + // This is to avoid the bug "SplitterDistance must be between Panel1MinSize and Width - Panel2MinSize." + this.splitContainer1.SplitterDistance = Properties.Settings.Default.SplitterDistance; + // TODO: This doesn't work, need to fix (race condition?) + } // this.RetrieveTasks(); } else