Changeset 7538 for branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3
- Timestamp:
- 03/01/12 15:15:22 (13 years ago)
- Location:
- branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/Plugin.cs.frame
r7363 r7538 25 25 [Plugin("HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views", "3.3.6.$WCREV$")] 26 26 [PluginFile("HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views-3.3.dll", PluginFileType.Assembly)] 27 [PluginDependency("HeuristicLab.Collections", "3.3")] 27 28 [PluginDependency("HeuristicLab.Common", "3.3")] 28 29 [PluginDependency("HeuristicLab.Common.Resources", "3.3")] … … 30 31 [PluginDependency("HeuristicLab.Core.Views", "3.3")] 31 32 [PluginDependency("HeuristicLab.Data", "3.3")] 33 [PluginDependency("HeuristicLab.Data.Views", "3.3")] 32 34 [PluginDependency("HeuristicLab.Encodings.IntegerVectorEncoding", "3.3")] 33 35 [PluginDependency("HeuristicLab.MainForm", "3.3")] … … 37 39 [PluginDependency("HeuristicLab.Parameters", "3.3")] 38 40 [PluginDependency("HeuristicLab.Problems.GeneralizedQuadraticAssignment", "3.3")] 41 [PluginDependency("HeuristicLab.Problems.Instances", "3.3")] 42 [PluginDependency("HeuristicLab.Visualization.ChartControlsExtensions", "3.3")] 39 43 public class HeuristicLabProblemsGeneralizedQuadraticAssignmentViewsPlugin : PluginBase { 40 44 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ProblemInstanceProviderView.Designer.cs
r7523 r7538 21 21 22 22 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views { 23 partial class ProblemInstanceProviderView {23 partial class ProblemInstanceProviderView<T> { 24 24 /// <summary> 25 25 /// Required designer variable. … … 48 48 this.label2 = new System.Windows.Forms.Label(); 49 49 this.instancesComboBox = new System.Windows.Forms.ComboBox(); 50 this.importButton = new System.Windows.Forms.Button(); 51 this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); 50 52 this.SuspendLayout(); 51 53 // … … 53 55 // 54 56 this.loadButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 55 this.loadButton.Location = new System.Drawing.Point( 535, -1);57 this.loadButton.Location = new System.Drawing.Point(451, -1); 56 58 this.loadButton.Name = "loadButton"; 57 59 this.loadButton.Size = new System.Drawing.Size(75, 23); … … 78 80 this.instancesComboBox.Location = new System.Drawing.Point(54, 0); 79 81 this.instancesComboBox.Name = "instancesComboBox"; 80 this.instancesComboBox.Size = new System.Drawing.Size( 475, 21);82 this.instancesComboBox.Size = new System.Drawing.Size(391, 21); 81 83 this.instancesComboBox.TabIndex = 7; 82 84 this.instancesComboBox.DataSourceChanged += new System.EventHandler(this.comboBox_DataSourceChanged); 85 // 86 // importButton 87 // 88 this.importButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 89 this.importButton.Location = new System.Drawing.Point(532, -1); 90 this.importButton.Name = "importButton"; 91 this.importButton.Size = new System.Drawing.Size(75, 23); 92 this.importButton.TabIndex = 6; 93 this.importButton.Text = "Import"; 94 this.importButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; 95 this.importButton.UseVisualStyleBackColor = true; 96 this.importButton.Click += new System.EventHandler(this.importButton_Click); 97 // 98 // openFileDialog 99 // 100 this.openFileDialog.Filter = "All files|*.*"; 83 101 // 84 102 // ProblemInstanceProviderView … … 87 105 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 88 106 this.Controls.Add(this.instancesComboBox); 107 this.Controls.Add(this.importButton); 89 108 this.Controls.Add(this.loadButton); 90 109 this.Controls.Add(this.label2); … … 101 120 private System.Windows.Forms.Label label2; 102 121 private System.Windows.Forms.ComboBox instancesComboBox; 122 private System.Windows.Forms.Button importButton; 123 private System.Windows.Forms.OpenFileDialog openFileDialog; 103 124 104 125 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ProblemInstanceProviderView.cs
r7505 r7538 23 23 using System.Linq; 24 24 using System.Windows.Forms; 25 using HeuristicLab.Common.Resources; 25 26 using HeuristicLab.MainForm; 26 27 using HeuristicLab.MainForm.WindowsForms; … … 29 30 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views { 30 31 [View("ProblemInstanceProviderView")] 31 [Content(typeof(IProblemInstanceProvider ), IsDefaultView = true)]32 public partial class ProblemInstanceProviderView : AsynchronousContentView {32 [Content(typeof(IProblemInstanceProvider<>), IsDefaultView = true)] 33 public partial class ProblemInstanceProviderView<T> : AsynchronousContentView { 33 34 34 public new IProblemInstanceProvider Content {35 get { return (IProblemInstanceProvider )base.Content; }35 public new IProblemInstanceProvider<T> Content { 36 get { return (IProblemInstanceProvider<T>)base.Content; } 36 37 set { base.Content = value; } 37 38 } … … 39 40 public ProblemInstanceProviderView() { 40 41 InitializeComponent(); 42 importButton.Image = VSImageLibrary.Open; 41 43 } 42 44 … … 53 55 protected override void SetEnabledStateOfControls() { 54 56 base.SetEnabledStateOfControls(); 55 instancesComboBox.Enabled = !ReadOnly && !Locked && Content != null && Content.Consumer CanBeFed;56 loadButton.Enabled = !ReadOnly && !Locked && Content != null && Content.Consumer CanBeFed;57 instancesComboBox.Enabled = !ReadOnly && !Locked && Content != null && Content.Consumer != null; 58 loadButton.Enabled = !ReadOnly && !Locked && Content != null && Content.Consumer != null; 57 59 } 58 60 59 61 private void loadButton_Click(object sender, EventArgs e) { 60 var instance = (IInstanceDescriptor)instancesComboBox.SelectedItem; 61 if (!Content.FeedConsumer(instance)) { 62 MessageBox.Show("This problem does not support loading the instance " + instance.Name + ".", "Cannot load instance"); 62 var descriptor = (IInstanceDescriptor)instancesComboBox.SelectedItem; 63 var instance = Content.LoadInstance(descriptor); 64 if (!Content.Consumer.LoadFrom(instance)) { 65 MessageBox.Show("This problem does not support loading the instance " + descriptor.Name + ".", "Cannot load instance"); 66 } 67 } 68 69 private void importButton_Click(object sender, EventArgs e) { 70 if (openFileDialog.ShowDialog() == DialogResult.OK) { 71 T instance = default(T); 72 try { 73 instance = Content.LoadInstance(openFileDialog.FileName); 74 } catch { 75 MessageBox.Show("There was an error parsing the file.", "Error while parsing", MessageBoxButtons.OK, MessageBoxIcon.Error); 76 return; 77 } 78 try { 79 if (!Content.Consumer.LoadFrom(instance)) { 80 MessageBox.Show("This problem does not support loading the instance in the file.", "Cannot load instance", MessageBoxButtons.OK, MessageBoxIcon.Error); 81 } 82 } catch { 83 MessageBox.Show("There was an error while importing the file."); 84 } 63 85 } 64 86 } … … 69 91 comboBox.Items.Clear(); 70 92 } 71 72 private void instancesComboBox_ToolTipRequired(object sender, ToolTipRequiredEventArgs e) {73 var instance = (IInstanceDescriptor)instancesComboBox.SelectedItem;74 e.ToolTip = instance.Description;75 }76 93 } 77 94 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ProblemInstanceProviderView.resx
r7448 r7538 118 118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 119 119 </resheader> 120 <metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 121 <value>17, 17</value> 122 </metadata> 120 123 </root> -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ProblemView.Designer.cs
r7482 r7538 103 103 // problemInstanceProviderComboBox 104 104 // 105 this.problemInstanceProviderComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDraw Fixed;105 this.problemInstanceProviderComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable; 106 106 this.problemInstanceProviderComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 107 this.problemInstanceProviderComboBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 107 108 this.problemInstanceProviderComboBox.FormattingEnabled = true; 108 109 this.problemInstanceProviderComboBox.Location = new System.Drawing.Point(50, 5); 110 this.problemInstanceProviderComboBox.MaxDropDownItems = 16; 109 111 this.problemInstanceProviderComboBox.Name = "problemInstanceProviderComboBox"; 110 112 this.problemInstanceProviderComboBox.Size = new System.Drawing.Size(173, 21); -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ProblemView.cs
r7523 r7538 63 63 if (problemInstanceProviderComboBox.SelectedIndex >= 0) { 64 64 var provider = (IProblemInstanceProvider)problemInstanceProviderComboBox.SelectedItem; 65 provider.SetConsumer((IProblemInstanceConsumer)Content); 65 var genericType = provider.GetType().GetInterfaces().Single(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IProblemInstanceProvider<>)).GetGenericArguments().First(); 66 this.GetType().GetMethod("SetConsumable").MakeGenericMethod(genericType).Invoke(this, new object[] { provider, Content }); 66 67 problemInstanceProviderViewHost.Content = provider; 67 68 } 69 } 70 71 /// <summary> 72 /// Do not change method name without changing the string reference above 73 /// </summary> 74 private void SetConsumable<T>(IProblemInstanceProvider<T> producer, IConsumable<T> consumer) { 75 producer.Consumer = consumer; 68 76 } 69 77 … … 77 85 var consumerTypes = Content.GetType().GetInterfaces() 78 86 .Where(x => x.IsGenericType 79 && typeof(IProblemInstanceConsumer).IsAssignableFrom(x));87 && x.GetGenericTypeDefinition() == typeof(IConsumable<>)); 80 88 81 89 if (consumerTypes.Any()) { -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ToolTipComboBox.Designer.cs
r7482 r7538 48 48 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 49 49 this.SuspendLayout(); 50 // 51 // ToolTipComboBox 52 // 53 this.MaxDropDownItems = 16; 50 54 this.ResumeLayout(false); 51 55 -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/ToolTipComboBox.cs
r7523 r7538 29 29 30 30 private ComboBoxState comboBoxState = ComboBoxState.Normal; 31 private bool mouseOver = false;32 31 33 32 public ToolTipComboBox() … … 36 35 SetStyle(ControlStyles.UserPaint, true); 37 36 InitializeComponent(); 38 DrawMode = System.Windows.Forms.DrawMode.OwnerDraw Variable;37 DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; 39 38 DropDownStyle = ComboBoxStyle.DropDownList; 40 }41 42 protected override void OnMeasureItem(MeasureItemEventArgs e) {43 base.OnMeasureItem(e);44 string text = GetItemText(Items[e.Index]);45 if (string.IsNullOrEmpty(text)) text = "test";46 var rect = TextRenderer.MeasureText(text, Font);47 e.ItemHeight = rect.Height - 2;48 e.ItemWidth = rect.Width;49 39 } 50 40 … … 72 62 } else { 73 63 using (var b = new SolidBrush(ForeColor)) { 74 Rectangle r = e.Bounds; 75 r.Offset(0, 1); 76 e.Graphics.DrawString(GetItemText(Items[e.Index]), Font, b, r); 64 var rect = new Rectangle(2, 4, Size.Width - 2, Size.Height - 4); 65 e.Graphics.DrawString(GetItemText(Items[e.Index]), Font, b, rect); 77 66 } 78 67 } … … 84 73 base.OnPaint(e); 85 74 if (Enabled == false) comboBoxState = ComboBoxState.Disabled; 86 Rectangle clip = Bounds; // using e.ClipRectangle leads to strange behavior when maximizing/unmaximizing, just redraw the entire region all the time87 clip. Offset(-clip.X, -clip.Y); // x and y need to be 075 Rectangle clip = new Rectangle(new Point(0, 0), Size); 76 clip.Inflate(0, 1); 88 77 if (VisualStyleInformation.IsSupportedByOS && VisualStyleInformation.IsEnabledByUser) { 89 78 PushButtonState pb_State = PushButtonState.Normal; … … 109 98 ComboBoxRenderer.DrawDropDownButton(e.Graphics, r, comboBoxState); 110 99 } 111 Rectangle rect = clip; 112 rect.Inflate(-2, -4); 113 rect.Offset(1, 0); 100 var rect = new Rectangle(2, 4, Size.Width - 2, Size.Height - 4); 114 101 if (SelectedIndex > -1 && Items.Count > 0) { 115 102 using (var b = new SolidBrush(ForeColor)) { … … 141 128 protected override void OnMouseEnter(EventArgs e) { 142 129 base.OnMouseEnter(e); 143 mouseOver = true;144 130 if (comboBoxState == ComboBoxState.Normal) { 145 131 comboBoxState = ComboBoxState.Hot; … … 158 144 protected override void OnMouseLeave(EventArgs e) { 159 145 base.OnMouseLeave(e); 160 mouseOver = false;161 146 if (comboBoxState == ComboBoxState.Hot) { 162 147 comboBoxState = ComboBoxState.Normal; … … 167 152 protected override void OnMouseDown(MouseEventArgs e) { 168 153 base.OnMouseDown(e); 169 comboBoxState = ComboBoxState.Pressed; 170 Invalidate(); 154 if (e.Button == MouseButtons.Left) { 155 comboBoxState = ComboBoxState.Pressed; 156 Invalidate(); 157 } 171 158 } 172 159
Note: See TracChangeset
for help on using the changeset viewer.