Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2839_HiveProjectManagement/HeuristicLab.Clients.Access.Administration/3.3/Views/UserView.cs @ 15953

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

#2839 worked on client side mgmt of project-resource assignments and project-user permissions

File size: 4.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 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.Core.Views;
25using HeuristicLab.MainForm;
26
27namespace HeuristicLab.Clients.Access.Administration {
28  [View("User View")]
29  [Content(typeof(User), true)]
30  public partial class UserView : ItemView {
31    public new User Content {
32      get { return (User)base.Content; }
33      set { base.Content = value; }
34    }
35
36    public UserView() {
37      InitializeComponent();
38    }
39
40    protected override void OnContentChanged() {
41      base.OnContentChanged();
42
43      if (Content == null) {
44        userNameTextBox.Clear();
45        fullNameTextBox.Clear();
46        emailTextBox.Clear();
47        idTextBox.Clear();
48        lastActivityTextBox.Clear();
49        lastLoginTextBox.Clear();
50        refreshableRoleSelectionListView.Content = null;
51        refreshableRoleSelectionListView.CurrentUser = null;
52      } else {
53        userNameTextBox.Text = Content.UserName;
54        fullNameTextBox.Text = Content.FullName;
55        emailTextBox.Text = Content.Email;
56        idTextBox.Text = Content.Id.ToString();
57        lastActivityTextBox.Text = Content.LastActivityDate.ToString();
58        lastLoginTextBox.Text = Content.LastLoginDate.ToString();
59        refreshableRoleSelectionListView.Content = Content.Id != Guid.Empty ? AccessAdministrationClient.Instance : null;
60        refreshableRoleSelectionListView.CurrentUser = Content;
61      }
62    }
63
64    protected override void SetEnabledStateOfControls() {
65      base.SetEnabledStateOfControls();
66      bool enabled = Content != null && !Locked;
67     
68      userNameTextBox.ReadOnly = !enabled;
69      fullNameTextBox.ReadOnly = !enabled;
70      emailTextBox.ReadOnly = !enabled;
71
72      if (Content == null) {
73        resetPasswordButton.Enabled = false;
74      } else {
75        resetPasswordButton.Enabled = Content.Id != Guid.Empty;
76      }
77    }
78
79    private void fullNameTextBox_TextChanged(object sender, System.EventArgs e) {
80      if (Content.FullName != fullNameTextBox.Text)
81        Content.FullName = fullNameTextBox.Text;
82    }
83
84    private void userNameTextBox_TextChanged(object sender, System.EventArgs e) {
85      if (Content.UserName != userNameTextBox.Text)
86        Content.UserName = userNameTextBox.Text;
87    }
88
89    private void emailTextBox_TextChanged(object sender, System.EventArgs e) {
90      if (Content.Email != emailTextBox.Text)
91        Content.Email = emailTextBox.Text;
92    }
93
94    private void resetPasswordButton_Click(object sender, System.EventArgs e) {
95      Action a = new Action(delegate {
96        string result = AccessAdministrationClient.CallAccessService<string>(s => s.ResetPassword(Content.Id));
97        ShowPassword(result);
98      });
99
100      AccessAdministrationClient.Instance.ExecuteActionAsync(a, PluginInfrastructure.ErrorHandling.ShowErrorDialog); ;
101    }
102
103    private void ShowPassword(string result) {
104      if (InvokeRequired) {
105        Invoke(new Action<string>(ShowPassword), result);
106      } else {
107        using (PasswordDisplayDialog dlg = new PasswordDisplayDialog()) {
108          dlg.Password = result;
109          dlg.ShowDialog(this);
110        }
111      }
112    }
113  }
114}
Note: See TracBrowser for help on using the repository browser.