Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKB/HeuristicLab.MainForm.WPF/WPFView.cs @ 6874

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

Integrated OKB clients for HL 3.3 (#1166)

File size: 1.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows.Controls;
6
7namespace HeuristicLab.MainForm.WPF {
8
9  public abstract class WPFView : UserControl, IView {   
10
11    private string caption = "WPF View";
12    public string Caption {
13      get {
14        return caption;
15      }
16      set {
17        if (value == caption) return;
18        if (value == null) throw new ArgumentNullException("View caption cannot be null");
19        caption = value;
20        OnCaptionChanged();
21      }
22    }
23    public event EventHandler CaptionChanged;
24    protected void OnCaptionChanged() {
25      EventHandler handler = CaptionChanged;
26      if (handler != null)
27        handler(this, EventArgs.Empty);
28    }   
29
30    public event EventHandler Changed;
31
32    protected void OnChanged() {
33      EventHandler handler = Changed;
34      if (handler != null)
35        handler(this, EventArgs.Empty);
36    }
37
38    public virtual void Close() {
39      MainFormManager.GetMainForm<WPFMainFormBase>().CloseView(this);
40      IsShown = false;
41    }
42
43    public void Hide() {
44      MainFormManager.GetMainForm<WPFMainFormBase>().HideView(this);
45      IsShown = false;
46    }
47   
48    public bool IsShown { get; protected set; }
49
50    private bool readOnly = false;
51    public bool ReadOnly {
52      get {
53        return readOnly;
54      }
55      set {
56        if (value == readOnly) return;
57        readOnly = value;
58        OnReadOnlyChanged();
59      }
60    }
61    public event EventHandler ReadOnlyChanged;
62    protected void OnReadOnlyChanged() {
63      EventHandler handler = ReadOnlyChanged;
64      if (handler != null)
65        handler(this, EventArgs.Empty);
66    }
67
68    protected abstract void OnFirstTimeShown();
69
70    public void Show() {
71      if (MainFormManager.GetMainForm<WPFMainFormBase>().ShowView(this))
72        OnFirstTimeShown();
73      IsShown = true;
74    }
75   
76  }
77}
Note: See TracBrowser for help on using the repository browser.