├── .gitattributes
├── .gitignore
├── DemosWPF
├── 3DBuildingsWindow.xaml
├── 3DBuildingsWindow.xaml.cs
├── App.config
├── App.xaml
├── App.xaml.cs
├── BingStyleWindow.xaml
├── BingStyleWindow.xaml.cs
├── DataBindingViewModel.cs
├── DataBindingWindow.xaml
├── DataBindingWindow.xaml.cs
├── DemosWPF.csproj
├── GeoJsonWindow.xaml
├── GeoJsonWindow.xaml.cs
├── HelloWorldWindow.xaml
├── HelloWorldWindow.xaml.cs
├── LocalRasterWindow.xaml
├── LocalRasterWindow.xaml.cs
├── LocalVectorWindow.xaml
├── LocalVectorWindow.xaml.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── OfflineWindow.xaml
├── OfflineWindow.xaml.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── StyleSwitchWindow.xaml
├── StyleSwitchWindow.xaml.cs
├── VideoOverlayWindow.xaml
├── VideoOverlayWindow.xaml.cs
├── XamlProjectionWindow.xaml
├── XamlProjectionWindow.xaml.cs
├── aliflux-style.json
├── images
│ ├── pikachu-hd.png
│ └── pikachu.png
└── packages.config
├── HelloWorldWinForms
├── App.config
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── HelloWorldWinForms.csproj
├── Program.cs
└── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── LICENSE
├── MapboxNet.sln
├── MapboxNetCore
├── Core.cs
├── DynamicExpression.cs
├── EnhancedExpandoObeject.cs
├── ExpressionBuilder.cs
├── GeoExtent.cs
├── GeoLocation.cs
├── IMap.cs
├── MapServer.cs
├── MapboxNetCore.csproj
├── Point2D.cs
└── web
│ ├── frame.js
│ ├── mapbox-gl.css
│ └── mapbox-gl.js
├── MapboxNetWPF
├── Map.xaml
├── Map.xaml.cs
├── MapboxNetWPF.csproj
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Relay.cs
└── packages.config
├── MapboxNetWinForms
├── Map.Designer.cs
├── Map.cs
├── Map.resx
├── MapboxNetWinForms.csproj
├── Properties
│ └── AssemblyInfo.cs
├── Relay.cs
└── packages.config
├── README.md
├── Raw
├── pikachu-hd.png
└── pikachu.png
└── images
├── 3d.png
├── bing.png
├── dark.png
├── geojson.png
├── local-raster.png
├── local-vector.png
└── oslo.png
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015/2017 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # Visual Studio 2017 auto generated files
33 | Generated\ Files/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # Benchmark Results
49 | BenchmarkDotNet.Artifacts/
50 |
51 | # .NET Core
52 | project.lock.json
53 | project.fragment.lock.json
54 | artifacts/
55 | **/Properties/launchSettings.json
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_i.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *.log
81 | *.vspscc
82 | *.vssscc
83 | .builds
84 | *.pidb
85 | *.svclog
86 | *.scc
87 |
88 | # Chutzpah Test files
89 | _Chutzpah*
90 |
91 | # Visual C++ cache files
92 | ipch/
93 | *.aps
94 | *.ncb
95 | *.opendb
96 | *.opensdf
97 | *.sdf
98 | *.cachefile
99 | *.VC.db
100 | *.VC.VC.opendb
101 |
102 | # Visual Studio profiler
103 | *.psess
104 | *.vsp
105 | *.vspx
106 | *.sap
107 |
108 | # Visual Studio Trace Files
109 | *.e2e
110 |
111 | # TFS 2012 Local Workspace
112 | $tf/
113 |
114 | # Guidance Automation Toolkit
115 | *.gpState
116 |
117 | # ReSharper is a .NET coding add-in
118 | _ReSharper*/
119 | *.[Rr]e[Ss]harper
120 | *.DotSettings.user
121 |
122 | # JustCode is a .NET coding add-in
123 | .JustCode
124 |
125 | # TeamCity is a build add-in
126 | _TeamCity*
127 |
128 | # DotCover is a Code Coverage Tool
129 | *.dotCover
130 |
131 | # AxoCover is a Code Coverage Tool
132 | .axoCover/*
133 | !.axoCover/settings.json
134 |
135 | # Visual Studio code coverage results
136 | *.coverage
137 | *.coveragexml
138 |
139 | # NCrunch
140 | _NCrunch_*
141 | .*crunch*.local.xml
142 | nCrunchTemp_*
143 |
144 | # MightyMoose
145 | *.mm.*
146 | AutoTest.Net/
147 |
148 | # Web workbench (sass)
149 | .sass-cache/
150 |
151 | # Installshield output folder
152 | [Ee]xpress/
153 |
154 | # DocProject is a documentation generator add-in
155 | DocProject/buildhelp/
156 | DocProject/Help/*.HxT
157 | DocProject/Help/*.HxC
158 | DocProject/Help/*.hhc
159 | DocProject/Help/*.hhk
160 | DocProject/Help/*.hhp
161 | DocProject/Help/Html2
162 | DocProject/Help/html
163 |
164 | # Click-Once directory
165 | publish/
166 |
167 | # Publish Web Output
168 | *.[Pp]ublish.xml
169 | *.azurePubxml
170 | # Note: Comment the next line if you want to checkin your web deploy settings,
171 | # but database connection strings (with potential passwords) will be unencrypted
172 | *.pubxml
173 | *.publishproj
174 |
175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
176 | # checkin your Azure Web App publish settings, but sensitive information contained
177 | # in these scripts will be unencrypted
178 | PublishScripts/
179 |
180 | # NuGet Packages
181 | *.nupkg
182 | # The packages folder can be ignored because of Package Restore
183 | **/[Pp]ackages/*
184 | # except build/, which is used as an MSBuild target.
185 | !**/[Pp]ackages/build/
186 | # Uncomment if necessary however generally it will be regenerated when needed
187 | #!**/[Pp]ackages/repositories.config
188 | # NuGet v3's project.json files produces more ignorable files
189 | *.nuget.props
190 | *.nuget.targets
191 |
192 | # Microsoft Azure Build Output
193 | csx/
194 | *.build.csdef
195 |
196 | # Microsoft Azure Emulator
197 | ecf/
198 | rcf/
199 |
200 | # Windows Store app package directories and files
201 | AppPackages/
202 | BundleArtifacts/
203 | Package.StoreAssociation.xml
204 | _pkginfo.txt
205 | *.appx
206 |
207 | # Visual Studio cache files
208 | # files ending in .cache can be ignored
209 | *.[Cc]ache
210 | # but keep track of directories ending in .cache
211 | !*.[Cc]ache/
212 |
213 | # Others
214 | ClientBin/
215 | ~$*
216 | *~
217 | *.dbmdl
218 | *.dbproj.schemaview
219 | *.jfm
220 | *.pfx
221 | *.publishsettings
222 | orleans.codegen.cs
223 |
224 | # Including strong name files can present a security risk
225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
226 | #*.snk
227 |
228 | # Since there are multiple workflows, uncomment next line to ignore bower_components
229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
230 | #bower_components/
231 |
232 | # RIA/Silverlight projects
233 | Generated_Code/
234 |
235 | # Backup & report files from converting an old project file
236 | # to a newer Visual Studio version. Backup files are not needed,
237 | # because we have git ;-)
238 | _UpgradeReport_Files/
239 | Backup*/
240 | UpgradeLog*.XML
241 | UpgradeLog*.htm
242 | ServiceFabricBackup/
243 |
244 | # SQL Server files
245 | *.mdf
246 | *.ldf
247 | *.ndf
248 |
249 | # Business Intelligence projects
250 | *.rdl.data
251 | *.bim.layout
252 | *.bim_*.settings
253 | *.rptproj.rsuser
254 |
255 | # Microsoft Fakes
256 | FakesAssemblies/
257 |
258 | # GhostDoc plugin setting file
259 | *.GhostDoc.xml
260 |
261 | # Node.js Tools for Visual Studio
262 | .ntvs_analysis.dat
263 | node_modules/
264 |
265 | # Visual Studio 6 build log
266 | *.plg
267 |
268 | # Visual Studio 6 workspace options file
269 | *.opt
270 |
271 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
272 | *.vbw
273 |
274 | # Visual Studio LightSwitch build output
275 | **/*.HTMLClient/GeneratedArtifacts
276 | **/*.DesktopClient/GeneratedArtifacts
277 | **/*.DesktopClient/ModelManifest.xml
278 | **/*.Server/GeneratedArtifacts
279 | **/*.Server/ModelManifest.xml
280 | _Pvt_Extensions
281 |
282 | # Paket dependency manager
283 | .paket/paket.exe
284 | paket-files/
285 |
286 | # FAKE - F# Make
287 | .fake/
288 |
289 | # JetBrains Rider
290 | .idea/
291 | *.sln.iml
292 |
293 | # CodeRush
294 | .cr/
295 |
296 | # Python Tools for Visual Studio (PTVS)
297 | __pycache__/
298 | *.pyc
299 |
300 | # Cake - Uncomment if you are using it
301 | # tools/**
302 | # !tools/packages.config
303 |
304 | # Tabs Studio
305 | *.tss
306 |
307 | # Telerik's JustMock configuration file
308 | *.jmconfig
309 |
310 | # BizTalk build output
311 | *.btp.cs
312 | *.btm.cs
313 | *.odx.cs
314 | *.xsd.cs
315 |
316 | # OpenCover UI analysis results
317 | OpenCover/
318 |
319 | # Azure Stream Analytics local run output
320 | ASALocalRun/
321 |
322 | # MSBuild Binary and Structured Log
323 | *.binlog
324 |
325 | # NVidia Nsight GPU debugger configuration file
326 | *.nvuser
327 |
328 | # MFractors (Xamarin productivity tool) working folder
329 | .mfractor/
330 | /packages
331 | /tile-cache
332 |
333 | *.psd
--------------------------------------------------------------------------------
/DemosWPF/3DBuildingsWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/DemosWPF/3DBuildingsWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace DemosWPF
16 | {
17 | ///
18 | /// Interaction logic for _3DBuildingsWindow.xaml
19 | ///
20 | public partial class _3DBuildingsWindow : Window
21 | {
22 | public _3DBuildingsWindow(string accessToken)
23 | {
24 | InitializeComponent();
25 | Map.AccessToken = accessToken;
26 | }
27 |
28 | private void Map_Styled(object sender, EventArgs e)
29 | {
30 |
31 | // Extruding the building polygons to create a 3D map view
32 |
33 | // Converted using the JSON to C# anonymous type converter
34 | // source: https://docs.mapbox.com/mapbox-gl-js/example/3d-buildings/
35 | // converter: https://jsfiddle.net/aliashrafx/c7pxomjb/39/
36 |
37 | var layers = Map.Invoke.getStyle().layers;
38 | var labelLayerId = "";
39 |
40 | // firstly, we get the text layer
41 |
42 | foreach (var layer in layers)
43 | if (layer.type == "" || (layer.ContainsKey("layout") && layer.layout.ContainsKey("text-field")))
44 | {
45 | labelLayerId = layer.id;
46 | break;
47 | }
48 |
49 | // then we create a new extrusion layer
50 |
51 | var obj = new Dictionary
52 | {
53 | ["id"] = "3d-buildings",
54 | ["source"] = "composite",
55 | ["source-layer"] = "building",
56 | ["filter"] = new [] { "==", "extrude", "true" },
57 | ["type"] = "fill-extrusion",
58 | ["minzoom"] = 15,
59 | ["paint"] = new Dictionary
60 | {
61 | ["fill-extrusion-color"] = "#dfe4ea",
62 | ["fill-extrusion-height"] = new object[] {
63 | "interpolate" ,
64 | new [] { "linear" },
65 | new [] { "zoom" },
66 | 14, 0, 15.05,
67 | new [] { "get", "height" }
68 | },
69 | ["fill-extrusion-base"] = new object[] {
70 | "interpolate",
71 | new [] { "linear" },
72 | new [] { "zoom" },
73 | 14, 0, 15.05,
74 | new [] { "get", "min_height" }
75 | },
76 | ["fill-extrusion-opacity"] = .6
77 | }
78 | };
79 |
80 | // now we add the new layer after text layer
81 |
82 | Map.Invoke.AddLayer(obj, labelLayerId);
83 |
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/DemosWPF/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/DemosWPF/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/DemosWPF/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace DemosWPF
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/DemosWPF/BingStyleWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/DemosWPF/BingStyleWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace DemosWPF
16 | {
17 | ///
18 | /// Interaction logic for BingStyleWindow.xaml
19 | ///
20 | public partial class BingStyleWindow : Window
21 | {
22 | public BingStyleWindow()
23 | {
24 | InitializeComponent();
25 |
26 | // Creating a custom style that takes bing satellite tile source as the raster layer
27 |
28 | var style = new Dictionary
29 | {
30 | ["version"] = 8,
31 | ["name"] = "Custom style",
32 | ["sources"] = new Dictionary
33 | {
34 | ["satellite"] = new Dictionary
35 | {
36 | ["type"] = "raster",
37 | ["tileSize"] = 256,
38 | ["tiles"] = new object[] {
39 | "http://ecn.t0.tiles.virtualearth.net/tiles/h{quadkey}.jpeg?g=129&mkt=en&stl=H",
40 | },
41 | },
42 | },
43 | ["layers"] = new object[] {
44 | new Dictionary {
45 | ["id"] = "satellite",
46 | ["type"] = "raster",
47 | ["source"] = "satellite",
48 | ["minzoom"] = 0,
49 | ["maxzoom"] = 22,
50 | ["layout"] = new Dictionary {
51 | },
52 | ["paint"] = new Dictionary {
53 | },
54 | },
55 | },
56 | ["glyphs"] = "http://glfonts.lukasmartinelli.ch/fonts/{fontstack}/{range}.pbf",
57 | ["id"] = "44004506-1129-4d81-9889-800854993041",
58 | };
59 |
60 | Map.MapStyle = style;
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/DemosWPF/DataBindingViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace DemosWPF
9 | {
10 | // A simple view-model that has the basic Map properties
11 |
12 | class DataBindingViewModel : INotifyPropertyChanged
13 | {
14 | MapboxNetCore.GeoLocation _location = new MapboxNetCore.GeoLocation(47.3769, 8.5417);
15 | public MapboxNetCore.GeoLocation Location
16 | {
17 | get => _location;
18 | set
19 | {
20 | if (value == _location)
21 | return;
22 |
23 | _location = value;
24 | OnPropertyRaised(nameof(Location));
25 | }
26 | }
27 |
28 | double _zoom = 13;
29 | public double Zoom
30 | {
31 | get => _zoom;
32 | set
33 | {
34 | if (value == _zoom)
35 | return;
36 |
37 | _zoom = value;
38 | OnPropertyRaised(nameof(Zoom));
39 | }
40 | }
41 |
42 | double _pitch;
43 | public double Pitch
44 | {
45 | get => _pitch;
46 | set
47 | {
48 | if (value == _pitch)
49 | return;
50 |
51 | _pitch = value;
52 | OnPropertyRaised(nameof(Pitch));
53 | }
54 | }
55 |
56 | double _bearing;
57 | public double Bearing
58 | {
59 | get => _bearing;
60 | set
61 | {
62 | if (value == _bearing)
63 | return;
64 |
65 | _bearing = value;
66 | OnPropertyRaised(nameof(Bearing));
67 | }
68 | }
69 |
70 | public event PropertyChangedEventHandler PropertyChanged;
71 | private void OnPropertyRaised(string propertyname)
72 | {
73 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyname));
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/DemosWPF/DataBindingWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/DemosWPF/DataBindingWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace DemosWPF
16 | {
17 | ///
18 | /// Interaction logic for DataBindingWindow.xaml
19 | ///
20 | public partial class DataBindingWindow : Window
21 | {
22 | public DataBindingWindow(string accessToken)
23 | {
24 | InitializeComponent();
25 | Map.AccessToken = accessToken;
26 |
27 | // Check the XAML for binding
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/DemosWPF/DemosWPF.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {F073EBC1-F2C2-4965-B07B-20647EDB5A69}
8 | WinExe
9 | DemosWPF
10 | DemosWPF
11 | v4.6.2
12 | 512
13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
14 | 4
15 | true
16 | true
17 |
18 |
19 |
20 |
21 | x86
22 | true
23 | full
24 | false
25 | bin\Debug\
26 | DEBUG;TRACE
27 | prompt
28 | 4
29 |
30 |
31 | AnyCPU
32 | pdbonly
33 | true
34 | bin\Release\
35 | TRACE
36 | prompt
37 | 4
38 |
39 |
40 | true
41 | bin\x86\Debug\
42 | DEBUG;TRACE
43 | full
44 | x86
45 | prompt
46 | MinimumRecommendedRules.ruleset
47 | true
48 |
49 |
50 | bin\x86\Release\
51 | TRACE
52 | true
53 | pdbonly
54 | x86
55 | prompt
56 | MinimumRecommendedRules.ruleset
57 | true
58 |
59 |
60 |
61 | ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll
62 |
63 |
64 |
65 |
66 | ..\packages\System.Data.SQLite.Core.1.0.110.0\lib\net46\System.Data.SQLite.dll
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | 4.0
76 |
77 |
78 | ..\packages\uHttpSharp.0.1.6.22\lib\net40\uhttpsharp.dll
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 | MSBuild:Compile
87 | Designer
88 |
89 |
90 | BingStyleWindow.xaml
91 |
92 |
93 |
94 | DataBindingWindow.xaml
95 |
96 |
97 | LocalRasterWindow.xaml
98 |
99 |
100 | LocalVectorWindow.xaml
101 |
102 |
103 | OfflineWindow.xaml
104 |
105 |
106 | StyleSwitchWindow.xaml
107 |
108 |
109 | VideoOverlayWindow.xaml
110 |
111 |
112 | XamlProjectionWindow.xaml
113 |
114 |
115 | Designer
116 | MSBuild:Compile
117 |
118 |
119 | Designer
120 | MSBuild:Compile
121 |
122 |
123 | Designer
124 | MSBuild:Compile
125 |
126 |
127 | Designer
128 | MSBuild:Compile
129 |
130 |
131 | Designer
132 | MSBuild:Compile
133 |
134 |
135 | Designer
136 | MSBuild:Compile
137 |
138 |
139 | Designer
140 | MSBuild:Compile
141 |
142 |
143 | MSBuild:Compile
144 | Designer
145 |
146 |
147 | 3DBuildingsWindow.xaml
148 |
149 |
150 | App.xaml
151 | Code
152 |
153 |
154 | GeoJsonWindow.xaml
155 |
156 |
157 | HelloWorldWindow.xaml
158 |
159 |
160 | MainWindow.xaml
161 | Code
162 |
163 |
164 | Designer
165 | MSBuild:Compile
166 |
167 |
168 | Designer
169 | MSBuild:Compile
170 |
171 |
172 | Designer
173 | MSBuild:Compile
174 |
175 |
176 | Designer
177 | MSBuild:Compile
178 |
179 |
180 |
181 |
182 | Code
183 |
184 |
185 | True
186 | True
187 | Resources.resx
188 |
189 |
190 | True
191 | Settings.settings
192 | True
193 |
194 |
195 | ResXFileCodeGenerator
196 | Resources.Designer.cs
197 |
198 |
199 |
200 | SettingsSingleFileGenerator
201 | Settings.Designer.cs
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 | {657821b4-5c50-4d72-9898-81352a6130dc}
210 | MapboxNetCore
211 |
212 |
213 | {f23272d5-b532-48f6-a178-25cdf0320484}
214 | MapboxNetWPF
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
229 |
230 |
231 |
232 |
--------------------------------------------------------------------------------
/DemosWPF/GeoJsonWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/DemosWPF/GeoJsonWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace DemosWPF
16 | {
17 | ///
18 | /// Interaction logic for GeoJsonWindow.xaml
19 | ///
20 | public partial class GeoJsonWindow : Window
21 | {
22 | public GeoJsonWindow(string accessToken)
23 | {
24 | InitializeComponent();
25 | Map.AccessToken = accessToken;
26 | }
27 |
28 | private void Map_Styled(object sender, EventArgs e)
29 | {
30 | // Making two layers, one is a geojson polygon, other is a set of pikachu markers/images
31 |
32 | // Converted using the JSON to C# anonymous type converter
33 | // source: https://docs.mapbox.com/mapbox-gl-js/example/geojson-polygon/
34 | // converter: https://jsfiddle.net/aliashrafx/c7pxomjb/39/
35 |
36 | var polygonLayer = new Dictionary
37 | {
38 | ["id"] = "maine",
39 | ["type"] = "fill",
40 | ["source"] = new Dictionary
41 | {
42 | ["type"] = "geojson",
43 | ["data"] = new Dictionary
44 | {
45 | ["type"] = "Feature",
46 | ["geometry"] = new Dictionary
47 | {
48 | ["type"] = "Polygon",
49 | ["coordinates"] = new object[] {
50 | new object[] {
51 | new object[] {
52 | -67.13734351262877, 45.137451890638886,
53 | },
54 | new object[] {
55 | -66.96466, 44.8097,
56 | },
57 | new object[] {
58 | -68.03252, 44.3252,
59 | },
60 | new object[] {
61 | -69.06, 43.98,
62 | },
63 | new object[] {
64 | -70.11617, 43.68405,
65 | },
66 | new object[] {
67 | -70.64573401557249, 43.090083319667144,
68 | },
69 | new object[] {
70 | -70.75102474636725, 43.08003225358635,
71 | },
72 | new object[] {
73 | -70.79761105007827, 43.21973948828747,
74 | },
75 | new object[] {
76 | -70.98176001655037, 43.36789581966826,
77 | },
78 | new object[] {
79 | -70.94416541205806, 43.46633942318431,
80 | },
81 | new object[] {
82 | -71.08482, 45.3052400000002,
83 | },
84 | new object[] {
85 | -70.6600225491012, 45.46022288673396,
86 | },
87 | new object[] {
88 | -70.30495378282376, 45.914794623389355,
89 | },
90 | new object[] {
91 | -70.00014034695016, 46.69317088478567,
92 | },
93 | new object[] {
94 | -69.23708614772835, 47.44777598732787,
95 | },
96 | new object[] {
97 | -68.90478084987546, 47.184794623394396,
98 | },
99 | new object[] {
100 | -68.23430497910454, 47.35462921812177,
101 | },
102 | new object[] {
103 | -67.79035274928509, 47.066248887716995,
104 | },
105 | new object[] {
106 | -67.79141211614706, 45.702585354182816,
107 | },
108 | new object[] {
109 | -67.13734351262877, 45.137451890638886,
110 | },
111 | },
112 | },
113 | },
114 | },
115 | },
116 | ["paint"] = new Dictionary
117 | {
118 | ["fill-color"] = "#9b59b6",
119 | ["fill-opacity"] = 0.4,
120 | ["fill-outline-color"] = "#e74c3c",
121 | },
122 | };
123 |
124 | // inspired by: https://docs.mapbox.com/mapbox-gl-js/example/add-image/
125 | // converter: https://jsfiddle.net/aliashrafx/c7pxomjb/39/
126 |
127 | var pikachuLayer = new Dictionary
128 | {
129 | ["id"] = "points",
130 | ["type"] = "symbol",
131 | ["source"] = new Dictionary
132 | {
133 | ["type"] = "geojson",
134 | ["data"] = new Dictionary
135 | {
136 | ["type"] = "FeatureCollection",
137 | ["features"] = new object[] {
138 | new Dictionary {
139 | ["type"] = "Feature",
140 | ["properties"] = new Dictionary {
141 | ["label"] = "Pika pika",
142 | },
143 | ["geometry"] = new Dictionary {
144 | ["type"] = "Point",
145 | ["coordinates"] = new object[] {
146 | -74.0124907170679, 40.7052768300975
147 | },
148 | },
149 | },
150 | new Dictionary {
151 | ["type"] = "Feature",
152 | ["properties"] = new Dictionary {
153 | ["label"] = "Pika chuuuu",
154 | },
155 | ["geometry"] = new Dictionary {
156 | ["type"] = "Point",
157 | ["coordinates"] = new object[] {
158 | -78.6569, 37.4316
159 | },
160 | },
161 | },
162 | new Dictionary {
163 | ["type"] = "Feature",
164 | ["properties"] = new Dictionary {
165 | ["label"] = "Pikaaa",
166 | },
167 | ["geometry"] = new Dictionary {
168 | ["type"] = "Point",
169 | ["coordinates"] = new object[] {
170 | -79.3832, 43.6532
171 | },
172 | },
173 | },
174 | },
175 | },
176 | },
177 | ["layout"] = new Dictionary
178 | {
179 | ["text-field"] = "{label}",
180 | ["text-anchor"] = "bottom",
181 | ["icon-anchor"] = "top",
182 | ["icon-image"] = "pikachu",
183 | ["icon-size"] = 0.75,
184 | },
185 | };
186 |
187 | // You can add images to the map using bitmap, stream, or base64
188 | Map.AddImage("pikachu", pikachuImage.Source as BitmapSource);
189 |
190 | Map.Invoke.AddLayer(polygonLayer);
191 | Map.Invoke.AddLayer(pikachuLayer);
192 |
193 | }
194 | }
195 | }
196 |
--------------------------------------------------------------------------------
/DemosWPF/HelloWorldWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/DemosWPF/HelloWorldWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace DemosWPF
4 | {
5 | ///
6 | /// Interaction logic for HelloWorldWindow.xaml
7 | ///
8 | public partial class HelloWorldWindow : Window
9 | {
10 | public HelloWorldWindow(string accessToken)
11 | {
12 | InitializeComponent();
13 | Map.AccessToken = accessToken;
14 |
15 | // Check the XAML
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/DemosWPF/LocalRasterWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/DemosWPF/LocalRasterWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 | using MapboxNetCore;
15 |
16 | namespace DemosWPF
17 | {
18 | ///
19 | /// Interaction logic for LocalRasterWindow.xaml
20 | ///
21 | public partial class LocalRasterWindow : Window
22 | {
23 | public LocalRasterWindow()
24 | {
25 | InitializeComponent();
26 |
27 | // Starting a tile server on a random port
28 |
29 | var server = new MapboxNetCore.MapServer(@"tiles\zurich-raster.mbtiles");
30 | server.GlyphsPath = @"fonts\";
31 | server.Start();
32 |
33 | // Creating a custom style that takes our MapServer tiles as a raster source
34 |
35 | var style = new Dictionary
36 | {
37 | ["version"] = 8,
38 | ["name"] = "Custom style",
39 | ["sources"] = new Dictionary
40 | {
41 | ["satellite"] = new Dictionary
42 | {
43 | ["type"] = "raster",
44 | ["tileSize"] = 256,
45 | ["tiles"] = new object[] {
46 | server.TilesURL, // using tile URL here
47 | },
48 | },
49 | },
50 | ["layers"] = new object[] {
51 | new Dictionary {
52 | ["id"] = "satellite",
53 | ["type"] = "raster",
54 | ["source"] = "satellite",
55 | ["minzoom"] = 0,
56 | ["maxzoom"] = 22,
57 | ["layout"] = new Dictionary {
58 | },
59 | ["paint"] = new Dictionary {
60 | },
61 | },
62 | },
63 | ["glyphs"] = server.GlyphsURL,
64 | ["id"] = "14004506-1129-4d81-9889-800854993041",
65 | };
66 |
67 | // You can create a hybrid satellite view as well by using a style that takes both Vector Tiles as Raster Tiles
68 |
69 | Map.MapStyle = style;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/DemosWPF/LocalVectorWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/DemosWPF/LocalVectorWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace DemosWPF
16 | {
17 | ///
18 | /// Interaction logic for LocalVectorWindow.xaml
19 | ///
20 | public partial class LocalVectorWindow : Window
21 | {
22 | public LocalVectorWindow()
23 | {
24 | InitializeComponent();
25 |
26 | // Starting the MapServer on a random port, that serves the vector tiles stored in .mbtiles format
27 |
28 | var server = new MapboxNetCore.MapServer(@"tiles\zurich.mbtiles");
29 | server.GlyphsPath = @"fonts\";
30 | server.Start();
31 |
32 | // pulling the style json stored as an embedded resource in this project, and decoding it into C# dynamic object
33 |
34 | var json = MapboxNetCore.Core.GetEmbeddedResource(this.GetType(), "DemosWPF.aliflux-style.json");
35 | dynamic style = MapboxNetCore.Core.DecodeJsonPlain(json);
36 |
37 | // modifying the style a bit so that it uses our tile server
38 |
39 | style.sources.openmaptiles.tiles.Add(server.TilesURL);
40 | style.glyphs = server.GlyphsURL;
41 |
42 | // NOTE: this style (aliflux-style.json) is using the openmaptiles spec, not the mapbox spec
43 | // It is specifically compatable with the zurich.mbtiles vector tiles
44 |
45 | Map.MapStyle = style;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/DemosWPF/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/DemosWPF/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace DemosWPF
17 | {
18 | ///
19 | /// Interaction logic for MainWindow.xaml
20 | ///
21 | public partial class MainWindow : Window
22 | {
23 | string accessToken = "";
24 |
25 | public MainWindow()
26 | {
27 | InitializeComponent();
28 |
29 | // Write your access token here...
30 | // or set `AccessToken` property on each map control
31 | // Go to http://mapbox.com to register and get your token
32 |
33 | accessToken = "";
34 |
35 | if (accessToken == "")
36 | {
37 | MessageBox.Show("Please write your access token in the code to enable all demos.");
38 |
39 | helloWorldButton.IsEnabled = false;
40 | threeDButton.IsEnabled = false;
41 | styleSwitchButton.IsEnabled = false;
42 | geoJsonButton.IsEnabled = false;
43 | dataBindingButton.IsEnabled = false;
44 | xamlProjectionButton.IsEnabled = false;
45 | videoOverlayButton.IsEnabled = false;
46 | }
47 | }
48 |
49 | private void helloWorldButton_Click(object sender, RoutedEventArgs e)
50 | {
51 | var window = new HelloWorldWindow(accessToken);
52 | window.Show();
53 | }
54 |
55 | private void threeDButton_Click(object sender, RoutedEventArgs e)
56 | {
57 | var window = new _3DBuildingsWindow(accessToken);
58 | window.Show();
59 | }
60 |
61 | private void styleSwitchButton_Click(object sender, RoutedEventArgs e)
62 | {
63 | var window = new StyleSwitchWindow(accessToken);
64 | window.Show();
65 | }
66 |
67 | private void geoJsonButton_Click(object sender, RoutedEventArgs e)
68 | {
69 | var window = new GeoJsonWindow(accessToken);
70 | window.Show();
71 | }
72 |
73 | private void dataBindingButton_Click(object sender, RoutedEventArgs e)
74 | {
75 | var window = new DataBindingWindow(accessToken);
76 | window.Show();
77 | }
78 |
79 | private void bingButton_Click(object sender, RoutedEventArgs e)
80 | {
81 | var window = new BingStyleWindow();
82 | window.Show();
83 | }
84 |
85 | private void customRasterButton_Click(object sender, RoutedEventArgs e)
86 | {
87 | var window = new LocalRasterWindow();
88 | window.Show();
89 | }
90 |
91 | private void customVectorButton_Click(object sender, RoutedEventArgs e)
92 | {
93 | var window = new LocalVectorWindow();
94 | window.Show();
95 | }
96 |
97 | private void xamlProjectionButton_Click(object sender, RoutedEventArgs e)
98 | {
99 | var window = new XamlProjectionWindow(accessToken);
100 | window.Show();
101 | }
102 |
103 | private void videoOverlayButton_Click(object sender, RoutedEventArgs e)
104 | {
105 | var window = new VideoOverlayWindow(accessToken);
106 | window.Show();
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/DemosWPF/OfflineWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/DemosWPF/OfflineWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace DemosWPF
16 | {
17 | ///
18 | /// Interaction logic for OfflineWindow.xaml
19 | ///
20 | public partial class OfflineWindow : Window
21 | {
22 | public OfflineWindow(string accessToken)
23 | {
24 | InitializeComponent();
25 |
26 | var style = new Dictionary
27 | {
28 | ["version"] = 8,
29 | ["name"] = "Custom style",
30 | ["sources"] = new Dictionary
31 | {
32 | ["satellite-mediumres"] = new Dictionary
33 | {
34 | ["type"] = "raster",
35 | ["tileSize"] = 256,
36 | ["tiles"] = new object[] {
37 | "http://ecn.t0.tiles.virtualearth.net/tiles/h{quadkey}.jpeg?g=129&mkt=en&stl=H",
38 | },
39 | },
40 | },
41 | ["layers"] = new object[] {
42 | new Dictionary {
43 | ["id"] = "satellite-mediumres",
44 | ["type"] = "raster",
45 | ["source"] = "satellite-mediumres",
46 | ["minzoom"] = 0,
47 | ["maxzoom"] = 22,
48 | ["layout"] = new Dictionary {
49 | },
50 | ["paint"] = new Dictionary {
51 | },
52 | },
53 | },
54 | ["glyphs"] = "https://maps.tilehosting.com/fonts/{fontstack}/{range}.pbf?key=yd4rAVOD6ZdfBCcbKnIE",
55 | ["id"] = "44004506-1129-4d81-9889-800854993041",
56 | };
57 |
58 | Map.MapStyle = style;
59 | }
60 |
61 | private void Map_Ready(object sender, EventArgs e)
62 | {
63 | }
64 |
65 | private void Map_Styled(object sender, EventArgs e)
66 | {
67 |
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/DemosWPF/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("DemosWPF")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("DemosWPF")]
15 | [assembly: AssemblyCopyright("Copyright © 2019")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/DemosWPF/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace DemosWPF.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DemosWPF.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/DemosWPF/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/DemosWPF/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace DemosWPF.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/DemosWPF/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/DemosWPF/StyleSwitchWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/DemosWPF/StyleSwitchWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace DemosWPF
16 | {
17 | ///
18 | /// Interaction logic for StyleSwitchWindow.xaml
19 | ///
20 | public partial class StyleSwitchWindow : Window
21 | {
22 | public StyleSwitchWindow(string accessToken)
23 | {
24 | InitializeComponent();
25 | Map.AccessToken = accessToken;
26 | }
27 |
28 | private void RadioButton_Checked(object sender, RoutedEventArgs e)
29 | {
30 | var button = sender as RadioButton;
31 | var style = button.Tag.ToString();
32 |
33 | Map.Invoke.SetStyle("mapbox://styles/mapbox/" + style);
34 |
35 | // MapStyle property can also be used but it reloads the whole map component
36 | //Map.MapStyle = "mapbox://styles/mapbox/" + style;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/DemosWPF/VideoOverlayWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/DemosWPF/VideoOverlayWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace DemosWPF
16 | {
17 | ///
18 | /// Interaction logic for VideoOverlayWindow.xaml
19 | ///
20 | public partial class VideoOverlayWindow : Window
21 | {
22 | public VideoOverlayWindow(string accessToken)
23 | {
24 | InitializeComponent();
25 | Map.AccessToken = accessToken;
26 | }
27 |
28 | private void Map_Ready(object sender, EventArgs e)
29 | {
30 |
31 | // Making a simple style that shows satellite view
32 | // with video playing at specific coordinates
33 |
34 | // Converted using the JSON to C# anonymous type converter
35 | // source: https://docs.mapbox.com/mapbox-gl-js/example/video-on-a-map/
36 | // converter: https://jsfiddle.net/aliashrafx/c7pxomjb/39/
37 |
38 | var videoStyle = new Dictionary
39 | {
40 | ["version"] = 8,
41 | ["sources"] = new Dictionary
42 | {
43 | ["satellite"] = new Dictionary
44 | {
45 | ["type"] = "raster",
46 | ["url"] = "mapbox://mapbox.satellite",
47 | ["tileSize"] = 512,
48 | },
49 | ["video"] = new Dictionary
50 | {
51 | ["type"] = "video",
52 | ["urls"] = new object[] {
53 | "https://static-assets.mapbox.com/mapbox-gl-js/drone.mp4",
54 | "https://static-assets.mapbox.com/mapbox-gl-js/drone.webm",
55 | },
56 | ["coordinates"] = new object[] {
57 | new object[] {
58 | -122.51596391201019, 37.56238816766053,
59 | },
60 | new object[] {
61 | -122.51467645168304, 37.56410183312965,
62 | },
63 | new object[] {
64 | -122.51309394836426, 37.563391708549425,
65 | },
66 | new object[] {
67 | -122.51423120498657, 37.56161849366671,
68 | },
69 | },
70 | },
71 | },
72 | ["layers"] = new object[] {
73 | new Dictionary {
74 | ["id"] = "background",
75 | ["type"] = "background",
76 | ["paint"] = new Dictionary {
77 | ["background-color"] = "rgb(4,7,14)",
78 | },
79 | },
80 | new Dictionary {
81 | ["id"] = "satellite",
82 | ["type"] = "raster",
83 | ["source"] = "satellite",
84 | },
85 | new Dictionary {
86 | ["id"] = "video",
87 | ["type"] = "raster",
88 | ["source"] = "video",
89 | },
90 | },
91 | };
92 |
93 | Map.Invoke.SetStyle(videoStyle);
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/DemosWPF/XamlProjectionWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 | This is a XAML element
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/DemosWPF/XamlProjectionWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 |
4 | namespace DemosWPF
5 | {
6 | ///
7 | /// Interaction logic for XamlProjectionWindow.xaml
8 | ///
9 | public partial class XamlProjectionWindow : Window
10 | {
11 | public XamlProjectionWindow(string accessToken)
12 | {
13 | InitializeComponent();
14 | Map.AccessToken = accessToken;
15 | }
16 |
17 | private void Map_Render(object sender, EventArgs e)
18 | {
19 | // Render event is called whenever the map is redrawn
20 | // basically when style/location/pitch/rotation/etc is changed
21 |
22 | // We convert a specific lat/lon into pixels
23 | var boxLocation = new MapboxNetCore.GeoLocation(61.767785, 4.898183);
24 | var pointOnScreen = Map.Project(boxLocation);
25 |
26 | // then set the box position to those pixels
27 | Box.Margin = new Thickness(pointOnScreen.X - Box.ActualWidth/2, pointOnScreen.Y - Box.ActualHeight/2, 0, 0);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/DemosWPF/images/pikachu-hd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliFlux/MapboxNet/75999304cdfb0a1e36d35acc3e31e2a9adeee9c0/DemosWPF/images/pikachu-hd.png
--------------------------------------------------------------------------------
/DemosWPF/images/pikachu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliFlux/MapboxNet/75999304cdfb0a1e36d35acc3e31e2a9adeee9c0/DemosWPF/images/pikachu.png
--------------------------------------------------------------------------------
/DemosWPF/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HelloWorldWinForms/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/HelloWorldWinForms/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace HelloWorldWinForms
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.map = new MapboxNetWinForms.Map();
32 | this.SuspendLayout();
33 | //
34 | // map
35 | //
36 | this.map.Name = "map";
37 | this.map.Size = new System.Drawing.Size(760, 443);
38 | this.map.TabIndex = 0;
39 | this.map.Dock = System.Windows.Forms.DockStyle.Fill;
40 | //
41 | // Form1
42 | //
43 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
44 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
45 | this.ClientSize = new System.Drawing.Size(784, 467);
46 | this.Controls.Add(this.map);
47 | this.Name = "Form1";
48 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
49 | this.Text = "Form1";
50 | this.ResumeLayout(false);
51 |
52 | }
53 |
54 | #endregion
55 |
56 | private MapboxNetWinForms.Map map;
57 | }
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/HelloWorldWinForms/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace HelloWorldWinForms
12 | {
13 | public partial class Form1 : Form
14 | {
15 | public Form1()
16 | {
17 | InitializeComponent();
18 |
19 |
20 | // Write your access token here...
21 | // or set `AccessToken` property on each map control
22 | // Go to http://mapbox.com to register and get your token
23 |
24 | var accessToken = "";
25 |
26 | if (accessToken == "")
27 | {
28 | MessageBox.Show("Please write your access token in the code to run this demo.");
29 | return;
30 | }
31 |
32 | map.AccessToken = accessToken;
33 | map.Center = new MapboxNetCore.GeoLocation(59.9058906, 10.7190694);
34 | map.Zoom = 12;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/HelloWorldWinForms/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/HelloWorldWinForms/HelloWorldWinForms.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {3C2DC754-35FC-4488-9046-697F97384C0A}
8 | WinExe
9 | HelloWorldWinForms
10 | HelloWorldWinForms
11 | v4.6.2
12 | 512
13 | true
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 | true
37 | bin\x86\Debug\
38 | DEBUG;TRACE
39 | full
40 | x86
41 | prompt
42 | MinimumRecommendedRules.ruleset
43 | true
44 |
45 |
46 | bin\x86\Release\
47 | TRACE
48 | true
49 | pdbonly
50 | x86
51 | prompt
52 | MinimumRecommendedRules.ruleset
53 | true
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | Form
71 |
72 |
73 | Form1.cs
74 |
75 |
76 |
77 |
78 | Form1.cs
79 |
80 |
81 | ResXFileCodeGenerator
82 | Resources.Designer.cs
83 | Designer
84 |
85 |
86 | True
87 | Resources.resx
88 | True
89 |
90 |
91 | SettingsSingleFileGenerator
92 | Settings.Designer.cs
93 |
94 |
95 | True
96 | Settings.settings
97 | True
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 | {657821b4-5c50-4d72-9898-81352a6130dc}
106 | MapboxNetCore
107 |
108 |
109 | {4662aba5-eae8-419d-ae4c-81dee38241bf}
110 | MapboxNetWinForms
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/HelloWorldWinForms/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace HelloWorldWinForms
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new Form1());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/HelloWorldWinForms/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("HelloWorldWinForms")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("HelloWorldWinForms")]
13 | [assembly: AssemblyCopyright("Copyright © 2019")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("3c2dc754-35fc-4488-9046-697f97384c0a")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/HelloWorldWinForms/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace HelloWorldWinForms.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HelloWorldWinForms.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/HelloWorldWinForms/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/HelloWorldWinForms/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace HelloWorldWinForms.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/HelloWorldWinForms/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Ali Ashraf
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MapboxNet.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.28803.202
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapboxNetWPF", "MapboxNetWPF\MapboxNetWPF.csproj", "{F23272D5-B532-48F6-A178-25CDF0320484}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demos", "Demos", "{B638501D-6F5D-4BA0-BD45-0C1593E2A50C}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MapboxNetCore", "MapboxNetCore\MapboxNetCore.csproj", "{657821B4-5C50-4D72-9898-81352A6130DC}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemosWPF", "DemosWPF\DemosWPF.csproj", "{F073EBC1-F2C2-4965-B07B-20647EDB5A69}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapboxNetWinForms", "MapboxNetWinForms\MapboxNetWinForms.csproj", "{4662ABA5-EAE8-419D-AE4C-81DEE38241BF}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorldWinForms", "HelloWorldWinForms\HelloWorldWinForms.csproj", "{3C2DC754-35FC-4488-9046-697F97384C0A}"
17 | EndProject
18 | Global
19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
20 | Debug|Any CPU = Debug|Any CPU
21 | Debug|x86 = Debug|x86
22 | Release|Any CPU = Release|Any CPU
23 | Release|x86 = Release|x86
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {F23272D5-B532-48F6-A178-25CDF0320484}.Debug|Any CPU.ActiveCfg = Debug|x86
27 | {F23272D5-B532-48F6-A178-25CDF0320484}.Debug|Any CPU.Build.0 = Debug|x86
28 | {F23272D5-B532-48F6-A178-25CDF0320484}.Debug|x86.ActiveCfg = Debug|Any CPU
29 | {F23272D5-B532-48F6-A178-25CDF0320484}.Debug|x86.Build.0 = Debug|Any CPU
30 | {F23272D5-B532-48F6-A178-25CDF0320484}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {F23272D5-B532-48F6-A178-25CDF0320484}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {F23272D5-B532-48F6-A178-25CDF0320484}.Release|x86.ActiveCfg = Release|x86
33 | {F23272D5-B532-48F6-A178-25CDF0320484}.Release|x86.Build.0 = Release|x86
34 | {657821B4-5C50-4D72-9898-81352A6130DC}.Debug|Any CPU.ActiveCfg = Debug|x86
35 | {657821B4-5C50-4D72-9898-81352A6130DC}.Debug|Any CPU.Build.0 = Debug|x86
36 | {657821B4-5C50-4D72-9898-81352A6130DC}.Debug|x86.ActiveCfg = Debug|Any CPU
37 | {657821B4-5C50-4D72-9898-81352A6130DC}.Debug|x86.Build.0 = Debug|Any CPU
38 | {657821B4-5C50-4D72-9898-81352A6130DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
39 | {657821B4-5C50-4D72-9898-81352A6130DC}.Release|Any CPU.Build.0 = Release|Any CPU
40 | {657821B4-5C50-4D72-9898-81352A6130DC}.Release|x86.ActiveCfg = Release|x86
41 | {657821B4-5C50-4D72-9898-81352A6130DC}.Release|x86.Build.0 = Release|x86
42 | {F073EBC1-F2C2-4965-B07B-20647EDB5A69}.Debug|Any CPU.ActiveCfg = Debug|x86
43 | {F073EBC1-F2C2-4965-B07B-20647EDB5A69}.Debug|Any CPU.Build.0 = Debug|x86
44 | {F073EBC1-F2C2-4965-B07B-20647EDB5A69}.Debug|x86.ActiveCfg = Debug|x86
45 | {F073EBC1-F2C2-4965-B07B-20647EDB5A69}.Debug|x86.Build.0 = Debug|x86
46 | {F073EBC1-F2C2-4965-B07B-20647EDB5A69}.Release|Any CPU.ActiveCfg = Release|Any CPU
47 | {F073EBC1-F2C2-4965-B07B-20647EDB5A69}.Release|Any CPU.Build.0 = Release|Any CPU
48 | {F073EBC1-F2C2-4965-B07B-20647EDB5A69}.Release|x86.ActiveCfg = Release|x86
49 | {F073EBC1-F2C2-4965-B07B-20647EDB5A69}.Release|x86.Build.0 = Release|x86
50 | {4662ABA5-EAE8-419D-AE4C-81DEE38241BF}.Debug|Any CPU.ActiveCfg = Debug|x86
51 | {4662ABA5-EAE8-419D-AE4C-81DEE38241BF}.Debug|Any CPU.Build.0 = Debug|x86
52 | {4662ABA5-EAE8-419D-AE4C-81DEE38241BF}.Debug|x86.ActiveCfg = Debug|Any CPU
53 | {4662ABA5-EAE8-419D-AE4C-81DEE38241BF}.Debug|x86.Build.0 = Debug|Any CPU
54 | {4662ABA5-EAE8-419D-AE4C-81DEE38241BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
55 | {4662ABA5-EAE8-419D-AE4C-81DEE38241BF}.Release|Any CPU.Build.0 = Release|Any CPU
56 | {4662ABA5-EAE8-419D-AE4C-81DEE38241BF}.Release|x86.ActiveCfg = Release|Any CPU
57 | {4662ABA5-EAE8-419D-AE4C-81DEE38241BF}.Release|x86.Build.0 = Release|Any CPU
58 | {3C2DC754-35FC-4488-9046-697F97384C0A}.Debug|Any CPU.ActiveCfg = Debug|x86
59 | {3C2DC754-35FC-4488-9046-697F97384C0A}.Debug|Any CPU.Build.0 = Debug|x86
60 | {3C2DC754-35FC-4488-9046-697F97384C0A}.Debug|x86.ActiveCfg = Debug|Any CPU
61 | {3C2DC754-35FC-4488-9046-697F97384C0A}.Debug|x86.Build.0 = Debug|Any CPU
62 | {3C2DC754-35FC-4488-9046-697F97384C0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
63 | {3C2DC754-35FC-4488-9046-697F97384C0A}.Release|Any CPU.Build.0 = Release|Any CPU
64 | {3C2DC754-35FC-4488-9046-697F97384C0A}.Release|x86.ActiveCfg = Release|Any CPU
65 | {3C2DC754-35FC-4488-9046-697F97384C0A}.Release|x86.Build.0 = Release|Any CPU
66 | EndGlobalSection
67 | GlobalSection(SolutionProperties) = preSolution
68 | HideSolutionNode = FALSE
69 | EndGlobalSection
70 | GlobalSection(NestedProjects) = preSolution
71 | {F073EBC1-F2C2-4965-B07B-20647EDB5A69} = {B638501D-6F5D-4BA0-BD45-0C1593E2A50C}
72 | {3C2DC754-35FC-4488-9046-697F97384C0A} = {B638501D-6F5D-4BA0-BD45-0C1593E2A50C}
73 | EndGlobalSection
74 | GlobalSection(ExtensibilityGlobals) = postSolution
75 | SolutionGuid = {19FB4130-D033-404B-897A-ADF52282780C}
76 | EndGlobalSection
77 | EndGlobal
78 |
--------------------------------------------------------------------------------
/MapboxNetCore/Core.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using Newtonsoft.Json.Linq;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Dynamic;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Reflection;
9 | using System.Text.RegularExpressions;
10 |
11 | namespace MapboxNetCore
12 | {
13 | public static class Core
14 | {
15 | static string getEmbeddedResource(string name)
16 | {
17 | return GetEmbeddedResource(typeof(Core), nameof(MapboxNetCore) + "." + name);
18 | }
19 |
20 | public static string GetEmbeddedResource(Type assemblyType, string resourceName)
21 | {
22 | var assembly = assemblyType.GetTypeInfo().Assembly;
23 |
24 | using (Stream stream = assembly.GetManifestResourceStream(resourceName))
25 | using (StreamReader reader = new StreamReader(stream))
26 | {
27 | return reader.ReadToEnd();
28 | }
29 | }
30 |
31 | public static string GetFrameScript(string accessToken, object style)
32 | {
33 | var mainScript = getEmbeddedResource("web.frame.js");
34 | var glScript = getEmbeddedResource("web.mapbox-gl.js");
35 | var css = getEmbeddedResource("web.mapbox-gl.css");
36 |
37 | var result = mainScript
38 | .Replace("{{mapbox-gl.js}}", glScript)
39 | .Replace("{{mapbox-gl.css}}", css)
40 | .Replace("{{style}}", JsonConvert.SerializeObject(style))
41 | .Replace("{{accessToken}}", JsonConvert.SerializeObject(accessToken));
42 |
43 | return result;
44 | }
45 |
46 | public static string ToLowerCamelCase(string s)
47 | {
48 | return Char.ToLowerInvariant(s[0]) + s.Substring(1);
49 | }
50 |
51 | public static string ToUpperCamelCase(string s)
52 | {
53 | return Char.ToUpperInvariant(s[0]) + s.Substring(1);
54 | }
55 |
56 | static object plainifyJson(JToken token)
57 | {
58 | if (token.Type == JTokenType.Object)
59 | {
60 | IDictionary dict = token as JObject;
61 |
62 | dynamic expandos = dict.Aggregate(new EnhancedExpandoObeject() as IDictionary,
63 | (a, p) => { a.Add(p.Key, plainifyJson(p.Value)); return a; });
64 |
65 | return expandos;
66 | }
67 | else if (token.Type == JTokenType.Array)
68 | {
69 | var array = token as JArray;
70 | return array.Select(item => plainifyJson(item)).ToList();
71 | }
72 | else
73 | {
74 | return token.ToObject