Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ClientUserManagement/HeuristicLab.Clients.Access/3.3/Views/RefreshableView.cs @ 7368

Last change on this file since 7368 was 7368, checked in by ascheibe, 13 years ago

#1648 added first version of an access client, access items and views for displaying them

File size: 2.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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.Windows.Forms;
24using HeuristicLab.MainForm;
25using HeuristicLab.MainForm.WindowsForms;
26
27namespace HeuristicLab.Clients.Access.Views {
28  [View("Refreshable View")]
29  [Content(typeof(AccessClient), true)]
30  public partial class RefreshableView : AsynchronousContentView {
31    public new AccessClient Content {
32      get { return (AccessClient)base.Content; }
33      set { base.Content = value; }
34    }
35    public RefreshableView() {
36      InitializeComponent();
37    }
38
39    protected override void DeregisterContentEvents() {
40      Content.Refreshing -= new EventHandler(Content_Refreshing);
41      Content.Refreshed -= new EventHandler(Content_Refreshed);
42      base.DeregisterContentEvents();
43    }
44
45    protected override void RegisterContentEvents() {
46      base.RegisterContentEvents();
47      Content.Refreshing += new EventHandler(Content_Refreshing);
48      Content.Refreshed += new EventHandler(Content_Refreshed);
49    }
50
51
52    protected override void OnContentChanged() {
53      base.OnContentChanged();
54      if (Content == null) {
55        //TODO: remove?
56      } else {
57
58      }
59    }
60
61    protected override void SetEnabledStateOfControls() {
62      base.SetEnabledStateOfControls();
63      refreshButton.Enabled = Content != null;
64    }
65
66    protected virtual void Content_Refreshing(object sender, EventArgs e) {
67      if (InvokeRequired) {
68        Invoke(new EventHandler(Content_Refreshing), sender, e);
69      } else {
70        Cursor = Cursors.AppStarting;
71        refreshButton.Enabled = false;
72      }
73    }
74
75    protected virtual void Content_Refreshed(object sender, EventArgs e) {
76      if (InvokeRequired) {
77        Invoke(new EventHandler(Content_Refreshed), sender, e);
78      } else {
79        Cursor = Cursors.Default;
80        refreshButton.Enabled = true;
81      }
82    }
83
84    protected virtual void RefreshData() { }
85
86    protected void refreshButton_Click(object sender, System.EventArgs e) {
87      RefreshData();
88    }
89  }
90}
Note: See TracBrowser for help on using the repository browser.