Changeset 8196
- Timestamp:
- 07/03/12 14:21:02 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.Instances.Views/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceProviderViewGeneric.Designer.cs
r8031 r8196 46 46 private void InitializeComponent() { 47 47 this.components = new System.ComponentModel.Container(); 48 this.loadButton = new System.Windows.Forms.Button();49 48 this.instanceLabel = new System.Windows.Forms.Label(); 50 49 this.instancesComboBox = new System.Windows.Forms.ComboBox(); 51 50 this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); 52 this.toolTip = new System.Windows.Forms.ToolTip(this.components);53 51 this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); 54 52 this.SuspendLayout(); 55 //56 // loadButton57 //58 this.loadButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));59 this.loadButton.Location = new System.Drawing.Point(667, -1);60 this.loadButton.Name = "loadButton";61 this.loadButton.Size = new System.Drawing.Size(24, 24);62 this.loadButton.TabIndex = 6;63 this.loadButton.Text = "Load";64 this.loadButton.UseVisualStyleBackColor = true;65 this.loadButton.Click += new System.EventHandler(this.loadButton_Click);66 53 // 67 54 // instanceLabel … … 76 63 // instancesComboBox 77 64 // 78 this.instancesComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 65 this.instancesComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 79 66 | System.Windows.Forms.AnchorStyles.Right))); 80 67 this.instancesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; … … 82 69 this.instancesComboBox.Location = new System.Drawing.Point(60, 1); 83 70 this.instancesComboBox.Name = "instancesComboBox"; 84 this.instancesComboBox.Size = new System.Drawing.Size(6 01, 21);71 this.instancesComboBox.Size = new System.Drawing.Size(632, 21); 85 72 this.instancesComboBox.TabIndex = 7; 86 73 this.instancesComboBox.DataSourceChanged += new System.EventHandler(this.instancesComboBox_DataSourceChanged); 87 this.instancesComboBox.Select edIndexChanged += new System.EventHandler(this.instancesComboBox_SelectedIndexChanged);74 this.instancesComboBox.SelectionChangeCommitted += new System.EventHandler(instancesComboBox_SelectionChangeCommitted); 88 75 // 89 76 // openFileDialog … … 102 89 this.Controls.Add(this.instanceLabel); 103 90 this.Controls.Add(this.instancesComboBox); 104 this.Controls.Add(this.loadButton);105 91 this.Name = "ProblemInstanceProviderViewGeneric"; 106 92 this.Size = new System.Drawing.Size(694, 21); … … 109 95 110 96 } 111 112 97 #endregion 113 98 114 99 protected System.Windows.Forms.OpenFileDialog openFileDialog; 115 protected System.Windows.Forms.ToolTip toolTip;116 protected System.Windows.Forms.Button loadButton;117 100 protected System.Windows.Forms.Label instanceLabel; 118 101 protected System.Windows.Forms.ComboBox instancesComboBox; -
trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceProviderViewGeneric.cs
r8031 r8196 24 24 using System.Linq; 25 25 using System.Windows.Forms; 26 using HeuristicLab.Common.Resources;27 26 using HeuristicLab.MainForm; 28 27 using HeuristicLab.MainForm.WindowsForms; … … 51 50 public ProblemInstanceProviderViewGeneric() { 52 51 InitializeComponent(); 53 loadButton.Text = String.Empty;54 loadButton.Image = VSImageLibrary.RefreshDocument;55 toolTip.SetToolTip(loadButton, "Load the selected problem.");56 52 } 57 53 … … 73 69 instanceLabel.Show(); 74 70 instancesComboBox.Show(); 75 loadButton.Show();76 71 } else { 77 72 instanceLabel.Hide(); 78 73 instancesComboBox.Hide(); 79 loadButton.Hide();80 74 } 81 75 } … … 84 78 base.SetEnabledStateOfControls(); 85 79 instancesComboBox.Enabled = !ReadOnly && !Locked && Content != null && GenericConsumer != null; 86 loadButton.Enabled = !ReadOnly && !Locked && Content != null && GenericConsumer != null && instancesComboBox.SelectedIndex >= 0;87 }88 89 protected virtual void loadButton_Click(object sender, EventArgs e) {90 var descriptor = (IDataDescriptor)instancesComboBox.SelectedItem;91 T instance = Content.LoadData(descriptor);92 try {93 GenericConsumer.Load(instance);94 }95 catch (Exception ex) {96 MessageBox.Show(String.Format("This problem does not support loading the instance {0}: {1}", descriptor.Name, Environment.NewLine + ex.Message), "Cannot load instance");97 }98 80 } 99 81 … … 104 86 } 105 87 106 private void instancesComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { 107 SetEnabledStateOfControls(); 88 private void instancesComboBox_SelectionChangeCommitted(object sender, System.EventArgs e) { 89 if (instancesComboBox.SelectedIndex >= 0) { 90 var descriptor = (IDataDescriptor)instancesComboBox.SelectedItem; 91 T instance = Content.LoadData(descriptor); 92 try { 93 GenericConsumer.Load(instance); 94 } 95 catch (Exception ex) { 96 MessageBox.Show(String.Format("This problem does not support loading the instance {0}: {1}", descriptor.Name, Environment.NewLine + ex.Message), "Cannot load instance"); 97 } 98 } 108 99 } 109 100 }
Note: See TracChangeset
for help on using the changeset viewer.