remove strong-name signing

This commit is contained in:
Paddy Xu
2018-01-27 14:44:53 +02:00
parent a63fd77a50
commit 804876a987
33 changed files with 191 additions and 147 deletions

View File

@@ -50,10 +50,11 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>true</SignAssembly> <SignAssembly>false</SignAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
@@ -106,7 +107,6 @@
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="key.snk" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@@ -49,10 +49,11 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>true</SignAssembly> <SignAssembly>false</SignAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="CsvHelper, Version=6.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL"> <Reference Include="CsvHelper, Version=6.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
@@ -91,7 +92,6 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="key.snk" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@@ -53,10 +53,11 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>true</SignAssembly> <SignAssembly>false</SignAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@@ -109,8 +110,5 @@
<EmbedInteropTypes>True</EmbedInteropTypes> <EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference> </COMReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="key.snk" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@@ -51,10 +51,11 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>true</SignAssembly> <SignAssembly>false</SignAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
@@ -103,8 +104,5 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="key.snk" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@@ -52,10 +52,11 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>true</SignAssembly> <SignAssembly>false</SignAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="LibAPNG"> <Reference Include="LibAPNG">
@@ -103,7 +104,6 @@
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="key.snk" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -49,10 +49,11 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>true</SignAssembly> <SignAssembly>false</SignAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Itenso.Rtf.Converter.Html, Version=1.7.0.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748, processorArchitecture=MSIL"> <Reference Include="Itenso.Rtf.Converter.Html, Version=1.7.0.0, Culture=neutral, PublicKeyToken=d7f23b760ed5c748, processorArchitecture=MSIL">
@@ -99,7 +100,6 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="key.snk" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@@ -50,10 +50,11 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>true</SignAssembly> <SignAssembly>false</SignAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
@@ -94,7 +95,6 @@
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="key.snk" />
<None Include="Resources\md2html.html" /> <None Include="Resources\md2html.html" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@@ -54,10 +54,11 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>true</SignAssembly> <SignAssembly>false</SignAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="PDFiumSharp, Version=0.1.2.0, Culture=neutral, PublicKeyToken=8828c73f39c04650, processorArchitecture=MSIL"> <Reference Include="PDFiumSharp, Version=0.1.2.0, Culture=neutral, PublicKeyToken=8828c73f39c04650, processorArchitecture=MSIL">
@@ -108,9 +109,6 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="key.snk" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="pdfium_x64.dll"> <Content Include="pdfium_x64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

View File

