OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 26 Jun 2010 20:09:58 +0000 (20:09 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 26 Jun 2010 20:09:58 +0000 (20:09 +0000)
- Integrated Windows 7 Taskbar support. The taskbar icon now shows the encode progress bar.

git-svn-id: svn://localhost/HandBrake/trunk@3409 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/HandBrake.ApplicationServices/Functions/Win7.cs [new file with mode: 0644]
win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
win/C#/HandBrake.ApplicationServices/Services/Encode.cs
win/C#/libraries/Microsoft.WindowsAPICodePack.Shell.dll [new file with mode: 0644]
win/C#/libraries/Microsoft.WindowsAPICodePack.dll [new file with mode: 0644]

diff --git a/win/C#/HandBrake.ApplicationServices/Functions/Win7.cs b/win/C#/HandBrake.ApplicationServices/Functions/Win7.cs
new file mode 100644 (file)
index 0000000..d8f522f
--- /dev/null
@@ -0,0 +1,75 @@
+/*  Win7.cs $\r
+    This file is part of the HandBrake source code.\r
+    Homepage: <http://handbrake.fr>.\r
+    It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace HandBrake.ApplicationServices.Functions\r
+{\r
+    using System;\r
+\r
+    using Microsoft.WindowsAPICodePack;\r
+    using Microsoft.WindowsAPICodePack.Taskbar;\r
+\r
+    /// <summary>\r
+    /// A class implimenting Windows 7 Specific features\r
+    /// </summary>\r
+    public class Win7\r
+    {\r
+        /// <summary>\r
+        /// The Windows Taskbar\r
+        /// </summary>\r
+        private TaskbarManager windowsTaskbar;\r
+\r
+        /// <summary>\r
+        /// Initializes a new instance of the <see cref="Win7"/> class.\r
+        /// </summary>\r
+        public Win7()\r
+        {\r
+            if (IsWindowsSeven)\r
+            {\r
+                windowsTaskbar = TaskbarManager.Instance;\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Gets a value indicating whether this is Windows Seven.\r
+        /// </summary>\r
+        public bool IsWindowsSeven\r
+        {\r
+            get\r
+            {\r
+                OperatingSystem os = Environment.OSVersion;\r
+                return os.Version.Major >= 6 && os.Version.Minor >= 1;\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Set the Task Bar Percentage.\r
+        /// </summary>\r
+        /// <param name="percentage">\r
+        /// The percentage.\r
+        /// </param>\r
+        public void SetTaskBarProgress(int percentage)\r
+        {\r
+            if (!IsWindowsSeven)\r
+            {\r
+                return;\r
+            }\r
+\r
+            windowsTaskbar.SetProgressValue(percentage, 100);\r
+        }\r
+\r
+        /// <summary>\r
+        /// Disable Task Bar Progress\r
+        /// </summary>\r
+        public void SetTaskBarProgressToNoProgress()\r
+        {\r
+            if (!IsWindowsSeven)\r
+            {\r
+                return;\r
+            }\r
+\r
+            windowsTaskbar.SetProgressState(TaskbarProgressBarState.NoProgress);\r
+        }\r
+    }\r
+}
\ No newline at end of file
index 94995c0..148ba78 100644 (file)
       <SpecificVersion>False</SpecificVersion>\r
       <HintPath>..\libraries\Growl.CoreLibrary.dll</HintPath>\r
     </Reference>\r
+    <Reference Include="Microsoft.WindowsAPICodePack, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">\r
+      <SpecificVersion>False</SpecificVersion>\r
+      <HintPath>..\libraries\Microsoft.WindowsAPICodePack.dll</HintPath>\r
+    </Reference>\r
+    <Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">\r
+      <SpecificVersion>False</SpecificVersion>\r
+      <HintPath>..\libraries\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>\r
+    </Reference>\r
     <Reference Include="System" />\r
     <Reference Include="System.Core">\r
       <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
@@ -73,6 +81,7 @@
     <Compile Include="Functions\GrowlCommunicator.cs" />\r
     <Compile Include="Functions\Main.cs" />\r
     <Compile Include="Functions\Win32.cs" />\r
+    <Compile Include="Functions\Win7.cs" />\r
     <Compile Include="Init.cs" />\r
     <Compile Include="Model\Cropping.cs" />\r
     <Compile Include="Model\Job.cs" />\r
       <SubType>Designer</SubType>\r
     </EmbeddedResource>\r
     <EmbeddedResource Include="Properties\Resources.resx">\r
-      <Generator>ResXFileCodeGenerator</Generator>\r
+      <Generator>PublicResXFileCodeGenerator</Generator>\r
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>\r
       <SubType>Designer</SubType>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <None Include="Resources\logo64.png" />\r
+    <EmbeddedResource Include="Resources\logo64.png" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <None Include="Resources\ErrorX.png" />\r
+    <EmbeddedResource Include="Resources\ErrorX.png" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <None Include="Properties\AssemblyInfo.cs.tmpl" />\r
-    <None Include="Resources\copy.png" />\r
+    <EmbeddedResource Include="Resources\copy.png" />\r
   </ItemGroup>\r
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
   <Import Project="$(ProgramFiles)\MSBuild\Microsoft\StyleCop\v4.3\Microsoft.StyleCop.targets" />\r
index cb6dbee..ad5cd8c 100644 (file)
@@ -57,6 +57,11 @@ namespace HandBrake.ApplicationServices.Services
         /// </summary>\r
         private int processID;\r
 \r
+        /// <summary>\r
+        /// Windows 7 API Pack wrapper\r
+        /// </summary>\r
+        private Win7 windowsSeven = new Win7();\r
+\r
         /* Constructor */\r
 \r
         /// <summary>\r
@@ -276,6 +281,11 @@ namespace HandBrake.ApplicationServices.Services
 \r
             if (this.EncodeEnded != null)\r
                 this.EncodeEnded(this, new EventArgs());\r
+\r
+            if (windowsSeven.IsWindowsSeven)\r
+            {\r
+                windowsSeven.SetTaskBarProgressToNoProgress();\r
+            }\r
         }\r
 \r
         /// <summary>\r
@@ -601,6 +611,14 @@ namespace HandBrake.ApplicationServices.Services
 \r
             if (this.EncodeStatusChanged != null)\r
                 this.EncodeStatusChanged(this, eventArgs);\r
+\r
+            if (windowsSeven.IsWindowsSeven)\r
+            {\r
+                int percent;\r
+                int.TryParse(Math.Round(percentComplete).ToString(), out percent);\r
+\r
+                windowsSeven.SetTaskBarProgress(percent);\r
+            }\r
         }\r
     }\r
 }
\ No newline at end of file
diff --git a/win/C#/libraries/Microsoft.WindowsAPICodePack.Shell.dll b/win/C#/libraries/Microsoft.WindowsAPICodePack.Shell.dll
new file mode 100644 (file)
index 0000000..340ddd5
Binary files /dev/null and b/win/C#/libraries/Microsoft.WindowsAPICodePack.Shell.dll differ
diff --git a/win/C#/libraries/Microsoft.WindowsAPICodePack.dll b/win/C#/libraries/Microsoft.WindowsAPICodePack.dll
new file mode 100644 (file)
index 0000000..85605b7
Binary files /dev/null and b/win/C#/libraries/Microsoft.WindowsAPICodePack.dll differ