Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2839_HiveProjectManagement/HeuristicLab.Clients.Access.Views/3.3/UserViews/RefreshableLightweightAccessClientInformationView.cs @ 17369

Last change on this file since 17369 was 15953, checked in by jzenisek, 7 years ago

#2839: Several changes and fixes:

  • added button tooltips
  • changed position of buttons
  • added refresh functionality to view of lightweight users ...
File size: 3.1 KB
RevLine 
[8042]1#region License Information
2/* HeuristicLab
[14185]3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[8042]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;
24
25namespace HeuristicLab.Clients.Access.Views {
[15953]26  public partial class RefreshableLightweightAccessClientInformationView : RefreshableView {
27    public RefreshableLightweightAccessClientInformationView() {
[8042]28      InitializeComponent();
29    }
30
31    private void RefreshUserData() {
32      UserInformation.Instance.Refresh();
33      lightweightUserInformationView.UserInformationChanged += new EventHandler(lightweightUserInformationView_Changed);
34    }
35
36    void lightweightUserInformationView_Changed(object sender, EventArgs e) {
37      if (!storeButton.Enabled) storeButton.Enabled = true;
38    }
39
40    protected override void RefreshData() {
41      Content.ExecuteActionAsync(RefreshUserData, PluginInfrastructure.ErrorHandling.ShowErrorDialog);
42    }
43
44    protected override void Content_Refreshing(object sender, EventArgs e) {
45      if (InvokeRequired) {
46        Invoke(new EventHandler(Content_Refreshing), sender, e);
47      } else {
48        base.Content_Refreshing(sender, e);
49        lightweightUserInformationView.Enabled = false;
50        storeButton.Enabled = false;
51      }
52    }
53
54    protected override void Content_Refreshed(object sender, EventArgs e) {
55      if (InvokeRequired) {
56        Invoke(new EventHandler(Content_Refreshed), sender, e);
57      } else {
58        base.Content_Refreshed(sender, e);
59        lightweightUserInformationView.Enabled = true;
60        if (!UserInformation.Instance.UserExists) {
61          MessageBox.Show("Couldn't fetch user information from the server." + Environment.NewLine +
62            "Please verify that you have an existing user and that your user name and password is correct. ", "HeuristicLab Access Service", MessageBoxButtons.OK, MessageBoxIcon.Error);
63          lightweightUserInformationView.Content = null;
64        } else {
65          lightweightUserInformationView.Content = UserInformation.Instance.User;
66        }
67      }
68    }
69
70    private void storeButton_Click(object sender, EventArgs e) {
71      AccessClient.Instance.ExecuteActionAsync(new Action(delegate {
72        AccessClient.CallAccessService(x => x.UpdateLightweightUser(UserInformation.Instance.User));
73      }), HeuristicLab.PluginInfrastructure.ErrorHandling.ShowErrorDialog);
74    }
75  }
76}
Note: See TracBrowser for help on using the repository browser.