source: branches/2520_PersistenceReintegration/HeuristicLab.Clients.Access.Administration/3.3/Views/RefreshableView.cs @ 16453

Last change on this file since 16453 was 16453, checked in by jkarder, 12 months ago

#2520: updated year of copyrights

File size: 2.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2019 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.Administration {
28  [View("Refreshable View")]
29  [Content(typeof(AccessAdministrationClient), true)]
30  public partial class RefreshableView : AsynchronousContentView {
31    public new AccessAdministrationClient Content {
32      get { return (AccessAdministrationClient)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    protected override void SetEnabledStateOfControls() {
52      base.SetEnabledStateOfControls();
53      refreshButton.Enabled = Content != null;
54    }
55
56    protected virtual void Content_Refreshing(object sender, EventArgs e) {
57      if (InvokeRequired) {
58        Invoke(new EventHandler(Content_Refreshing), sender, e);
59      } else {
60        Cursor = Cursors.AppStarting;
61        refreshButton.Enabled = false;
62      }
63    }
64
65    protected virtual void Content_Refreshed(object sender, EventArgs e) {
66      if (InvokeRequired) {
67        Invoke(new EventHandler(Content_Refreshed), sender, e);
68      } else {
69        Cursor = Cursors.Default;
70        refreshButton.Enabled = true;
71      }
72    }
73
74    protected virtual void RefreshData() { }
75
76    protected void refreshButton_Click(object sender, System.EventArgs e) {
77      RefreshData();
78    }
79  }
80}
Note: See TracBrowser for help on using the repository browser.