Changeset 16388 for branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Access.Views/3.3/UserViews/RefreshableLightweightUserInformationView.cs
- Timestamp:
- 12/15/18 12:36:08 (6 years ago)
- Location:
- branches/2892_LR-prediction-intervals
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2892_LR-prediction-intervals
- Property svn:ignore
-
old new 1 *.docstates 2 *.psess 3 *.resharper 4 *.suo 5 *.user 6 *.vsp 7 Doxygen 8 FxCopResults.txt 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 11 HeuristicLab 3.3.5.1.ReSharper.user 12 HeuristicLab 3.3.6.0.ReSharper.user 13 HeuristicLab.4.5.resharper.user 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 16 HeuristicLab.resharper.user 17 ProtoGen.exe 1 18 TestResults 19 _ReSharper.HeuristicLab 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 22 _ReSharper.HeuristicLab.ExtLibs 23 bin 24 protoc.exe 25 obj 26 .vs
-
- Property svn:mergeinfo changed
-
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:ignore
-
branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Access.Views
- Property svn:mergeinfo changed
-
branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Access.Views/3.3/UserViews/RefreshableLightweightUserInformationView.cs
r15583 r16388 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 this.Locked = true; 48 refreshButton.Enabled = Content != null; 49 } 50 51 protected override void DeregisterContentEvents() { 52 Refreshing -= new EventHandler(Content_Refreshing); 53 Refreshed -= new EventHandler(Content_Refreshed); 54 base.DeregisterContentEvents(); 55 } 56 57 protected override void RegisterContentEvents() { 58 base.RegisterContentEvents(); 59 Refreshing += new EventHandler(Content_Refreshing); 60 Refreshed += new EventHandler(Content_Refreshed); 61 } 62 63 protected void Content_Refreshing(object sender, EventArgs e) { 64 if (InvokeRequired) { 65 Invoke(new EventHandler(Content_Refreshing), sender, e); 66 } else { 67 Cursor = Cursors.AppStarting; 68 refreshButton.Enabled = false; 69 70 lightweightUserInformationView.Enabled = false; 71 } 72 } 73 74 protected void Content_Refreshed(object sender, EventArgs e) { 75 if (InvokeRequired) { 76 Invoke(new EventHandler(Content_Refreshed), sender, e); 77 } else { 78 Cursor = Cursors.Default; 79 refreshButton.Enabled = true; 80 81 lightweightUserInformationView.Enabled = true; 82 if (!UserInformation.Instance.UserExists) { 83 MessageBox.Show("Couldn't fetch user information from the server." + Environment.NewLine + 84 "Please verify that you have an existing user and that your user name and password is correct. ", "HeuristicLab Access Service", MessageBoxButtons.OK, MessageBoxIcon.Error); 85 lightweightUserInformationView.Content = null; 86 } else { 87 lightweightUserInformationView.Content = Content; 88 } 89 } 90 } 91 92 void lightweightUserInformationView_Changed(object sender, EventArgs e) { 93 // nothing to do 29 94 } 30 95 … … 34 99 } 35 100 36 void lightweightUserInformationView_Changed(object sender, EventArgs e) {37 if (!storeButton.Enabled) storeButton.Enabled = true;101 private void RefreshData() { 102 ExecuteActionAsync(RefreshUserData, PluginInfrastructure.ErrorHandling.ShowErrorDialog); 38 103 } 39 104 40 p rotected override void RefreshData() {41 Content.ExecuteActionAsync(RefreshUserData, PluginInfrastructure.ErrorHandling.ShowErrorDialog);105 public void ManualRefresh() { 106 RefreshData(); 42 107 } 43 108 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 } 109 protected void refreshButton_Click(object sender, System.EventArgs e) { 110 RefreshData(); 52 111 } 53 112 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; 113 public void ExecuteActionAsync(Action action, Action<Exception> exceptionCallback) { 114 var call = new Func<Exception>(delegate () { 115 try { 116 OnRefreshing(); 117 action(); 118 } catch (Exception ex) { 119 return ex; 120 } finally { 121 OnRefreshed(); 66 122 } 67 } 123 return null; 124 }); 125 call.BeginInvoke(delegate (IAsyncResult result) { 126 Exception ex = call.EndInvoke(result); 127 if (ex != null) exceptionCallback(ex); 128 }, null); 68 129 } 69 130 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); 131 #region Events 132 public event EventHandler Refreshing; 133 private void OnRefreshing() { 134 EventHandler handler = Refreshing; 135 if (handler != null) handler(this, EventArgs.Empty); 74 136 } 137 public event EventHandler Refreshed; 138 private void OnRefreshed() { 139 EventHandler handler = Refreshed; 140 if (handler != null) handler(this, EventArgs.Empty); 141 } 142 #endregion 75 143 } 76 144 }
Note: See TracChangeset
for help on using the changeset viewer.