@@ -50,10 +50,11 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>true</SignAssembly> <SignAssembly>false</SignAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="ICSharpCode.AvalonEdit, Version=5.0.3.0, Culture=neutral, PublicKeyToken=9cc39be672370310, processorArchitecture=MSIL"> <Reference Include="ICSharpCode.AvalonEdit, Version=5.0.3.0, Culture=neutral, PublicKeyToken=9cc39be672370310, processorArchitecture=MSIL">
@@ -93,7 +94,6 @@
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="key.snk" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -53,10 +53,11 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>true</SignAssembly> <SignAssembly>false</SignAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="ffme.common"> <Reference Include="ffme.common">
@@ -109,7 +110,6 @@
<Compile Include="Properties\AssemblyInfo.cs"> <Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<None Include="key.snk" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -25,7 +25,6 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using QuickLook.Helpers; using QuickLook.Helpers;
using QuickLook.Properties;
namespace QuickLook namespace QuickLook
{ {
@@ -39,8 +38,8 @@ namespace QuickLook
public static readonly bool Is64Bit = Environment.Is64BitProcess; public static readonly bool Is64Bit = Environment.Is64BitProcess;
public static readonly bool IsUWP = ProcessHelper.IsRunningAsUWP(); public static readonly bool IsUWP = ProcessHelper.IsRunningAsUWP();
public static readonly bool IsWin10 = Environment.OSVersion.Version >= new Version(10, 0); public static readonly bool IsWin10 = Environment.OSVersion.Version >= new Version(10, 0);
public static readonly string LocalDataPath = Path.GetFullPath(Path.Combine(ConfigurationManager public static readonly string LocalDataPath =
.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath, @"..\..\")); Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"pooi.moe\QuickLook\");
private bool _isFirstInstance; private bool _isFirstInstance;
private Mutex _isRunning; private Mutex _isRunning;
@@ -74,7 +73,7 @@ namespace QuickLook
RemoteCallShowPreview(e); RemoteCallShowPreview(e);
// second instance: duplicate // second instance: duplicate
else else
MessageBox.Show(TranslationHelper.GetString("APP_SECOND")); MessageBox.Show(TranslationHelper.Get("APP_SECOND"));
Shutdown(); Shutdown();
return; return;
@@ -91,24 +90,23 @@ namespace QuickLook
private void CheckUpdate() private void CheckUpdate()
{ {
if (DateTime.Now - Settings.Default.LastUpdate < TimeSpan.FromDays(7)) if (DateTime.Now - SettingHelper.Get<DateTime>("LastUpdate") < TimeSpan.FromDays(7))
return; return;
Task.Delay(120 * 1000).ContinueWith(_ => Updater.CheckForUpdates(true)); Task.Delay(120 * 1000).ContinueWith(_ => Updater.CheckForUpdates(true));
Settings.Default.LastUpdate = DateTime.Now; SettingHelper.Set("LastUpdate", DateTime.Now);
Settings.Default.Save();
} }
private void UpgradeSettings() private void UpgradeSettings()
{ {
try try
{ {
if (!Settings.Default.Upgraded) if (!SettingHelper.Get("Upgraded", true))
return; return;
Updater.CollectAndShowReleaseNotes(); Updater.CollectAndShowReleaseNotes();
Settings.Default.Upgrade(); SettingHelper.Set("Upgraded", false);
} }
catch (ConfigurationErrorsException e) catch (ConfigurationErrorsException e)
{ {
@@ -124,8 +122,7 @@ namespace QuickLook
//return; //return;
} }
Settings.Default.Upgraded = false; SettingHelper.Set("Upgraded", false);
Settings.Default.Save();
} }
private void RemoteCallShowPreview(StartupEventArgs e) private void RemoteCallShowPreview(StartupEventArgs e)
@@ -137,7 +134,7 @@ namespace QuickLook
{ {
TrayIconManager.GetInstance(); TrayIconManager.GetInstance();
if (!e.Args.Contains("/autorun") && !IsUWP) if (!e.Args.Contains("/autorun") && !IsUWP)
TrayIconManager.ShowNotification("", TranslationHelper.GetString("APP_START")); TrayIconManager.ShowNotification("", TranslationHelper.Get("APP_START"));
if (e.Args.Contains("/first")) if (e.Args.Contains("/first"))
AutoStartupHelper.CreateAutorunShortcut(); AutoStartupHelper.CreateAutorunShortcut();

View File

@@ -0,0 +1,113 @@
// Copyright © 2018 Paddy Xu
//
// This file is part of QuickLook program.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Xml;
namespace QuickLook.Helpers
{
internal class SettingHelper
{
private static readonly Dictionary<string, XmlDocument> FileCache = new Dictionary<string, XmlDocument>();
[MethodImpl(MethodImplOptions.NoInlining)]
public static T Get<T>(string id, T failsafe = default(T), Assembly calling = null)
{
if (!typeof(T).IsSerializable && !typeof(ISerializable).IsAssignableFrom(typeof(T)))
throw new InvalidOperationException("A serializable Type is required");
var file = Path.Combine(App.LocalDataPath,
(calling ?? Assembly.GetCallingAssembly()).GetName().Name + ".config");
var doc = GetConfigFile(file);
// try to get setting
var s = GetSettingFromXml(doc, id, failsafe);
return s != null ? s : failsafe;
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Set(string id, object value, Assembly calling = null)
{
if (!value.GetType().IsSerializable)
throw new NotSupportedException("New value if not serializable.");
var file = Path.Combine(App.LocalDataPath,
(calling ?? Assembly.GetCallingAssembly()).GetName().Name + ".config");
WriteSettingToXml(GetConfigFile(file), id, value);
}
private static T GetSettingFromXml<T>(XmlDocument doc, string id, T failsafe)
{
var v = doc.SelectSingleNode($@"/Settings/{id}");
var result = v == null ? failsafe : (T) Convert.ChangeType(v.InnerText, typeof(T));
return result;
}
private static void WriteSettingToXml(XmlDocument doc, string id, object value)
{
var v = doc.SelectSingleNode($@"/Settings/{id}");
if (v != null)
{
v.InnerText = value.ToString();
}
else
{
var node = doc.CreateNode(XmlNodeType.Element, id, doc.NamespaceURI);
node.InnerText = value.ToString();
doc.SelectSingleNode(@"/Settings").AppendChild(node);
}
doc.Save(new Uri(doc.BaseURI).LocalPath);
}
private static XmlDocument GetConfigFile(string file)
{
if (FileCache.ContainsKey(file))
return FileCache[file];
Directory.CreateDirectory(Path.GetDirectoryName(file));
if (!File.Exists(file))
CreateNewConfig(file);
var doc = new XmlDocument();
doc.Load(file);
FileCache.Add(file, doc);
return doc;
}
private static void CreateNewConfig(string file)
{
using (var writer = XmlWriter.Create(file))
{
writer.WriteStartDocument();
writer.WriteStartElement("Settings");
writer.WriteEndElement();
writer.WriteEndDocument();
}
}
}
}

View File

@@ -30,10 +30,9 @@ namespace QuickLook.Helpers
//private static readonly CultureInfo CurrentCultureInfo = CultureInfo.GetCultureInfo("zh-CN"); //private static readonly CultureInfo CurrentCultureInfo = CultureInfo.GetCultureInfo("zh-CN");
private static readonly Dictionary<string, XPathNavigator> FileCache = new Dictionary<string, XPathNavigator>(); private static readonly Dictionary<string, XPathNavigator> FileCache = new Dictionary<string, XPathNavigator>();
private static readonly Dictionary<string, string> StringCache = new Dictionary<string, string>();
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
public static string GetString(string id, string file = null, CultureInfo locale = null, string failsafe = null, public static string Get(string id, string file = null, CultureInfo locale = null, string failsafe = null,
Assembly calling = null) Assembly calling = null)
{ {
if (file == null) if (file == null)
@@ -69,12 +68,7 @@ namespace QuickLook.Helpers
private static string GetStringFromXml(XPathNavigator nav, string id, CultureInfo locale) private static string GetStringFromXml(XPathNavigator nav, string id, CultureInfo locale)
{ {
var cacheKey = $"{nav.BaseURI.GetHashCode()}::{locale.Name}::{id}";
if (StringCache.ContainsKey(cacheKey))
return StringCache[cacheKey];
var result = nav.SelectSingleNode($@"/Translations/{locale.Name}/{id}"); var result = nav.SelectSingleNode($@"/Translations/{locale.Name}/{id}");
StringCache.Add(cacheKey, result?.Value);
return result?.Value; return result?.Value;
} }

View File

@@ -48,7 +48,7 @@ namespace QuickLook.Helpers
if (!silent) if (!silent)
Application.Current.Dispatcher.Invoke( Application.Current.Dispatcher.Invoke(
() => TrayIconManager.ShowNotification("", () => TrayIconManager.ShowNotification("",
TranslationHelper.GetString("Update_NoUpdate"))); TranslationHelper.Get("Update_NoUpdate")));
return; return;
} }
@@ -58,7 +58,7 @@ namespace QuickLook.Helpers
() => () =>
{ {
TrayIconManager.ShowNotification("", TrayIconManager.ShowNotification("",
string.Format(TranslationHelper.GetString("Update_Found"), nVersion), string.Format(TranslationHelper.Get("Update_Found"), nVersion),
timeout: 20000, timeout: 20000,
clickEvent: clickEvent:
() => Process.Start( () => Process.Start(
@@ -70,7 +70,7 @@ namespace QuickLook.Helpers
Debug.WriteLine(e.Message); Debug.WriteLine(e.Message);
Application.Current.Dispatcher.Invoke( Application.Current.Dispatcher.Invoke(
() => TrayIconManager.ShowNotification("", () => TrayIconManager.ShowNotification("",
string.Format(TranslationHelper.GetString("Update_Error"), e.Message))); string.Format(TranslationHelper.Get("Update_Error"), e.Message)));
} }
}); });
} }
@@ -106,7 +106,7 @@ namespace QuickLook.Helpers
Debug.WriteLine(e.Message); Debug.WriteLine(e.Message);
Application.Current.Dispatcher.Invoke( Application.Current.Dispatcher.Invoke(
() => TrayIconManager.ShowNotification("", () => TrayIconManager.ShowNotification("",
string.Format(TranslationHelper.GetString("Update_Error"), e.Message))); string.Format(TranslationHelper.Get("Update_Error"), e.Message)));
} }
}); });
} }

