- Timestamp:
- 01/11/11 12:00:36 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForm.cs
r5237 r5270 21 21 22 22 using System; 23 using System.Collections;24 23 using System.Collections.Generic; 25 24 using System.Linq; … … 220 219 221 220 public IContentView ShowContent(IContent content) { 222 if (content == null) 223 throw new ArgumentNullException("Content cannot be null."); 221 if (content == null) throw new ArgumentNullException("Content cannot be null."); 224 222 Type viewType = MainFormManager.GetDefaultViewType(content.GetType()); 225 if (viewType != null) 226 return ShowContent(content, viewType); 223 if (viewType != null) return ShowContent(content, viewType); 227 224 return null; 225 } 226 227 public IContentView ShowContent<T>(T content, bool reuseExistingView, IEqualityComparer<T> comparer = null) where T : class,IContent { 228 if (content == null) throw new ArgumentNullException("Content cannot be null."); 229 if (!reuseExistingView) return ShowContent(content); 230 231 IContentView view = null; 232 if (comparer == null) view = Views.OfType<IContentView>().Where(v => (v.Content as T) == content).FirstOrDefault(); 233 else view = Views.OfType<IContentView>().Where(v => comparer.Equals((v.Content as T), content)).FirstOrDefault(); 234 235 if (view == null) view = ShowContent(content); 236 else view.Show(); 237 238 return view; 228 239 } 229 240 … … 231 242 if (InvokeRequired) return (IContentView)Invoke((Func<IContent, Type, IContentView>)ShowContent, content, viewType); 232 243 else { 233 if (content == null) 234 throw new ArgumentNullException("Content cannot be null."); 235 if (viewType == null) 236 throw new ArgumentNullException("ViewType cannot be null."); 237 238 IContentView view; 239 if (this.ShowContentInViewHost) { 244 if (content == null) throw new ArgumentNullException("Content cannot be null."); 245 if (viewType == null) throw new ArgumentNullException("ViewType cannot be null."); 246 247 IContentView view = null; 248 if (ShowContentInViewHost) { 240 249 ViewHost viewHost = new ViewHost(); 241 250 viewHost.ViewType = viewType; 242 251 view = viewHost; 243 } else 244 252 253 } else view = MainFormManager.CreateView(viewType); 245 254 246 255 view.Content = content;
Note: See TracChangeset
for help on using the changeset viewer.