]> granicus.if.org Git - handbrake/commitdiff
WinGui: Add option to show progress percentage in app title bar, and the task tray...
authorsr55 <sr55.hb@outlook.com>
Thu, 16 Mar 2017 20:26:05 +0000 (20:26 +0000)
committersr55 <sr55.hb@outlook.com>
Thu, 16 Mar 2017 20:26:14 +0000 (20:26 +0000)
15 files changed:
win/CS/HandBrakeWPF/HandBrakeWPF.csproj
win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
win/CS/HandBrakeWPF/Properties/Resources.resx
win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
win/CS/HandBrakeWPF/Services/Interfaces/INotifyIconService.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/Services/NotifyIconService.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/Startup/AppBootstrapper.cs
win/CS/HandBrakeWPF/UserSettingConstants.cs
win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
win/CS/HandBrakeWPF/Views/OptionsView.xaml
win/CS/HandBrakeWPF/Views/ShellView.xaml
win/CS/HandBrakeWPF/Views/ShellView.xaml.cs
win/CS/HandBrakeWPF/defaultsettings.xml

index b77dcaddac7048436241146f14f07f79e864f6e5..6cf6ae4f64adc780652b9b7f6cb5094a25d7d81d 100644 (file)
     <Compile Include="Services\Encode\Model\Models\Video\VideoPreset.cs" />\r
     <Compile Include="Services\Encode\Model\Models\Video\VideoProfile.cs" />\r
     <Compile Include="Services\Encode\Model\Models\Video\VideoTune.cs" />\r
+    <Compile Include="Services\Interfaces\INotifyIconService.cs" />\r
     <Compile Include="Services\Presets\Factories\JsonPresetFactory.cs" />\r
     <Compile Include="Services\Presets\Interfaces\IPresetObject.cs" />\r
     <Compile Include="Services\Presets\Model\PresetDisplayCategory.cs" />\r
     <Compile Include="Services\Scan\Model\Source.cs" />\r
     <Compile Include="Services\Scan\Model\Subtitle.cs" />\r
     <Compile Include="Services\Scan\Model\Title.cs" />\r
+    <Compile Include="Services\NotifyIconService.cs" />\r
     <Compile Include="Services\UserSettingService.cs" />\r
     <Compile Include="Startup\StartupOptions.cs" />\r
     <Compile Include="Utilities\AppcastReader.cs" />\r
index d218534498fde163a89bd408bf27345278ba78b6..d0b3c079bce1ef0d1669056ba2f77f6ef5ab4a92 100644 (file)
@@ -1731,6 +1731,16 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to {1}%, Pass {2} of {3}\r
+        ///Remaining Time: {4}.\r
+        /// </summary>\r
+        public static string TaskTrayStatusTitle {\r
+            get {\r
+                return ResourceManager.GetString("TaskTrayStatusTitle", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to Unknown Error.\r
         /// </summary>\r
@@ -1906,5 +1916,14 @@ namespace HandBrakeWPF.Properties {
                 return ResourceManager.GetString("Warning", resourceCulture);\r
             }\r
         }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to {0} - ({1}%, Pass {2} of {3}).\r
+        /// </summary>\r
+        public static string WindowTitleStatus {\r
+            get {\r
+                return ResourceManager.GetString("WindowTitleStatus", resourceCulture);\r
+            }\r
+        }\r
     }\r
 }\r
index ed52a4a8f8f400fd3fc8342746b100b75b49bae7..1b263c8e98200b4fb1376f389d3a655e34f140af 100644 (file)
@@ -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">\r
     <value>No Additional Information</value>\r
   </data>\r
+  <data name="WindowTitleStatus" xml:space="preserve">\r
+    <value>{0} - ({1}%, Pass {2} of {3})</value>\r
+  </data>\r
+  <data name="TaskTrayStatusTitle" xml:space="preserve">\r
+    <value>{1}%, Pass {2} of {3}\r
+Remaining Time: {4}</value>\r
+  </data>\r
 </root>
