Skip to content

Commit

Permalink
refactor: Hide waitcursor behind the IMainFormView interface
Browse files Browse the repository at this point in the history
Merge pull request activescott#154 from learn-more/view_abstraction
  • Loading branch information
activescott authored Jan 7, 2021
2 parents 5c3afd9 + f51df57 commit a082afe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/LessMsi.Gui/IMainFormView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
// Authors:
// Scott Willeke ([email protected])
//
using System;
using System.Collections.Generic;
using LessMsi.Gui.Model;

Expand Down Expand Up @@ -94,5 +95,11 @@ internal interface IMainFormView
/// </summary>
void SetStreamSelectorSource(IEnumerable<StreamInfoView> streamNames);
void SetCabContainedFileListSource(IEnumerable<CabContainedFileView> streamFiles);

/// <summary>
/// Start a wait cursor to indicate.
/// </summary>
/// <returns>An object that should be disposed when the operation is done.</returns>
IDisposable StartWaitCursor();
}
}
5 changes: 5 additions & 0 deletions src/LessMsi.Gui/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,11 @@ private ExtractionProgressDialog BeginShowingProgressDialog()
return progressDialog;
}

public IDisposable StartWaitCursor()
{
return new DisposableCursor(this);
}

protected bool IsFileTabSelected
{
get
Expand Down
6 changes: 3 additions & 3 deletions src/LessMsi.Gui/MainFormPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void ViewFiles(Database msidb)
if (msidb == null)
return;

using (new DisposableCursor(ViewLeakedAbstraction))
using (View.StartWaitCursor())
{
try
{
Expand Down Expand Up @@ -316,7 +316,7 @@ public void LoadTables()

using (var msidb = new Database(this.SelectedMsiFile.FullName, OpenDatabase.ReadOnly))
{
using (new DisposableCursor(ViewLeakedAbstraction))
using (View.StartWaitCursor())
{
try
{
Expand Down Expand Up @@ -425,7 +425,7 @@ private void UpdateMSiTableGrid(Database msidb, string tableName)

Status(string.Concat("Processing Table \'", tableName, "\'."));

using (new DisposableCursor(ViewLeakedAbstraction))
using (View.StartWaitCursor())
{ // clear the columns no matter what happens (in the event the table doesn't exist we don't want to show anything).
View.ClearTableViewGridColumns();
try
Expand Down

0 comments on commit a082afe

Please sign in to comment.