- Timestamp:
- 09/25/18 15:05:56 (6 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Clients.Access.Views/3.3/UserViews/RefreshableLightweightUserInformationView.Designer.cs
r15583 r16186 20 20 #endregion 21 21 22 using System;23 22 namespace HeuristicLab.Clients.Access.Views { 24 23 partial class RefreshableLightweightUserInformationView { … … 34 33 protected override void Dispose(bool disposing) { 35 34 if (disposing && (components != null)) { 36 lightweightUserInformationView.UserInformationChanged -= new EventHandler(lightweightUserInformationView_Changed);37 35 components.Dispose(); 38 36 } … … 47 45 /// </summary> 48 46 private void InitializeComponent() { 47 components = new System.ComponentModel.Container(); 49 48 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RefreshableLightweightUserInformationView)); 50 49 this.lightweightUserInformationView = new HeuristicLab.Clients.Access.Views.LightweightUserInformationView(); 51 this.storeButton = new System.Windows.Forms.Button(); 50 this.refreshButton = new System.Windows.Forms.Button(); 51 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 52 52 this.SuspendLayout(); 53 53 // 54 54 // refreshButton 55 55 // 56 this.refreshButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh; 56 57 this.refreshButton.Location = new System.Drawing.Point(4, 3); 58 this.refreshButton.Name = "refreshButton"; 59 this.refreshButton.Size = new System.Drawing.Size(24, 24); 60 this.refreshButton.TabIndex = 1; 61 this.toolTip.SetToolTip(this.refreshButton, "Refresh data"); 62 this.refreshButton.UseVisualStyleBackColor = true; 63 this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click); 57 64 // 58 65 // lightweightUserInformationView … … 69 76 this.lightweightUserInformationView.TabIndex = 2; 70 77 // 71 // storeButton72 //73 this.storeButton.Enabled = false;74 this.storeButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb;75 this.storeButton.Location = new System.Drawing.Point(34, 3);76 this.storeButton.Name = "storeButton";77 this.storeButton.Size = new System.Drawing.Size(24, 24);78 this.storeButton.TabIndex = 3;79 this.storeButton.UseVisualStyleBackColor = true;80 this.storeButton.Click += new System.EventHandler(this.storeButton_Click);81 //82 78 // RefreshableLightweightUserInformationView 83 79 // … … 85 81 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 86 82 this.Controls.Add(this.lightweightUserInformationView); 87 this.Controls.Add(this. storeButton);83 this.Controls.Add(this.refreshButton); 88 84 this.Name = "RefreshableLightweightUserInformationView"; 89 85 this.Size = new System.Drawing.Size(384, 281); 90 this.Controls.SetChildIndex(this.storeButton, 0);91 86 this.Controls.SetChildIndex(this.lightweightUserInformationView, 0); 92 this.Controls.SetChildIndex(this.refreshButton, 0);87 this.Controls.SetChildIndex(this.refreshButton, 1); 93 88 this.ResumeLayout(false); 94 89 … … 98 93 99 94 private LightweightUserInformationView lightweightUserInformationView; 100 private System.Windows.Forms. Button storeButton;101 95 private System.Windows.Forms.ToolTip toolTip; 96 private System.Windows.Forms.Button refreshButton; 102 97 } 103 98 } -
trunk/HeuristicLab.Clients.Access.Views/3.3/UserViews/RefreshableLightweightUserInformationView.cs
r15583 r16186 22 22 using System; 23 23 using System.Windows.Forms; 24 using HeuristicLab.MainForm; 25 using HeuristicLab.MainForm.WindowsForms; 24 26 25 27 namespace HeuristicLab.Clients.Access.Views { 26 public partial class RefreshableLightweightUserInformationView : RefreshableView { 28 [View("RefreshableLightweightUserInformation View")] 29 [Content(typeof(LightweightUser), false)] 30 public partial class RefreshableLightweightUserInformationView : AsynchronousContentView { 31 public new LightweightUser Content { 32 get { return (LightweightUser)base.Content; } 33 set { base.Content = value; } 34 } 35 27 36 public RefreshableLightweightUserInformationView() { 28 37 InitializeComponent(); 38 } 39 40 protected override void OnContentChanged() { 41 base.OnContentChanged(); 42 lightweightUserInformationView.Content = Content; 43 } 44 45 protected override void SetEnabledStateOfControls() { 46 base.SetEnabledStateOfControls(); 47 refreshButton.Enabled = Content != null; 48 } 49 50 protected override void DeregisterContentEvents() { 51 Refreshing -= new EventHandler(Content_Refreshing); 52 Refreshed -= new EventHandler(Content_Refreshed); 53 base.DeregisterContentEvents(); 54 } 55 56 protected override void RegisterContentEvents() { 57 base.RegisterContentEvents(); 58 Refreshing += new EventHandler(Content_Refreshing); 59 Refreshed += new EventHandler(Content_Refreshed); 60 } 61 62 protected void Content_Refreshing(object sender, EventArgs e) { 63 if (InvokeRequired) { 64 Invoke(new EventHandler(Content_Refreshing), sender, e); 65 } else { 66 Cursor = Cursors.AppStarting; 67 refreshButton.Enabled = false; 68 69 lightweightUserInformationView.Enabled = false; 70 } 71 } 72 73 protected void Content_Refreshed(object sender, EventArgs e) { 74 if (InvokeRequired) { 75 Invoke(new EventHandler(Content_Refreshed), sender, e); 76 } else { 77 Cursor = Cursors.Default; 78 refreshButton.Enabled = true; 79 80 lightweightUserInformationView.Enabled = true; 81 if (!UserInformation.Instance.UserExists) { 82 MessageBox.Show("Couldn't fetch user information from the server." + Environment.NewLine + 83 "Please verify that you have an existing user and that your user name and password is correct. ", "HeuristicLab Access Service", MessageBoxButtons.OK, MessageBoxIcon.Error); 84 lightweightUserInformationView.Content = null; 85 } else { 86 lightweightUserInformationView.Content = Content; 87 } 88 } 89 } 90 91 void lightweightUserInformationView_Changed(object sender, EventArgs e) { 92 // nothing to do 29 93 } 30 94 … … 34 98 } 35 99 36 void lightweightUserInformationView_Changed(object sender, EventArgs e) {37 if (!storeButton.Enabled) storeButton.Enabled = true;100 private void RefreshData() { 101 ExecuteActionAsync(RefreshUserData, PluginInfrastructure.ErrorHandling.ShowErrorDialog); 38 102 } 39 103 40 p rotected override void RefreshData() {41 Content.ExecuteActionAsync(RefreshUserData, PluginInfrastructure.ErrorHandling.ShowErrorDialog);104 public void ManualRefresh() { 105 RefreshData(); 42 106 } 43 107 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 } 108 protected void refreshButton_Click(object sender, System.EventArgs e) { 109 RefreshData(); 52 110 } 53 111 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; 112 public void ExecuteActionAsync(Action action, Action<Exception> exceptionCallback) { 113 var call = new Func<Exception>(delegate () { 114 try { 115 OnRefreshing(); 116 action(); 117 } catch (Exception ex) { 118 return ex; 119 } finally { 120 OnRefreshed(); 66 121 } 67 } 122 return null; 123 }); 124 call.BeginInvoke(delegate (IAsyncResult result) { 125 Exception ex = call.EndInvoke(result); 126 if (ex != null) exceptionCallback(ex); 127 }, null); 68 128 } 69 129 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); 130 #region Events 131 public event EventHandler Refreshing; 132 private void OnRefreshing() { 133 EventHandler handler = Refreshing; 134 if (handler != null) handler(this, EventArgs.Empty); 74 135 } 136 public event EventHandler Refreshed; 137 private void OnRefreshed() { 138 EventHandler handler = Refreshed; 139 if (handler != null) handler(this, EventArgs.Empty); 140 } 141 #endregion 75 142 } 76 143 } -
trunk/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectPermissionsView.cs
r16184 r16186 117 117 var selectedPermission = (UserGroupBase)e.Node.Tag; 118 118 detailsViewHost.Content = selectedPermission; 119 if (selectedPermission is LightweightUser) 120 detailsViewHost.ViewType = typeof(Access.Views.RefreshableLightweightUserInformationView); 119 121 } 120 122
Note: See TracChangeset
for help on using the changeset viewer.