Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ClientUserManagement/HeuristicLab.Clients.Access.Views/3.3/UserViews/LightweightUserInformationView.cs @ 7942

Last change on this file since 7942 was 7942, checked in by ascheibe, 12 years ago

#1648 improved user information dialog

File size: 3.2 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.Windows.Forms;
23using HeuristicLab.MainForm;
24using HeuristicLab.MainForm.WindowsForms;
25
26namespace HeuristicLab.Clients.Access.Views {
27  [View("RefreshableLightweightUserInformation View")]
28  [Content(typeof(LightweightUser), true)]
29  public partial class LightweightUserInformationView : AsynchronousContentView {
30    public new LightweightUser Content {
31      get { return (LightweightUser)base.Content; }
32      set { base.Content = value; }
33    }
34
35    public LightweightUserInformationView() {
36      InitializeComponent();
37    }
38
39    protected override void OnContentChanged() {
40      base.OnContentChanged();
41      rolesListView.Items.Clear();
42      groupsListView.Items.Clear();
43      rolesListView.SmallImageList.Images.Clear();
44      groupsListView.SmallImageList.Images.Clear();
45
46      if (Content == null) {
47        userNameTextBox.Clear();
48        fullNameTextBox.Clear();
49      } else {
50        userNameTextBox.Text = Content.UserName;
51        fullNameTextBox.Text = Content.FullName;
52
53        foreach (Role r in Content.Roles)
54          rolesListView.Items.Add(CreateListViewRoleItem(r));
55
56        foreach (UserGroup g in Content.Groups)
57          groupsListView.Items.Add(CreateListViewGroupItem(g));
58
59        rolesListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
60        groupsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
61      }
62    }
63
64    private void changePasswordButton_Click(object sender, System.EventArgs e) {
65      using (ChangePasswordDialog dialog = new ChangePasswordDialog()) {
66        dialog.ShowDialog(this);
67      }
68    }
69
70    private ListViewItem CreateListViewRoleItem(Role item) {
71      ListViewItem listViewItem = new ListViewItem();
72
73      listViewItem.Text = item.ToString();
74      rolesListView.SmallImageList.Images.Add(item.ItemImage);
75      listViewItem.ImageIndex = rolesListView.SmallImageList.Images.Count - 1;
76      listViewItem.Tag = item;
77
78      return listViewItem;
79    }
80
81    private ListViewItem CreateListViewGroupItem(UserGroup item) {
82      ListViewItem listViewItem = new ListViewItem();
83
84      listViewItem.Text = item.ToString();
85      groupsListView.SmallImageList.Images.Add(item.ItemImage);
86      listViewItem.ImageIndex = rolesListView.SmallImageList.Images.Count - 1;
87      listViewItem.Tag = item;
88
89      return listViewItem;
90    }
91  }
92}
Note: See TracBrowser for help on using the repository browser.