Changeset 3416
- Timestamp:
- 04/19/10 21:00:30 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 26 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/Clipboard.cs
r3407 r3416 231 231 if (listView.SelectedItems.Count == 1) { 232 232 T item = (T)listView.SelectedItems[0].Tag; 233 IView view = MainFormManager.CreateDefaultView(item, ReadOnly); 234 if (view != null) view.Show(); 233 IView view = MainFormManager.CreateDefaultView(item); 234 if (view != null) { 235 view.ReadOnly = this.ReadOnly; 236 view.Show(); 237 } 235 238 } 236 239 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.cs
r3407 r3416 230 230 T item = itemsListView.SelectedItems[0].Tag as T; 231 231 if (item != null) { 232 IView view = MainFormManager.CreateDefaultView(item, ReadOnly); 233 if (view != null) view.Show(); 232 IView view = MainFormManager.CreateDefaultView(item); 233 if (view != null) { 234 view.ReadOnly = ReadOnly; 235 view.Show(); 236 } 234 237 } 235 238 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs
r3407 r3416 190 190 if (itemsListView.SelectedItems.Count == 1) { 191 191 T item = (T)itemsListView.SelectedItems[0].Tag; 192 IView view = MainFormManager.CreateDefaultView(item, ReadOnly); 193 if (view != null) view.Show(); 192 IView view = MainFormManager.CreateDefaultView(item); 193 if (view != null) { 194 view.ReadOnly = this.ReadOnly; 195 view.Show(); 196 } 194 197 } 195 198 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.cs
r3407 r3416 224 224 if (itemsListView.SelectedItems.Count == 1) { 225 225 T item = (T)itemsListView.SelectedItems[0].Tag; 226 IView view = MainFormManager.CreateDefaultView(item, ReadOnly); 227 if (view != null) view.Show(); 226 IView view = MainFormManager.CreateDefaultView(item); 227 if (view != null) { 228 view.ReadOnly = ReadOnly; 229 view.Show(); 230 } 228 231 } 229 232 } -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorTreeView.cs
r3407 r3416 355 355 IOperator op = GetOperatorTag(graphTreeView.SelectedNode); 356 356 if (op != null) { 357 IView view = MainFormManager.CreateDefaultView(op , ReadOnly);357 IView view = MainFormManager.CreateDefaultView(op); 358 358 if (view != null) { 359 view.ReadOnly = this.ReadOnly; 359 360 viewToolStripMenuItem.Enabled = true; 360 361 viewToolStripMenuItem.Tag = view; -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/AsynchronousContentView.cs
r3342 r3416 8 8 using System.Windows.Forms; 9 9 using System.Threading; 10 using HeuristicLab.Common; 10 11 11 12 namespace HeuristicLab.MainForm.WindowsForms { … … 15 16 } 16 17 17 public AsynchronousContentView( object content)18 public AsynchronousContentView(IContent content) 18 19 : this() { 19 20 this.Content = content; -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/AsynchronousStorableContentView.Designer.cs
r3410 r3416 1 1 namespace HeuristicLab.MainForm.WindowsForms { 2 partial class ContentView {2 partial class AsynchronousStorableContentView { 3 3 /// <summary> 4 4 /// Required designer variable. -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/AsynchronousStorableContentView.cs
r3410 r3416 28 28 using System.Text; 29 29 using System.Windows.Forms; 30 using HeuristicLab.Common; 31 using System.Threading; 30 32 31 33 namespace HeuristicLab.MainForm.WindowsForms { 32 public partial class ContentView : View, IContentView { 33 private object content; 34 public object Content { 35 get { return content; } 36 set { 37 if ((value != null) && (!MainFormManager.ViewCanViewObject(this, value))) 38 throw new ArgumentException(string.Format("View \"{0}\" cannot view object \"{1}\".", this.GetType().Name, value.GetType().Name)); 39 if (InvokeRequired) { 40 Invoke(new Action<object>(delegate(object o) { this.Content = o; }), value); 41 } else { 42 if (this.content != value) { 43 if (this.content != null) this.DeregisterContentEvents(); 44 this.content = value; 45 if (this.content != null) this.RegisterContentEvents(); 46 this.OnContentChanged(); 47 } 48 } 49 } 34 public partial class AsynchronousStorableContentView : StorableContentView { 35 public AsynchronousStorableContentView() 36 : base() { 37 InitializeComponent(); 50 38 } 51 private bool saveEnabled; 52 public bool SaveEnabled { 53 get { return saveEnabled; } 54 protected set { 55 if (value != saveEnabled) { 56 saveEnabled = value; 57 OnChanged(); 58 } 39 public AsynchronousStorableContentView(IStorableContent content) 40 : base() { 41 this.Content = content; 42 } 43 44 /// <summary> 45 /// Asynchronous call of GUI updating. 46 /// </summary> 47 /// <param name="method">The delegate to invoke.</param> 48 protected new void Invoke(Delegate method) { 49 // prevents blocking of worker thread in Invoke, if the control is disposed 50 IAsyncResult result = BeginInvoke(method); 51 result.AsyncWaitHandle.WaitOne(1000, false); 52 if (result.IsCompleted) try { EndInvoke(result); } 53 catch (ObjectDisposedException) { } else { 54 ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, 55 new WaitOrTimerCallback((x, b) => { try { EndInvoke(result); } catch (ObjectDisposedException) { } }), 56 null, -1, true); 59 57 } 60 58 } 61 59 62 public ContentView()63 : base() {64 InitializeComponent();65 saveEnabled = true;66 }67 public ContentView(object content)68 : this() {69 this.content = content;70 }71 72 60 /// <summary> 73 /// A dds eventhandlers to the current instance.61 /// Asynchronous call of GUI updating. 74 62 /// </summary> 75 protected virtual void RegisterContentEvents() { 76 } 77 78 /// <summary> 79 /// Removes the eventhandlers from the current instance. 80 /// </summary> 81 protected virtual void DeregisterContentEvents() { 82 } 83 84 /// <summary> 85 /// Is called when the content property changes. 86 /// </summary> 87 protected virtual void OnContentChanged() { 63 /// <param name="method">The delegate to invoke.</param> 64 /// <param name="args">The invoke arguments.</param> 65 protected new void Invoke(Delegate method, params object[] args) { 66 // prevents blocking of worker thread in Invoke, if the control is disposed 67 IAsyncResult result = BeginInvoke(method, args); 68 result.AsyncWaitHandle.WaitOne(1000, false); 69 if (result.IsCompleted) try { EndInvoke(result); } 70 catch (ObjectDisposedException) { } else { 71 ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, 72 new WaitOrTimerCallback((x, b) => { try { EndInvoke(result); } catch (ObjectDisposedException) { } }), 73 null, -1, true); 74 } 88 75 } 89 76 } -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/ContentView.cs
r3389 r3416 28 28 using System.Text; 29 29 using System.Windows.Forms; 30 using HeuristicLab.Common; 31 using System.Reflection; 30 32 31 33 namespace HeuristicLab.MainForm.WindowsForms { 32 34 public partial class ContentView : View, IContentView { 33 private object content;34 public object Content {35 private IContent content; 36 public IContent Content { 35 37 get { return content; } 36 38 set { … … 38 40 throw new ArgumentException(string.Format("View \"{0}\" cannot view object \"{1}\".", this.GetType().Name, value.GetType().Name)); 39 41 if (InvokeRequired) { 40 Invoke(new Action< object>(delegate(object o) { this.Content = o; }), value);42 Invoke(new Action<IContent>(delegate(IContent o) { this.Content = o; }), value); 41 43 } else { 42 44 if (this.content != value) { … … 49 51 } 50 52 } 51 private bool saveEnabled;52 public bool SaveEnabled {53 get { return saveEnabled; }54 protected set {55 if (value != saveEnabled) {56 saveEnabled = value;57 OnChanged();58 }59 }60 }61 53 62 54 public ContentView() 63 55 : base() { 64 56 InitializeComponent(); 65 saveEnabled = true;57 this.locked = false; 66 58 } 67 public ContentView( object content)59 public ContentView(IContent content) 68 60 : this() { 69 61 this.content = content; 62 } 63 64 private bool locked; 65 public virtual bool Locked { 66 get { return this.locked; } 67 set { 68 if (InvokeRequired) { 69 Action<bool> action = delegate(bool b) { this.Locked = b; }; 70 Invoke(action, value); 71 } else { 72 if (value != locked) { 73 locked = value; 74 PropertyInfo prop = typeof(IContentView).GetProperty("Locked"); 75 PropagateStateChanges(this, typeof(IContentView), prop); 76 OnLockedChanged(); 77 OnChanged(); 78 } 79 } 80 } 81 } 82 public event EventHandler LockedChanged; 83 protected virtual void OnLockedChanged() { 84 if (InvokeRequired) 85 Invoke((MethodInvoker)OnLockedChanged); 86 else { 87 EventHandler handler = LockedChanged; 88 if (handler != null) 89 handler(this, EventArgs.Empty); 90 } 70 91 } 71 92 -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/HeuristicLab.MainForm.WindowsForms-3.2.csproj
r3281 r3416 100 100 <None Include="HeuristicLabMainFormWindowsFormsPlugin.cs.frame" /> 101 101 <Compile Include="ControlExtensions.cs" /> 102 <Compile Include="AsynchronousStorableContentView.cs"> 103 <SubType>UserControl</SubType> 104 </Compile> 105 <Compile Include="AsynchronousStorableContentView.Designer.cs"> 106 <DependentUpon>AsynchronousStorableContentView.cs</DependentUpon> 107 </Compile> 108 <Compile Include="StorableContentView.cs"> 109 <SubType>UserControl</SubType> 110 </Compile> 111 <Compile Include="StorableContentView.Designer.cs"> 112 <DependentUpon>StorableContentView.cs</DependentUpon> 113 </Compile> 102 114 <Compile Include="DockForm.cs"> 103 115 <SubType>Form</SubType> … … 167 179 <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project> 168 180 <Name>HeuristicLab.Common.Resources-3.2</Name> 181 </ProjectReference> 182 <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj"> 183 <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project> 184 <Name>HeuristicLab.Common-3.3</Name> 169 185 </ProjectReference> 170 186 <ProjectReference Include="..\..\HeuristicLab.ExtLibs\HeuristicLab.WinFormsUI\2.3.1\WinFormsUI-2.3.1\WinFormsUI-2.3.1.csproj"> -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/StorableContentView.Designer.cs
r3410 r3416 1 1 namespace HeuristicLab.MainForm.WindowsForms { 2 partial class ContentView {2 partial class StorableContentView { 3 3 /// <summary> 4 4 /// Required designer variable. -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/StorableContentView.cs
r3410 r3416 28 28 using System.Text; 29 29 using System.Windows.Forms; 30 using HeuristicLab.Common; 30 31 31 32 namespace HeuristicLab.MainForm.WindowsForms { 32 public partial class ContentView : View, IContentView { 33 private object content; 34 public object Content { 35 get { return content; } 36 set { 37 if ((value != null) && (!MainFormManager.ViewCanViewObject(this, value))) 38 throw new ArgumentException(string.Format("View \"{0}\" cannot view object \"{1}\".", this.GetType().Name, value.GetType().Name)); 39 if (InvokeRequired) { 40 Invoke(new Action<object>(delegate(object o) { this.Content = o; }), value); 41 } else { 42 if (this.content != value) { 43 if (this.content != null) this.DeregisterContentEvents(); 44 this.content = value; 45 if (this.content != null) this.RegisterContentEvents(); 46 this.OnContentChanged(); 47 } 48 } 49 } 33 public partial class StorableContentView : ContentView, IStorableContentView { 34 public StorableContentView() 35 : base() { 36 InitializeComponent(); 50 37 } 51 private bool saveEnabled; 52 public bool SaveEnabled { 53 get { return saveEnabled; } 54 protected set { 55 if (value != saveEnabled) { 56 saveEnabled = value; 57 OnChanged(); 58 } 59 } 38 public StorableContentView(IStorableContent content) 39 : this() { 40 this.Content = content; 60 41 } 61 42 62 public ContentView() 63 : base() { 64 InitializeComponent(); 65 saveEnabled = true; 66 } 67 public ContentView(object content) 68 : this() { 69 this.content = content; 70 } 71 72 /// <summary> 73 /// Adds eventhandlers to the current instance. 74 /// </summary> 75 protected virtual void RegisterContentEvents() { 76 } 77 78 /// <summary> 79 /// Removes the eventhandlers from the current instance. 80 /// </summary> 81 protected virtual void DeregisterContentEvents() { 82 } 83 84 /// <summary> 85 /// Is called when the content property changes. 86 /// </summary> 87 protected virtual void OnContentChanged() { 43 public new IStorableContent Content { 44 get { return (IStorableContent)base.Content; } 45 set { base.Content = value; } 88 46 } 89 47 } -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/View.cs
r3403 r3416 21 21 22 22 using System; 23 using System.Linq; 23 24 using System.Windows.Forms; 25 using System.Reflection; 26 using System.ComponentModel; 24 27 25 28 namespace HeuristicLab.MainForm.WindowsForms { … … 65 68 if (value != readOnly) { 66 69 readOnly = value; 70 PropertyInfo prop = typeof(IView).GetProperty("ReadOnly"); 71 PropagateStateChanges(this, typeof(IView), prop); 67 72 OnReadOnlyChanged(); 68 73 } … … 135 140 } 136 141 } 142 protected void PropagateStateChanges(Control control, Type type, PropertyInfo propertyInfo) { 143 if (!type.GetProperties().Contains(propertyInfo)) 144 throw new ArgumentException("The specified type " + type + "implement the property " + propertyInfo.Name + "."); 145 if (!type.IsAssignableFrom(this.GetType())) 146 throw new ArgumentException("The specified type " + type + "must be the same or a base class / interface of this object."); 147 if (!propertyInfo.CanWrite) 148 throw new ArgumentException("The specified property " + propertyInfo.Name + " must have a setter."); 149 150 foreach (Control c in control.Controls) { 151 Type controlType = c.GetType(); 152 PropertyInfo controlPropertyInfo = controlType.GetProperty(propertyInfo.Name, propertyInfo.PropertyType); 153 if (type.IsAssignableFrom(controlType) && controlPropertyInfo!= null) { 154 var thisValue = propertyInfo.GetValue(this, null); 155 controlPropertyInfo.SetValue(c, thisValue, null); 156 } else 157 PropagateStateChanges(c, type, propertyInfo); 158 } 159 } 137 160 public event EventHandler Changed; 138 161 protected virtual void OnChanged() { -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/ViewHost.cs
r3403 r3416 25 25 using System.Windows.Forms; 26 26 using HeuristicLab.MainForm; 27 using HeuristicLab.Common; 27 28 28 29 namespace HeuristicLab.MainForm.WindowsForms { … … 38 39 activeView = null; 39 40 } 40 public ViewHost( object content)41 public ViewHost(IContent content) 41 42 : this() { 42 43 this.Content = content; … … 75 76 View view = activeView as View; 76 77 if (view != null) 77 view.OnShown(new ViewShownEventArgs(view, false));78 view.OnShown(new ViewShownEventArgs(view, false)); 78 79 } 79 80 ActiveViewChanged(); … … 95 96 } 96 97 } 97 public new object Content {98 public new IContent Content { 98 99 get { return base.Content; } 99 100 set { … … 116 117 } 117 118 118 protected override void OnReadOnlyChanged() { 119 base.OnReadOnlyChanged(); 120 foreach (IContentView view in cachedViews.Values) 121 view.ReadOnly = this.ReadOnly; 122 } 119 123 120 124 121 protected override void OnContentChanged() { … … 162 159 view = cachedViews[ViewType]; 163 160 else { 164 view = MainFormManager.CreateView(viewType, Content, ReadOnly); 161 view = MainFormManager.CreateView(viewType, Content); 162 view.ReadOnly = this.ReadOnly; 163 view.Locked = this.Locked; 165 164 cachedViews.Add(viewType, view); 166 165 } … … 192 191 if (ActiveView != null) { 193 192 this.Caption = this.ActiveView.Caption; 194 this. SaveEnabled = this.ActiveView.SaveEnabled;193 this.Locked = this.ActiveView.Locked; 195 194 } 196 195 } 197 196 198 197 #region forwarding of view events 198 protected override void OnReadOnlyChanged() { 199 base.OnReadOnlyChanged(); 200 foreach (IContentView view in cachedViews.Values) 201 view.ReadOnly = this.ReadOnly; 202 } 203 protected override void OnLockedChanged() { 204 base.OnLockedChanged(); 205 foreach (IContentView view in cachedViews.Values) 206 view.Locked = this.Locked; 207 } 199 208 internal protected override void OnShown(ViewShownEventArgs e) { 200 209 base.OnShown(e); … … 203 212 view.OnShown(e); 204 213 } 205 206 214 internal protected override void OnHidden(EventArgs e) { 207 215 base.OnHidden(e); … … 210 218 view.OnHidden(e); 211 219 } 212 213 220 internal protected override void OnClosing(FormClosingEventArgs e) { 214 221 base.OnClosing(e); … … 216 223 view.OnClosing(e); 217 224 } 218 219 225 internal protected override void OnClosed(FormClosedEventArgs e) { 220 226 base.OnClosed(e); … … 246 252 247 253 private void viewsLabel_DoubleClick(object sender, EventArgs e) { 248 MainFormManager.CreateView(viewType, Content, ReadOnly).Show(); 254 IContentView view = MainFormManager.CreateView(viewType, Content); 255 view.ReadOnly = this.ReadOnly; 256 view.Locked = this.Locked; 257 view.Show(); 249 258 } 250 259 private void viewContextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { … … 255 264 private bool startDragAndDrop; 256 265 private void viewsLabel_MouseDown(object sender, MouseEventArgs e) { 257 startDragAndDrop = true; 258 viewsLabel.Capture = false; 266 if (!Locked) { 267 startDragAndDrop = true; 268 viewsLabel.Capture = false; 269 } 259 270 } 260 271 private void viewsLabel_MouseLeave(object sender, EventArgs e) { -
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 -
trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs
r3407 r3416 153 153 else { 154 154 this.ReadOnly = Content.ExecutionState == ExecutionState.Started; 155 SaveEnabled = Content.ExecutionState != ExecutionState.Started;155 Locked = Content.ExecutionState == ExecutionState.Started; 156 156 EnableDisableButtons(); 157 157 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs
r3407 r3416 120 120 else { 121 121 this.ReadOnly = Content.ExecutionState == ExecutionState.Started; 122 SaveEnabled = Content.ExecutionState != ExecutionState.Started;122 Locked = Content.ExecutionState == ExecutionState.Started; 123 123 newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = saveAlgorithmButton.Enabled = Content.ExecutionState != ExecutionState.Started; 124 124 EnableDisableButtons(); -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentView.cs
r3367 r3416 107 107 nameTextBox.Enabled = Content.ExecutionState != ExecutionState.Started; 108 108 descriptionTextBox.Enabled = Content.ExecutionState != ExecutionState.Started; 109 SaveEnabled = Content.ExecutionState != ExecutionState.Started;109 Locked = Content.ExecutionState == ExecutionState.Started; 110 110 EnableDisableButtons(); 111 111 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs
r3393 r3416 166 166 if (itemsListView.SelectedItems.Count == 1) { 167 167 IRun item = (IRun)itemsListView.SelectedItems[0].Tag; 168 IView view = MainFormManager.CreateDefaultView(item,ReadOnly); 169 if (view != null) view.Show(); 168 IView view = MainFormManager.CreateDefaultView(item); 169 if (view != null) { 170 view.ReadOnly = ReadOnly; 171 view.Show(); 172 } 170 173 } 171 174 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunView.cs
r3376 r3416 120 120 if (listView.SelectedItems.Count == 1) { 121 121 viewHost.ViewType = null; 122 viewHost.Content = listView.SelectedItems[0].Tag;122 viewHost.Content = (IContent) listView.SelectedItems[0].Tag; 123 123 } else { 124 124 viewHost.Content = null; … … 128 128 if (listView.SelectedItems.Count == 1) { 129 129 IItem item = (IItem)listView.SelectedItems[0].Tag; 130 IView view = MainFormManager.CreateDefaultView(item,ReadOnly); 131 if (view != null) view.Show(); 130 IView view = MainFormManager.CreateDefaultView(item); 131 if (view != null) { 132 view.ReadOnly = ReadOnly; 133 view.Show(); 134 } 132 135 } 133 136 } … … 141 144 } 142 145 private void showAlgorithmButton_Click(object sender, EventArgs e) { 143 MainFormManager.CreateDefaultView(Content.Algorithm.Clone(),ReadOnly).Show(); 146 IContentView view = MainFormManager.CreateDefaultView(Content.Algorithm.Clone()); 147 if (view != null) { 148 view.ReadOnly = ReadOnly; 149 view.Show(); 150 } 144 151 } 145 152 } -
trunk/sources/HeuristicLab.Optimizer/3.3/FileManager.cs
r3177 r3416 108 108 } 109 109 private static void Save(IContentView view) { 110 if ( view.SaveEnabled) {110 if (!view.Locked) { 111 111 if ((!files.ContainsKey(view)) || (!File.Exists(files[view].Filename))) { 112 112 SaveAs(view); … … 127 127 } 128 128 public static void SaveAs(IContentView view) { 129 if ( view.SaveEnabled) {129 if (!view.Locked) { 130 130 if (saveFileDialog == null) { 131 131 saveFileDialog = new SaveFileDialog(); -
trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/CopyToClipboardMenuItem.cs
r3376 r3416 48 48 protected override void OnActiveViewChanged(object sender, EventArgs e) { 49 49 ItemView activeView = MainFormManager.MainForm.ActiveView as ItemView; 50 ToolStripItem.Enabled = (activeView != null) && ( activeView.SaveEnabled);50 ToolStripItem.Enabled = (activeView != null) && (!activeView.Locked); 51 51 } 52 52 53 53 public override void Execute() { 54 54 ItemView activeView = MainFormManager.MainForm.ActiveView as ItemView; 55 if ((activeView != null) && ( activeView.SaveEnabled)) {55 if ((activeView != null) && (!activeView.Locked)) { 56 56 Clipboard<IItem> clipboard = ((OptimizerMainForm)MainFormManager.MainForm).Clipboard; 57 57 clipboard.AddItem((IItem)activeView.Content.Clone()); -
trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/SaveAllMenuItem.cs
r2961 r3416 47 47 protected override void OnActiveViewChanged(object sender, EventArgs e) { 48 48 var views = from v in MainFormManager.MainForm.Views.OfType<IContentView>() 49 where v.SaveEnabled49 where !v.Locked 50 50 select v; 51 51 ToolStripItem.Enabled = views.FirstOrDefault() != null; -
trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/SaveAsMenuItem.cs
r2961 r3416 45 45 protected override void OnActiveViewChanged(object sender, EventArgs e) { 46 46 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 47 ToolStripItem.Enabled = (activeView != null) && ( activeView.SaveEnabled);47 ToolStripItem.Enabled = (activeView != null) && (!activeView.Locked); 48 48 } 49 49 -
trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/SaveMenuItem.cs
r2961 r3416 49 49 protected override void OnActiveViewChanged(object sender, EventArgs e) { 50 50 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 51 ToolStripItem.Enabled = (activeView != null) && ( activeView.SaveEnabled);51 ToolStripItem.Enabled = (activeView != null) && (!activeView.Locked); 52 52 } 53 53 -
trunk/sources/HeuristicLab.Optimizer/3.3/ToolBarItems/SaveAllToolBarItem.cs
r2961 r3416 46 46 protected override void OnActiveViewChanged(object sender, EventArgs e) { 47 47 var views = from v in MainFormManager.MainForm.Views.OfType<IContentView>() 48 where v.SaveEnabled48 where !v.Locked 49 49 select v; 50 50 ToolStripItem.Enabled = views.FirstOrDefault() != null; -
trunk/sources/HeuristicLab.Optimizer/3.3/ToolBarItems/SaveToolBarItem.cs
r2961 r3416 45 45 protected override void OnActiveViewChanged(object sender, EventArgs e) { 46 46 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 47 ToolStripItem.Enabled = (activeView != null) && ( activeView.SaveEnabled);47 ToolStripItem.Enabled = (activeView != null) && (!activeView.Locked); 48 48 } 49 49
Note: See TracChangeset
for help on using the changeset viewer.