- Timestamp:
- 10/18/09 01:08:12 (15 years ago)
- Location:
- branches/Mainform refactoring
- Files:
-
- 8 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/Mainform refactoring/HeuristicLab.MainForm.Test/3.2/Actions/NewFormAction.cs
r2426 r2437 9 9 public void Execute(IMainForm mainform) { 10 10 MessageBox.Show("New form called"); 11 FormView x = new FormView();11 FormView1 x = new FormView1(); 12 12 x.Caption = "FormView"; 13 13 mainform.ShowView(x); -
branches/Mainform refactoring/HeuristicLab.MainForm.Test/3.2/ButtonItems/SaveToolStripButtonItem.cs
r2433 r2437 28 28 this.ToolStripItem.Enabled = false; 29 29 else 30 this.ToolStripItem.Enabled = !(mainform.ActiveView is FormView );30 this.ToolStripItem.Enabled = !(mainform.ActiveView is FormView1); 31 31 } 32 32 -
branches/Mainform refactoring/HeuristicLab.MainForm.Test/3.2/EditorView.cs
r2433 r2437 8 8 using System.Windows.Forms; 9 9 using HeuristicLab.MainForm.WindowsForms; 10 using System.Collections; 10 11 11 12 namespace HeuristicLab.MainForm.Test { 12 13 [DefaultView] 13 public partial class EditorView : ViewBase< object>,IView<string> {14 public partial class EditorView : ViewBase<IList> { 14 15 public EditorView() { 15 16 InitializeComponent(); … … 17 18 18 19 private void ChangeStateButton_Click(object sender, EventArgs e) { 19 IEnumerable<Type> views = MainFormManager.GetViewTypes(typeof( string));20 IEnumerable<Type> views = MainFormManager.GetViewTypes(typeof(ArrayList)); 20 21 views.ToString(); 21 IEnumerable<Type> views1 = MainFormManager.GetViewTypes(typeof( object));22 IEnumerable<Type> views1 = MainFormManager.GetViewTypes(typeof(IList)); 22 23 views1.ToString(); 23 Type def1 = MainFormManager.GetDefaultViewType(typeof(string)); 24 //IEnumerable<Type> views2 = MainFormManager.GetViewTypes(typeof(object)); 25 //views2.ToString(); 26 Type def2 = MainFormManager.GetDefaultViewType(typeof(IList)); 27 def2.ToString(); 28 Type def1 = MainFormManager.GetDefaultViewType(typeof(ArrayList)); 24 29 def1.ToString(); 25 Type def2 = MainFormManager.GetDefaultViewType(typeof(object)); 26 def2.ToString(); 27 28 IView<string> v = MainFormManager.CreateDefaultView<string>("x"); 29 v.Caption = "lala"; 30 //Type def3 = MainFormManager.GetDefaultViewType(typeof(object)); 31 //def3.ToString(); 30 32 31 33 this.OnChanged(); -
branches/Mainform refactoring/HeuristicLab.MainForm.Test/3.2/FormView.Designer.cs
r2250 r2437 1 1 namespace HeuristicLab.MainForm.Test { 2 partial class FormView {2 partial class FormView1 { 3 3 /// <summary> 4 4 /// Required designer variable. -
branches/Mainform refactoring/HeuristicLab.MainForm.Test/3.2/FormView.cs
r2433 r2437 10 10 11 11 namespace HeuristicLab.MainForm.Test { 12 public partial class FormView : ViewBase<object> { 12 [DefaultView] 13 public partial class FormView1 : ViewBase<ICloneable> { 13 14 private int[] array; 14 public FormView () {15 public FormView1() { 15 16 InitializeComponent(); 16 17 } -
branches/Mainform refactoring/HeuristicLab.MainForm.Test/3.2/FormView2.Designer.cs
r2436 r2437 1 1 namespace HeuristicLab.MainForm.Test { 2 partial class FormView {2 partial class FormView2 { 3 3 /// <summary> 4 4 /// Required designer variable. -
branches/Mainform refactoring/HeuristicLab.MainForm.Test/3.2/FormView2.cs
r2436 r2437 1 1 using System; 2 using System.Collections .Generic;2 using System.Collections; 3 3 using System.ComponentModel; 4 4 using System.Drawing; … … 10 10 11 11 namespace HeuristicLab.MainForm.Test { 12 public partial class FormView : ViewBase<object> {12 public partial class FormView2 : ViewBase<ArrayList> { 13 13 private int[] array; 14 public FormView () {14 public FormView2() { 15 15 InitializeComponent(); 16 16 } -
branches/Mainform refactoring/HeuristicLab.MainForm.Test/3.2/HeuristicLab.MainForm.Test-3.2.csproj
r2426 r2437 87 87 <Compile Include="ButtonItems\SaveToolStripButtonItem.cs" /> 88 88 <Compile Include="ButtonItems\OpenToolStripButtonItem.cs" /> 89 <Compile Include="FormView2.cs"> 90 <SubType>UserControl</SubType> 91 </Compile> 92 <Compile Include="FormView2.Designer.cs"> 93 <DependentUpon>FormView2.cs</DependentUpon> 94 </Compile> 89 95 <Compile Include="HeuristicLabSingleDocumentMainFormTestApplication.cs" /> 90 96 <Compile Include="HeuristicLabMultipleDocumentMainFormTestApplication.cs" /> … … 140 146 </ItemGroup> 141 147 <ItemGroup> 148 <EmbeddedResource Include="FormView2.resx"> 149 <DependentUpon>FormView2.cs</DependentUpon> 150 </EmbeddedResource> 142 151 <EmbeddedResource Include="EditorView.resx"> 143 152 <DependentUpon>EditorView.cs</DependentUpon> -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/MainFormBase.cs
r2426 r2437 75 75 public Type UserInterfaceItemType { 76 76 get { return this.userInterfaceItemType; } 77 protected set { this.userInterfaceItemType = value; }78 77 } 79 78 -
branches/Mainform refactoring/HeuristicLab.MainForm/3.2/MainFormManager.cs
r2433 r2437 84 84 85 85 public static IEnumerable<Type> GetViewTypes(Type viewableType) { 86 List<Type> viewsForType; 87 if (!views.ContainsKey(viewableType)) 88 viewsForType = new List<Type>(); 89 else 90 viewsForType = views[viewableType]; 91 92 if (viewableType.BaseType != null) 93 viewsForType.AddRange(GetViewTypes(viewableType.BaseType)); 86 List<Type> viewsForType = new List<Type>(); 87 foreach (KeyValuePair<Type, List<Type>> v in views) { 88 if (v.Key.IsAssignableFrom(viewableType)) 89 viewsForType.AddRange(v.Value); 90 } 94 91 return viewsForType.Distinct(); 95 92 } … … 100 97 101 98 public static Type GetDefaultViewType(Type viewableType) { 102 if (!defaultViews.ContainsKey(viewableType)) 103 return null; 104 return defaultViews[viewableType]; 99 if (!defaultViews.ContainsKey(viewableType)) { 100 List<Type> temp = defaultViews.Keys.Where(x => x.IsAssignableFrom(viewableType)).ToList(); 101 if (temp.Count == 0) 102 return null; 103 else if (temp.Count == 1) 104 return defaultViews[temp[0]]; 105 else { 106 temp.Sort(delegate(Type t1, Type t2) { 107 if (t1.IsAssignableFrom(t2)) 108 return 1; 109 return -1; 110 } 111 ); 112 if (!temp[0].IsAssignableFrom(temp[1]) && !temp[1].IsAssignableFrom(temp[0])) 113 throw new Exception("Could not determine which is the default view for type " + viewableType.ToString() + "."); 114 else 115 return defaultViews[temp[0]]; 116 } 117 } else 118 return defaultViews[viewableType]; 105 119 } 106 120 … … 110 124 return null; 111 125 else 112 return (IView<T>) 126 return (IView<T>)Activator.CreateInstance(t); 113 127 } 114 128 }
Note: See TracChangeset
for help on using the changeset viewer.