Skip to content

Commit

Permalink
Add ApplicationUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Dec 11, 2023
1 parent 4036eec commit 54f23c2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ricaun.Revit.UI.StatusBar/Revit/Commands/CommandRevit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme
{
UIApplication uiapp = commandData.Application;

var stopwatch = System.Diagnostics.Stopwatch.StartNew();

RevitProgressBarUtils.Run(uiapp.Application.VersionName, 100, (i) =>
{
System.Threading.Thread.Sleep(i);
});

System.Console.WriteLine($"Stopwatch: {stopwatch.ElapsedMilliseconds}");

return Result.Succeeded;
}
}
Expand Down
6 changes: 3 additions & 3 deletions ricaun.Revit.UI.StatusBar/RevitProgressBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@ private RevitProgressBar RefreshStopwatchBackground()
private void RefreshBackground(bool disable = false)
{
RevitRibbonController.Disable();
System.Windows.Forms.Application.DoEvents();
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
ApplicationUtils.DoEvents();
ApplicationUtils.SetCursorWait();
//progressBarStackPanel.Dispatcher.Invoke(() => { }, System.Windows.Threading.DispatcherPriority.Render);
if (disable)
{
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
ApplicationUtils.SetCursorDefault();
RevitRibbonController.Enable();
}
}
Expand Down
32 changes: 32 additions & 0 deletions ricaun.Revit.UI.StatusBar/Utils/ApplicationUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace ricaun.Revit.UI.StatusBar
{
/// <summary>
/// ApplicationUtils
/// </summary>
public static class ApplicationUtils
{
/// <summary>
/// DoEvents
/// </summary>
public static void DoEvents()
{
System.Windows.Forms.Application.DoEvents();
}

/// <summary>
/// SetCursorWait
/// </summary>
public static void SetCursorWait()
{
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
}

/// <summary>
/// SetCursorDefault
/// </summary>
public static void SetCursorDefault()
{
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
}
}
}
2 changes: 1 addition & 1 deletion ricaun.Revit.UI.StatusBar/ricaun.Revit.UI.StatusBar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

<PropertyGroup>
<PackageId>ricaun.Revit.UI.StatusBar</PackageId>
<Version>1.0.0-alpha.1</Version>
<Version>1.0.0-alpha.2</Version>
<ProjectGuid>{841E5210-49AA-415B-9B05-23B47C840BA1}</ProjectGuid>
</PropertyGroup>

Expand Down

0 comments on commit 54f23c2

Please sign in to comment.