diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/PluginInterface.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/PluginInterface.cs
index def0646..ec1076e 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/PluginInterface.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/PluginInterface.cs
@@ -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;
diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs
index b245c11..f0635e4 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs
@@ -13,7 +13,9 @@ namespace QuickLook.Plugin.VideoViewer
///
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)
diff --git a/QuickLook/App.xaml.cs b/QuickLook/App.xaml.cs
index b6e84b2..6e101a5 100644
--- a/QuickLook/App.xaml.cs
+++ b/QuickLook/App.xaml.cs
@@ -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();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/QuickLook/Plugin/ContextObject.cs b/QuickLook/Plugin/ContextObject.cs
index e83d0a6..c476d09 100644
--- a/QuickLook/Plugin/ContextObject.cs
+++ b/QuickLook/Plugin/ContextObject.cs
@@ -30,6 +30,17 @@ namespace QuickLook.Plugin
}
}
+ ///
+ /// Show a notification balloon.
+ ///
+ /// Title of the notification.
+ /// The content.
+ /// Is this indicates a error?
+ public void ShowNotification(string title, string content, bool isError = false)
+ {
+ TrayIcon.GetInstance().ShowNotification(title, content, isError);
+ }
+
///
/// Get or set the viewer content control.
///
diff --git a/QuickLook/Properties/Resources.Designer.cs b/QuickLook/Properties/Resources.Designer.cs
index b98ee60..ee5fc6d 100644
--- a/QuickLook/Properties/Resources.Designer.cs
+++ b/QuickLook/Properties/Resources.Designer.cs
@@ -8,10 +8,10 @@
//
//------------------------------------------------------------------------------
-namespace QuickLook.Properties
-{
-
-
+namespace QuickLook.Properties {
+ using System;
+
+
///
/// A strongly-typed resource class, for looking up localized strings, etc.
///
@@ -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() {
}
-
+
///
/// Returns the cached ResourceManager instance used by this class.
///
[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;
}
}
-
+
///
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
///
[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;
}
}
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
+ ///
+ internal static System.Drawing.Icon app {
+ get {
+ object obj = ResourceManager.GetObject("app", resourceCulture);
+ return ((System.Drawing.Icon)(obj));
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
+ ///
+ internal static System.Drawing.Icon app_white {
+ get {
+ object obj = ResourceManager.GetObject("app_white", resourceCulture);
+ return ((System.Drawing.Icon)(obj));
+ }
+ }
}
}
diff --git a/QuickLook/Properties/Resources.resx b/QuickLook/Properties/Resources.resx
index af7dbeb..c156f27 100644
--- a/QuickLook/Properties/Resources.resx
+++ b/QuickLook/Properties/Resources.resx
@@ -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.
-->
+
@@ -68,9 +69,10 @@
-
+
+
@@ -85,9 +87,10 @@
-
+
+
@@ -109,9 +112,16 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ ..\Resources\app.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\app_white.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/QuickLook/QuickLook.csproj b/QuickLook/QuickLook.csproj
index c9b7589..6604217 100644
--- a/QuickLook/QuickLook.csproj
+++ b/QuickLook/QuickLook.csproj
@@ -48,6 +48,9 @@
prompt
4
+
+ Resources\app.ico
+
..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll
@@ -90,6 +93,7 @@
+
ViewContentContainer.xaml
@@ -172,5 +176,11 @@
false
+
+
+
+
+
+
\ No newline at end of file
diff --git a/QuickLook/Resources/app.ico b/QuickLook/Resources/app.ico
new file mode 100644
index 0000000..dc7e486
Binary files /dev/null and b/QuickLook/Resources/app.ico differ
diff --git a/QuickLook/Resources/app_white.ico b/QuickLook/Resources/app_white.ico
new file mode 100644
index 0000000..e0652e8
Binary files /dev/null and b/QuickLook/Resources/app_white.ico differ
diff --git a/QuickLook/TrayIcon.cs b/QuickLook/TrayIcon.cs
new file mode 100644
index 0000000..95e2146
--- /dev/null
+++ b/QuickLook/TrayIcon.cs
@@ -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());
+ }
+ }
+}
diff --git a/README.md b/README.md
index 2e6428a..e43d0b8 100644
--- a/README.md
+++ b/README.md
@@ -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 `\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).