mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-11 17:59:17 +00:00
Add application icons
This commit is contained in:
@@ -41,7 +41,7 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
|
||||
public void View(string path, ContextObject context)
|
||||
{
|
||||
_vp = new ViewerPanel();
|
||||
_vp = new ViewerPanel(context);
|
||||
|
||||
context.ViewerContent = _vp;
|
||||
|
||||
|
@@ -13,7 +13,9 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
/// </summary>
|
||||
public partial class ViewerPanel : UserControl, IDisposable
|
||||
{
|
||||
public ViewerPanel()
|
||||
private ContextObject _context;
|
||||
|
||||
public ViewerPanel(ContextObject context)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@@ -21,8 +23,8 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
|
||||
mediaElement.PropertyChanged += ChangePlayPauseButton;
|
||||
mediaElement.MouseLeftButtonUp += TogglePlayPause;
|
||||
mediaElement.MediaErrored += ShowErrorOverlay;
|
||||
mediaElement.MediaFailed += ShowErrorOverlay;
|
||||
mediaElement.MediaErrored += ShowErrorNotification;
|
||||
mediaElement.MediaFailed += ShowErrorNotification;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -48,10 +50,11 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
: FontAwesomeIcon.PlayCircleOutline;
|
||||
}
|
||||
|
||||
private void ShowErrorOverlay(object sender, MediaErrorRoutedEventArgs e)
|
||||
private void ShowErrorNotification(object sender, MediaErrorRoutedEventArgs e)
|
||||
{
|
||||
mediaElement.Stop();
|
||||
errorOverlay.Visibility = Visibility.Visible;
|
||||
|
||||
_context.ShowNotification("", "An error occurred while loading the video.");
|
||||
}
|
||||
|
||||
public void LoadAndPlay(string path)
|
||||
|
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
|
||||
namespace QuickLook
|
||||
@@ -13,6 +15,8 @@ namespace QuickLook
|
||||
public static readonly string AppFullPath = Assembly.GetExecutingAssembly().Location;
|
||||
public static readonly string AppPath = Path.GetDirectoryName(AppFullPath);
|
||||
|
||||
private Mutex isRunning;
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
AppDomain.CurrentDomain.UnhandledException +=
|
||||
@@ -24,9 +28,25 @@ namespace QuickLook
|
||||
|
||||
private void Application_Startup(object sender, StartupEventArgs e)
|
||||
{
|
||||
EnsureSingleInstance();
|
||||
|
||||
if (!e.Args.Contains("/autorun"))
|
||||
TrayIcon.GetInstance().ShowNotification("", "QuickLook is running in the background.");
|
||||
|
||||
PluginManager.GetInstance();
|
||||
|
||||
BackgroundListener.GetInstance();
|
||||
}
|
||||
|
||||
private void EnsureSingleInstance()
|
||||
{
|
||||
bool isNew = false;
|
||||
isRunning = new Mutex(true, "QuickLook.App", out isNew);
|
||||
if (!isNew)
|
||||
{
|
||||
MessageBox.Show("QuickLook is already running in the background.");
|
||||
Current.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -30,6 +30,17 @@ namespace QuickLook.Plugin
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show a notification balloon.
|
||||
/// </summary>
|
||||
/// <param name="title">Title of the notification.</param>
|
||||
/// <param name="content">The content.</param>
|
||||
/// <param name="isError">Is this indicates a error?</param>
|
||||
public void ShowNotification(string title, string content, bool isError = false)
|
||||
{
|
||||
TrayIcon.GetInstance().ShowNotification(title, content, isError);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get or set the viewer content control.
|
||||
/// </summary>
|
||||
|
62
QuickLook/Properties/Resources.Designer.cs
generated
62
QuickLook/Properties/Resources.Designer.cs
generated
@@ -8,10 +8,10 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace QuickLook.Properties
|
||||
{
|
||||
|
||||
|
||||
namespace QuickLook.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
@@ -22,50 +22,62 @@ namespace QuickLook.Properties
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("QuickLook.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon app {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("app", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon app_white {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("app_white", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
@@ -60,6 +60,7 @@
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
@@ -68,9 +69,10 @@
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
@@ -85,9 +87,10 @@
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
@@ -109,9 +112,16 @@
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="app" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\app.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="app_white" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\app_white.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
@@ -48,6 +48,9 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Resources\app.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FontAwesome.WPF, Version=4.7.0.37774, Culture=neutral, PublicKeyToken=0758b07a11a4f466, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll</HintPath>
|
||||
@@ -90,6 +93,7 @@
|
||||
<Compile Include="Plugin\InfoPanel\WindowsThumbnailProvider.cs" />
|
||||
<Compile Include="Plugin\IViewer.cs" />
|
||||
<Compile Include="Helpers\DpiHelpers.cs" />
|
||||
<Compile Include="TrayIcon.cs" />
|
||||
<Compile Include="ViewContentContainer.xaml.cs">
|
||||
<DependentUpon>ViewContentContainer.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -172,5 +176,11 @@
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\app.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\app_white.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
BIN
QuickLook/Resources/app.ico
Normal file
BIN
QuickLook/Resources/app.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 105 KiB |
BIN
QuickLook/Resources/app_white.ico
Normal file
BIN
QuickLook/Resources/app_white.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 101 KiB |
36
QuickLook/TrayIcon.cs
Normal file
36
QuickLook/TrayIcon.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace QuickLook
|
||||
{
|
||||
public class TrayIcon
|
||||
{
|
||||
private static TrayIcon _instance;
|
||||
|
||||
private NotifyIcon _icon;
|
||||
|
||||
internal TrayIcon()
|
||||
{
|
||||
_icon = new NotifyIcon
|
||||
{
|
||||
Icon = Properties.Resources.app_white,
|
||||
Visible = true
|
||||
};
|
||||
}
|
||||
|
||||
public void ShowNotification(string title, string content, bool isError = false)
|
||||
{
|
||||
_icon.ShowBalloonTip(5000, title, content, isError ? ToolTipIcon.Error : ToolTipIcon.Info);
|
||||
}
|
||||
|
||||
internal static TrayIcon GetInstance()
|
||||
{
|
||||
return _instance ?? (_instance = new TrayIcon());
|
||||
}
|
||||
}
|
||||
}
|
@@ -29,5 +29,9 @@ Hotkeys in preview window:
|
||||
|
||||
## Development
|
||||
|
||||
The previewing ability can be extended by new plugins. Read the [plugin interface](https://github.com/xupefei/QuickLook/blob/master/QuickLook/Plugin/IViewer.cs), [context object](https://github.com/xupefei/QuickLook/blob/master/QuickLook/Plugin/ContextObject.cs) for more information. [Pre-shipped plugins](https://github.com/xupefei/QuickLook/tree/master/QuickLook.Plugin) contains more detailed implementation.
|
||||
The previewing ability can be extended by new plugins. Read the [plugin interface](https://github.com/xupefei/QuickLook/blob/master/QuickLook/Plugin/IViewer.cs), [context object](https://github.com/xupefei/QuickLook/blob/master/QuickLook/Plugin/ContextObject.cs) for more information. [Pre-shipped plugins](https://github.com/xupefei/QuickLook/tree/master/QuickLook.Plugin) contains more detailed implementation.
|
||||
Note that any plugin must be under the `QuickLook.Plugin` namespace, has the filename similar to `QuickLook.Plugin.YourPlugin.dll` and placed under `<Application>\Plugins\QuickLook.Plugin.YourPlugin\` subfolder.
|
||||
|
||||
## Licenses
|
||||
|
||||
Application icons made by Freepik from www.flaticon.com. Used under the [Flaticon Basic License](http://file000.flaticon.com/downloads/license/license.pdf).
|
||||
|
Reference in New Issue
Block a user