Changeset 7375
- Timestamp:
- 01/19/12 17:51:26 (13 years ago)
- Location:
- branches/ClientUserManagement
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ClientUserManagement/HeuristicLab.Clients.Access/3.3/AccessClient.cs
r7368 r7375 48 48 49 49 #region Refresh 50 private void Refresh() { 51 OnRefreshing(); 50 public void Refresh() { 52 51 users = new ItemList<LightweightUser>(); 53 54 try { 55 users.AddRange(CallRunCreationService<ItemList<LightweightUser>>(s => new ItemList<LightweightUser>(s.GetAllLightweightUsers()))); 56 } 57 finally { 58 OnRefreshed(); 59 } 52 users.AddRange(CallRunCreationService<ItemList<LightweightUser>>(s => new ItemList<LightweightUser>(s.GetAllLightweightUsers()))); 60 53 } 61 54 public void RefreshAsync(Action<Exception> exceptionCallback) { 62 55 var call = new Func<Exception>(delegate() { 63 56 try { 57 OnRefreshing(); 64 58 Refresh(); 65 59 } 66 60 catch (Exception ex) { 67 61 return ex; 62 } 63 finally { 64 OnRefreshed(); 65 } 66 return null; 67 }); 68 call.BeginInvoke(delegate(IAsyncResult result) { 69 Exception ex = call.EndInvoke(result); 70 if (ex != null) exceptionCallback(ex); 71 }, null); 72 } 73 public void ExecuteActionAsync(Action action, Action<Exception> exceptionCallback) { 74 var call = new Func<Exception>(delegate() { 75 try { 76 OnRefreshing(); 77 action(); 78 } 79 catch (Exception ex) { 80 return ex; 81 } 82 finally { 83 OnRefreshed(); 68 84 } 69 85 return null; -
branches/ClientUserManagement/HeuristicLab.Clients.Access/3.3/ServiceClients/LightweightUser.cs
r7368 r7375 39 39 40 40 public override string ToString() { 41 return UserName + " ( 41 return UserName + " (" + FullName + ")"; 42 42 } 43 43 } -
branches/ClientUserManagement/HeuristicLab.Clients.Access/3.3/Views/LightweightUserView.Designer.cs
r7368 r7375 24 24 /// </summary> 25 25 private void InitializeComponent() { 26 this.checkedListBox = new System.Windows.Forms.CheckedListBox();27 26 this.SuspendLayout(); 28 //29 // checkedListBox30 //31 this.checkedListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)32 | System.Windows.Forms.AnchorStyles.Left)33 | System.Windows.Forms.AnchorStyles.Right)));34 this.checkedListBox.CheckOnClick = true;35 this.checkedListBox.FormattingEnabled = true;36 this.checkedListBox.Location = new System.Drawing.Point(3, 3);37 this.checkedListBox.Name = "checkedListBox";38 this.checkedListBox.Size = new System.Drawing.Size(532, 229);39 this.checkedListBox.TabIndex = 0;40 27 // 41 28 // LightweightUserView … … 43 30 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 44 31 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 45 this.Controls.Add(this.checkedListBox);46 32 this.Name = "LightweightUserView"; 47 33 this.Size = new System.Drawing.Size(538, 235); … … 52 38 #endregion 53 39 54 private System.Windows.Forms.CheckedListBox checkedListBox;55 40 } 56 41 } -
branches/ClientUserManagement/HeuristicLab.Clients.Access/3.3/Views/LightweightUserView.cs
r7368 r7375 21 21 22 22 using System; 23 using System.Collections.Generic; 23 using System.Windows.Forms; 24 using HeuristicLab.Collections; 24 25 using HeuristicLab.Core; 26 using HeuristicLab.Core.Views; 25 27 using HeuristicLab.MainForm; 26 28 using HeuristicLab.MainForm.WindowsForms; … … 29 31 30 32 [View("LightweightUser View")] 31 [Content(typeof( ItemList<LightweightUser>), true)]32 public partial class LightweightUserView : C ontentView{33 public new ItemList<LightweightUser> Content{34 get { return (ItemList<LightweightUser>)base.Content; }35 set { base.Content = value; }33 [Content(typeof(CheckedItemList<LightweightUser>), true)] 34 public partial class LightweightUserView : CheckedItemListView<LightweightUser> { 35 public LightweightUserView() { 36 InitializeComponent(); 37 this.showDetailsCheckBox.Checked = false; 36 38 } 37 39 38 p ublic List<Guid> SelectedUsers { get; set; }39 40 public LightweightUserView() {41 InitializeComponent();42 SelectedUsers = new List<Guid>();40 protected override void SetEnabledStateOfControls() { 41 base.SetEnabledStateOfControls(); 42 this.addButton.Enabled = false; 43 this.showDetailsCheckBox.Enabled = false; 44 this.removeButton.Enabled = false; 43 45 } 44 46 45 protected override void OnContentChanged() { 46 base.OnContentChanged(); 47 protected override void itemsListView_SelectedIndexChanged(object sender, EventArgs e) { 48 base.itemsListView_SelectedIndexChanged(sender, e); 49 this.removeButton.Enabled = false; 50 } 47 51 48 SelectedUsers.Clear(); 49 if (Content == null) { 50 checkedListBox.Items.Clear(); 51 } else { 52 Content.ForEach(x => checkedListBox.Items.Add(x)); 52 protected override void Content_CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<LightweightUser>> e) { 53 base.Content_CheckedItemsChanged(sender, e); 54 OnSelectedUsersChanged(); 55 } 56 57 public event EventHandler SelectedUsersChanged; 58 protected virtual void OnSelectedUsersChanged() { 59 if (InvokeRequired) 60 Invoke((MethodInvoker)OnSelectedUsersChanged); 61 else { 62 EventHandler handler = SelectedUsersChanged; 63 if (handler != null) 64 handler(this, EventArgs.Empty); 53 65 } 54 66 } -
branches/ClientUserManagement/HeuristicLab.Clients.Access/3.3/Views/RefreshableLightweightUserView.Designer.cs
r7368 r7375 24 24 /// </summary> 25 25 private void InitializeComponent() { 26 this.refreshButton = new System.Windows.Forms.Button(); 27 this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 26 this.lightweightUserView = new HeuristicLab.Clients.Access.Views.LightweightUserView(); 28 27 this.SuspendLayout(); 29 28 // 30 // refreshButton29 // lightweightUserView 31 30 // 32 this.refreshButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh; 33 this.refreshButton.Location = new System.Drawing.Point(3, 3); 34 this.refreshButton.Name = "refreshButton"; 35 this.refreshButton.Size = new System.Drawing.Size(24, 24); 36 this.refreshButton.TabIndex = 1; 37 this.refreshButton.UseVisualStyleBackColor = true; 38 this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click); 39 // 40 // viewHost 41 // 42 this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 31 this.lightweightUserView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 43 32 | System.Windows.Forms.AnchorStyles.Left) 44 33 | System.Windows.Forms.AnchorStyles.Right))); 45 this.viewHost.Caption = "View"; 46 this.viewHost.Content = null; 47 this.viewHost.Enabled = false; 48 this.viewHost.Location = new System.Drawing.Point(3, 33); 49 this.viewHost.Name = "viewHost"; 50 this.viewHost.ReadOnly = false; 51 this.viewHost.Size = new System.Drawing.Size(500, 218); 52 this.viewHost.TabIndex = 2; 53 this.viewHost.ViewsLabelVisible = true; 54 this.viewHost.ViewType = null; 34 this.lightweightUserView.Caption = "LightweightUser View"; 35 this.lightweightUserView.Content = null; 36 this.lightweightUserView.Location = new System.Drawing.Point(3, 33); 37 this.lightweightUserView.Name = "lightweightUserView"; 38 this.lightweightUserView.ReadOnly = false; 39 this.lightweightUserView.Size = new System.Drawing.Size(500, 218); 40 this.lightweightUserView.TabIndex = 2; 41 this.lightweightUserView.SelectedUsersChanged += new System.EventHandler(this.lightweightUserView_SelectedUsersChanged); 55 42 // 56 // Refreshable View43 // RefreshableLightweightUserView 57 44 // 58 45 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 59 46 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 60 this.Controls.Add(this. viewHost);61 this. Controls.Add(this.refreshButton);62 this. Name = "RefreshableView";63 this. Size = new System.Drawing.Size(506, 254);47 this.Controls.Add(this.lightweightUserView); 48 this.Name = "RefreshableLightweightUserView"; 49 this.Controls.SetChildIndex(this.lightweightUserView, 0); 50 this.Controls.SetChildIndex(this.refreshButton, 0); 64 51 this.ResumeLayout(false); 65 52 … … 68 55 #endregion 69 56 70 private System.Windows.Forms.Button refreshButton; 71 private MainForm.WindowsForms.ViewHost viewHost; 57 private LightweightUserView lightweightUserView; 72 58 } 73 59 } -
branches/ClientUserManagement/HeuristicLab.Clients.Access/3.3/Views/RefreshableLightweightUserView.cs
r7368 r7375 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Windows.Forms; 25 using HeuristicLab.Core; 23 26 using HeuristicLab.MainForm; 24 27 using HeuristicLab.MainForm.WindowsForms; … … 31 34 public RefreshableLightweightUserView() { 32 35 InitializeComponent(); 36 33 37 } 34 38 39 //set an action like a webservice call to retrieve the users which should be marked as checked 40 //TODO: disable refresh button if not set 41 public Func<List<Guid>> FetchSelectedUsers { get; set; } 42 private List<Guid> selectedUsers; 43 35 44 protected override void RefreshData() { 36 Content.RefreshAsync(new Action<Exception>((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Refresh failed.", ex))); 45 Action completeRefreshAction = new Action(delegate { 46 selectedUsers = FetchSelectedUsers(); 47 Content.Refresh(); 48 }); 49 50 Content.ExecuteActionAsync(completeRefreshAction, new Action<Exception>((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Refresh failed.", ex))); 37 51 } 38 52 39 53 protected override void Content_Refreshing(object sender, EventArgs e) { 40 54 base.Content_Refreshing(sender, e); 41 viewHost.Content = null;55 lightweightUserView.Content = null; 42 56 } 43 57 … … 45 59 base.Content_Refreshed(sender, e); 46 60 47 viewHost.Content = Content.Users; 61 var checkedUsers = new CheckedItemList<LightweightUser>(Content.Users); 62 checkedUsers.ForEach(u => { 63 int idx = checkedUsers.IndexOf(u); 64 checkedUsers.SetItemCheckedState(idx, selectedUsers.Contains(u.Id)); 65 }); 66 lightweightUserView.Content = checkedUsers; 67 } 68 69 public ICheckedItemList<LightweightUser> GetCheckedUsers() { 70 if (lightweightUserView.Content == null) 71 return null; 72 else 73 return lightweightUserView.Content; 74 } 75 76 public event EventHandler SelectedUsersChanged; 77 protected virtual void OnSelectedUsersChanged() { 78 if (InvokeRequired) 79 Invoke((MethodInvoker)OnSelectedUsersChanged); 80 else { 81 EventHandler handler = SelectedUsersChanged; 82 if (handler != null) 83 handler(this, EventArgs.Empty); 84 } 85 } 86 87 private void lightweightUserView_SelectedUsersChanged(object sender, EventArgs e) { 88 OnSelectedUsersChanged(); 48 89 } 49 90 } -
branches/ClientUserManagement/HeuristicLab.Clients.Access/3.3/Views/RefreshableView.Designer.cs
r7368 r7375 24 24 /// </summary> 25 25 private void InitializeComponent() { 26 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RefreshableView)); 26 27 this.refreshButton = new System.Windows.Forms.Button(); 27 this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();28 28 this.SuspendLayout(); 29 29 // 30 30 // refreshButton 31 31 // 32 this.refreshButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh;32 this.refreshButton.Image = ((System.Drawing.Image)(resources.GetObject("refreshButton.Image"))); 33 33 this.refreshButton.Location = new System.Drawing.Point(3, 3); 34 34 this.refreshButton.Name = "refreshButton"; … … 38 38 this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click); 39 39 // 40 // viewHost41 //42 this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)43 | System.Windows.Forms.AnchorStyles.Left)44 | System.Windows.Forms.AnchorStyles.Right)));45 this.viewHost.Caption = "View";46 this.viewHost.Content = null;47 this.viewHost.Enabled = false;48 this.viewHost.Location = new System.Drawing.Point(3, 33);49 this.viewHost.Name = "viewHost";50 this.viewHost.ReadOnly = false;51 this.viewHost.Size = new System.Drawing.Size(500, 218);52 this.viewHost.TabIndex = 2;53 this.viewHost.ViewsLabelVisible = true;54 this.viewHost.ViewType = null;55 //56 40 // RefreshableView 57 41 // 58 42 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 59 43 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 60 this.Controls.Add(this.viewHost);61 44 this.Controls.Add(this.refreshButton); 62 45 this.Name = "RefreshableView"; … … 68 51 #endregion 69 52 70 private System.Windows.Forms.Button refreshButton; 71 private MainForm.WindowsForms.ViewHost viewHost; 53 protected System.Windows.Forms.Button refreshButton; 72 54 } 73 55 }
Note: See TracChangeset
for help on using the changeset viewer.