Changeset 3416 for trunk/sources/HeuristicLab.MainForm/3.2
- Timestamp:
- 04/19/10 21:00:30 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.MainForm/3.2
- Files:
-
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm/3.2/HeuristicLab.MainForm-3.2.csproj
r2900 r3416 85 85 <ItemGroup> 86 86 <None Include="HeuristicLabMainFormPlugin.cs.frame" /> 87 <Compile Include="Interfaces\IStorableContentView.cs" /> 87 88 <Compile Include="ViewAttribute.cs" /> 88 89 <Compile Include="Interfaces\IContentView.cs" /> … … 109 110 </ItemGroup> 110 111 <ItemGroup> 112 <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj"> 113 <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project> 114 <Name>HeuristicLab.Common-3.3</Name> 115 </ProjectReference> 111 116 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> 112 117 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> -
trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IContentView.cs
r3389 r3416 24 24 using System.Text; 25 25 using System.ComponentModel; 26 using HeuristicLab.Common; 26 27 27 28 namespace HeuristicLab.MainForm { 28 29 public interface IContentView : IView { 29 object Content { get; set; } 30 bool SaveEnabled { get; } 30 IContent Content { get; set; } 31 bool Locked { get; set; } 32 event EventHandler LockedChanged; 31 33 } 32 34 } -
trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IStorableContentView.cs
r3410 r3416 24 24 using System.Text; 25 25 using System.ComponentModel; 26 using HeuristicLab.Common; 26 27 27 28 namespace HeuristicLab.MainForm { 28 public interface IContentView : IView { 29 object Content { get; set; } 30 bool SaveEnabled { get; } 29 public interface IStorableContentView : IContentView { 30 new IStorableContent Content { get; set; } 31 31 } 32 32 } -
trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IView.cs
r3350 r3416 27 27 namespace HeuristicLab.MainForm { 28 28 public interface IView { 29 30 29 bool IsShown { get; } 31 30 string Caption { get; set; } -
trunk/sources/HeuristicLab.MainForm/3.2/MainFormManager.cs
r3389 r3416 26 26 using HeuristicLab.PluginInfrastructure; 27 27 using System.Diagnostics; 28 using HeuristicLab.Common; 28 29 29 30 namespace HeuristicLab.MainForm { … … 75 76 76 77 public static IEnumerable<Type> GetViewTypes(Type contentType) { 78 CheckForContentType(contentType); 77 79 List<Type> viewTypes = (from v in views 78 80 where ContentAttribute.CanViewType(v, contentType) … … 86 88 87 89 public static IEnumerable<Type> GetViewTypes(Type contentType, bool returnOnlyMostSpecificViewTypes) { 90 CheckForContentType(contentType); 88 91 List<Type> viewTypes = new List<Type>(GetViewTypes(contentType)); 89 92 if (returnOnlyMostSpecificViewTypes) { … … 102 105 } 103 106 104 public static bool ViewCanViewObject(IContentView view, object content) {107 public static bool ViewCanViewObject(IContentView view, IContent content) { 105 108 return ContentAttribute.CanViewType(view.GetType(), content.GetType()); 106 109 } 107 110 108 111 public static Type GetDefaultViewType(Type contentType) { 112 CheckForContentType(contentType); 109 113 //check base classes for default view 110 114 Type type = contentType; … … 148 152 return (IContentView)Activator.CreateInstance(t, content); 149 153 } 150 public static IContentView CreateDefaultView(object content, bool readOnly) {151 IContentView view = CreateDefaultView(content);152 if (view != null)153 view.ReadOnly = readOnly;154 return view;155 }156 157 154 public static IContentView CreateView(Type viewType) { 158 if (!typeof(I ContentView).IsAssignableFrom(viewType))155 if (!typeof(IView).IsAssignableFrom(viewType)) 159 156 throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is not of type IView."); 160 157 if (viewType.IsGenericTypeDefinition) … … 163 160 return (IContentView)Activator.CreateInstance(viewType); 164 161 } 165 public static IContentView CreateView(Type viewType, bool readOnly) {166 IContentView view = CreateView(viewType);167 view.ReadOnly = readOnly;168 return view;169 }170 171 162 public static IContentView CreateView(Type viewType, object content) { 172 if (!typeof(IContentView).IsAssignableFrom(viewType)) 173 throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is not of type IView."); 163 CheckForContentType(content.GetType()); 164 CheckForContentViewType(viewType); 165 174 166 Type view = viewType; 175 167 if (view.IsGenericTypeDefinition) … … 178 170 return (IContentView)Activator.CreateInstance(view, content); 179 171 } 180 public static IContentView CreateView(Type viewType, object content, bool readOnly) { 181 IContentView view = CreateView(viewType, content); 182 view.ReadOnly = readOnly; 183 return view; 172 173 private static void CheckForContentType(Type contentType) { 174 if (!typeof(IContent).IsAssignableFrom(contentType)) 175 throw new ArgumentException("DefaultViews are only specified for types of IContent and not for " + contentType + "."); 176 } 177 private static void CheckForContentViewType(Type viewType) { 178 if (!typeof(IContentView).IsAssignableFrom(viewType)) 179 throw new ArgumentException("View can not be created becaues given type " + viewType.ToString() + " is not of type IContentView."); 184 180 } 185 181
Note: See TracChangeset
for help on using the changeset viewer.