View File

@@ -198,7 +198,25 @@ namespace QuickLook.Plugin
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
public string GetString(string id, string file = null, CultureInfo locale = null, string failsafe = null) public string GetString(string id, string file = null, CultureInfo locale = null, string failsafe = null)
{ {
return TranslationHelper.GetString(id, file, locale, failsafe, Assembly.GetCallingAssembly()); return TranslationHelper.Get(id, file, locale, failsafe, Assembly.GetCallingAssembly());
}
/// <summary>
/// Get a setting from Xml document.
/// </summary>
[MethodImpl(MethodImplOptions.NoInlining)]
public T GetSetting<T>(string id, T failsafe = default(T))
{
return SettingHelper.Get(id, failsafe, Assembly.GetCallingAssembly());
}
/// <summary>
/// Set a setting from Xml document.
/// </summary>
[MethodImpl(MethodImplOptions.NoInlining)]
public void SetSetting(string id, object value)
{
SettingHelper.Set(id, value, Assembly.GetCallingAssembly());
} }
/// <summary> /// <summary>

View File

@@ -68,7 +68,7 @@ namespace QuickLook.Plugin.InfoPanel
filename.Text = string.IsNullOrEmpty(name) ? path : name; filename.Text = string.IsNullOrEmpty(name) ? path : name;
var last = File.GetLastWriteTime(path); var last = File.GetLastWriteTime(path);
modDate.Text = string.Format(TranslationHelper.GetString("InfoPanel_LastModified"), modDate.Text = string.Format(TranslationHelper.Get("InfoPanel_LastModified"),
last.ToString(CultureInfo.CurrentCulture)); last.ToString(CultureInfo.CurrentCulture));
Stop = false; Stop = false;
@@ -91,7 +91,7 @@ namespace QuickLook.Plugin.InfoPanel
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
totalSize.Text = totalSize.Text =
string.Format(TranslationHelper.GetString("InfoPanel_DriveSize"), string.Format(TranslationHelper.Get("InfoPanel_DriveSize"),
totalSpace.ToPrettySize(2), totalSpace.ToPrettySize(2),
totalFreeSpace.ToPrettySize(2)); totalFreeSpace.ToPrettySize(2));
}); });
@@ -107,16 +107,16 @@ namespace QuickLook.Plugin.InfoPanel
string t; string t;
var folders = totalDirsL == 0 var folders = totalDirsL == 0
? string.Empty ? string.Empty
: string.Format(TranslationHelper.GetString( : string.Format(TranslationHelper.Get(
totalDirsL == 1 ? "InfoPanel_Folder" : "InfoPanel_Folders"), totalDirsL); totalDirsL == 1 ? "InfoPanel_Folder" : "InfoPanel_Folders"), totalDirsL);
var files = totalFilesL == 0 var files = totalFilesL == 0
? string.Empty ? string.Empty
: string.Format(TranslationHelper.GetString( : string.Format(TranslationHelper.Get(
totalFilesL == 1 ? "InfoPanel_File" : "InfoPanel_Files"), totalFilesL); totalFilesL == 1 ? "InfoPanel_File" : "InfoPanel_Files"), totalFilesL);
if (!string.IsNullOrEmpty(folders) && !string.IsNullOrEmpty(files)) if (!string.IsNullOrEmpty(folders) && !string.IsNullOrEmpty(files))
t = string.Format( t = string.Format(
TranslationHelper.GetString("InfoPanel_FolderAndFile"), folders, files); TranslationHelper.Get("InfoPanel_FolderAndFile"), folders, files);
else if (string.IsNullOrEmpty(folders) && string.IsNullOrEmpty(files)) else if (string.IsNullOrEmpty(folders) && string.IsNullOrEmpty(files))
t = string.Empty; t = string.Empty;
else else