\ No newline at end of file
index e04dbe4b57a493de942b9987851e80bc18a7391d..35d2f654819f440b99e4714c0b1ac7bfbc285fcf 100644 (file)
@@ -1482,6 +1482,15 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Show the encode status in the application title bar..\r
+        /// </summary>\r
+        public static string OptionsView_ShowStatusInTitleBar {\r
+            get {\r
+                return ResourceManager.GetString("OptionsView_ShowStatusInTitleBar", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to Anamorphic:.\r
         /// </summary>\r
index 87e584e96efa2d233387c74df3834db3a87fa782..33f0658df66ff7fdf3e61cc83242201d6d3b823f 100644 (file)
@@ -893,4 +893,7 @@ This will not affect your current settings in the Subtitle tab.</value>
   <data name="Options_LowDiskspaceSize" xml:space="preserve">\r
     <value>Low diskspace warning level (GB):</value>\r
   </data>\r
+  <data name="OptionsView_ShowStatusInTitleBar" xml:space="preserve">\r
+    <value>Show the encode status in the application title bar.</value>\r
+  </data>\r
 </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 (file)
index 0000000..439c74e
--- /dev/null
@@ -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 (file)
index 0000000..2319f93
--- /dev/null
@@ -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;
+        }
+    }
+}
index 7163b26cd77edc72aea54dcd4b9b1601b9060969..44043d95d239e2e96880a4e0e27500af6e964629 100644 (file)
@@ -92,6 +92,7 @@ namespace HandBrakeWPF.Startup
 \r
             // Shell\r
             this.container.Singleton<IShellViewModel, ShellViewModel>();\r
+            this.container.Singleton<INotifyIconService, NotifyIconService>();\r
 \r
             base.Configure();\r
         }\r
index a5ba0c7ffb290dbf66e5dafb158cd78ba8b7f088..a47c185836699cc10caff1acc8f08debeb1f6986 100644 (file)
@@ -231,6 +231,11 @@ namespace HandBrakeWPF
         /// </summary>\r
         public const string PresetExpandedStateList = "PresetExpandedStateList";\r
 \r
+        /// <summary>\r
+        /// Setting to turn on/off the ability to show status in the title bar.\r
+        /// </summary>\r
+        public const string ShowStatusInTitleBar = "ShowStatusInTitleBar";\r
+\r
         #endregion\r
     }\r
 }
\ No newline at end of file
index 3c62616411a2b9352649ec890104df4ec312bce9..fbe0f6ad0e585b04a5ac89018075c7979e374255 100644 (file)
@@ -75,6 +75,7 @@ namespace HandBrakeWPF.ViewModels
         private readonly IErrorService errorService;\r
         private readonly IUpdateService updateService;\r
         private readonly IWindowManager windowManager;\r
+        private readonly INotifyIconService notifyIconService;\r
         private readonly IUserSettingService userSettingService;\r
         private readonly IScan scanService;\r
         private readonly IEncode encodeService;\r
@@ -163,12 +164,13 @@ namespace HandBrakeWPF.ViewModels
         /// <param name="metaDataViewModel">\r
         /// The Meta Data View Model\r
         /// </param>\r
+        /// <param name="notifyIconService">Wrapper around the WinForms NotifyIcon for this app. </param>\r
         public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService, \r
             IErrorService errorService, IUpdateService updateService, \r
             IPrePostActionService whenDoneService, IWindowManager windowManager, IPictureSettingsViewModel pictureSettingsViewModel, IVideoViewModel videoViewModel, \r
             IFiltersViewModel filtersViewModel, IAudioViewModel audioViewModel, ISubtitlesViewModel subtitlesViewModel,\r
             IX264ViewModel advancedViewModel, IChaptersViewModel chaptersViewModel, IStaticPreviewViewModel staticPreviewViewModel,\r
