diff --git a/Plugin.cs b/Plugin.cs
index d0c2196..7d66b86 100644
--- a/Plugin.cs
+++ b/Plugin.cs
@@ -1,7 +1,14 @@
-using System.IO;
+using System;
+using System.IO;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Forms;
+using System.Windows.Forms.Integration;
using QuickLook.Common.Plugin;
+using SharpMap.Data.Providers;
+using SharpMap.Forms;
+using SharpMap.Layers;
+using static SharpMap.Forms.MapBox;
namespace QuickLook.Plugin.HelloWorld
{
@@ -11,30 +18,60 @@ public class Plugin : IViewer
public void Init()
{
+ // do nothing
}
public bool CanHandle(string path)
{
- return !Directory.Exists(path) && path.ToLower().EndsWith(".zzz");
+ return !Directory.Exists(path) && path.ToLower().EndsWith(".shp");
}
public void Prepare(string path, ContextObject context)
{
- context.PreferredSize = new Size {Width = 600, Height = 400};
+ context.SetPreferredSizeFit(new Size { Width = 1920, Height = 1440 }, 0.9);
}
public void View(string path, ContextObject context)
{
- var viewer = new Label {Content = "I am a Label. I do nothing at all."};
-
- context.ViewerContent = viewer;
context.Title = $"{Path.GetFileName(path)}";
+ try
+ {
+ MapBox mapBox = new MapBox()
+ {
+ Dock = DockStyle.Fill,
+ ActiveTool = Tools.Pan,
+ PreviewMode = PreviewModes.Fast
+ };
+ WindowsFormsHost host = new WindowsFormsHost()
+ {
+ Child = mapBox,
+ };
+ VectorLayer layer = new VectorLayer(Path.GetFileName(path))
+ {
+ DataSource = new ShapeFile(path, false, true)
+ };
+ mapBox.Map.Layers.Add(layer);
+ mapBox.Map.ZoomToExtents();
+ mapBox.Refresh();
- context.IsBusy = false;
+ context.ViewerContent = host;
+ }
+ catch (Exception ex)
+ {
+ context.ViewerContent = new System.Windows.Controls.Label
+ {
+ Content = $"Can not open shapefile because of: {ex.Message}"
+ };
+ }
+ finally
+ {
+ context.IsBusy = false;
+ }
}
public void Cleanup()
{
+ // do nothing
}
}
}
\ No newline at end of file
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
index eeeabf4..bb453e9 100644
--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -5,11 +5,11 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-[assembly: AssemblyTitle("QuickLook.Plugin.HelloWorld")]
+[assembly: AssemblyTitle("QuickLook.Plugin.ShapefileViewer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("pooi.moe")]
-[assembly: AssemblyProduct("QuickLook.Plugin.HelloWorld")]
+[assembly: AssemblyProduct("QuickLook.Plugin.ShapefileViewer")]
[assembly: AssemblyCopyright("Copyright © Paddy Xu 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
diff --git a/QuickLook.Plugin.HelloWorld.csproj b/QuickLook.Plugin.HelloWorld.csproj
deleted file mode 100644
index cc1bb43..0000000
--- a/QuickLook.Plugin.HelloWorld.csproj
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {863ECAAC-18D9-4256-A27D-0F308089FB47}
- library
- QuickLook.Plugin.HelloWorld
- QuickLook.Plugin.HelloWorld
- v4.6.2
- 512
- {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 4
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
- true
- Debug\
- DEBUG;TRACE
- full
- x86
- prompt
- MinimumRecommendedRules.ruleset
-
-
- Release\
- TRACE
- true
- pdbonly
- x86
- prompt
- MinimumRecommendedRules.ruleset
-
-
- false
-
-
-
-
-
-
-
-
-
- 4.0
-
-
-
-
-
-
-
-
-
-
-
-
- {85fdd6ba-871d-46c8-bd64-f6bb0cb5ea95}
- QuickLook.Common
- False
-
-
-
-
-
- Always
-
-
-
-
\ No newline at end of file
diff --git a/QuickLook.Plugin.Metadata.Base.config b/QuickLook.Plugin.Metadata.Base.config
index d24f4b9..b58036b 100644
--- a/QuickLook.Plugin.Metadata.Base.config
+++ b/QuickLook.Plugin.Metadata.Base.config
@@ -1,6 +1,6 @@
- QuickLook.Plugin.HelloWorld
+ QuickLook.Plugin.ShapefileViewer
0
- This plugin does nothing at all.
+ View ESRI Shapefile (*.shp).
\ No newline at end of file
diff --git a/QuickLook.Plugin.ShapefileViewer.csproj b/QuickLook.Plugin.ShapefileViewer.csproj
new file mode 100644
index 0000000..9471d32
--- /dev/null
+++ b/QuickLook.Plugin.ShapefileViewer.csproj
@@ -0,0 +1,144 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {863ECAAC-18D9-4256-A27D-0F308089FB47}
+ library
+ QuickLook.Plugin.ShapefileViewer
+ QuickLook.Plugin.ShapefileViewer
+ v4.6.2
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ true
+ Debug\
+ DEBUG;TRACE
+ full
+ x86
+ prompt
+ MinimumRecommendedRules.ruleset
+
+
+ Release\
+ TRACE
+ true
+ pdbonly
+ x86
+ prompt
+ MinimumRecommendedRules.ruleset
+
+
+ false
+
+
+
+
+
+
+
+ packages\BruTile.0.7.4.4\lib\net40\BruTile.dll
+
+
+ packages\BruTile.0.7.4.4\lib\net40\BruTile.Desktop.dll
+
+
+ packages\BruTile.0.7.4.4\lib\net40\BruTile.MbTiles.dll
+
+
+ packages\BruTile.0.7.4.4\lib\net40\BruTile.Serialization.dll
+
+
+ packages\Common.Logging.2.0.0\lib\2.0\Common.Logging.dll
+
+
+ packages\GeoAPI.1.7.2\lib\net403-client\GeoAPI.dll
+
+
+ packages\NetTopologySuite.1.13.2\lib\net403-client\NetTopologySuite.dll
+
+
+ packages\NetTopologySuite.IO.1.13.2\lib\net403-client\NetTopologySuite.IO.GeoTools.dll
+
+
+ packages\NetTopologySuite.IO.1.13.2\lib\net403-client\NetTopologySuite.IO.MsSqlSpatial.dll
+
+
+ packages\NetTopologySuite.IO.1.13.2\lib\net403-client\NetTopologySuite.IO.PostGis.dll
+
+
+ packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll
+
+
+ packages\NetTopologySuite.1.13.2\lib\net403-client\PowerCollections.dll
+
+
+ packages\ProjNET4GeoAPI.1.3.0.3\lib\net403-client\ProjNet.dll
+
+
+ packages\SharpMap.1.1.0\lib\net40-client\SharpMap.dll
+
+
+ packages\SharpMap.UI.1.1.0\lib\net40-client\SharpMap.UI.dll
+
+
+
+
+
+ packages\System.Data.SQLite.MSIL.1.0.86.0\lib\net45\System.Data.SQLite.dll
+
+
+ packages\System.Data.SQLite.MSIL.1.0.86.0\lib\net45\System.Data.SQLite.Linq.dll
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {85fdd6ba-871d-46c8-bd64-f6bb0cb5ea95}
+ QuickLook.Common
+ False
+
+
+
+
+
+
+ Always
+
+
+
+
\ No newline at end of file
diff --git a/QuickLook.Plugin.HelloWorld.sln b/QuickLook.Plugin.ShapefileViewer.sln
similarity index 95%
rename from QuickLook.Plugin.HelloWorld.sln
rename to QuickLook.Plugin.ShapefileViewer.sln
index 5b826dc..b6f830f 100644
--- a/QuickLook.Plugin.HelloWorld.sln
+++ b/QuickLook.Plugin.ShapefileViewer.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2003
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.HelloWorld", "QuickLook.Plugin.HelloWorld.csproj", "{863ECAAC-18D9-4256-A27D-0F308089FB47}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.ShapefileViewer", "QuickLook.Plugin.ShapefileViewer.csproj", "{863ECAAC-18D9-4256-A27D-0F308089FB47}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Common", "QuickLook.Common\QuickLook.Common.csproj", "{85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}"
EndProject
diff --git a/README.md b/README.md
index 2dc22d2..0c9712d 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
![QuickLook icon](https://user-images.githubusercontent.com/1687847/29485863-8cd61b7c-84e2-11e7-97d5-eacc2ba10d28.png)
-# QuickLook.Plugin.HelloWorld
+# QuickLook.Plugin.ShapefileViewer
This plugin illustrates the development process of [QuickLook](https://github.com/QL-Win/QuickLook).
diff --git a/Scripts/pack-zip.ps1 b/Scripts/pack-zip.ps1
index 3710fa2..c41bfc0 100644
--- a/Scripts/pack-zip.ps1
+++ b/Scripts/pack-zip.ps1
@@ -1,5 +1,5 @@
-Remove-Item ..\QuickLook.Plugin.HelloWorld.qlplugin -ErrorAction SilentlyContinue
+Remove-Item ..\QuickLook.Plugin.ShapefileViewer.qlplugin -ErrorAction SilentlyContinue
$files = Get-ChildItem -Path ..\bin\Release\ -Exclude *.pdb,*.xml
-Compress-Archive $files ..\QuickLook.Plugin.HelloWorld.zip
-Move-Item ..\QuickLook.Plugin.HelloWorld.zip ..\QuickLook.Plugin.HelloWorld.qlplugin
\ No newline at end of file
+Compress-Archive $files ..\QuickLook.Plugin.ShapefileViewer.zip
+Move-Item ..\QuickLook.Plugin.ShapefileViewer.zip ..\QuickLook.Plugin.ShapefileViewer.qlplugin
\ No newline at end of file
diff --git a/packages.config b/packages.config
new file mode 100644
index 0000000..4fe3611
--- /dev/null
+++ b/packages.config
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file