View File

@@ -1,50 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace QuickLook.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool Upgraded {
get {
return ((bool)(this["Upgraded"]));
}
set {
this["Upgraded"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("2017-01-01")]
public global::System.DateTime LastUpdate {
get {
return ((global::System.DateTime)(this["LastUpdate"]));
}
set {
this["LastUpdate"] = value;
}
}
}
}

View File

@@ -1,14 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"
GeneratedClassNamespace="QuickLook.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="Upgraded" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="LastUpdate" Type="System.DateTime" Scope="User">
<Value Profile="(Default)">2017-01-01</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -79,10 +79,11 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignAssembly>true</SignAssembly> <SignAssembly>false</SignAssembly>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@@ -134,6 +135,7 @@
<Compile Include="ExtensionMethods\TypeExtensions.cs" /> <Compile Include="ExtensionMethods\TypeExtensions.cs" />
<Compile Include="Helpers\FileHelper.cs" /> <Compile Include="Helpers\FileHelper.cs" />
<Compile Include="Helpers\ProcessHelper.cs" /> <Compile Include="Helpers\ProcessHelper.cs" />
<Compile Include="Helpers\SettingHelper.cs" />
<Compile Include="Helpers\TranslationHelper.cs" /> <Compile Include="Helpers\TranslationHelper.cs" />
<Compile Include="PipeServerManager.cs" /> <Compile Include="PipeServerManager.cs" />
<Compile Include="PluginManager.cs" /> <Compile Include="PluginManager.cs" />
@@ -207,11 +209,6 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Resources\app_white_16.ico" /> <None Include="Resources\app_white_16.ico" />
<None Include="Resources\app_16.ico" /> <None Include="Resources\app_16.ico" />
@@ -231,11 +228,6 @@
<Content Include="Fonts\segmdl2.ttf"> <Content Include="Fonts\segmdl2.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<None Include="key.snk" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />

