Index: src/DeltaShell/DeltaShell.Gui/Forms/ProgressDialog/ProgressDialog.cs =================================================================== diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a --- src/DeltaShell/DeltaShell.Gui/Forms/ProgressDialog/ProgressDialog.cs (.../ProgressDialog.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9) +++ src/DeltaShell/DeltaShell.Gui/Forms/ProgressDialog/ProgressDialog.cs (.../ProgressDialog.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -12,8 +12,11 @@ { public partial class ProgressDialog : Form { + public event EventHandler CancelClicked; private Timer refreshTimer = new Timer(); private BindingList bindingList; + + private IEventedList data; //private IEnumerable activities; public ProgressDialog() @@ -26,30 +29,33 @@ refreshTimer.Tick += RefreshTimerOnTick; } - protected override void OnFormClosing(FormClosingEventArgs e) + public IEventedList Data { - if (e.CloseReason == CloseReason.UserClosing) //user shouldn't close this (with Alt-F4 or anything) + get { - e.Cancel = true; + return data; } - - refreshTimer.Start(); + set + { + /*if (data != null) + { + UnWireBindingList(); + }*/ + //create a bindinglist + data = value; + if (data != null) + { + CreateBindingList(); + WireBindingList(); + dgvActivities.DataSource = bindingList; + } + //data = value; + } } - protected override void OnLoad(EventArgs e) - { - CenterToParent(); - refreshTimer.Start(); - } - - private void RefreshTimerOnTick(object sender, EventArgs eventArgs) - { - dgvActivities.Refresh(); - } - public void CenterToParent() { - if(Owner == null) + if (Owner == null) { CenterToScreen(); //temp hack for wpf shizzle return; @@ -62,20 +68,41 @@ return; } - var x = Owner.DesktopLocation.X + (Owner.Width - Width) / 2; - int y = Owner.DesktopLocation.Y + (Owner.Height - Height) / 2; + var x = Owner.DesktopLocation.X + (Owner.Width - Width)/2; + int y = Owner.DesktopLocation.Y + (Owner.Height - Height)/2; Location = new Point(x, y); } - public event EventHandler CancelClicked; + protected override void OnFormClosing(FormClosingEventArgs e) + { + if (e.CloseReason == CloseReason.UserClosing) //user shouldn't close this (with Alt-F4 or anything) + { + e.Cancel = true; + } + refreshTimer.Start(); + } + + protected override void OnLoad(EventArgs e) + { + CenterToParent(); + refreshTimer.Start(); + } + + private void RefreshTimerOnTick(object sender, EventArgs eventArgs) + { + dgvActivities.Refresh(); + } + private void btnCancel_Click(object sender, EventArgs e) { SetButtonState(true); if (CancelClicked != null) + { CancelClicked(this, EventArgs.Empty); + } } private void SetButtonState(bool cancelling) @@ -92,43 +119,15 @@ } } - - private IEventedList data; - - public IEventedList Data + private void UnWireBindingList() { - get - { - return data; - } - set - { - /*if (data != null) - { - UnWireBindingList(); - }*/ - //create a bindinglist - data = value; - if (data != null) - { - CreateBindingList(); - WireBindingList(); - dgvActivities.DataSource = bindingList; - } - //data = value; - } - } - - void UnWireBindingList() - { if (data is INotifyPropertyChanged) { data.CollectionChanged -= DataCollectionChanged; } } - - void WireBindingList() + private void WireBindingList() { if (data is INotifyPropertyChanged) { @@ -137,14 +136,16 @@ } [InvokeRequired] - void DataCollectionChanged(object sender, NotifyCollectionChangingEventArgs e) + private void DataCollectionChanged(object sender, NotifyCollectionChangingEventArgs e) { //dont handle bubbled events if (sender != data) + { return; + } if (e.Action == NotifyCollectionChangeAction.Add) { - bindingList.Add(new ActivityInfo((IActivity)e.Item)); + bindingList.Add(new ActivityInfo((IActivity) e.Item)); SetButtonState(false); } if (e.Action == NotifyCollectionChangeAction.Remove) @@ -153,11 +154,11 @@ } if (e.Action == NotifyCollectionChangeAction.Replace) { - bindingList[e.Index]= new ActivityInfo((IActivity) e.Item); + bindingList[e.Index] = new ActivityInfo((IActivity) e.Item); } } - void CreateBindingList() + private void CreateBindingList() { bindingList = new BindingList(); foreach (var activity in data)