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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.ComponentModel;
|
---|
25 | using System.Drawing;
|
---|
26 | using System.Data;
|
---|
27 | using System.Text;
|
---|
28 | using System.Xml;
|
---|
29 | using System.Windows.Forms;
|
---|
30 | using HeuristicLab.MainForm;
|
---|
31 | using HeuristicLab.MainForm.WindowsForms;
|
---|
32 |
|
---|
33 | namespace 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 | }
|
---|