View File

@@ -30,7 +30,7 @@ namespace QuickLook
private readonly NotifyIcon _icon; private readonly NotifyIcon _icon;
private readonly MenuItem _itemAutorun = private readonly MenuItem _itemAutorun =
new MenuItem(TranslationHelper.GetString("Icon_RunAtStartup"), new MenuItem(TranslationHelper.Get("Icon_RunAtStartup"),
(sender, e) => (sender, e) =>
{ {
if (AutoStartupHelper.IsAutorun()) if (AutoStartupHelper.IsAutorun())
@@ -43,7 +43,7 @@ namespace QuickLook
{ {
_icon = new NotifyIcon _icon = new NotifyIcon
{ {
Text = string.Format(TranslationHelper.GetString("Icon_ToolTip"), Text = string.Format(TranslationHelper.Get("Icon_ToolTip"),
Application.ProductVersion), Application.ProductVersion),
Icon = GetTrayIconByDPI(), Icon = GetTrayIconByDPI(),
Visible = true, Visible = true,
@@ -51,10 +51,10 @@ namespace QuickLook
{ {
new MenuItem($"v{Application.ProductVersion}{(App.IsUWP ? " (UWP)" : "")}") {Enabled = false}, new MenuItem($"v{Application.ProductVersion}{(App.IsUWP ? " (UWP)" : "")}") {Enabled = false},
new MenuItem("-"), new MenuItem("-"),
new MenuItem(TranslationHelper.GetString("Icon_CheckUpdate"), new MenuItem(TranslationHelper.Get("Icon_CheckUpdate"),
(sender, e) => Updater.CheckForUpdates()) {Enabled = !App.IsUWP}, (sender, e) => Updater.CheckForUpdates()) {Enabled = !App.IsUWP},
_itemAutorun, _itemAutorun,
new MenuItem(TranslationHelper.GetString("Icon_Quit"), new MenuItem(TranslationHelper.Get("Icon_Quit"),
(sender, e) => System.Windows.Application.Current.Shutdown()) (sender, e) => System.Windows.Application.Current.Shutdown())
}) })
}; };

View File

@@ -243,7 +243,7 @@ namespace QuickLook
if (replaceWith.Length > 16) if (replaceWith.Length > 16)
replaceWith = replaceWith.Substring(0, 14) + "…" + replaceWith.Substring(replaceWith.Length - 2); replaceWith = replaceWith.Substring(0, 14) + "…" + replaceWith.Substring(replaceWith.Length - 2);
str = TranslationHelper.GetString(str); str = TranslationHelper.Get(str);
var elements = str.Split(new[] {"{0}"}, StringSplitOptions.None).ToList(); var elements = str.Split(new[] {"{0}"}, StringSplitOptions.None).ToList();
while (elements.Count < 2) while (elements.Count < 2)
elements.Add(string.Empty); elements.Add(string.Empty);

View File

@@ -41,7 +41,7 @@ namespace QuickLook
InitializeComponent(); InitializeComponent();
FontFamily = new FontFamily(TranslationHelper.GetString("UI_FontFamily", failsafe: "Segoe UI")); FontFamily = new FontFamily(TranslationHelper.Get("UI_FontFamily", failsafe: "Segoe UI"));
SizeChanged += SaveWindowSizeOnSizeChanged; SizeChanged += SaveWindowSizeOnSizeChanged;

Binary file not shown.