summaryrefslogtreecommitdiffstats
path: root/ComicRackWebViewer/Plugin.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ComicRackWebViewer/Plugin.cs')
-rw-r--r--ComicRackWebViewer/Plugin.cs77
1 files changed, 77 insertions, 0 deletions
diff --git a/ComicRackWebViewer/Plugin.cs b/ComicRackWebViewer/Plugin.cs
new file mode 100644
index 0000000..38e94f3
--- /dev/null
+++ b/ComicRackWebViewer/Plugin.cs
@@ -0,0 +1,77 @@
+using System;
+using System.Windows;
+using cYo.Projects.ComicRack.Plugins.Automation;
+
+namespace ComicRackWebViewer
+{
+ public static class Plugin
+ {
+ internal static IApplication Application;
+ private static WebServicePanel panel;
+ private static Version requiredVersion = new Version(0, 9, 153);
+
+ public static void Run(IApplication app)
+ {
+ try
+ {
+ Application = app;
+ var comicVersion = new Version(app.ProductVersion);
+ if (comicVersion < requiredVersion)
+ {
+ MessageBox.Show("ComicRack version required: " + requiredVersion);
+ return;
+ }
+ if (panel == null)
+ {
+ panel = new WebServicePanel();
+ panel.Closed += new EventHandler(panel_Closed);
+ }
+ panel.ShowDialog();
+ }
+ catch (Exception e)
+ {
+ MessageBox.Show(e.ToString());
+ }
+ }
+
+ public static void RunAtStartup(IApplication app)
+ {
+ try
+ {
+ Application = app;
+ var comicVersion = new Version(app.ProductVersion);
+ if (comicVersion < requiredVersion)
+ {
+ MessageBox.Show("ComicRack version required: " + requiredVersion);
+ return;
+ }
+ if (panel == null)
+ {
+ panel = new WebServicePanel();
+ }
+ panel.StartService();
+ }
+ catch (Exception e)
+ {
+ MessageBox.Show(e.ToString());
+ }
+ }
+
+ static void panel_Closed(object sender, EventArgs e)
+ {
+ panel = null;
+ }
+
+ [STAThread]
+ public static void Main()
+ {
+ if (panel == null)
+ {
+ panel = new WebServicePanel();
+ panel.Closed += new EventHandler(panel_Closed);
+ }
+ panel.ShowDialog();
+ }
+
+ }
+}