Changeset 3350
- Timestamp:
- 04/15/10 01:34:27 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs
r3341 r3350 69 69 Caption = "Item Collection"; 70 70 while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]); 71 itemsListView.Enabled = false;72 detailsGroupBox.Enabled = false;73 71 viewHost.Content = null; 74 addButton.Enabled = false;75 sortAscendingButton.Enabled = false;76 sortDescendingButton.Enabled = false;77 removeButton.Enabled = false;78 79 72 if (Content != null) { 80 73 Caption += " (" + Content.GetType().Name + ")"; 81 itemsListView.Enabled = true;82 addButton.Enabled = !Content.IsReadOnly;83 74 foreach (T item in Content) 84 75 AddListViewItem(CreateListViewItem(item)); 76 SortItemsListView(SortOrder.Ascending); 77 } 78 SetEnableStateOfControls(); 79 } 80 81 protected override void OnReadOnlyChanged() { 82 base.OnReadOnlyChanged(); 83 SetEnableStateOfControls(); 84 } 85 private void SetEnableStateOfControls() { 86 if (Content == null) { 87 itemsListView.Enabled = false; 88 detailsGroupBox.Enabled = false; 85 89 sortAscendingButton.Enabled = itemsListView.Items.Count > 0; 86 90 sortDescendingButton.Enabled = itemsListView.Items.Count > 0; 87 SortItemsListView(SortOrder.Ascending); 91 viewHost.Enabled = false; 92 addButton.Enabled = false; 93 removeButton.Enabled = false; 94 } else { 95 itemsListView.Enabled = true; 96 detailsGroupBox.Enabled = true; 97 sortAscendingButton.Enabled = true; 98 sortDescendingButton.Enabled = true; 99 viewHost.Enabled = true; 100 viewHost.ReadOnly = ReadOnly; 101 addButton.Enabled = !ReadOnly; 102 removeButton.Enabled = !ReadOnly; 88 103 } 89 104 } -
trunk/sources/HeuristicLab.Core.Views/3.3/NamedItemView.cs
r2917 r3350 66 66 Caption = "NamedItem"; 67 67 nameTextBox.Text = "-"; 68 nameTextBox.Enabled = false;69 68 descriptionTextBox.Text = ""; 70 descriptionTextBox.Enabled = false;71 69 toolTip.SetToolTip(descriptionTextBox, string.Empty); 72 70 } else { 73 71 Caption = Content.Name + " (" + Content.GetType().Name + ")"; 74 72 nameTextBox.Text = Content.Name; 75 nameTextBox.ReadOnly = !Content.CanChangeName; 73 descriptionTextBox.Text = Content.Description; 74 toolTip.SetToolTip(descriptionTextBox, Content.Description); 75 } 76 SetEnableStateOfControls(); 77 } 78 79 protected override void OnReadOnlyChanged() { 80 base.OnReadOnlyChanged(); 81 SetEnableStateOfControls(); 82 } 83 private void SetEnableStateOfControls() { 84 if (Content == null) { 85 nameTextBox.Enabled = false; 86 descriptionTextBox.Enabled = false; 87 } else { 76 88 nameTextBox.Enabled = true; 77 descriptionTextBox.Text = Content.Description; 78 descriptionTextBox.ReadOnly = !Content.CanChangeDescription; 89 nameTextBox.ReadOnly = ReadOnly || !Content.CanChangeName; ; 79 90 descriptionTextBox.Enabled = true; 80 toolTip.SetToolTip(descriptionTextBox, Content.Description);91 descriptionTextBox.ReadOnly = ReadOnly || !Content.CanChangeDescription; 81 92 } 82 93 } -
trunk/sources/HeuristicLab.Data.Views/3.3/BoolValueView.cs
r3317 r3350 58 58 Caption = "BoolValue View"; 59 59 valueCheckBox.Checked = false; 60 valueCheckBox.Enabled = false;61 60 } else { 62 61 Caption = Content.ToString() + " (" + Content.GetType().Name + ")"; 63 62 valueCheckBox.Checked = Content.Value; 64 valueCheckBox.Enabled = !Content.ReadOnlyView;65 63 } 64 SetEnableStateOfControls(); 65 } 66 67 protected override void OnReadOnlyChanged() { 68 base.OnReadOnlyChanged(); 69 SetEnableStateOfControls(); 70 } 71 private void SetEnableStateOfControls() { 72 if (Content == null) valueCheckBox.Enabled = false; 73 else valueCheckBox.Enabled = !ReadOnly; 66 74 } 67 75 -
trunk/sources/HeuristicLab.Data.Views/3.3/ComparisonView.cs
r3317 r3350 62 62 Caption = Content.ToString() + " (" + Content.GetType().Name + ")"; 63 63 valueComboBox.SelectedItem = Content.Value; 64 valueComboBox.Enabled = !Content.ReadOnlyView;65 64 } 65 SetEnableStateOfControls(); 66 } 67 protected override void OnReadOnlyChanged() { 68 base.OnReadOnlyChanged(); 69 SetEnableStateOfControls(); 70 } 71 private void SetEnableStateOfControls() { 72 if (Content == null) valueComboBox.Enabled = false; 73 else valueComboBox.Enabled = !ReadOnly; 66 74 } 67 75 -
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.cs
r3317 r3350 54 54 } 55 55 56 57 56 protected override void RegisterContentEvents() { 58 57 base.RegisterContentEvents(); … … 66 65 Caption = "StringConvertibleArray View"; 67 66 lengthTextBox.Text = ""; 68 lengthTextBox.Enabled = false;69 67 dataGridView.Rows.Clear(); 70 68 dataGridView.Columns.Clear(); 71 dataGridView.Enabled = false;72 69 } else { 73 70 Caption = "StringConvertibleArray (" + Content.GetType().Name + ")"; 74 71 UpdateData(); 72 } 73 SetEnableStateOfControls(); 74 } 75 protected override void OnReadOnlyChanged() { 76 base.OnReadOnlyChanged(); 77 SetEnableStateOfControls(); 78 } 79 private void SetEnableStateOfControls() { 80 if (Content == null) { 81 lengthTextBox.Enabled = false; 82 dataGridView.Enabled = false; 83 } else { 84 lengthTextBox.Enabled = true; 85 dataGridView.Enabled = true; 86 lengthTextBox.ReadOnly = ReadOnly; 87 dataGridView.ReadOnly = ReadOnly; 75 88 } 76 89 } -
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs
r3346 r3350 82 82 Caption = "StringConvertibleMatrix View"; 83 83 rowsTextBox.Text = ""; 84 rowsTextBox.Enabled = false;85 84 columnsTextBox.Text = ""; 86 columnsTextBox.Enabled = false;87 85 dataGridView.Rows.Clear(); 88 86 dataGridView.Columns.Clear(); 89 dataGridView.Enabled = false;90 87 virtualRowIndizes = new int[0]; 91 88 } else { 92 89 Caption = "StringConvertibleMatrix (" + Content.GetType().Name + ")"; 93 UpdateReadOnlyControls();94 90 UpdateData(); 91 } 92 SetEnableStateOfControls(); 93 } 94 protected override void OnReadOnlyChanged() { 95 base.OnReadOnlyChanged(); 96 SetEnableStateOfControls(); 97 } 98 private void SetEnableStateOfControls() { 99 if (Content == null) { 100 rowsTextBox.Enabled = false; 101 columnsTextBox.Enabled = false; 102 dataGridView.Enabled = false; 103 } else { 104 rowsTextBox.Enabled = true; 105 columnsTextBox.Enabled = true; 106 dataGridView.Enabled = true; 107 rowsTextBox.ReadOnly = ReadOnly; 108 columnsTextBox.ReadOnly = ReadOnly; 109 dataGridView.ReadOnly = ReadOnly; 95 110 } 96 111 } … … 338 353 339 354 foreach (KeyValuePair<int, SortOrder> pair in sortedIndizes.Where(p => p.Value != SortOrder.None)) { 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 355 string1 = matrix.GetValue(x, pair.Key); 356 string2 = matrix.GetValue(y, pair.Key); 357 if (double.TryParse(string1, out double1) && double.TryParse(string2, out double2)) 358 result = double1.CompareTo(double2); 359 else if (DateTime.TryParse(string1, out dateTime1) && DateTime.TryParse(string2, out dateTime2)) 360 result = dateTime1.CompareTo(dateTime2); 361 else { 362 if (string1 != null) 363 result = string1.CompareTo(string2); 364 else if (string2 != null) 365 result = string2.CompareTo(string1) * -1; 366 } 367 if (pair.Value == SortOrder.Descending) 368 result *= -1; 369 if (result != 0) 370 return result; 356 371 } 357 372 return result; -
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleValueView.cs
r3317 r3350 61 61 Caption = "StringConvertibleValue View"; 62 62 valueTextBox.Text = string.Empty; 63 valueTextBox.Enabled = false;64 63 } else { 65 64 Caption = Content.GetValue() + " (" + Content.GetType().Name + ")"; 66 65 valueTextBox.Text = Content.GetValue(); 67 valueTextBox.ReadOnly = Content.ReadOnlyView; 66 } 67 SetEnableStateOfControls(); 68 } 69 protected override void OnReadOnlyChanged() { 70 base.OnReadOnlyChanged(); 71 SetEnableStateOfControls(); 72 } 73 private void SetEnableStateOfControls() { 74 if (Content == null) valueTextBox.Enabled = false; 75 else { 68 76 valueTextBox.Enabled = true; 77 valueTextBox.ReadOnly = ReadOnly; 69 78 } 70 79 } -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/View.cs
r3301 r3350 31 31 this.isShown = false; 32 32 this.closeReason = CloseReason.None; 33 } 34 35 private string myCaption; 33 this.readOnly = false; 34 } 35 36 public View(bool readOnly) 37 : this() { 38 this.readOnly = readOnly; 39 } 40 41 private string caption; 36 42 public string Caption { 37 get { return myCaption; }43 get { return caption; } 38 44 set { 39 45 if (InvokeRequired) { … … 41 47 Invoke(action, value); 42 48 } else { 43 if (value != myCaption) {44 myCaption = value;49 if (value != caption) { 50 caption = value; 45 51 OnCaptionChanged(); 52 } 53 } 54 } 55 } 56 57 private bool readOnly; 58 public virtual bool ReadOnly { 59 get { return this.readOnly; } 60 set { 61 if (InvokeRequired) { 62 Action<bool> action = delegate(bool b) { this.ReadOnly = b; }; 63 Invoke(action, value); 64 } else { 65 if (value != readOnly) { 66 readOnly = value; 67 OnReadOnlyChanged(); 46 68 } 47 69 } … … 95 117 public event EventHandler CaptionChanged; 96 118 protected virtual void OnCaptionChanged() { 97 if (CaptionChanged != null) 98 CaptionChanged(this, EventArgs.Empty); 99 } 100 119 if (InvokeRequired) 120 Invoke((MethodInvoker)OnCaptionChanged); 121 else { 122 EventHandler handler = CaptionChanged; 123 if (handler != null) 124 handler(this, EventArgs.Empty); 125 } 126 } 127 public event EventHandler ReadOnlyChanged; 128 protected virtual void OnReadOnlyChanged() { 129 if (InvokeRequired) 130 Invoke((MethodInvoker)OnReadOnlyChanged); 131 else { 132 EventHandler handler = ReadOnlyChanged; 133 if (handler != null) 134 handler(this, EventArgs.Empty); 135 foreach (Control control in this.Controls) { 136 IView view = control as IView; 137 if (view != null) 138 view.ReadOnly = this.readOnly; 139 ViewHost viewHost = control as ViewHost; 140 if (viewHost != null) 141 viewHost.ReadOnly = this.readOnly; 142 } 143 } 144 } 101 145 public event EventHandler Changed; 102 146 protected virtual void OnChanged() { 103 147 if (InvokeRequired) 104 148 Invoke((MethodInvoker)OnChanged); 105 else if (Changed != null) 106 Changed(this, EventArgs.Empty); 149 else { 150 EventHandler handler = Changed; 151 if (handler != null) 152 handler(this, EventArgs.Empty); 153 } 107 154 } 108 155 -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/ViewHost.cs
r3281 r3350 28 28 namespace HeuristicLab.MainForm.WindowsForms { 29 29 public sealed partial class ViewHost : UserControl { 30 private Dictionary<Type, IView> cachedViews; 31 public ViewHost() { 32 InitializeComponent(); 33 viewType = null; 34 content = null; 35 cachedViews = new Dictionary<Type, IView>(); 36 Initialize(); 37 } 38 public ViewHost(bool readOnly) 39 : this() { 40 this.ReadOnly = readOnly; 41 } 42 30 43 private Type viewType; 31 44 public Type ViewType { … … 49 62 content = value; 50 63 viewContextMenuStrip.Item = content; 64 cachedViews.Clear(); 51 65 Initialize(); 52 66 } … … 59 73 this.SuspendRepaint(); 60 74 base.Enabled = value; 75 this.viewsLabel.Enabled = value; 61 76 this.ResumeRepaint(true); 62 77 } 63 78 } 79 private bool readOnly; 80 public bool ReadOnly { 81 get { return this.readOnly; } 82 set { 83 if (InvokeRequired) { 84 Action<bool> action = delegate(bool b) { this.ReadOnly = b; }; 85 Invoke(action, value); 86 } else { 87 if (value != readOnly) { 88 readOnly = value; 89 OnReadOnlyChanged(); 90 } 91 } 92 } 93 } 64 94 65 public ViewHost() { 66 InitializeComponent(); 67 viewType = null; 68 content = null; 69 Initialize(); 95 public event EventHandler ReadOnlyChanged; 96 private void OnReadOnlyChanged() { 97 if (InvokeRequired) 98 Invoke((MethodInvoker)OnReadOnlyChanged); 99 else { 100 EventHandler handler = ReadOnlyChanged; 101 if (handler != null) 102 handler(this, EventArgs.Empty); 103 foreach (IView view in cachedViews.Values) 104 view.ReadOnly = this.readOnly; 105 } 70 106 } 71 107 72 108 private void Initialize() { 73 109 viewsLabel.Visible = false; 74 viewsLabel.Enabled = false;75 viewContextMenuStrip.Enabled = false;76 messageLabel.Visible = false;77 78 110 viewPanel.Visible = false; 79 111 if (viewPanel.Controls.Count > 0) viewPanel.Controls[0].Dispose(); … … 81 113 82 114 if (Content != null) { 83 if (viewContextMenuStrip.Items.Count == 0) {115 if (viewContextMenuStrip.Items.Count == 0) 84 116 messageLabel.Visible = true; 85 } else {117 else 86 118 viewsLabel.Visible = true; 87 viewsLabel.Enabled = viewContextMenuStrip.Items.Count > 1;88 viewContextMenuStrip.Enabled = viewContextMenuStrip.Items.Count > 1; ;89 }90 119 91 120 if (!ViewCanShowContent(viewType, Content)) { … … 110 139 111 140 UpdateActiveMenuItem(); 112 Control view = (Control)MainFormManager.CreateView(viewType, Content); 113 viewPanel.Tag = view; 141 cachedViews.Clear(); 142 Control view = (Control)MainFormManager.CreateView(viewType, Content,ReadOnly); 143 cachedViews.Add(viewType, ((IView)view)); 114 144 view.Dock = DockStyle.Fill; 115 145 viewPanel.Controls.Add(view); … … 138 168 139 169 private void viewsLabel_DoubleClick(object sender, EventArgs e) { 140 MainFormManager.CreateView(viewType, Content ).Show();170 MainFormManager.CreateView(viewType, Content,ReadOnly).Show(); 141 171 } 142 172 -
trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IView.cs
r2790 r3350 30 30 bool IsShown { get; } 31 31 string Caption { get; set; } 32 bool ReadOnly { get; set; } 33 event EventHandler ReadOnlyChanged; 32 34 event EventHandler CaptionChanged; 33 35 event EventHandler Changed; -
trunk/sources/HeuristicLab.MainForm/3.2/MainFormManager.cs
r3278 r3350 148 148 return (IView)Activator.CreateInstance(t, content); 149 149 } 150 public static IView CreateDefaultView(object content, bool readOnly) { 151 IView view = CreateDefaultView(content); 152 if (view != null) 153 view.ReadOnly = readOnly; 154 return null; 155 } 150 156 151 157 public static IView CreateView(Type viewType) { … … 156 162 157 163 return (IView)Activator.CreateInstance(viewType); 164 } 165 public static IView CreateView(Type viewType, bool readOnly) { 166 IView view = CreateView(viewType); 167 view.ReadOnly = readOnly; 168 return view; 158 169 } 159 170 … … 166 177 167 178 return (IView)Activator.CreateInstance(view, content); 179 } 180 public static IView CreateView(Type viewType, object content, bool readOnly) { 181 IView view = CreateView(viewType, content); 182 view.ReadOnly = readOnly; 183 return view; 168 184 } 169 185 -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ResultCollectionView.cs
r3274 r3350 30 30 [Content(typeof(IObservableKeyedCollection<string, IResult>), false)] 31 31 public partial class ResultCollectionView : NamedItemCollectionView<IResult> { 32 public override bool ReadOnly { 33 get { return base.ReadOnly; } 34 set { /*not needed because results are always readonly */} 35 } 32 36 /// <summary> 33 37 /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View". … … 37 41 Caption = "ResultCollection"; 38 42 itemsGroupBox.Text = "Results"; 43 base.ReadOnly = true; 39 44 } 40 45 /// <summary> -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ResultView.cs
r3226 r3350 44 44 } 45 45 46 public override bool ReadOnly { 47 get { return base.ReadOnly; } 48 set { /*not needed because results are always readonly */} 49 } 50 46 51 /// <summary> 47 52 /// Initializes a new instance of <see cref="VariableView"/> with caption "Variable". … … 50 55 InitializeComponent(); 51 56 Caption = "Result"; 57 base.ReadOnly = true; 52 58 } 53 59 /// <summary> … … 84 90 Caption = "Result"; 85 91 dataTypeTextBox.Text = "-"; 86 dataTypeTextBox.Enabled = false;87 valueGroupBox.Enabled = false;88 92 viewHost.Content = null; 89 93 } else { 90 94 Caption = Content.Name + " (" + Content.GetType().Name + ")"; 91 95 dataTypeTextBox.Text = Content.DataType.GetPrettyName(); 96 viewHost.ViewType = null; 97 viewHost.Content = Content.Value; 98 } 99 SetEnableStateOfControls(); 100 } 101 protected override void OnReadOnlyChanged() { 102 base.OnReadOnlyChanged(); 103 SetEnableStateOfControls(); 104 } 105 private void SetEnableStateOfControls() { 106 if (Content == null) { 107 dataTypeTextBox.Enabled = false; 108 valueGroupBox.Enabled = false; 109 viewHost.Enabled = false; 110 } else { 92 111 dataTypeTextBox.Enabled = true; 93 112 valueGroupBox.Enabled = true; 94 viewHost. ViewType = null;95 viewHost. Content = Content.Value;113 viewHost.Enabled = true; 114 viewHost.ReadOnly = ReadOnly; 96 115 } 97 116 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.cs
r3349 r3350 43 43 Caption = "Run Collection Bubble Chart"; 44 44 this.categoricalMapping = new Dictionary<int, Dictionary<object, double>>(); 45 base.ReadOnly = true; 45 46 } 46 47 … … 53 54 get { return (RunCollection)base.Content; } 54 55 set { base.Content = value; } 56 } 57 public override bool ReadOnly { 58 get { return base.ReadOnly; } 59 set { /*not needed because results are always readonly */} 55 60 } 56 61 -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionTabularView.cs
r3347 r3350 40 40 Caption = "Run Collection"; 41 41 this.dataGridView.RowHeaderMouseDoubleClick += new DataGridViewCellMouseEventHandler(dataGridView_RowHeaderMouseDoubleClick); 42 base.ReadOnly = true; 42 43 } 43 44 … … 45 46 : this() { 46 47 Content = content; 48 } 49 50 public override bool ReadOnly { 51 get { return base.ReadOnly; } 52 set { /*not needed because results are always readonly */} 47 53 } 48 54 -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs
r3341 r3350 45 45 InitializeComponent(); 46 46 Caption = "Run Collection"; 47 base.ReadOnly = true; 47 48 } 48 49 … … 50 51 : this() { 51 52 Content = content; 53 } 54 public override bool ReadOnly { 55 get { return base.ReadOnly; } 56 set { /*not needed because results are always readonly */} 52 57 } 53 58 … … 69 74 Caption = "Run Collection"; 70 75 while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]); 71 itemsListView.Enabled = false;72 detailsGroupBox.Enabled = false;73 76 viewHost.Content = null; 74 removeButton.Enabled = false;75 77 76 78 if (Content != null) { 77 79 Caption += " (" + Content.GetType().Name + ")"; 78 itemsListView.Enabled = true;79 80 foreach (IRun item in Content) 80 81 AddListViewItem(CreateListViewItem(item)); 82 } 83 SetEnableStateOfControls(); 84 } 85 86 protected override void OnReadOnlyChanged() { 87 base.OnReadOnlyChanged(); 88 SetEnableStateOfControls(); 89 } 90 private void SetEnableStateOfControls() { 91 if (Content == null) { 92 itemsListView.Enabled = false; 93 detailsGroupBox.Enabled = false; 94 viewHost.Enabled = false; 95 removeButton.Enabled = false; 96 } else { 97 itemsListView.Enabled = true; 98 detailsGroupBox.Enabled = true; 99 removeButton.Enabled = true; 100 viewHost.Enabled = true; 101 viewHost.ReadOnly = ReadOnly; 81 102 } 82 103 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunView.cs
r3341 r3350 43 43 } 44 44 45 public override bool ReadOnly { 46 get { return base.ReadOnly; } 47 set { /*not needed because results are always readonly */} 48 } 49 45 50 /// <summary> 46 51 /// Initializes a new instance of <see cref="VariableView"/> with caption "Variable". … … 49 54 InitializeComponent(); 50 55 Caption = "Run"; 56 base.ReadOnly = true; 51 57 } 52 58 /// <summary> … … 65 71 viewHost.ViewType = null; 66 72 viewHost.Content = null; 73 if (Content == null) 74 Caption = "Run"; 75 else 76 Caption = Content.Name + " (" + Content.GetType().Name + ")"; 77 SetEnableStateOfControls(); 78 } 79 protected override void OnReadOnlyChanged() { 80 base.OnReadOnlyChanged(); 81 SetEnableStateOfControls(); 82 } 83 private void SetEnableStateOfControls() { 67 84 if (Content == null) { 68 Caption = "Run";69 85 parametersResultsGroupBox.Enabled = false; 86 viewHost.Enabled = false; 70 87 } else { 71 Caption = Content.Name + " (" + Content.GetType().Name + ")";72 88 parametersResultsGroupBox.Enabled = true; 89 viewHost.Enabled = true; 90 viewHost.ReadOnly = ReadOnly; 73 91 } 74 92 }
Note: See TracChangeset
for help on using the changeset viewer.