Changeset 2701
- Timestamp:
- 01/28/10 16:43:36 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.GP/3.3
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP/3.3/FunctionLibrary.cs
r2222 r2701 42 42 if (!functions.Contains(fun)) { 43 43 functions.Add(fun); 44 fun.Changed += new EventHandler(fun_Changed); 44 45 OnChanged(); 45 46 } … … 48 49 public void RemoveFunction(IFunction fun) { 49 50 functions.Remove(fun); 51 fun.Changed -= new EventHandler(fun_Changed); 50 52 51 53 // remove the operator from the allowed sub-functions of all functions … … 55 57 } 56 58 } 59 OnChanged(); 60 } 61 62 void fun_Changed(object sender, EventArgs e) { 57 63 OnChanged(); 58 64 } -
trunk/sources/HeuristicLab.GP/3.3/FunctionLibraryEditor.Designer.cs
r2222 r2701 47 47 this.tabControl = new System.Windows.Forms.TabControl(); 48 48 this.functionsTabPage = new System.Windows.Forms.TabPage(); 49 this.splitContainer = new System.Windows.Forms.SplitContainer(); 50 this.availableFunctionsGroupBox = new System.Windows.Forms.GroupBox(); 51 this.functionsListView = new System.Windows.Forms.ListView(); 52 this.removeButton = new System.Windows.Forms.Button(); 53 this.addButton = new System.Windows.Forms.Button(); 54 this.functionDetailsGroupBox = new System.Windows.Forms.GroupBox(); 55 this.functionDetailsPanel = new System.Windows.Forms.Panel(); 56 this.functionsComboBox = new System.Windows.Forms.ComboBox(); 49 57 this.initializationTabPage = new System.Windows.Forms.TabPage(); 50 58 this.initSplitContainer = new System.Windows.Forms.SplitContainer(); … … 55 63 this.mutationListView = new System.Windows.Forms.ListView(); 56 64 this.mutationVariableView = new HeuristicLab.Core.VariableView(); 57 this.addButton = new System.Windows.Forms.Button();58 this.removeButton = new System.Windows.Forms.Button();59 this.functionsListView = new System.Windows.Forms.ListView();60 65 this.tabControl.SuspendLayout(); 61 66 this.functionsTabPage.SuspendLayout(); 67 this.splitContainer.Panel1.SuspendLayout(); 68 this.splitContainer.Panel2.SuspendLayout(); 69 this.splitContainer.SuspendLayout(); 70 this.availableFunctionsGroupBox.SuspendLayout(); 71 this.functionDetailsGroupBox.SuspendLayout(); 62 72 this.initializationTabPage.SuspendLayout(); 63 73 this.initSplitContainer.Panel1.SuspendLayout(); … … 84 94 // functionsTabPage 85 95 // 86 this.functionsTabPage.Controls.Add(this.functionsListView); 87 this.functionsTabPage.Controls.Add(this.removeButton); 88 this.functionsTabPage.Controls.Add(this.addButton); 96 this.functionsTabPage.Controls.Add(this.splitContainer); 89 97 this.functionsTabPage.Location = new System.Drawing.Point(4, 22); 90 98 this.functionsTabPage.Name = "functionsTabPage"; … … 94 102 this.functionsTabPage.Text = "Functions"; 95 103 this.functionsTabPage.UseVisualStyleBackColor = true; 104 // 105 // splitContainer 106 // 107 this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill; 108 this.splitContainer.Location = new System.Drawing.Point(3, 3); 109 this.splitContainer.Name = "splitContainer"; 110 // 111 // splitContainer.Panel1 112 // 113 this.splitContainer.Panel1.Controls.Add(this.availableFunctionsGroupBox); 114 // 115 // splitContainer.Panel2 116 // 117 this.splitContainer.Panel2.Controls.Add(this.functionDetailsGroupBox); 118 this.splitContainer.Size = new System.Drawing.Size(663, 529); 119 this.splitContainer.SplitterDistance = 230; 120 this.splitContainer.TabIndex = 4; 121 // 122 // availableFunctionsGroupBox 123 // 124 this.availableFunctionsGroupBox.Controls.Add(this.functionsListView); 125 this.availableFunctionsGroupBox.Controls.Add(this.removeButton); 126 this.availableFunctionsGroupBox.Controls.Add(this.addButton); 127 this.availableFunctionsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; 128 this.availableFunctionsGroupBox.Location = new System.Drawing.Point(0, 0); 129 this.availableFunctionsGroupBox.Name = "availableFunctionsGroupBox"; 130 this.availableFunctionsGroupBox.Size = new System.Drawing.Size(230, 529); 131 this.availableFunctionsGroupBox.TabIndex = 5; 132 this.availableFunctionsGroupBox.TabStop = false; 133 this.availableFunctionsGroupBox.Text = "Available functions:"; 134 // 135 // functionsListView 136 // 137 this.functionsListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 138 | System.Windows.Forms.AnchorStyles.Left) 139 | System.Windows.Forms.AnchorStyles.Right))); 140 this.functionsListView.Location = new System.Drawing.Point(6, 19); 141 this.functionsListView.MultiSelect = false; 142 this.functionsListView.Name = "functionsListView"; 143 this.functionsListView.Size = new System.Drawing.Size(218, 475); 144 this.functionsListView.TabIndex = 3; 145 this.functionsListView.UseCompatibleStateImageBehavior = false; 146 this.functionsListView.View = System.Windows.Forms.View.List; 147 this.functionsListView.SelectedIndexChanged += new System.EventHandler(this.functionsListView_SelectedIndexChanged); 148 this.functionsListView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.functionsListView_ItemDrag); 149 // 150 // removeButton 151 // 152 this.removeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 153 this.removeButton.Location = new System.Drawing.Point(87, 500); 154 this.removeButton.Name = "removeButton"; 155 this.removeButton.Size = new System.Drawing.Size(75, 23); 156 this.removeButton.TabIndex = 2; 157 this.removeButton.Text = "Remove"; 158 this.removeButton.UseVisualStyleBackColor = true; 159 this.removeButton.Click += new System.EventHandler(this.removeButton_Click); 160 // 161 // addButton 162 // 163 this.addButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 164 this.addButton.Location = new System.Drawing.Point(6, 500); 165 this.addButton.Name = "addButton"; 166 this.addButton.Size = new System.Drawing.Size(75, 23); 167 this.addButton.TabIndex = 1; 168 this.addButton.Text = "Add..."; 169 this.addButton.UseVisualStyleBackColor = true; 170 this.addButton.Click += new System.EventHandler(this.addButton_Click); 171 // 172 // functionDetailsGroupBox 173 // 174 this.functionDetailsGroupBox.Controls.Add(this.functionDetailsPanel); 175 this.functionDetailsGroupBox.Controls.Add(this.functionsComboBox); 176 this.functionDetailsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; 177 this.functionDetailsGroupBox.Location = new System.Drawing.Point(0, 0); 178 this.functionDetailsGroupBox.Name = "functionDetailsGroupBox"; 179 this.functionDetailsGroupBox.Size = new System.Drawing.Size(429, 529); 180 this.functionDetailsGroupBox.TabIndex = 8; 181 this.functionDetailsGroupBox.TabStop = false; 182 this.functionDetailsGroupBox.Text = "Function details:"; 183 // 184 // functionDetailsPanel 185 // 186 this.functionDetailsPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 187 | System.Windows.Forms.AnchorStyles.Left) 188 | System.Windows.Forms.AnchorStyles.Right))); 189 this.functionDetailsPanel.Location = new System.Drawing.Point(6, 46); 190 this.functionDetailsPanel.Name = "functionDetailsPanel"; 191 this.functionDetailsPanel.Size = new System.Drawing.Size(417, 477); 192 this.functionDetailsPanel.TabIndex = 7; 193 // 194 // functionsComboBox 195 // 196 this.functionsComboBox.FormattingEnabled = true; 197 this.functionsComboBox.Location = new System.Drawing.Point(6, 19); 198 this.functionsComboBox.Name = "functionsComboBox"; 199 this.functionsComboBox.Size = new System.Drawing.Size(178, 21); 200 this.functionsComboBox.TabIndex = 0; 201 this.functionsComboBox.SelectedIndexChanged += new System.EventHandler(this.functionsComboBox_SelectedIndexChanged); 96 202 // 97 203 // initializationTabPage … … 194 300 this.mutationVariableView.Variable = null; 195 301 // 196 // addButton197 //198 this.addButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));199 this.addButton.Location = new System.Drawing.Point(6, 506);200 this.addButton.Name = "addButton";201 this.addButton.Size = new System.Drawing.Size(75, 23);202 this.addButton.TabIndex = 1;203 this.addButton.Text = "Add...";204 this.addButton.UseVisualStyleBackColor = true;205 this.addButton.Click += new System.EventHandler(this.addButton_Click);206 //207 // removeButton208 //209 this.removeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));210 this.removeButton.Location = new System.Drawing.Point(87, 506);211 this.removeButton.Name = "removeButton";212 this.removeButton.Size = new System.Drawing.Size(75, 23);213 this.removeButton.TabIndex = 2;214 this.removeButton.Text = "Remove";215 this.removeButton.UseVisualStyleBackColor = true;216 this.removeButton.Click += new System.EventHandler(this.removeButton_Click);217 //218 // functionsListView219 //220 this.functionsListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)221 | System.Windows.Forms.AnchorStyles.Left)222 | System.Windows.Forms.AnchorStyles.Right)));223 this.functionsListView.Location = new System.Drawing.Point(3, 6);224 this.functionsListView.Name = "functionsListView";225 this.functionsListView.Size = new System.Drawing.Size(660, 494);226 this.functionsListView.TabIndex = 3;227 this.functionsListView.UseCompatibleStateImageBehavior = false;228 this.functionsListView.SelectedIndexChanged += new System.EventHandler(this.functionsListView_SelectedIndexChanged);229 //230 302 // FunctionLibraryEditor 231 303 // … … 237 309 this.tabControl.ResumeLayout(false); 238 310 this.functionsTabPage.ResumeLayout(false); 311 this.splitContainer.Panel1.ResumeLayout(false); 312 this.splitContainer.Panel2.ResumeLayout(false); 313 this.splitContainer.ResumeLayout(false); 314 this.availableFunctionsGroupBox.ResumeLayout(false); 315 this.functionDetailsGroupBox.ResumeLayout(false); 239 316 this.initializationTabPage.ResumeLayout(false); 240 317 this.initSplitContainer.Panel1.ResumeLayout(false); … … 264 341 private System.Windows.Forms.Button addButton; 265 342 private System.Windows.Forms.ListView functionsListView; 343 private System.Windows.Forms.SplitContainer splitContainer; 344 private System.Windows.Forms.Panel functionDetailsPanel; 345 private System.Windows.Forms.ComboBox functionsComboBox; 346 private System.Windows.Forms.GroupBox availableFunctionsGroupBox; 347 private System.Windows.Forms.GroupBox functionDetailsGroupBox; 266 348 } 267 349 } -
trunk/sources/HeuristicLab.GP/3.3/FunctionLibraryEditor.cs
r2222 r2701 48 48 protected override void UpdateControls() { 49 49 base.UpdateControls(); 50 functionsListView.Clear(); 51 functionsComboBox.Items.Clear(); 50 52 foreach (IFunction fun in FunctionLibrary.Functions) { 53 functionsListView.Items.Add(CreateListViewItem(fun)); 54 functionsComboBox.Items.Add(fun); 51 55 if (fun.Manipulator != null) { 52 56 mutationListView.Items.Add(CreateListViewItem(fun)); … … 82 86 if (chooseFunctionDialog.ShowDialog(this) == DialogResult.OK) { 83 87 FunctionLibrary.AddFunction((IFunction)chooseFunctionDialog.Item); 84 functionsListView.Items.Add(CreateListViewItem((IFunction)chooseFunctionDialog.Item));85 functionsListView.Sort();86 88 } 87 89 } … … 89 91 private void removeButton_Click(object sender, EventArgs e) { 90 92 // delete from the end of the list 91 IEnumerable<int> removeIndices = functionsListView.SelectedIndices.OfType<int>().OrderBy(x => 1.0 / x);93 List<int> removeIndices = functionsListView.SelectedIndices.OfType<int>().OrderBy(x => 1.0 / x).ToList(); 92 94 foreach (int selectedIndex in removeIndices) { 93 FunctionLibrary.RemoveFunction((IFunction)functionsListView.Items[selectedIndex].Tag); 94 functionsListView.Items.RemoveAt(selectedIndex); 95 FunctionLibrary.RemoveFunction((IFunction)functionsListView.Items[selectedIndex].Tag); 95 96 } 96 97 } 97 98 98 99 private void functionsListView_SelectedIndexChanged(object sender, EventArgs e) { 99 removeButton.Enabled = functionsListView.SelectedIndices.Count > 0; 100 if (functionsListView.SelectedIndices.Count > 0) { 101 removeButton.Enabled = true; 102 } else { 103 removeButton.Enabled = false; 104 } 100 105 } 101 106 … … 107 112 return item; 108 113 } 114 115 private void functionsListView_ItemDrag(object sender, ItemDragEventArgs e) { 116 ListViewItem item = (ListViewItem)e.Item; 117 IFunction fun = (IFunction)item.Tag; 118 DataObject data = new DataObject(); 119 data.SetData("IFunction", fun); 120 data.SetData("DragSource", functionsListView); 121 DoDragDrop(data, DragDropEffects.Link); 122 } 123 124 private void functionsComboBox_SelectedIndexChanged(object sender, EventArgs e) { 125 if (functionsComboBox.SelectedItem != null) { 126 IFunction selectedFun = (IFunction)functionsComboBox.SelectedItem; 127 Control funView = (Control)selectedFun.CreateView(); 128 funView.Dock = DockStyle.Fill; 129 functionDetailsPanel.Controls.Clear(); 130 functionDetailsPanel.Controls.Add(funView); 131 } 132 } 109 133 } 110 134 } -
trunk/sources/HeuristicLab.GP/3.3/HeuristicLab.GP-3.3.csproj
r2629 r2701 83 83 <ItemGroup> 84 84 <Compile Include="BaseClasses\BinaryFunction.cs" /> 85 <Compile Include="BaseClasses\Function.cs" /> 85 86 <Compile Include="BaseClasses\FunctionLibraryInjectorBase.cs" /> 87 <Compile Include="BaseClasses\FunctionTree.cs" /> 86 88 <Compile Include="BaseClasses\TerminalTreeNode.cs" /> 87 <Compile Include="BaseClasses\FunctionBase.cs" />88 <Compile Include="BaseClasses\FunctionTreeBase.cs" />89 89 <Compile Include="BaseClasses\Terminal.cs" /> 90 90 <Compile Include="BaseClasses\UnaryFunction.cs" /> 91 <Compile Include="FunctionView.cs"> 92 <SubType>UserControl</SubType> 93 </Compile> 94 <Compile Include="FunctionView.Designer.cs"> 95 <DependentUpon>FunctionView.cs</DependentUpon> 96 </Compile> 91 97 <Compile Include="GeneticProgrammingModelView.cs"> 92 98 <SubType>UserControl</SubType> … … 132 138 </ItemGroup> 133 139 <ItemGroup> 140 <EmbeddedResource Include="FunctionView.resx"> 141 <DependentUpon>FunctionView.cs</DependentUpon> 142 </EmbeddedResource> 134 143 <EmbeddedResource Include="GeneticProgrammingModelView.resx"> 135 144 <DependentUpon>GeneticProgrammingModelView.cs</DependentUpon>
Note: See TracChangeset
for help on using the changeset viewer.