Browse Source

Show progress of SD status bar also in Windows 7 taskbar.

Delay hiding the progress bar a bit in case of errors to give the user a visual clue that his build failed in the screen area he's looking at (the progress bar).

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5490 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
3c7d526857
  1. 59
      src/Main/Base/Project/Src/Gui/Components/StatusBar/SdStatusBar.cs
  2. 4
      src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.xaml
  3. 9
      src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs
  4. 2
      src/Main/Base/Project/Src/Services/File/FileChangeWatcher.cs

59
src/Main/Base/Project/Src/Gui/Components/StatusBar/SdStatusBar.cs

@ -12,6 +12,7 @@ using System.Windows.Controls.Primitives; @@ -12,6 +12,7 @@ using System.Windows.Controls.Primitives;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shell;
using ICSharpCode.Core;
@ -113,17 +114,32 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -113,17 +114,32 @@ namespace ICSharpCode.SharpDevelop.Gui
public void DisplayProgress(string taskName, double workDone, OperationStatus status)
{
// LoggingService.Debug("DisplayProgress(\"" + taskName + "\", " + workDone + ", " + status + ")");
if (!statusProgressBarIsVisible) {
statusProgressBarItem.Visibility = Visibility.Visible;
statusProgressBarIsVisible = true;
StopHideProgress();
}
TaskbarItemProgressState taskbarProgressState;
if (double.IsNaN(workDone)) {
statusProgressBar.IsIndeterminate = true;
status = OperationStatus.Normal; // indeterminate doesn't support foreground color
taskbarProgressState = TaskbarItemProgressState.Indeterminate;
} else {
statusProgressBar.IsIndeterminate = false;
statusProgressBar.Value = workDone;
if (status == OperationStatus.Error)
taskbarProgressState = TaskbarItemProgressState.Error;
else
taskbarProgressState = TaskbarItemProgressState.Normal;
}
TaskbarItemInfo taskbar = WorkbenchSingleton.MainWindow.TaskbarItemInfo;
if (taskbar != null) {
taskbar.ProgressState = taskbarProgressState;
taskbar.ProgressValue = workDone;
}
if (status != currentStatus) {
@ -135,11 +151,11 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -135,11 +151,11 @@ namespace ICSharpCode.SharpDevelop.Gui
if (status == OperationStatus.Error) {
statusProgressBar.Foreground = progressForegroundBrush;
progressForegroundBrush.BeginAnimation(SolidColorBrush.ColorProperty, new ColorAnimation(
Colors.Red, new Duration(TimeSpan.FromSeconds(0.6)), FillBehavior.HoldEnd));
Colors.Red, new Duration(TimeSpan.FromSeconds(0.2)), FillBehavior.HoldEnd));
} else if (status == OperationStatus.Warning) {
statusProgressBar.Foreground = progressForegroundBrush;
progressForegroundBrush.BeginAnimation(SolidColorBrush.ColorProperty, new ColorAnimation(
Colors.YellowGreen, new Duration(TimeSpan.FromSeconds(0.6)), FillBehavior.HoldEnd));
Colors.YellowGreen, new Duration(TimeSpan.FromSeconds(0.2)), FillBehavior.HoldEnd));
} else {
statusProgressBar.ClearValue(ProgressBar.ForegroundProperty);
progressForegroundBrush = null;
@ -155,9 +171,44 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -155,9 +171,44 @@ namespace ICSharpCode.SharpDevelop.Gui
public void HideProgress()
{
// LoggingService.Debug("HideProgress()");
statusProgressBarIsVisible = false;
statusProgressBarItem.Visibility = Visibility.Collapsed;
jobNamePanel.Content = currentTaskName = "";
// to allow the user to see the red progress bar as a visual clue of a failed
// build even if it occurs close to the end of the build, we'll hide the progress bar
// with a bit of time delay
WorkbenchSingleton.CallLater(
TimeSpan.FromMilliseconds(currentStatus == OperationStatus.Error ? 500 : 150),
new Action(DoHideProgress));
}
void DoHideProgress()
{
if (!statusProgressBarIsVisible) {
// make stuff look nice and delay it a little more by using an animation
// on the progress bar
TimeSpan timeSpan = TimeSpan.FromSeconds(0.25);
var animation = new DoubleAnimation(0, new Duration(timeSpan), FillBehavior.HoldEnd);
statusProgressBarItem.BeginAnimation(OpacityProperty, animation);
jobNamePanel.BeginAnimation(OpacityProperty, animation);
WorkbenchSingleton.CallLater(
timeSpan,
delegate{
if (!statusProgressBarIsVisible) {
statusProgressBarItem.Visibility = Visibility.Collapsed;
jobNamePanel.Content = currentTaskName = "";
var taskbar = WorkbenchSingleton.MainWindow.TaskbarItemInfo;
if (taskbar != null)
taskbar.ProgressState = TaskbarItemProgressState.None;
StopHideProgress();
}
});
}
}
void StopHideProgress()
{
statusProgressBarItem.BeginAnimation(OpacityProperty, null);
jobNamePanel.BeginAnimation(OpacityProperty, null);
}
}
}

4
src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.xaml

@ -11,6 +11,10 @@ @@ -11,6 +11,10 @@
AllowDrop = "True"
Style = "{x:Static core:GlobalStyles.WindowStyle}"
>
<Window.TaskbarItemInfo>
<TaskbarItemInfo />
</Window.TaskbarItemInfo>
<DockPanel Name="dockPanel">
<Menu Name="mainMenu" DockPanel.Dock="Top"/>
<!-- Toolbars will be inserted here (index: 1) -->

9
src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs

@ -242,16 +242,17 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -242,16 +242,17 @@ namespace ICSharpCode.SharpDevelop.Gui
/// <summary>
/// Calls a method on the GUI thread, but delays the call a bit.
/// </summary>
public static void CallLater(int delayMilliseconds, Action method)
public static void CallLater(TimeSpan delay, Action method)
{
if (delayMilliseconds <= 0)
throw new ArgumentOutOfRangeException("delayMilliseconds", delayMilliseconds, "Value must be positive");
int delayMilliseconds = (int)delay.TotalMilliseconds;
if (delayMilliseconds < 0)
throw new ArgumentOutOfRangeException("delay", delay, "Value must be positive");
if (method == null)
throw new ArgumentNullException("method");
SafeThreadAsyncCall(
delegate {
Timer t = new Timer();
t.Interval = delayMilliseconds;
t.Interval = Math.Max(1, delayMilliseconds);
t.Tick += delegate {
t.Stop();
t.Dispose();

2
src/Main/Base/Project/Src/Services/File/FileChangeWatcher.cs

@ -161,7 +161,7 @@ namespace ICSharpCode.SharpDevelop @@ -161,7 +161,7 @@ namespace ICSharpCode.SharpDevelop
// when the file changes twice in quick succession; and prevents
// trying to reload the file while it is still being written
WorkbenchSingleton.CallLater(
500,
TimeSpan.FromSeconds(0.5),
delegate { MainForm_Activated(this, EventArgs.Empty); } );
}
}

Loading…
Cancel
Save