diff options
author | sr55 <[email protected]> | 2017-03-16 20:26:05 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2017-03-16 20:26:14 +0000 |
commit | e359b4e1fceb25ad9e9bd7f9543e50339d688e7a (patch) | |
tree | 01bea01e99706e6b8efdc52dfa5805575f214ef7 /win/CS | |
parent | cdf2b1d0efe8265b66df05f428cf01ff67bb4621 (diff) |
WinGui: Add option to show progress percentage in app title bar, and the task tray header and system tray tooltip. (Configured via preferences). #630
Diffstat (limited to 'win/CS')
-rw-r--r-- | win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/Resources.Designer.cs | 19 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/Resources.resx | 7 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs | 9 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/ResourcesUI.resx | 3 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Interfaces/INotifyIconService.cs | 15 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/NotifyIconService.cs | 25 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Startup/AppBootstrapper.cs | 1 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/UserSettingConstants.cs | 5 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 14 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 24 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/OptionsView.xaml | 1 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/ShellView.xaml | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/ShellView.xaml.cs | 9 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/defaultsettings.xml | 10 |
15 files changed, 139 insertions, 7 deletions
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index b77dcadda..6cf6ae4f6 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -225,6 +225,7 @@ <Compile Include="Services\Encode\Model\Models\Video\VideoPreset.cs" />
<Compile Include="Services\Encode\Model\Models\Video\VideoProfile.cs" />
<Compile Include="Services\Encode\Model\Models\Video\VideoTune.cs" />
+ <Compile Include="Services\Interfaces\INotifyIconService.cs" />
<Compile Include="Services\Presets\Factories\JsonPresetFactory.cs" />
<Compile Include="Services\Presets\Interfaces\IPresetObject.cs" />
<Compile Include="Services\Presets\Model\PresetDisplayCategory.cs" />
@@ -249,6 +250,7 @@ <Compile Include="Services\Scan\Model\Source.cs" />
<Compile Include="Services\Scan\Model\Subtitle.cs" />
<Compile Include="Services\Scan\Model\Title.cs" />
+ <Compile Include="Services\NotifyIconService.cs" />
<Compile Include="Services\UserSettingService.cs" />
<Compile Include="Startup\StartupOptions.cs" />
<Compile Include="Utilities\AppcastReader.cs" />
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index d21853449..d0b3c079b 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -1732,6 +1732,16 @@ namespace HandBrakeWPF.Properties { }
/// <summary>
+ /// Looks up a localized string similar to {1}%, Pass {2} of {3}
+ ///Remaining Time: {4}.
+ /// </summary>
+ public static string TaskTrayStatusTitle {
+ get {
+ return ResourceManager.GetString("TaskTrayStatusTitle", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Unknown Error.
/// </summary>
public static string UnknownError {
@@ -1906,5 +1916,14 @@ namespace HandBrakeWPF.Properties { return ResourceManager.GetString("Warning", resourceCulture);
}
}
+
+ /// <summary>
+ /// Looks up a localized string similar to {0} - ({1}%, Pass {2} of {3}).
+ /// </summary>
+ public static string WindowTitleStatus {
+ get {
+ return ResourceManager.GetString("WindowTitleStatus", resourceCulture);
+ }
+ }
}
}
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index ed52a4a8f..1b263c8e9 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -833,4 +833,11 @@ Your preset file will be archived and new one created. You will need to re-creat <data name="NoAdditionalInformation" xml:space="preserve">
<value>No Additional Information</value>
</data>
+ <data name="WindowTitleStatus" xml:space="preserve">
+ <value>{0} - ({1}%, Pass {2} of {3})</value>
+ </data>
+ <data name="TaskTrayStatusTitle" xml:space="preserve">
+ <value>{1}%, Pass {2} of {3}
+Remaining Time: {4}</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs index e04dbe4b5..35d2f6548 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs @@ -1483,6 +1483,15 @@ namespace HandBrakeWPF.Properties { }
/// <summary>
+ /// Looks up a localized string similar to Show the encode status in the application title bar..
+ /// </summary>
+ public static string OptionsView_ShowStatusInTitleBar {
+ get {
+ return ResourceManager.GetString("OptionsView_ShowStatusInTitleBar", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Anamorphic:.
/// </summary>
public static string PictureSettingsView_Anamorphic {
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx index 87e584e96..33f0658df 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx @@ -893,4 +893,7 @@ This will not affect your current settings in the Subtitle tab.</value> <data name="Options_LowDiskspaceSize" xml:space="preserve">
<value>Low diskspace warning level (GB):</value>
</data>
+ <data name="OptionsView_ShowStatusInTitleBar" xml:space="preserve">
+ <value>Show the encode status in the application title bar.</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Interfaces/INotifyIconService.cs b/win/CS/HandBrakeWPF/Services/Interfaces/INotifyIconService.cs new file mode 100644 index 000000000..439c74e4b --- /dev/null +++ b/win/CS/HandBrakeWPF/Services/Interfaces/INotifyIconService.cs @@ -0,0 +1,15 @@ +// <copyright file="INotifyIconService.cs" company="HandBrake Project (http://handbrake.fr)"> +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// </copyright> + +namespace HandBrakeWPF.Services.Interfaces +{ + using System.Windows.Forms; + + public interface INotifyIconService + { + void RegisterNotifyIcon(NotifyIcon ni); + + void SetTooltip(string text); + } +}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/NotifyIconService.cs b/win/CS/HandBrakeWPF/Services/NotifyIconService.cs new file mode 100644 index 000000000..2319f93bc --- /dev/null +++ b/win/CS/HandBrakeWPF/Services/NotifyIconService.cs @@ -0,0 +1,25 @@ +// <copyright file="NotifyIconService.cs" company="HandBrake Project (http://handbrake.fr)"> +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// </copyright> + +namespace HandBrakeWPF.Services +{ + using System.Windows.Forms; + + using HandBrakeWPF.Services.Interfaces; + + public class NotifyIconService : INotifyIconService + { + private NotifyIcon notifyIcon; + + public void RegisterNotifyIcon(NotifyIcon ni) + { + this.notifyIcon = ni; + } + + public void SetTooltip(string text) + { + this.notifyIcon.Text = text; + } + } +} diff --git a/win/CS/HandBrakeWPF/Startup/AppBootstrapper.cs b/win/CS/HandBrakeWPF/Startup/AppBootstrapper.cs index 7163b26cd..44043d95d 100644 --- a/win/CS/HandBrakeWPF/Startup/AppBootstrapper.cs +++ b/win/CS/HandBrakeWPF/Startup/AppBootstrapper.cs @@ -92,6 +92,7 @@ namespace HandBrakeWPF.Startup // Shell
this.container.Singleton<IShellViewModel, ShellViewModel>();
+ this.container.Singleton<INotifyIconService, NotifyIconService>();
base.Configure();
}
diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs index a5ba0c7ff..a47c18583 100644 --- a/win/CS/HandBrakeWPF/UserSettingConstants.cs +++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs @@ -231,6 +231,11 @@ namespace HandBrakeWPF /// </summary>
public const string PresetExpandedStateList = "PresetExpandedStateList";
+ /// <summary>
+ /// Setting to turn on/off the ability to show status in the title bar.
+ /// </summary>
+ public const string ShowStatusInTitleBar = "ShowStatusInTitleBar";
+
#endregion
}
}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 3c6261641..fbe0f6ad0 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -75,6 +75,7 @@ namespace HandBrakeWPF.ViewModels private readonly IErrorService errorService;
private readonly IUpdateService updateService;
private readonly IWindowManager windowManager;
+ private readonly INotifyIconService notifyIconService;
private readonly IUserSettingService userSettingService;
private readonly IScan scanService;
private readonly IEncode encodeService;
@@ -163,12 +164,13 @@ namespace HandBrakeWPF.ViewModels /// <param name="metaDataViewModel">
/// The Meta Data View Model
/// </param>
+ /// <param name="notifyIconService">Wrapper around the WinForms NotifyIcon for this app. </param>
public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,
IErrorService errorService, IUpdateService updateService,
IPrePostActionService whenDoneService, IWindowManager windowManager, IPictureSettingsViewModel pictureSettingsViewModel, IVideoViewModel videoViewModel,
IFiltersViewModel filtersViewModel, IAudioViewModel audioViewModel, ISubtitlesViewModel subtitlesViewModel,
IX264ViewModel advancedViewModel, IChaptersViewModel chaptersViewModel, IStaticPreviewViewModel staticPreviewViewModel,
- IQueueViewModel queueViewModel, IMetaDataViewModel metaDataViewModel)
+ IQueueViewModel queueViewModel, IMetaDataViewModel metaDataViewModel, INotifyIconService notifyIconService)
{
this.scanService = scanService;
this.encodeService = encodeService;
@@ -176,6 +178,7 @@ namespace HandBrakeWPF.ViewModels this.errorService = errorService;
this.updateService = updateService;
this.windowManager = windowManager;
+ this.notifyIconService = notifyIconService;
this.QueueViewModel = queueViewModel;
this.userSettingService = userSettingService;
this.queueProcessor = IoC.Get<IQueueProcessor>();
@@ -311,6 +314,7 @@ namespace HandBrakeWPF.ViewModels if (!Equals(this.windowName, value))
{
this.windowName = value;
+ this.NotifyOfPropertyChange(() => this.WindowTitle);
}
}
}
@@ -2419,11 +2423,19 @@ namespace HandBrakeWPF.ViewModels lastEncodePercentage = percent;
this.ProgressPercentage = percent;
this.NotifyOfPropertyChange(() => ProgressPercentage);
+
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowStatusInTitleBar))
+ {
+ this.WindowTitle = string.Format(Resources.WindowTitleStatus, Resources.HandBrake_Title, this.ProgressPercentage, e.Task, e.TaskCount);
+ this.notifyIconService.SetTooltip(string.Format(Resources.TaskTrayStatusTitle, Resources.HandBrake_Title, this.ProgressPercentage, e.Task, e.TaskCount, e.EstimatedTimeLeft));
+ }
}
else
{
this.ProgramStatusLabel = Resources.Main_QueueFinished;
this.IsEncoding = false;
+ this.WindowTitle = Resources.HandBrake_Title;
+ this.notifyIconService.SetTooltip(this.WindowTitle);
if (this.windowsSeven.IsWindowsSeven)
{
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index d261ff16b..da9a0e8b5 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -92,7 +92,9 @@ namespace HandBrakeWPF.ViewModels private bool showQueueInline;
private bool pauseOnLowDiskspace;
private long pauseOnLowDiskspaceLevel;
- private bool useQsvDecodeForNonQsvEnc;
+ private bool useQsvDecodeForNonQsvEnc;
+
+ private bool showStatusInTitleBar;
#endregion
@@ -348,6 +350,24 @@ namespace HandBrakeWPF.ViewModels }
}
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to show encode status in the tile bar.
+ /// </summary>
+ public bool ShowStatusInTitleBar
+ {
+ get
+ {
+ return this.showStatusInTitleBar;
+ }
+ set
+ {
+ if (value == this.showStatusInTitleBar) return;
+ this.showStatusInTitleBar = value;
+ this.NotifyOfPropertyChange(() => this.ShowStatusInTitleBar);
+ }
+ }
+
#endregion
#region Output Files
@@ -1221,6 +1241,7 @@ namespace HandBrakeWPF.ViewModels this.Arguments = this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileToArgs) ?? string.Empty;
this.ResetWhenDoneAction = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ResetWhenDoneAction);
this.ShowQueueInline = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowQueueInline);
+ this.ShowStatusInTitleBar = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowStatusInTitleBar);
// #############################
// Output Settings
@@ -1370,6 +1391,7 @@ namespace HandBrakeWPF.ViewModels this.userSettingService.SetUserSetting(UserSettingConstants.SendFileToArgs, this.Arguments);
this.userSettingService.SetUserSetting(UserSettingConstants.ResetWhenDoneAction, this.ResetWhenDoneAction);
this.userSettingService.SetUserSetting(UserSettingConstants.ShowQueueInline, this.ShowQueueInline);
+ this.userSettingService.SetUserSetting(UserSettingConstants.ShowStatusInTitleBar, this.ShowStatusInTitleBar);
/* Output Files */
this.userSettingService.SetUserSetting(UserSettingConstants.AutoNaming, this.AutomaticallyNameFiles);
diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml index 8fcd517ac..c9e522db0 100644 --- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml +++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml @@ -160,6 +160,7 @@ <CheckBox Content="{x:Static Properties:ResourcesUI.Options_ClearCompleted}" IsChecked="{Binding ClearQueueOnEncodeCompleted}" />
<CheckBox Content="{x:Static Properties:ResourcesUI.Options_AdvancedTab}" IsChecked="{Binding ShowAdvancedTab}" />
<CheckBox Content="{x:Static Properties:ResourcesUI.Options_ShowQueueInline}" IsChecked="{Binding ShowQueueInline}" />
+ <CheckBox Content="{x:Static Properties:ResourcesUI.OptionsView_ShowStatusInTitleBar}" IsChecked="{Binding ShowStatusInTitleBar}" />
</StackPanel>
</StackPanel>
</StackPanel>
diff --git a/win/CS/HandBrakeWPF/Views/ShellView.xaml b/win/CS/HandBrakeWPF/Views/ShellView.xaml index fafa28d31..9eb2e9469 100644 --- a/win/CS/HandBrakeWPF/Views/ShellView.xaml +++ b/win/CS/HandBrakeWPF/Views/ShellView.xaml @@ -5,7 +5,7 @@ xmlns:Converters="clr-namespace:HandBrakeWPF.Converters"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:cal="http://www.caliburnproject.org"
- Title="{Data:Binding Path=WindowTitle}"
+ Title="{Data:Binding Path=MainViewModel.WindowTitle}"
Width="1015"
Height="675"
MinWidth="750"
diff --git a/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs b/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs index cd8dfea5a..c1a45a58f 100644 --- a/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs @@ -45,13 +45,18 @@ namespace HandBrakeWPF.Views {
this.InitializeComponent();
+
+
IUserSettingService userSettingService = IoC.Get<IUserSettingService>();
bool minimiseToTray = userSettingService.GetUserSetting<bool>(UserSettingConstants.MainWindowMinimize);
if (minimiseToTray)
{
+
+ INotifyIconService notifyIconService = IoC.Get<INotifyIconService>();
this.notifyIcon = new NotifyIcon();
this.notifyIcon.ContextMenu = new ContextMenu(new[] { new MenuItem("Restore", NotifyIconClick), new MenuItem("Mini Status Display", ShowMiniStatusDisplay) });
+ notifyIconService.RegisterNotifyIcon(this.notifyIcon);
StreamResourceInfo streamResourceInfo = Application.GetResourceStream(new Uri("pack://application:,,,/handbrakepineapple.ico"));
if (streamResourceInfo != null)
@@ -132,9 +137,7 @@ namespace HandBrakeWPF.Views if (this.WindowState == WindowState.Minimized)
{
this.ShowInTaskbar = false;
- notifyIcon.Visible = true;
-
- // notifyIcon.ShowBalloonTip(5000, "HandBrake", "Application Minimised", ToolTipIcon.Info);
+ notifyIcon.Visible = true;
}
else if (this.WindowState == WindowState.Normal)
{
diff --git a/win/CS/HandBrakeWPF/defaultsettings.xml b/win/CS/HandBrakeWPF/defaultsettings.xml index f28f8b9cb..4bec7eca1 100644 --- a/win/CS/HandBrakeWPF/defaultsettings.xml +++ b/win/CS/HandBrakeWPF/defaultsettings.xml @@ -479,5 +479,13 @@ <value>
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>
</value>
- </item>
+ </item>
+ <item>
+ <key>
+ <string>ShowStatusInTitleBar</string>
+ </key>
+ <value>
+ <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>
+ </value>
+ </item>
</dictionary>
\ No newline at end of file |