-            IQueueViewModel queueViewModel, IMetaDataViewModel metaDataViewModel)\r
+            IQueueViewModel queueViewModel, IMetaDataViewModel metaDataViewModel, INotifyIconService notifyIconService)\r
         {\r
             this.scanService = scanService;\r
             this.encodeService = encodeService;\r
@@ -176,6 +178,7 @@ namespace HandBrakeWPF.ViewModels
             this.errorService = errorService;\r
             this.updateService = updateService;\r
             this.windowManager = windowManager;\r
+            this.notifyIconService = notifyIconService;\r
             this.QueueViewModel = queueViewModel;\r
             this.userSettingService = userSettingService;\r
             this.queueProcessor = IoC.Get<IQueueProcessor>();\r
@@ -311,6 +314,7 @@ namespace HandBrakeWPF.ViewModels
                 if (!Equals(this.windowName, value))\r
                 {\r
                     this.windowName = value;\r
+                    this.NotifyOfPropertyChange(() => this.WindowTitle);\r
                 }\r
             }\r
         }\r
@@ -2419,11 +2423,19 @@ namespace HandBrakeWPF.ViewModels
                         lastEncodePercentage = percent;\r
                         this.ProgressPercentage = percent;\r
                         this.NotifyOfPropertyChange(() => ProgressPercentage);\r
+\r
+                        if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowStatusInTitleBar))\r
+                        {\r
+                            this.WindowTitle = string.Format(Resources.WindowTitleStatus, Resources.HandBrake_Title, this.ProgressPercentage, e.Task, e.TaskCount);\r
+                            this.notifyIconService.SetTooltip(string.Format(Resources.TaskTrayStatusTitle, Resources.HandBrake_Title, this.ProgressPercentage, e.Task, e.TaskCount, e.EstimatedTimeLeft));\r
+                        }\r
                     }\r
                     else\r
                     {\r
                         this.ProgramStatusLabel = Resources.Main_QueueFinished;\r
                         this.IsEncoding = false;\r
+                        this.WindowTitle = Resources.HandBrake_Title;\r
+                        this.notifyIconService.SetTooltip(this.WindowTitle);\r
 \r
                         if (this.windowsSeven.IsWindowsSeven)\r
                         {\r
index d261ff16b3057cac9a42e9388301d3ee99e8b1d1..da9a0e8b5d8df891f5555b0aa987517cca08e2ea 100644 (file)
@@ -92,7 +92,9 @@ namespace HandBrakeWPF.ViewModels
         private bool showQueueInline;\r
         private bool pauseOnLowDiskspace;\r
         private long pauseOnLowDiskspaceLevel;\r
-        private bool useQsvDecodeForNonQsvEnc;  \r
+        private bool useQsvDecodeForNonQsvEnc;\r
+\r
+        private bool showStatusInTitleBar;\r
 \r
         #endregion\r
 \r
@@ -348,6 +350,24 @@ namespace HandBrakeWPF.ViewModels
             }\r
         }\r
 \r
+\r
+        /// <summary>\r
+        /// Gets or sets a value indicating whether to show encode status in the tile bar.\r
+        /// </summary>\r
+        public bool ShowStatusInTitleBar\r
+        {\r
+            get\r
+            {\r
+                return this.showStatusInTitleBar;\r
+            }\r
+            set\r
+            {\r
+                if (value == this.showStatusInTitleBar) return;\r
+                this.showStatusInTitleBar = value;\r
+                this.NotifyOfPropertyChange(() => this.ShowStatusInTitleBar);\r
+            }\r
+        }\r
+        \r
         #endregion\r
 \r
         #region Output Files\r
@@ -1221,6 +1241,7 @@ namespace HandBrakeWPF.ViewModels
             this.Arguments = this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileToArgs) ?? string.Empty;\r
             this.ResetWhenDoneAction = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ResetWhenDoneAction);\r
             this.ShowQueueInline = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowQueueInline);\r
+            this.ShowStatusInTitleBar = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowStatusInTitleBar);\r
 \r
             // #############################\r
             // Output Settings\r
@@ -1370,6 +1391,7 @@ namespace HandBrakeWPF.ViewModels
             this.userSettingService.SetUserSetting(UserSettingConstants.SendFileToArgs, this.Arguments);\r
             this.userSettingService.SetUserSetting(UserSettingConstants.ResetWhenDoneAction, this.ResetWhenDoneAction);\r
             this.userSettingService.SetUserSetting(UserSettingConstants.ShowQueueInline, this.ShowQueueInline);\r
