Compare commits

...

4 Commits

Author SHA1 Message Date
Paddy Xu
eef76468c4 Use git tag for AssemblyVersion etc. 2017-05-11 01:31:58 +03:00
Paddy Xu
23d90b3de4 Use faster APIs for getting drive info 2017-05-11 01:28:19 +03:00
Paddy Xu
ba2d5d2ab2 Catch all exceptions (even SEH).
Fix #7?
2017-05-10 23:22:23 +03:00
Paddy Xu
3e99427d0b Update README.md 2017-05-09 00:37:17 +03:00
23 changed files with 100 additions and 26 deletions

1
.gitignore vendored
View File

@@ -288,3 +288,4 @@ __pycache__/
*.xsd.cs
/QuickLook.Plugin.PDFViewer/MoonPdfLib
/GitVersion.cs

View File

@@ -1,2 +0,0 @@
bc a -r Debug_%date:~-4,4%%date:~-7,2%%date:~-10,2%.zip Build\Debug\*.exe Build\Debug\*.dll
bc a -r Release_%date:~-4,4%%date:~-7,2%%date:~-10,2%.zip Build\Release\*.exe Build\Release\*.dll

View File

@@ -30,6 +30,4 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
// [assembly: AssemblyVersion("1.0.*")]

View File

@@ -50,6 +50,9 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\GitVersion.cs">
<Link>Properties\GitVersion.cs</Link>
</Compile>
<Compile Include="ArchiveInfoPanel.xaml.cs">
<DependentUpon>ArchiveInfoPanel.xaml</DependentUpon>
</Compile>

View File

@@ -30,6 +30,4 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
// [assembly: AssemblyVersion("1.0.*")]

View File

@@ -49,6 +49,9 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\GitVersion.cs">
<Link>Properties\GitVersion.cs</Link>
</Compile>
<Compile Include="ImageFileHelper.cs" />
<Compile Include="ImagePanel.xaml.cs">
<DependentUpon>ImagePanel.xaml</DependentUpon>

View File

@@ -48,6 +48,4 @@ using System.Windows;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
// [assembly: AssemblyVersion("1.0.*")]

View File

@@ -67,6 +67,9 @@
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\GitVersion.cs">
<Link>Properties\GitVersion.cs</Link>
</Compile>
<Compile Include="OfficeInteropWrapper.cs" />
<Compile Include="PluginInterface.cs">
<SubType>Code</SubType>

View File

@@ -30,6 +30,4 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
// [assembly: AssemblyVersion("1.0.*")]

View File

@@ -49,6 +49,9 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\GitVersion.cs">
<Link>Properties\GitVersion.cs</Link>
</Compile>
<Compile Include="PdfViewerControl.xaml.cs">
<DependentUpon>PdfViewerControl.xaml</DependentUpon>
</Compile>

View File

@@ -30,6 +30,4 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
// [assembly: AssemblyVersion("1.0.*")]

View File

@@ -46,6 +46,9 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\GitVersion.cs">
<Link>Properties\GitVersion.cs</Link>
</Compile>
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TextViewerPanel.xaml.cs">

View File

@@ -48,6 +48,4 @@ using System.Windows;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
// [assembly: AssemblyVersion("1.0.*")]

View File

@@ -60,6 +60,9 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="..\..\GitVersion.cs">
<Link>Properties\GitVersion.cs</Link>
</Compile>
<Compile Include="DoubleToHMSConverter.cs" />
<Compile Include="PluginInterface.cs" />
<Compile Include="ViewerPanel.xaml.cs">

View File

@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.7
VisualStudioVersion = 15.0.26430.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook", "QuickLook\QuickLook.csproj", "{8B4A9CE5-67B5-4A94-81CB-3771F688FDEB}"
ProjectSection(ProjectDependencies) = postProject
@@ -24,6 +24,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.OfficeView
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.VideoViewer", "QuickLook.Plugin\QuickLook.Plugin.VideoViewer\QuickLook.Plugin.VideoViewer.csproj", "{1B746D92-49A5-4A37-9D75-DCC490393290}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BAE81497-98FA-4A7A-A0FB-2B86C9694B9C}"
ProjectSection(SolutionItems) = preProject
GitVersion.cs = GitVersion.cs
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86

View File

