Changeset 12206
- Timestamp:
- 03/16/15 15:47:07 (10 years ago)
- Location:
- branches/NewItemDialog/HeuristicLab.Optimizer/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/NewItemDialog/HeuristicLab.Optimizer/3.3/NewItemDialog.Designer.cs
r12205 r12206 62 62 this.expandAllButton = new System.Windows.Forms.Button(); 63 63 this.collapseAllButton = new System.Windows.Forms.Button(); 64 this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); 65 this.expandToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 66 this.expandAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 67 this.collapseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 68 this.collapseAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 64 69 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); 65 70 this.splitContainer.Panel1.SuspendLayout(); … … 68 73 this.availableItemsGroupBox.SuspendLayout(); 69 74 this.descriptionGroupBox.SuspendLayout(); 75 this.contextMenuStrip.SuspendLayout(); 70 76 this.SuspendLayout(); 71 77 // … … 167 173 this.typesTreeView.VisibleChanged += new System.EventHandler(this.itemsTreeView_VisibleChanged); 168 174 this.typesTreeView.DoubleClick += new System.EventHandler(this.itemTreeView_DoubleClick); 175 this.typesTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.typesTreeView_MouseDown); 169 176 // 170 177 // imageList … … 246 253 this.collapseAllButton.UseVisualStyleBackColor = true; 247 254 this.collapseAllButton.Click += new System.EventHandler(this.collapseAllButton_Click); 255 // 256 // contextMenuStrip 257 // 258 this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 259 this.expandToolStripMenuItem, 260 this.expandAllToolStripMenuItem, 261 this.collapseToolStripMenuItem, 262 this.collapseAllToolStripMenuItem}); 263 this.contextMenuStrip.Name = "contextMenuStrip"; 264 this.contextMenuStrip.Size = new System.Drawing.Size(153, 114); 265 // 266 // expandToolStripMenuItem 267 // 268 this.expandToolStripMenuItem.Name = "expandToolStripMenuItem"; 269 this.expandToolStripMenuItem.Size = new System.Drawing.Size(152, 22); 270 this.expandToolStripMenuItem.Text = "Expand"; 271 this.expandToolStripMenuItem.Click += new System.EventHandler(this.expandToolStripMenuItem_Click); 272 // 273 // expandAllToolStripMenuItem 274 // 275 this.expandAllToolStripMenuItem.Name = "expandAllToolStripMenuItem"; 276 this.expandAllToolStripMenuItem.Size = new System.Drawing.Size(152, 22); 277 this.expandAllToolStripMenuItem.Text = "Expand All"; 278 this.expandAllToolStripMenuItem.Click += new System.EventHandler(this.expandAllToolStripMenuItem_Click); 279 // 280 // collapseToolStripMenuItem 281 // 282 this.collapseToolStripMenuItem.Name = "collapseToolStripMenuItem"; 283 this.collapseToolStripMenuItem.Size = new System.Drawing.Size(152, 22); 284 this.collapseToolStripMenuItem.Text = "Collapse"; 285 this.collapseToolStripMenuItem.Click += new System.EventHandler(this.collapseToolStripMenuItem_Click); 286 // 287 // collapseAllToolStripMenuItem 288 // 289 this.collapseAllToolStripMenuItem.Name = "collapseAllToolStripMenuItem"; 290 this.collapseAllToolStripMenuItem.Size = new System.Drawing.Size(152, 22); 291 this.collapseAllToolStripMenuItem.Text = "Collapse All"; 292 this.collapseAllToolStripMenuItem.Click += new System.EventHandler(this.collapseAllToolStripMenuItem_Click); 248 293 // 249 294 // NewItemDialog … … 276 321 this.descriptionGroupBox.ResumeLayout(false); 277 322 this.descriptionGroupBox.PerformLayout(); 323 this.contextMenuStrip.ResumeLayout(false); 278 324 this.ResumeLayout(false); 279 325 … … 297 343 private System.Windows.Forms.TextBox versionTextBox; 298 344 private System.Windows.Forms.TextBox pluginTextBox; 345 private System.Windows.Forms.ContextMenuStrip contextMenuStrip; 346 private System.Windows.Forms.ToolStripMenuItem expandToolStripMenuItem; 347 private System.Windows.Forms.ToolStripMenuItem expandAllToolStripMenuItem; 348 private System.Windows.Forms.ToolStripMenuItem collapseToolStripMenuItem; 349 private System.Windows.Forms.ToolStripMenuItem collapseAllToolStripMenuItem; 299 350 } 300 351 } -
branches/NewItemDialog/HeuristicLab.Optimizer/3.3/NewItemDialog.cs
r12205 r12206 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing; 24 25 using System.Linq; 25 26 using System.Windows.Forms; … … 101 102 } 102 103 private void NewItemDialog_Shown(object sender, EventArgs e) { 103 SelectedType = null; 104 searchTextBox.Text = string.Empty; 105 searchTextBox.Focus(); 104 106 } 105 107 … … 263 265 typesTreeView.CollapseAll(); 264 266 } 267 268 private TreeNode toolStripMenuNode = null; 269 private void typesTreeView_MouseDown(object sender, MouseEventArgs e) { 270 if (e.Button == MouseButtons.Right) { 271 Point coordinates = typesTreeView.PointToClient(Cursor.Position); 272 toolStripMenuNode = typesTreeView.GetNodeAt(coordinates); 273 274 if (toolStripMenuNode != null && coordinates.X >= toolStripMenuNode.Bounds.Left && 275 coordinates.X <= toolStripMenuNode.Bounds.Right) { 276 typesTreeView.SelectedNode = toolStripMenuNode; 277 278 expandToolStripMenuItem.Enabled = 279 expandToolStripMenuItem.Visible = !toolStripMenuNode.IsExpanded && toolStripMenuNode.Nodes.Count > 0; 280 collapseToolStripMenuItem.Enabled = collapseToolStripMenuItem.Visible = toolStripMenuNode.IsExpanded; 281 } else { 282 expandToolStripMenuItem.Enabled = expandToolStripMenuItem.Visible = false; 283 collapseToolStripMenuItem.Enabled = collapseToolStripMenuItem.Visible = false; 284 } 285 expandAllToolStripMenuItem.Enabled = 286 expandAllToolStripMenuItem.Visible = 287 !typesTreeView.Nodes.OfType<TreeNode>().All(x => TreeNodeIsFullyExpanded(x)); 288 collapseAllToolStripMenuItem.Enabled = 289 collapseAllToolStripMenuItem.Visible = typesTreeView.Nodes.OfType<TreeNode>().Any(x => x.IsExpanded); 290 if (contextMenuStrip.Items.Cast<ToolStripMenuItem>().Any(item => item.Enabled)) 291 contextMenuStrip.Show(Cursor.Position); 292 } 293 } 294 private bool TreeNodeIsFullyExpanded(TreeNode node) { 295 return (node.Nodes.Count == 0) || (node.IsExpanded && node.Nodes.OfType<TreeNode>().All(x => TreeNodeIsFullyExpanded(x))); 296 } 297 298 private void expandToolStripMenuItem_Click(object sender, EventArgs e) { 299 if (toolStripMenuNode != null) toolStripMenuNode.ExpandAll(); 300 } 301 private void expandAllToolStripMenuItem_Click(object sender, EventArgs e) { 302 typesTreeView.ExpandAll(); 303 } 304 private void collapseToolStripMenuItem_Click(object sender, EventArgs e) { 305 if (toolStripMenuNode != null) toolStripMenuNode.Collapse(); 306 } 307 private void collapseAllToolStripMenuItem_Click(object sender, EventArgs e) { 308 typesTreeView.CollapseAll(); 309 } 265 310 } 266 311 }
Note: See TracChangeset
for help on using the changeset viewer.