+            this.userSettingService.SetUserSetting(UserSettingConstants.ShowStatusInTitleBar, this.ShowStatusInTitleBar);\r
 \r
             /* Output Files */\r
             this.userSettingService.SetUserSetting(UserSettingConstants.AutoNaming, this.AutomaticallyNameFiles);\r
index 8fcd517acab0dc2883bc4d66e3965e12909c3250..c9e522db01d33309c65ebe5828f288d7aed89152 100644 (file)
                             <CheckBox Content="{x:Static Properties:ResourcesUI.Options_ClearCompleted}" IsChecked="{Binding ClearQueueOnEncodeCompleted}" />\r
                             <CheckBox Content="{x:Static Properties:ResourcesUI.Options_AdvancedTab}" IsChecked="{Binding ShowAdvancedTab}" />\r
                             <CheckBox Content="{x:Static Properties:ResourcesUI.Options_ShowQueueInline}" IsChecked="{Binding ShowQueueInline}" />\r
+                            <CheckBox Content="{x:Static Properties:ResourcesUI.OptionsView_ShowStatusInTitleBar}" IsChecked="{Binding ShowStatusInTitleBar}" />\r
                         </StackPanel>\r
                     </StackPanel>\r
                 </StackPanel>\r
index fafa28d31fcaa772ef20372def009cbd8bd6162a..9eb2e9469b99b20bf9914368411fe21ca9b49906 100644 (file)
@@ -5,7 +5,7 @@
         xmlns:Converters="clr-namespace:HandBrakeWPF.Converters"\r
         xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"\r
         xmlns:cal="http://www.caliburnproject.org"\r
-        Title="{Data:Binding Path=WindowTitle}"\r
+        Title="{Data:Binding Path=MainViewModel.WindowTitle}"\r
         Width="1015"\r
         Height="675"\r
         MinWidth="750"\r
index cd8dfea5a5a5ae439c5fe0b210955b0a6efc478d..c1a45a58fcaf94dfeb012e0b39b234d900d8a85b 100644 (file)
@@ -45,13 +45,18 @@ namespace HandBrakeWPF.Views
         {\r
             this.InitializeComponent();\r
 \r
+\r
+\r
             IUserSettingService userSettingService = IoC.Get<IUserSettingService>();\r
             bool minimiseToTray = userSettingService.GetUserSetting<bool>(UserSettingConstants.MainWindowMinimize);\r
 \r
             if (minimiseToTray)\r
             {\r
+\r
+                INotifyIconService notifyIconService = IoC.Get<INotifyIconService>();\r
                 this.notifyIcon = new NotifyIcon();\r
                 this.notifyIcon.ContextMenu = new ContextMenu(new[] { new MenuItem("Restore", NotifyIconClick), new MenuItem("Mini Status Display", ShowMiniStatusDisplay) });\r
+                notifyIconService.RegisterNotifyIcon(this.notifyIcon);\r
 \r
                 StreamResourceInfo streamResourceInfo = Application.GetResourceStream(new Uri("pack://application:,,,/handbrakepineapple.ico"));\r
                 if (streamResourceInfo != null)\r
@@ -132,9 +137,7 @@ namespace HandBrakeWPF.Views
                 if (this.WindowState == WindowState.Minimized)\r
                 {\r
                     this.ShowInTaskbar = false;\r
-                    notifyIcon.Visible = true;\r
-\r
-                    // notifyIcon.ShowBalloonTip(5000, "HandBrake", "Application Minimised", ToolTipIcon.Info);          \r
+                    notifyIcon.Visible = true;      \r
                 }\r
                 else if (this.WindowState == WindowState.Normal)\r
                 {\r
index f28f8b9cba41a9d6cf67f78c6091e58cb605e476..4bec7eca1efe1f123a8183f49debdb2c7ecea3cd 100644 (file)
     <value>\r
       <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>\r
     </value>\r
-  </item> \r
+  </item>\r
+  <item>\r
+    <key>\r
+      <string>ShowStatusInTitleBar</string>\r
+    </key>\r
+    <value>\r
+      <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>\r
+    </value>\r
+  </item>\r
 </dictionary>
\ No newline at end of file