@@ -4,4 +4,7 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<runtime>
<legacyCorruptedStateExceptionsPolicy enabled="true" />
</runtime>
</configuration>

View File

@@ -6,6 +6,16 @@ namespace QuickLook.Plugin.InfoPanel
{
public static class FileHelper
{
public static void GetDriveSpace(string path, out long totalSpace, out long totalFreeSpace)
{
totalSpace = totalFreeSpace = 0L;
var root = new DriveInfo(Path.GetPathRoot(path));
totalSpace = root.TotalSize;
totalFreeSpace = root.AvailableFreeSpace;
}
public static void CountFolder(string root, ref bool stop, out long totalDirs, out long totalFiles,
out long totalSize)
{

View File

@@ -51,6 +51,19 @@ namespace QuickLook.Plugin.InfoPanel
Dispatcher.Invoke(() => { totalSize.Text = size.ToPrettySize(2); });
}
else if (Path.GetPathRoot(path) == path) // is this a drive?
{
long totalSpace;
long totalFreeSpace;
FileHelper.GetDriveSpace(path, out totalSpace, out totalFreeSpace);
Dispatcher.Invoke(() =>
{
totalSize.Text =
$"Capacity {totalSpace.ToPrettySize(2)}, {totalFreeSpace.ToPrettySize(2)} available";
});
}
else if (Directory.Exists(path))
{
long totalDirsL;

View File

@@ -48,6 +48,4 @@ using System.Windows;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
// [assembly: AssemblyVersion("1.0.*")]

View File

@@ -78,6 +78,9 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="..\GitVersion.cs">
<Link>Properties\GitVersion.cs</Link>
</Compile>
<Compile Include="Helpers\AutoStartupHelper.cs" />
<Compile Include="Controls\BackgroundVisualHost.cs" />
<Compile Include="Controls\BusyDecorator.cs" />
@@ -185,4 +188,7 @@
<None Include="Resources\app_white.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>"$(SolutionDir)update-version.cmd" "$(SolutionDir)" "$(SolutionDir)GitVersion.cs"</PreBuildEvent>
</PropertyGroup>
</Project>

View File

@@ -47,15 +47,37 @@ namespace QuickLook
{
_viewWindow.BeginShow(matchedPlugin, path);
}
catch (Exception e) // if current plugin failed, switch to default one
catch (Exception e) // if current plugin failed, switch to default one.
{
_viewWindow.Close();
Debug.WriteLine(e.ToString());
Debug.WriteLine(e.StackTrace);
if (matchedPlugin.GetType() != PluginManager.GetInstance().DefaultPlugin)
{
matchedPlugin.Dispose();
_viewWindow.BeginShow(PluginManager.GetInstance().DefaultPlugin.CreateInstance<IViewer>(), path);
matchedPlugin = PluginManager.GetInstance().DefaultPlugin.CreateInstance<IViewer>();
BeginShowNewWindow(matchedPlugin, path);
}
else
{
throw;
}
}
catch // Catch SEH exceptions here.
{
_viewWindow.Close();
if (matchedPlugin.GetType() != PluginManager.GetInstance().DefaultPlugin)
{
matchedPlugin.Dispose();
matchedPlugin = PluginManager.GetInstance().DefaultPlugin.CreateInstance<IViewer>();
BeginShowNewWindow(matchedPlugin, path);
}
else
{
throw;
}
}
}

View File

@@ -1,3 +1,5 @@
![QuickLook icon](https://cloud.githubusercontent.com/assets/1687847/25826439/8970e36a-344f-11e7-8118-9783c7739862.png)
# QuickLook
[![Build status](https://ci.appveyor.com/api/projects/status/w5lx1mlq8b0mb8fo?svg=true)](https://ci.appveyor.com/project/xupefei/quicklook)

10
update-version.cmd Normal file
View File

@@ -0,0 +1,10 @@
rem @echo off
cd %1
for /F "delims=" %%i in ('git describe --always --tags "--abbrev=0"') do set git_tag=%%i
for /F "delims=" %%i in ('git describe --always --tags') do set git_revision=%%i
echo // This file is generated by update-version.cmd > %2
echo. >> %2
echo using System.Reflection;>> %2
echo. >> %2
echo [assembly: AssemblyVersion("%git_tag%")]>> %2
echo [assembly: AssemblyInformationalVersion("%git_revision%")]>> %2