Changeset 10628
- Timestamp:
- 03/19/14 14:24:40 (11 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/HeuristicLab.DataPreprocessing.Views-3.3.csproj
r10614 r10628 97 97 </Compile> 98 98 <Compile Include="Plugin.cs" /> 99 <Compile Include="PreprocessingCheckedItemListView.cs"> 100 <SubType>UserControl</SubType> 101 </Compile> 102 <Compile Include="PreprocessingCheckedItemListView.Designer.cs"> 103 <DependentUpon>PreprocessingCheckedItemListView.cs</DependentUpon> 104 </Compile> 99 105 <Compile Include="PreprocessingDataTableView.cs"> 100 106 <SubType>UserControl</SubType> -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/LineChartView.Designer.cs
r10558 r10628 20 20 #endregion 21 21 22 using HeuristicLab.Data; 22 23 namespace HeuristicLab.DataPreprocessing.Views { 23 24 partial class LineChartView { … … 46 47 private void InitializeComponent() { 47 48 this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 48 this.variablesListBox = new System.Windows.Forms.CheckedListBox();49 this.groupBoxAttributs = new System.Windows.Forms.GroupBox();50 49 this.groupBoxOptions = new System.Windows.Forms.GroupBox(); 51 this. groupBoxAttributs.SuspendLayout();50 this.checkedItemList = new HeuristicLab.DataPreprocessing.Views.PreprocessingCheckedItemListView(); 52 51 this.SuspendLayout(); 53 52 // 54 53 // viewHost 55 54 // 56 this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 57 | System.Windows.Forms.AnchorStyles.Left) 55 this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 56 | System.Windows.Forms.AnchorStyles.Left) 58 57 | System.Windows.Forms.AnchorStyles.Right))); 59 58 this.viewHost.Caption = "View"; … … 68 67 this.viewHost.ViewType = null; 69 68 // 70 // variablesListBox71 //72 this.variablesListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)73 | System.Windows.Forms.AnchorStyles.Left)74 | System.Windows.Forms.AnchorStyles.Right)));75 this.variablesListBox.FormattingEnabled = true;76 this.variablesListBox.Location = new System.Drawing.Point(6, 19);77 this.variablesListBox.Name = "variablesListBox";78 this.variablesListBox.Size = new System.Drawing.Size(141, 229);79 this.variablesListBox.TabIndex = 1;80 this.variablesListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.variablesListBox_ItemCheck);81 //82 // groupBoxAttributs83 //84 this.groupBoxAttributs.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)85 | System.Windows.Forms.AnchorStyles.Left)));86 this.groupBoxAttributs.Controls.Add(this.variablesListBox);87 this.groupBoxAttributs.Location = new System.Drawing.Point(3, 4);88 this.groupBoxAttributs.Name = "groupBoxAttributs";89 this.groupBoxAttributs.Size = new System.Drawing.Size(153, 252);90 this.groupBoxAttributs.TabIndex = 2;91 this.groupBoxAttributs.TabStop = false;92 this.groupBoxAttributs.Text = "Attributes";93 //94 69 // groupBoxOptions 95 70 // … … 102 77 this.groupBoxOptions.Text = "Options"; 103 78 // 79 // checkedItemList 80 // 81 this.checkedItemList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 82 | System.Windows.Forms.AnchorStyles.Left))); 83 this.checkedItemList.Caption = "View"; 84 this.checkedItemList.Content = null; 85 this.checkedItemList.Location = new System.Drawing.Point(4, 4); 86 this.checkedItemList.Name = "checkedItemList"; 87 this.checkedItemList.ReadOnly = false; 88 this.checkedItemList.Size = new System.Drawing.Size(152, 252); 89 this.checkedItemList.TabIndex = 4; 90 // 104 91 // LineChartView 105 92 // 106 93 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 107 94 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 95 this.Controls.Add(this.checkedItemList); 108 96 this.Controls.Add(this.groupBoxOptions); 109 this.Controls.Add(this.groupBoxAttributs);110 97 this.Controls.Add(this.viewHost); 111 98 this.Name = "LineChartView"; 112 99 this.Size = new System.Drawing.Size(654, 403); 113 this.groupBoxAttributs.ResumeLayout(false);114 100 this.ResumeLayout(false); 115 101 … … 119 105 120 106 private MainForm.WindowsForms.ViewHost viewHost; 121 private System.Windows.Forms.CheckedListBox variablesListBox;122 private System.Windows.Forms.GroupBox groupBoxAttributs;123 107 private System.Windows.Forms.GroupBox groupBoxOptions; 108 private PreprocessingCheckedItemListView checkedItemList; 124 109 } 125 110 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/LineChartView.cs
r10573 r10628 21 21 22 22 using System.Windows.Forms; 23 using HeuristicLab.Analysis; 24 using HeuristicLab.Collections; 25 using HeuristicLab.Core; 23 26 using HeuristicLab.Core.Views; 27 using HeuristicLab.Data; 24 28 using HeuristicLab.MainForm; 25 29 … … 30 34 public partial class LineChartView : ItemView { 31 35 36 private ILineChartLogic logic; 37 private DataTable dataTable; 38 private ICheckedItemList<StringValue> itemList; 39 private const string LINE_CHART_TITLE = "LineChart"; 40 32 41 public LineChartView() { 33 42 InitializeComponent(); 34 43 } 35 44 45 private void CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<StringValue>> checkedItems) { 46 foreach(IndexedItem<StringValue> item in checkedItems.Items) 47 { 48 string variableName = item.Value.Value; 49 if (VariableIsDisplayed(variableName)) { 50 dataTable.Rows.Remove(variableName); 51 } else { 52 dataTable.Rows.Add(logic.CreateDataRow(variableName)); 53 } 54 } 55 } 56 57 public bool VariableIsDisplayed(string name) { 58 59 foreach (var item in dataTable.Rows) { 60 if (item.Name == name) 61 return true; 62 } 63 return false; 64 } 65 36 66 private void InitDataTable() { 37 ILineChartLogic logic = Content.LineChartLogic; 38 viewHost.Content = logic.GetDataTable(); 67 dataTable = logic.CreateDataTable(LINE_CHART_TITLE); 68 viewHost.Content = dataTable; 69 } 70 71 private void InitVariablesListBox() { 72 itemList = logic.CreateVariableItemList(); 73 checkedItemList.Content = itemList; 39 74 } 40 75 … … 61 96 base.OnContentChanged(); 62 97 if (Content != null) { 98 logic = Content.LineChartLogic; 63 99 InitDataTable(); 64 100 InitVariablesListBox(); 101 itemList.CheckedItemsChanged += CheckedItemsChanged; 102 logic.Changed += PreprocessingData_Changed; 65 103 } 66 104 } 67 105 68 private void InitVariablesListBox() { 69 ILineChartLogic logic = Content.LineChartLogic; 70 71 foreach (var variableName in logic.GetVariableNames()) { 72 variablesListBox.Items.Add(variableName, true); 106 //TODO: refactor: possible code duplication with HistogramLogic 107 void PreprocessingData_Changed(object sender, DataPreprocessingChangedEventArgs e) { 108 switch (e.Type) { 109 case DataPreprocessingChangedEventType.DeleteColumn: 110 RemoveVariable(logic.GetVariableNameByIndex(e.Column)); 111 break; 112 case DataPreprocessingChangedEventType.AddColumn: 113 AddVariable(logic.GetVariableNameByIndex(e.Column)); 114 break; 115 case DataPreprocessingChangedEventType.ChangeColumn: 116 case DataPreprocessingChangedEventType.ChangeItem: 117 dataTable.Rows.Remove(logic.GetVariableNameByIndex(e.Column)); 118 dataTable.Rows.Add(logic.CreateDataRow((logic.GetVariableNameByIndex(e.Column)))); 119 break; 120 case DataPreprocessingChangedEventType.DeleteRow: 121 case DataPreprocessingChangedEventType.AddRow: 122 InitDataTable(); 123 break; 73 124 } 74 125 } 75 126 76 private void variablesListBox_ItemCheck(object sender, ItemCheckEventArgs e) { 77 string item = variablesListBox.Items[e.Index] as string; 127 // add variable to data table and item list 128 private void AddVariable(string name) { 129 dataTable.Rows.Add(logic.CreateDataRow(name)); 130 itemList.Add(new StringValue(name)); 131 } 132 133 // remove variable from data table and item list 134 private void RemoveVariable(string name) { 135 dataTable.Rows.Remove(name); 136 137 StringValue stringValue = FindVariableItemList(name); 138 if (stringValue != null) 139 itemList.Remove(stringValue); 140 141 } 142 143 private StringValue FindVariableItemList(string name) { 144 foreach (StringValue stringValue in itemList) { 145 if (stringValue.Value == name) 146 return stringValue; 147 } 148 return null; 149 } 78 150 79 151 80 if (e.NewValue == CheckState.Checked && !Content.LineChartLogic.VariableIsDisplayed(item))81 Content.LineChartLogic.AddVariable(item);82 else if (e.NewValue == CheckState.Unchecked && Content.LineChartLogic.VariableIsDisplayed(item))83 Content.LineChartLogic.RemoveVariable(item);84 }85 152 } 86 153 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/LineChartLogic.cs
r10586 r10628 23 23 using System.Collections.Generic; 24 24 using HeuristicLab.Analysis; 25 using HeuristicLab.Core; 26 using HeuristicLab.Data; 25 27 26 28 namespace HeuristicLab.DataPreprocessing { 27 29 public class LineChartLogic : ILineChartLogic { 30 28 31 private ITransactionalPreprocessingData preprocessingData; 29 private DataTable dataTable;30 32 31 33 public LineChartLogic(ITransactionalPreprocessingData preprocessingData) { 32 34 this.preprocessingData = preprocessingData; 33 dataTable = new DataTable("LineChart");34 FillDataTable();35 preprocessingData.Changed += PreprocessingData_Changed;36 35 } 37 36 38 private void FillDataTable() { 39 IEnumerable<string> variableNames = preprocessingData.VariableNames; 37 public DataTable CreateDataTable(String title) { 38 DataTable dataTable = new DataTable(title); 39 IEnumerable<string> variableNames = GetVariableNames(); 40 40 41 41 foreach (string variableName in variableNames) { 42 IList<double> values = preprocessingData.GetValues<double>(variableName); 43 DataRow row = new DataRow(variableName, "", values); 42 DataRow row = CreateDataRow(variableName); 44 43 dataTable.Rows.Add(row); 45 44 } 46 45 return dataTable; 47 46 } 48 47 49 public IEnumerable<object> GetVariableNames() { 48 public DataRow CreateDataRow(string variableName) { 49 IList<double> values = preprocessingData.GetValues<double>(variableName); 50 DataRow row = new DataRow(variableName, "", values); 51 return row; 52 } 53 54 private IEnumerable<string> GetVariableNames() { 50 55 List<string> doubleVariableNames = new List<string>(); 51 56 … … 59 64 } 60 65 61 public DataTable GetDataTable() { 62 return dataTable; 63 } 64 65 public void RemoveVariable(string name) { 66 dataTable.Rows.Remove(name); 67 } 68 69 public void AddVariable(string name) { 70 IList<double> values = preprocessingData.GetValues<double>(name); 71 DataRow row = new DataRow(name, "", values); 72 dataTable.Rows.Add(row); 73 } 74 75 public bool VariableIsDisplayed(string name) { 76 77 foreach (var item in dataTable.Rows) { 78 if (item.Name == name) 79 return true; 66 public ICheckedItemList<StringValue> CreateVariableItemList() { 67 ICheckedItemList<StringValue> itemList = new CheckedItemList<StringValue>(); 68 foreach (string name in GetVariableNames()) { 69 itemList.Add(new StringValue(name), true); 80 70 } 81 return false; 82 } 83 84 //TODO: refactor: possible code duplication with HistogramLogic 85 void PreprocessingData_Changed(object sender, DataPreprocessingChangedEventArgs e) { 86 switch (e.Type) { 87 case DataPreprocessingChangedEventType.DeleteColumn: 88 dataTable.Rows.Remove(preprocessingData.GetVariableName(e.Column)); 89 break; 90 case DataPreprocessingChangedEventType.AddColumn: 91 dataTable.Rows.Add(new DataRow(preprocessingData.GetVariableName(e.Column), String.Empty, preprocessingData.GetValues<double>(e.Column))); 92 break; 93 case DataPreprocessingChangedEventType.ChangeColumn: 94 case DataPreprocessingChangedEventType.ChangeItem: 95 dataTable.Rows.Remove(preprocessingData.GetVariableName(e.Column)); 96 dataTable.Rows.Add(new DataRow(preprocessingData.GetVariableName(e.Column), String.Empty, preprocessingData.GetValues<double>(e.Column))); 97 break; 98 case DataPreprocessingChangedEventType.DeleteRow: 99 case DataPreprocessingChangedEventType.AddRow: 100 dataTable.Rows.Clear(); 101 FillDataTable(); 102 break; 103 } 71 return new ReadOnlyCheckedItemList<StringValue>(itemList); 104 72 } 105 73 … … 108 76 remove { preprocessingData.Changed -= value; } 109 77 } 78 79 public string GetVariableNameByIndex(int index) { 80 return preprocessingData.GetVariableName(index); 81 } 82 110 83 } 111 84 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/ILineChartLogic.cs
r10573 r10628 22 22 using System.Collections.Generic; 23 23 using HeuristicLab.Analysis; 24 using HeuristicLab.Core; 25 using HeuristicLab.Data; 24 26 25 27 namespace HeuristicLab.DataPreprocessing { 26 28 public interface ILineChartLogic { 27 29 28 void RemoveVariable(string name); 29 30 void AddVariable(string name); 31 32 IEnumerable<object> GetVariableNames(); 33 34 DataTable GetDataTable(); 35 36 bool VariableIsDisplayed(string name); 30 DataTable CreateDataTable(string title); 37 31 38 32 event DataPreprocessingChangedEventHandler Changed; 33 34 ICheckedItemList<StringValue> CreateVariableItemList(); 35 36 DataRow CreateDataRow(string variableName); 37 38 string GetVariableNameByIndex(int index); 39 39 } 40 40 }
Note: See TracChangeset
for help on using the changeset viewer.