Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Core.Views/3.3/ItemView.cs @ 2727

Last change on this file since 2727 was 2727, checked in by swagner, 14 years ago

Operator architecture refactoring (#95)

  • worked on content definitions of views
  • corrected bug in cloning of CombinedOperator
File size: 3.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.ComponentModel;
25using System.Drawing;
26using System.Data;
27using System.Text;
28using System.Xml;
29using System.Windows.Forms;
30using HeuristicLab.MainForm;
31using HeuristicLab.MainForm.WindowsForms;
32
33namespace HeuristicLab.Core.Views {
34  /// <summary>
35  /// Base class for all visual representations.
36  /// </summary>
37  [Content(typeof(Item), false)]
38  [Content(typeof(IItem), false)]
39  public partial class ItemView : ContentView {
40    public new IItem Content {
41      get { return (IItem)base.Content; }
42      set { base.Content = value; }
43    }
44
45    /// <summary>
46    /// Initializes a new instance of <see cref="ViewBase"/> with the caption "View".
47    /// </summary>
48    public ItemView() {
49      InitializeComponent();
50      Caption = "View";
51    }
52    public ItemView(IItem content)
53      : this() {
54      Content = content;
55    }
56
57    protected override void OnContentChanged() {
58      base.OnContentChanged();
59      if (Content == null) {
60        Caption = "View";
61      } else {
62        Caption = Content.ItemName;
63      }
64    }
65
66    /// <summary>
67    /// Asynchron call of GUI updating.
68    /// </summary>
69    /// <param name="method">The delegate to invoke.</param>
70    protected new void Invoke(Delegate method) {
71      // enforce context switch to improve GUI response time
72      System.Threading.Thread.Sleep(0);
73
74      // prevent blocking of worker thread in Invoke, if the control is disposed
75      IAsyncResult result = BeginInvoke(method);
76      while ((!result.AsyncWaitHandle.WaitOne(100, false)) && (!IsDisposed)) { }
77      if (!IsDisposed) EndInvoke(result);
78    }
79    /// <summary>
80    /// Asynchron call of GUI updating.
81    /// </summary>
82    /// <param name="method">The delegate to invoke.</param>
83    /// <param name="args">The invoke arguments.</param>
84    protected new void Invoke(Delegate method, params object[] args) {
85      // enforce context switch to improve GUI response time
86      System.Threading.Thread.Sleep(0);
87
88      // prevent blocking of worker thread in Invoke, if the control is disposed
89      IAsyncResult result = BeginInvoke(method, args);
90      while ((!result.AsyncWaitHandle.WaitOne(100, false)) && (!IsDisposed)) { }
91      if (!IsDisposed) EndInvoke(result);
92    }
93  }
94}
Note: See TracBrowser for help on using the repository browser.