diff --git a/Demo.WindowsMobile/Demo.WindowsMobile.csproj b/Demo.WindowsMobile/Demo.WindowsMobile.csproj deleted file mode 100644 --- a/Demo.WindowsMobile/Demo.WindowsMobile.csproj +++ /dev/null @@ -1,149 +0,0 @@ - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {27C6704C-040E-43BB-91CC-924EE351A6C7} - WinExe - Properties - Demo.WindowsMobile - GMap.NET - {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - PocketPC - b2c48bd2-963d-4549-9169-1fa021dce484 - 5.2 - GMap.NET - v3.5 - Windows Mobile 6 Professional SDK - - - %25CSIDL_PROGRAM_FILES%25 - Resources\ImageReady.ico - true - - - true - full - false - bin\Debug\ - TRACE;DEBUG;PocketPC - true - true - prompt - 512 - 4 - Off - - - none - true - bin\Release\ - TRACE;PocketPC - true - true - prompt - 512 - 4 - Off - - - - Source\DemoStuff.cs - - - UserControl - - - Search.cs - - - UserControl - - - GPS.cs - - - Form - - - MainForm.cs - - - UserControl - - - Transport.cs - - - - - - Search.cs - Designer - - - GPS.cs - Designer - - - MainForm.cs - Designer - - - Transport.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - - - - - {421813B1-A007-44B2-8C53-32751C45113E} - GMap.NET.WindowsMobile %28GMap.NET\GMap.NET.WindowsMobile%29 - - - - - - - - - - False - ..\References\CompactFramework\System.Data.SQLite.dll - True - - - - - - - - SQLite.Interop.081.dll - PreserveNewest - - - - - - - - - - - - - \ No newline at end of file diff --git a/Demo.WindowsMobile/Forms/GPS.Designer.cs b/Demo.WindowsMobile/Forms/GPS.Designer.cs deleted file mode 100644 --- a/Demo.WindowsMobile/Forms/GPS.Designer.cs +++ /dev/null @@ -1,86 +0,0 @@ -namespace Demo.WindowsMobile -{ - partial class GPS - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if(disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.status = new System.Windows.Forms.Label(); - this.splitter1 = new System.Windows.Forms.Splitter(); - this.panelSignals = new System.Windows.Forms.Panel(); - this.SuspendLayout(); - // - // status - // - this.status.BackColor = System.Drawing.Color.Navy; - this.status.Dock = System.Windows.Forms.DockStyle.Top; - this.status.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Regular); - this.status.ForeColor = System.Drawing.Color.Lime; - this.status.Location = new System.Drawing.Point(0, 0); - this.status.Name = "status"; - this.status.Size = new System.Drawing.Size(391, 417); - this.status.Text = "Loading..."; - // - // splitter1 - // - this.splitter1.BackColor = System.Drawing.Color.Black; - this.splitter1.Dock = System.Windows.Forms.DockStyle.Top; - this.splitter1.Location = new System.Drawing.Point(0, 417); - this.splitter1.MinExtra = 0; - this.splitter1.MinSize = 0; - this.splitter1.Name = "splitter1"; - this.splitter1.Size = new System.Drawing.Size(391, 11); - // - // panelSignals - // - this.panelSignals.BackColor = System.Drawing.Color.DarkBlue; - this.panelSignals.Dock = System.Windows.Forms.DockStyle.Fill; - this.panelSignals.Location = new System.Drawing.Point(0, 428); - this.panelSignals.Name = "panelSignals"; - this.panelSignals.Size = new System.Drawing.Size(391, 103); - this.panelSignals.Paint += new System.Windows.Forms.PaintEventHandler(this.panelSignals_Paint); - // - // GPS - // - this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.Controls.Add(this.panelSignals); - this.Controls.Add(this.splitter1); - this.Controls.Add(this.status); - this.Name = "GPS"; - this.Size = new System.Drawing.Size(391, 531); - this.Resize += new System.EventHandler(this.GPS_Resize); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Splitter splitter1; - internal System.Windows.Forms.Label status; - internal System.Windows.Forms.Panel panelSignals; - } -} diff --git a/Demo.WindowsMobile/Forms/GPS.cs b/Demo.WindowsMobile/Forms/GPS.cs deleted file mode 100644 --- a/Demo.WindowsMobile/Forms/GPS.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Text; -using System.Windows.Forms; - -namespace Demo.WindowsMobile -{ - public partial class GPS : UserControl - { - MainForm Main; - - Pen penForSat = new Pen(Color.White, 3.0f); - Brush brushForSatOk = new SolidBrush(Color.LimeGreen); - Brush brushForSatNo = new SolidBrush(Color.Red); - Font fSignal = new Font(FontFamily.GenericSansSerif, 6, FontStyle.Regular); - Brush bSignal = new SolidBrush(Color.Blue); - StringFormat sformat = new StringFormat(); - - public GPS(MainForm main) - { - InitializeComponent(); - Main = main; - sformat.LineAlignment = StringAlignment.Far; - sformat.Alignment = StringAlignment.Center; - } - - private void panelSignals_Paint(object sender, PaintEventArgs e) - { - lock(Main.Satellites) - { - if(Main.Satellites.Count > 0) - { - int cc = Width / Main.Satellites.Count; - for(int i = 0; i < Main.Satellites.Count; i++) - { - int str = (int) (2.0 * (panelSignals.Height * Main.Satellites[i].SignalStrength)/100.0); - - if(Main.Satellites[i].InSolution) - { - e.Graphics.FillRectangle(brushForSatOk, new Rectangle(i*cc, panelSignals.Height - str, cc, str)); - } - else - { - e.Graphics.FillRectangle(brushForSatNo, new Rectangle(i*cc, panelSignals.Height - str, cc, str)); - } - - e.Graphics.DrawRectangle(penForSat, new Rectangle(i*cc + (int) penForSat.Width/2, 0, cc - (int) penForSat.Width/2, panelSignals.Height)); - - e.Graphics.DrawString(Main.Satellites[i].SignalStrength + "dB", fSignal, bSignal, new Rectangle(i*cc, 0, cc, (int)(panelSignals.Height-fSignal.Size/2)), sformat); - } - } - } - } - - private void GPS_Resize(object sender, EventArgs e) - { - if(Parent != null) - { - status.Height = Parent.Height - 44*5; - } - } - } -} diff --git a/Demo.WindowsMobile/Forms/GPS.resx b/Demo.WindowsMobile/Forms/GPS.resx deleted file mode 100644 --- a/Demo.WindowsMobile/Forms/GPS.resx +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 2 - - - Pocket_PC_Phone - - - Pocket_PC_Phone - - \ No newline at end of file diff --git a/Demo.WindowsMobile/Forms/MainForm.Designer.cs b/Demo.WindowsMobile/Forms/MainForm.Designer.cs deleted file mode 100644 --- a/Demo.WindowsMobile/Forms/MainForm.Designer.cs +++ /dev/null @@ -1,450 +0,0 @@ -namespace Demo.WindowsMobile -{ - partial class MainForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - private System.Windows.Forms.MainMenu mainMenu1; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if(disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); - this.mainMenu1 = new System.Windows.Forms.MainMenu(); - this.menuItem1 = new System.Windows.Forms.MenuItem(); - this.menuItemGotoMap = new System.Windows.Forms.MenuItem(); - this.menuItemGotoGps = new System.Windows.Forms.MenuItem(); - this.menuItemSearch = new System.Windows.Forms.MenuItem(); - this.menuItemGotoTransport = new System.Windows.Forms.MenuItem(); - this.menuItem34 = new System.Windows.Forms.MenuItem(); - this.menuItem32 = new System.Windows.Forms.MenuItem(); - this.menuItem2 = new System.Windows.Forms.MenuItem(); - this.menuItem29 = new System.Windows.Forms.MenuItem(); - this.menuItemGPSenabled = new System.Windows.Forms.MenuItem(); - this.menuItem8 = new System.Windows.Forms.MenuItem(); - this.menuItem12 = new System.Windows.Forms.MenuItem(); - this.menuItem13 = new System.Windows.Forms.MenuItem(); - this.menuItem9 = new System.Windows.Forms.MenuItem(); - this.menuItem10 = new System.Windows.Forms.MenuItem(); - this.menuItem11 = new System.Windows.Forms.MenuItem(); - this.menuItem16 = new System.Windows.Forms.MenuItem(); - this.menuItem18 = new System.Windows.Forms.MenuItem(); - this.menuItem24 = new System.Windows.Forms.MenuItem(); - this.menuItem20 = new System.Windows.Forms.MenuItem(); - this.menuItem21 = new System.Windows.Forms.MenuItem(); - this.menuItem17 = new System.Windows.Forms.MenuItem(); - this.menuItem14 = new System.Windows.Forms.MenuItem(); - this.menuItem15 = new System.Windows.Forms.MenuItem(); - this.menuItem19 = new System.Windows.Forms.MenuItem(); - this.menuItem7 = new System.Windows.Forms.MenuItem(); - this.menuItemCacheOnly = new System.Windows.Forms.MenuItem(); - this.menuItemServerAndCache = new System.Windows.Forms.MenuItem(); - this.menuItemServerOnly = new System.Windows.Forms.MenuItem(); - this.menuItem30 = new System.Windows.Forms.MenuItem(); - this.menuItemEnableGrid = new System.Windows.Forms.MenuItem(); - this.menuItemDisableAutoSleep = new System.Windows.Forms.MenuItem(); - this.menuItemSnapToGps = new System.Windows.Forms.MenuItem(); - this.menuItem6 = new System.Windows.Forms.MenuItem(); - this.menuItem36 = new System.Windows.Forms.MenuItem(); - this.menuItem37 = new System.Windows.Forms.MenuItem(); - this.menuItem35 = new System.Windows.Forms.MenuItem(); - this.menuItem38 = new System.Windows.Forms.MenuItem(); - this.menuItem41 = new System.Windows.Forms.MenuItem(); - this.menuItem42 = new System.Windows.Forms.MenuItem(); - this.menuItem43 = new System.Windows.Forms.MenuItem(); - this.menuItem40 = new System.Windows.Forms.MenuItem(); - this.menuItem39 = new System.Windows.Forms.MenuItem(); - this.menuItem27 = new System.Windows.Forms.MenuItem(); - this.menuItem28 = new System.Windows.Forms.MenuItem(); - this.menuItem3 = new System.Windows.Forms.MenuItem(); - this.timerKeeperOfLife = new System.Windows.Forms.Timer(); - this.MainMap = new Map(); - this.menuItemshowDestination = new System.Windows.Forms.MenuItem(); - this.menuItemSetDestination = new System.Windows.Forms.MenuItem(); - this.SuspendLayout(); - // - // mainMenu1 - // - this.mainMenu1.MenuItems.Add(this.menuItem1); - this.mainMenu1.MenuItems.Add(this.menuItem2); - // - // menuItem1 - // - this.menuItem1.MenuItems.Add(this.menuItemGotoMap); - this.menuItem1.MenuItems.Add(this.menuItemGotoGps); - this.menuItem1.MenuItems.Add(this.menuItemSearch); - this.menuItem1.MenuItems.Add(this.menuItemGotoTransport); - this.menuItem1.MenuItems.Add(this.menuItem34); - this.menuItem1.MenuItems.Add(this.menuItem32); - this.menuItem1.Text = "Page"; - // - // menuItemGotoMap - // - this.menuItemGotoMap.Checked = true; - this.menuItemGotoMap.Text = "Map"; - this.menuItemGotoMap.Click += new System.EventHandler(this.menuItemGotoMap_Click); - // - // menuItemGotoGps - // - this.menuItemGotoGps.Text = "GPS"; - this.menuItemGotoGps.Click += new System.EventHandler(this.menuItemGotoGps_Click); - // - // menuItemSearch - // - this.menuItemSearch.Text = "Search"; - this.menuItemSearch.Click += new System.EventHandler(this.menuItemSearch_Click); - // - // menuItemGotoTransport - // - this.menuItemGotoTransport.Text = "Vilnius Transport"; - this.menuItemGotoTransport.Click += new System.EventHandler(this.menuItemGotoTransport_Click); - // - // menuItem34 - // - this.menuItem34.Text = "-"; - // - // menuItem32 - // - this.menuItem32.Text = "Hide"; - this.menuItem32.Click += new System.EventHandler(this.menuItem32_Click); - // - // menuItem2 - // - this.menuItem2.MenuItems.Add(this.menuItem29); - this.menuItem2.MenuItems.Add(this.menuItem8); - this.menuItem2.MenuItems.Add(this.menuItem7); - this.menuItem2.MenuItems.Add(this.menuItem30); - this.menuItem2.MenuItems.Add(this.menuItem6); - this.menuItem2.MenuItems.Add(this.menuItem36); - this.menuItem2.MenuItems.Add(this.menuItem38); - this.menuItem2.MenuItems.Add(this.menuItem27); - this.menuItem2.MenuItems.Add(this.menuItem28); - this.menuItem2.MenuItems.Add(this.menuItem3); - this.menuItem2.Text = "Menu"; - // - // menuItem29 - // - this.menuItem29.MenuItems.Add(this.menuItemGPSenabled); - this.menuItem29.Text = "GPS"; - // - // menuItemGPSenabled - // - this.menuItemGPSenabled.Checked = true; - this.menuItemGPSenabled.Text = "Enabled"; - this.menuItemGPSenabled.Click += new System.EventHandler(this.menuItemGPSenabled_Click); - // - // menuItem8 - // - this.menuItem8.MenuItems.Add(this.menuItem12); - this.menuItem8.MenuItems.Add(this.menuItem13); - this.menuItem8.MenuItems.Add(this.menuItem9); - this.menuItem8.MenuItems.Add(this.menuItem10); - this.menuItem8.MenuItems.Add(this.menuItem11); - this.menuItem8.MenuItems.Add(this.menuItem16); - this.menuItem8.MenuItems.Add(this.menuItem18); - this.menuItem8.MenuItems.Add(this.menuItem24); - this.menuItem8.MenuItems.Add(this.menuItem20); - this.menuItem8.MenuItems.Add(this.menuItem21); - this.menuItem8.MenuItems.Add(this.menuItem17); - this.menuItem8.MenuItems.Add(this.menuItem14); - this.menuItem8.MenuItems.Add(this.menuItem15); - this.menuItem8.MenuItems.Add(this.menuItem19); - this.menuItem8.Text = "Map"; - // - // menuItem12 - // - this.menuItem12.Text = "OpenStreetMap"; - this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click); - // - // menuItem13 - // - this.menuItem13.Text = "-"; - // - // menuItem9 - // - this.menuItem9.Text = "GoogleMap"; - this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click); - // - // menuItem10 - // - this.menuItem10.Text = "Google Hybrid"; - this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click); - // - // menuItem11 - // - this.menuItem11.Text = "-"; - // - // menuItem16 - // - this.menuItem16.Text = "Bing"; - this.menuItem16.Click += new System.EventHandler(this.menuItem16_Click); - // - // menuItem18 - // - this.menuItem18.Text = "Bing Hybrid"; - this.menuItem18.Click += new System.EventHandler(this.menuItem18_Click); - // - // menuItem24 - // - this.menuItem24.Text = "-"; - // - // menuItem20 - // - this.menuItem20.Text = "Yahoo"; - this.menuItem20.Click += new System.EventHandler(this.menuItem20_Click); - // - // menuItem21 - // - this.menuItem21.Text = "Yahoo Hybrid"; - this.menuItem21.Click += new System.EventHandler(this.menuItem21_Click); - // - // menuItem17 - // - this.menuItem17.Text = "-"; - // - // menuItem14 - // - this.menuItem14.Text = "Maps.LT"; - this.menuItem14.Click += new System.EventHandler(this.menuItem14_Click); - // - // menuItem15 - // - this.menuItem15.Text = "Maps.LT Hybrid"; - this.menuItem15.Click += new System.EventHandler(this.menuItem15_Click); - // - // menuItem19 - // - this.menuItem19.Text = "-"; - // - // menuItem7 - // - this.menuItem7.MenuItems.Add(this.menuItemCacheOnly); - this.menuItem7.MenuItems.Add(this.menuItemServerAndCache); - this.menuItem7.MenuItems.Add(this.menuItemServerOnly); - this.menuItem7.Text = "Mode"; - // - // menuItemCacheOnly - // - this.menuItemCacheOnly.Text = "CacheOnly"; - this.menuItemCacheOnly.Click += new System.EventHandler(this.menuItemCacheOnly_Click); - // - // menuItemServerAndCache - // - this.menuItemServerAndCache.Text = "ServerAndCache"; - this.menuItemServerAndCache.Click += new System.EventHandler(this.menuItemServerAndCache_Click); - // - // menuItemServerOnly - // - this.menuItemServerOnly.Text = "ServerOnly"; - this.menuItemServerOnly.Click += new System.EventHandler(this.menuItemServerOnly_Click); - // - // menuItem30 - // - this.menuItem30.MenuItems.Add(this.menuItemshowDestination); - this.menuItem30.MenuItems.Add(this.menuItemSnapToGps); - this.menuItem30.MenuItems.Add(this.menuItemDisableAutoSleep); - this.menuItem30.MenuItems.Add(this.menuItemEnableGrid); - this.menuItem30.Text = "Options"; - // - // menuItemEnableGrid - // - this.menuItemEnableGrid.Text = "Enable Grid"; - this.menuItemEnableGrid.Click += new System.EventHandler(this.menuItemEnableGrid_Click); - // - // menuItemDisableAutoSleep - // - this.menuItemDisableAutoSleep.Checked = true; - this.menuItemDisableAutoSleep.Text = "Disable Auto Sleep"; - this.menuItemDisableAutoSleep.Click += new System.EventHandler(this.menuItemDisableAutoSleep_Click); - // - // menuItemSnapToGps - // - this.menuItemSnapToGps.Checked = true; - this.menuItemSnapToGps.Text = "Snap To GPS"; - this.menuItemSnapToGps.Click += new System.EventHandler(this.menuItemSnapToGps_Click); - // - // menuItem6 - // - this.menuItem6.Text = "-"; - // - // menuItem36 - // - this.menuItem36.MenuItems.Add(this.menuItem37); - this.menuItem36.MenuItems.Add(this.menuItem35); - this.menuItem36.MenuItems.Add(this.menuItemSetDestination); - this.menuItem36.Text = "Markers"; - // - // menuItem37 - // - this.menuItem37.Text = "Clear"; - this.menuItem37.Click += new System.EventHandler(this.menuItem37_Click); - // - // menuItem35 - // - this.menuItem35.Text = "Fit to All"; - this.menuItem35.Click += new System.EventHandler(this.menuItem35_Click); - // - // menuItem38 - // - this.menuItem38.MenuItems.Add(this.menuItem41); - this.menuItem38.MenuItems.Add(this.menuItem42); - this.menuItem38.MenuItems.Add(this.menuItem43); - this.menuItem38.MenuItems.Add(this.menuItem40); - this.menuItem38.MenuItems.Add(this.menuItem39); - this.menuItem38.Text = "Zoom"; - // - // menuItem41 - // - this.menuItem41.Text = "In"; - this.menuItem41.Click += new System.EventHandler(this.menuItem4_Click); - // - // menuItem42 - // - this.menuItem42.Text = "Out"; - this.menuItem42.Click += new System.EventHandler(this.menuItem5_Click); - // - // menuItem43 - // - this.menuItem43.Text = "-"; - // - // menuItem40 - // - this.menuItem40.Text = "Max"; - this.menuItem40.Click += new System.EventHandler(this.menuItem33_Click); - // - // menuItem39 - // - this.menuItem39.Text = "Min"; - this.menuItem39.Click += new System.EventHandler(this.menuItem31_Click); - // - // menuItem27 - // - this.menuItem27.Text = "Reload"; - this.menuItem27.Click += new System.EventHandler(this.menuItem27_Click); - // - // menuItem28 - // - this.menuItem28.Text = "-"; - // - // menuItem3 - // - this.menuItem3.Text = "Exit"; - this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click); - // - // timerKeeperOfLife - // - this.timerKeeperOfLife.Tick += new System.EventHandler(this.timerKeeperOfLife_Tick); - // - // MainMap - // - this.MainMap.BackColor = System.Drawing.Color.White; - this.MainMap.Dock = System.Windows.Forms.DockStyle.Fill; - this.MainMap.Location = new System.Drawing.Point(0, 0); - this.MainMap.Name = "MainMap"; - this.MainMap.Size = new System.Drawing.Size(480, 696); - this.MainMap.TabIndex = 0; - // - // menuItemshowDestination - // - this.menuItemshowDestination.Text = "Show Destination"; - this.menuItemshowDestination.Click += new System.EventHandler(this.menuItemshowDestination_Click); - // - // menuItemSetDestination - // - this.menuItemSetDestination.Text = "Set Destination"; - this.menuItemSetDestination.Click += new System.EventHandler(this.menuItemSetDestination_Click); - // - // MainForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(192F, 192F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.AutoScroll = true; - this.ClientSize = new System.Drawing.Size(480, 696); - this.Controls.Add(this.MainMap); - this.KeyPreview = true; - this.Location = new System.Drawing.Point(0, 52); - this.Menu = this.mainMenu1; - this.Name = "MainForm"; - this.Text = "GMap.NET"; - this.Load += new System.EventHandler(this.MainForm_Load); - this.Closed += new System.EventHandler(this.MainForm_Closed); - this.Activated += new System.EventHandler(this.MainForm_Activated); - this.ResumeLayout(false); - - } - - #endregion - - internal Map MainMap; - private System.Windows.Forms.MenuItem menuItem1; - private System.Windows.Forms.MenuItem menuItem2; - private System.Windows.Forms.MenuItem menuItem3; - private System.Windows.Forms.MenuItem menuItem6; - private System.Windows.Forms.MenuItem menuItem8; - private System.Windows.Forms.MenuItem menuItem12; - private System.Windows.Forms.MenuItem menuItem13; - private System.Windows.Forms.MenuItem menuItem9; - private System.Windows.Forms.MenuItem menuItem10; - private System.Windows.Forms.MenuItem menuItem11; - private System.Windows.Forms.MenuItem menuItem14; - private System.Windows.Forms.MenuItem menuItem15; - private System.Windows.Forms.MenuItem menuItem16; - private System.Windows.Forms.MenuItem menuItem18; - private System.Windows.Forms.MenuItem menuItem24; - private System.Windows.Forms.MenuItem menuItem21; - private System.Windows.Forms.MenuItem menuItem20; - private System.Windows.Forms.MenuItem menuItem17; - private System.Windows.Forms.MenuItem menuItem19; - private System.Windows.Forms.MenuItem menuItem27; - private System.Windows.Forms.MenuItem menuItem28; - private System.Windows.Forms.MenuItem menuItem7; - private System.Windows.Forms.MenuItem menuItemServerAndCache; - private System.Windows.Forms.MenuItem menuItemCacheOnly; - private System.Windows.Forms.MenuItem menuItem29; - private System.Windows.Forms.MenuItem menuItemGPSenabled; - private System.Windows.Forms.MenuItem menuItem30; - private System.Windows.Forms.MenuItem menuItemEnableGrid; - private System.Windows.Forms.Timer timerKeeperOfLife; - private System.Windows.Forms.MenuItem menuItemDisableAutoSleep; - private System.Windows.Forms.MenuItem menuItemGotoMap; - private System.Windows.Forms.MenuItem menuItemGotoGps; - private System.Windows.Forms.MenuItem menuItem34; - private System.Windows.Forms.MenuItem menuItem32; - private System.Windows.Forms.MenuItem menuItemServerOnly; - private System.Windows.Forms.MenuItem menuItemGotoTransport; - private System.Windows.Forms.MenuItem menuItem36; - private System.Windows.Forms.MenuItem menuItem37; - private System.Windows.Forms.MenuItem menuItem35; - private System.Windows.Forms.MenuItem menuItemSearch; - private System.Windows.Forms.MenuItem menuItem38; - private System.Windows.Forms.MenuItem menuItem41; - private System.Windows.Forms.MenuItem menuItem42; - private System.Windows.Forms.MenuItem menuItem43; - private System.Windows.Forms.MenuItem menuItem40; - private System.Windows.Forms.MenuItem menuItem39; - private System.Windows.Forms.MenuItem menuItemSnapToGps; - internal System.Windows.Forms.MenuItem menuItemshowDestination; - private System.Windows.Forms.MenuItem menuItemSetDestination; - } -} - diff --git a/Demo.WindowsMobile/Forms/MainForm.cs b/Demo.WindowsMobile/Forms/MainForm.cs deleted file mode 100644 --- a/Demo.WindowsMobile/Forms/MainForm.cs +++ /dev/null @@ -1,1215 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Data.Common; -using System.Data.SQLite; -using System.Diagnostics; -using System.Drawing; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; -using System.Windows.Forms; -using GMap.NET; -using GMap.NET.GPS; -using GMap.NET.Internals; -using GMap.NET.WindowsForms; -using GMap.NET.WindowsForms.Markers; -using Microsoft.Win32; -using Microsoft.WindowsCE.Forms; -using GMap.NET.MapProviders; - -namespace Demo.WindowsMobile -{ - public partial class MainForm : Form - { - PointLatLng start = new PointLatLng(54.6961334816182, 25.2985095977783); - PointLatLng destinationPoint = new PointLatLng(54.6961334816182, 25.2985095977783); - - // marker - GMarkerCross gpsPos; - - // layers - GMapOverlay top; - internal GMapOverlay objects; - - #region -- variables -- - string LogDb; - SQLiteConnection cn; - DbCommand cmd; - DateTime LastFlush = DateTime.Now; - TimeSpan FlushDelay = TimeSpan.FromSeconds(60); - - readonly Gps gps = new Gps(); - GpsDeviceState device = null; - - int count = 0; - int countReal = 0; - double Total = 0; - - EventHandler updateDataHandler; - TimeSpan delay = TimeSpan.FromSeconds(1); - DateTime? TimeUTC; - double? Lat = 0; - double? Lng = 0; - double Delta = 0; - internal readonly List Satellites = new List(); - - IntPtr gpsPowerHandle = IntPtr.Zero; - - GPS pageGps; - Transport pageTransport; - Search pageSearch; - - readonly HookKeys hook = new HookKeys(); - #endregion - - public MainForm() - { - InitializeComponent(); - - pageGps = new GPS(this); - pageTransport = new Transport(this); - pageSearch = new Search(this); - -#if DEBUG - MainMap.Manager.Mode = AccessMode.ServerAndCache; - menuItemServerAndCache.Checked = true; - menuItemEnableGrid.Checked = true; - menuItemGPSenabled.Checked = false; - MainMap.ShowTileGridLines = true; -#else - menuItemGPSenabled.Checked = false; - MainMap.Manager.Mode = AccessMode.CacheOnly; - menuItemCacheOnly.Checked = true; -#endif - MainMap.MapProvider = GMapProviders.LithuaniaMap; - MainMap.MaxZoom = 11; - MainMap.MinZoom = 1; - MainMap.Zoom = MainMap.MinZoom + 1; - MainMap.Position = start; - - MainMap.OnMapTypeChanged += new MapTypeChanged(MainMap_OnMapTypeChanged); - MainMap.OnMapZoomChanged += new MapZoomChanged(MainMap_OnMapZoomChanged); - MainMap.OnPositionChanged += new PositionChanged(MainMap_OnPositionChanged); - - // add custom layers - { - objects = new GMapOverlay("objects"); - MainMap.Overlays.Add(objects); - - top = new GMapOverlay("top"); - MainMap.Overlays.Add(top); - } - - // gps pos - gpsPos = new GMarkerCross(MainMap.Position); - gpsPos.IsVisible = false; - top.Markers.Add(gpsPos); - -#if DEBUG - // transparent marker test - GMapMarkerTransparentGoogleGreen goo = new GMapMarkerTransparentGoogleGreen(MainMap.Position); - goo.ToolTipMode = MarkerTooltipMode.Always; - goo.ToolTipText = "Welcome to Lithuania! ;}"; - objects.Markers.Add(goo); -#endif - - // hook for volume up/down zooming - hook.HookEvent += new HookKeys.HookEventHandler(hook_HookEvent); - - // test performance - if(PerfTestEnabled) - { - timer.Interval = 111; - timer.Tick += new EventHandler(timer_Tick); - timer.Enabled = true; - } - } - - void MainMap_OnPositionChanged(PointLatLng point) - { - if(menuItemshowDestination.Checked && !menuItemGPSenabled.Checked) - { - UpdateDestinationRoute(true, menuItemSnapToGps.Checked ? MainMap.Position : gpsPos.Position); - } - } - - readonly IntPtr volumeUp = new IntPtr(257); - - bool hook_HookEvent(HookEventArgs e, KeyBoardInfo keyBoardInfo) - { - if(keyBoardInfo.vkCode == 117) - { - if(e.wParam == volumeUp) - { - MainMap.Zoom = (int) (MainMap.Zoom) + 1; - } - } - else if(keyBoardInfo.vkCode == 118) - { - if(e.wParam == volumeUp) - { - MainMap.Zoom = (int) (MainMap.Zoom) - 1; - } - } - return true; - } - - #region -- performance test-- - - bool PerfTestEnabled = false; - - double NextDouble(Random rng, double min, double max) - { - return min + (rng.NextDouble() * (max - min)); - } - - Random r = new Random(); - - int tt = 0; - void timer_Tick(object sender, EventArgs e) - { - var pos = new PointLatLng(NextDouble(r, MainMap.ViewArea.Top, MainMap.ViewArea.Bottom), NextDouble(r, MainMap.ViewArea.Left, MainMap.ViewArea.Right)); - GMapMarker m = new GMapMarkerGoogleGreen(pos); - { - m.ToolTipText = (tt++).ToString(); - m.ToolTipMode = MarkerTooltipMode.Always; - m.Offset = new System.Drawing.Point(-m.Size.Width, -m.Size.Height); - } - - objects.Markers.Add(m); - - if(tt >= 44) - { - timer.Enabled = false; - tt = 0; - } - } - - Timer timer = new Timer(); - #endregion - - public void ZoomToFitMarkers() - { - if(objects.Markers.Count > 0) - { - RectLatLng? m = MainMap.GetRectOfAllMarkers(null); - if(m.HasValue) - { - MainMap.SetZoomToFitRect(m.Value); - } - } - } - - void MainMap_OnMapZoomChanged() - { - this.Text = "GMap.NET: " + (int) MainMap.Zoom; - } - - void MainMap_OnMapTypeChanged(GMapProvider type) - { - //if(routes.Routes.Count > 0) - //{ - // MainMap.ZoomAndCenterRoutes(null); - //} - } - - private void menuItem3_Click(object sender, EventArgs e) - { - this.Close(); - } - - // zoom in - private void menuItem4_Click(object sender, EventArgs e) - { - MainMap.Zoom = (int) (MainMap.Zoom) + 1; - } - - // zoom out - private void menuItem5_Click(object sender, EventArgs e) - { - MainMap.Zoom = (int) (MainMap.Zoom) - 1; - } - - private void menuItem15_Click(object sender, EventArgs e) - { - MainMap.MapProvider = GMapProviders.LithuaniaOrtoFotoMap; - } - - private void menuItem10_Click(object sender, EventArgs e) - { - MainMap.MapProvider = GMapProviders.GoogleHybridMap; - } - - private void menuItem12_Click(object sender, EventArgs e) - { - MainMap.MapProvider = GMapProviders.OpenStreetMap; - } - - private void menuItem22_Click(object sender, EventArgs e) - { - //MainMap.MapProvider = GMapProviders.OpenStreetMapSurfer; - } - - private void menuItem23_Click(object sender, EventArgs e) - { - //MainMap.MapProvider = GMapProviders.OpenStreetOsm; - } - - private void menuItem9_Click(object sender, EventArgs e) - { - MainMap.MapProvider = GMapProviders.GoogleMap; - } - - private void menuItem16_Click(object sender, EventArgs e) - { - MainMap.MapProvider = GMapProviders.BingMap; - } - - private void menuItem18_Click(object sender, EventArgs e) - { - MainMap.MapProvider = GMapProviders.BingHybridMap; - } - - private void menuItem20_Click(object sender, EventArgs e) - { - MainMap.MapProvider = GMapProviders.YahooMap; - } - - private void menuItem21_Click(object sender, EventArgs e) - { - MainMap.MapProvider = GMapProviders.YahooHybridMap; - } - - private void menuItem14_Click(object sender, EventArgs e) - { - MainMap.MapProvider = GMapProviders.LithuaniaMap; - } - - private void menuItem25_Click(object sender, EventArgs e) - { - MainMap.MapProvider = GMapProviders.ArcGIS_World_Topo_Map; - } - - private void menuItem26_Click(object sender, EventArgs e) - { - MainMap.MapProvider = GMapProviders.ArcGIS_World_Physical_Map; - } - - private void menuItem27_Click(object sender, EventArgs e) - { - MainMap.ReloadMap(); - } - - private void menuItemCacheOnly_Click(object sender, EventArgs e) - { - MainMap.Manager.Mode = AccessMode.CacheOnly; - menuItemCacheOnly.Checked = true; - menuItemServerAndCache.Checked = false; - menuItemServerOnly.Checked = false; - } - - private void menuItemServerAndCache_Click(object sender, EventArgs e) - { - MainMap.Manager.Mode = AccessMode.ServerAndCache; - menuItemServerAndCache.Checked = true; - menuItemCacheOnly.Checked = false; - menuItemServerOnly.Checked = false; - } - - private void menuItemServerOnly_Click(object sender, EventArgs e) - { - MainMap.Manager.Mode = AccessMode.ServerOnly; - menuItemServerOnly.Checked = true; - menuItemServerAndCache.Checked = false; - menuItemCacheOnly.Checked = false; - } - - private void menuItemGPSenabled_Click(object sender, EventArgs e) - { - menuItemGPSenabled.Checked = !menuItemGPSenabled.Checked; - - if(!menuItemGPSenabled.Checked) - { - if(gps.Opened) - { - gps.Close(); - SetOffGPSPower(); - } - - count = 0; - countReal = 0; - Total = 0; - { - TimeUTC = null; - Lat = null; - Lng = null; - Delta = 0; - } - lock(Satellites) - { - Satellites.Clear(); - Satellites.TrimExcess(); - } - - if(Controls.Contains(pageGps)) - { - pageGps.panelSignals.Invalidate(); - } - - TryCommitData(); - - gpsPos.Pen.Color = Color.Blue; - } - else // start tracking - { - gpsPos.Pen.Color = Color.Red; - gpsPos.IsVisible = true; - - if(!gps.Opened) - { - gps.Open(); - SetOnGPSPower(); - } - } - } - - public new void Hide() - { - Native.ShowWindow(this.Handle, Native.SW_MINIMIZED); - timerKeeperOfLife.Enabled = false; - IsVisible = false; - - hook.Stop(); - } - - object visibleLock = new object(); - bool visible = true; - public bool IsVisible - { - get - { - lock(visibleLock) - { - return visible; - } - } - set - { - lock(visibleLock) - { - visible = value; - } - } - } - - public bool AddToLogCurrentInfo(GpsPosition data) - { - if(string.IsNullOrEmpty(LogDb)) - { - return false; - } - - bool ret = true; - try - { - { - if(cmd.Transaction == null) - { - cmd.Transaction = cn.BeginTransaction(IsolationLevel.Serializable); - Debug.WriteLine("BeginTransaction: " + DateTime.Now.ToLongTimeString()); - } - - cmd.Parameters["@p1"].Value = data.Time.Value; - cmd.Parameters["@p2"].Value = countReal++; - cmd.Parameters["@p3"].Value = Delta; - cmd.Parameters["@p4"].Value = data.Speed; - cmd.Parameters["@p5"].Value = data.SeaLevelAltitude; - cmd.Parameters["@p6"].Value = data.EllipsoidAltitude; - cmd.Parameters["@p7"].Value = (short?) data.SatellitesInViewCount; - cmd.Parameters["@p8"].Value = (short?) data.SatelliteCount; - cmd.Parameters["@p9"].Value = data.Latitude.Value; - cmd.Parameters["@p10"].Value = data.Longitude.Value; - cmd.Parameters["@p11"].Value = data.PositionDilutionOfPrecision; - cmd.Parameters["@p12"].Value = data.HorizontalDilutionOfPrecision; - cmd.Parameters["@p13"].Value = data.VerticalDilutionOfPrecision; - cmd.Parameters["@p14"].Value = (byte) data.FixQuality; - cmd.Parameters["@p15"].Value = (byte) data.FixType; - cmd.Parameters["@p16"].Value = (byte) data.FixSelection; - - cmd.ExecuteNonQuery(); - } - - if(DateTime.Now - LastFlush >= FlushDelay) - { - TryCommitData(); - } - } - catch(Exception ex) - { - Debug.WriteLine("AddToLog: " + ex.ToString()); - ret = false; - } - - return ret; - } - - void TryCommitData() - { - try - { - if(cmd.Transaction != null) - { - using(cmd.Transaction) - { - cmd.Transaction.Commit(); - LastFlush = DateTime.Now; - } - cmd.Transaction = null; - Debug.WriteLine("TryCommitData: OK " + LastFlush.ToLongTimeString()); - } - } - catch(Exception ex) - { - Debug.WriteLine("TryCommitData: " + ex.ToString()); - } - } - - public bool CheckLogDb(string file) - { - bool ret = true; - - try - { - string dir = Path.GetDirectoryName(file); - if(!Directory.Exists(dir)) - { - Directory.CreateDirectory(dir); - } - - cn = new SQLiteConnection(); - { - cn.ConnectionString = string.Format("Data Source=\"{0}\";FailIfMissing=False;", file); - cn.Open(); - { - using(DbTransaction tr = cn.BeginTransaction()) - { - try - { - using(DbCommand cmd = cn.CreateCommand()) - { - cmd.Transaction = tr; - cmd.CommandText = @"CREATE TABLE IF NOT EXISTS GPS (id INTEGER NOT NULL PRIMARY KEY, - TimeUTC DATETIME NOT NULL, - SessionCounter INTEGER NOT NULL, - Delta DOUBLE, - Speed DOUBLE, - SeaLevelAltitude DOUBLE, - EllipsoidAltitude DOUBLE, - SatellitesInView TINYINT, - SatelliteCount TINYINT, - Lat DOUBLE NOT NULL, - Lng DOUBLE NOT NULL, - PositionDilutionOfPrecision DOUBLE, - HorizontalDilutionOfPrecision DOUBLE, - VerticalDilutionOfPrecision DOUBLE, - FixQuality TINYINT NOT NULL, - FixType TINYINT NOT NULL, - FixSelection TINYINT NOT NULL); - CREATE INDEX IF NOT EXISTS IndexOfGPS ON GPS (TimeUTC, PositionDilutionOfPrecision);"; - cmd.ExecuteNonQuery(); - } - - this.cmd = cn.CreateCommand(); - { - cmd.CommandText = @"INSERT INTO GPS - (TimeUTC, - SessionCounter, - Delta, - Speed, - SeaLevelAltitude, - EllipsoidAltitude, - SatellitesInView, - SatelliteCount, - Lat, - Lng, - PositionDilutionOfPrecision, - HorizontalDilutionOfPrecision, - VerticalDilutionOfPrecision, - FixQuality, - FixType, - FixSelection) VALUES(@p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11, @p12, @p13, @p14, @p15, @p16);"; - - cmd.Parameters.Add(new SQLiteParameter("@p1")); - cmd.Parameters.Add(new SQLiteParameter("@p2")); - cmd.Parameters.Add(new SQLiteParameter("@p3")); - cmd.Parameters.Add(new SQLiteParameter("@p4")); - cmd.Parameters.Add(new SQLiteParameter("@p5")); - cmd.Parameters.Add(new SQLiteParameter("@p6")); - cmd.Parameters.Add(new SQLiteParameter("@p7")); - cmd.Parameters.Add(new SQLiteParameter("@p8")); - cmd.Parameters.Add(new SQLiteParameter("@p9")); - cmd.Parameters.Add(new SQLiteParameter("@p10")); - cmd.Parameters.Add(new SQLiteParameter("@p11")); - cmd.Parameters.Add(new SQLiteParameter("@p12")); - cmd.Parameters.Add(new SQLiteParameter("@p13")); - cmd.Parameters.Add(new SQLiteParameter("@p14")); - cmd.Parameters.Add(new SQLiteParameter("@p15")); - cmd.Parameters.Add(new SQLiteParameter("@p16")); - cmd.Prepare(); - } - - tr.Commit(); - } - catch - { - tr.Rollback(); - ret = false; - } - } - } - } - } - catch(Exception ex) - { - if(cn != null) - { - cn.Dispose(); - cn = null; - } - if(cmd != null) - { - cmd.Dispose(); - cmd = null; - } - Debug.WriteLine("CreateEmptyDB: " + ex.ToString()); - ret = false; - } - - if(ret) - { - LogDb = file; - } - else - { - LogDb = null; - } - - return ret; - } - - private void MainForm_Load(object sender, EventArgs e) - { - updateDataHandler = new EventHandler(UpdateData); - - gps.DeviceStateChanged += new DeviceStateChangedEventHandler(gps_DeviceStateChanged); - gps.LocationChanged += new LocationChangedEventHandler(gps_LocationChanged); - - string sd = Native.GetRemovableStorageDirectory(); - if(!string.IsNullOrEmpty(sd)) - { - var fileName = sd + Path.DirectorySeparatorChar + "GMap.NET" + Path.DirectorySeparatorChar + "log.gpsd"; - { - CheckLogDb(fileName); - } - } - - timerKeeperOfLife.Interval = ShortestTimeoutInterval() * 1000; - timerKeeperOfLife.Enabled = true; - - if(menuItemGPSenabled.Checked) - { - if(!gps.Opened) - { - gps.Open(); - gpsPos.Pen.Color = Color.Red; - gpsPos.IsVisible = true; - - SetOnGPSPower(); - } - } - else - { - gpsPos.Pen.Color = Color.Blue; - gpsPos.IsVisible = false; - } - - try - { - // Config AutoRotate - { - using(RegistryKey Config = Registry.CurrentUser.OpenSubKey(@"Software\HTC\HTCSENSOR\GSensor\ModuleName", true)) - { - if(Config != null) - { - string gmapnet = Config.GetValue("GMapNET", null) as string; - if(string.IsNullOrEmpty(gmapnet)) - { - Config.SetValue("GMapNET", @"\Program files\gmap.net\GMap.NET.exe"); - } - } - } - - using(RegistryKey Config = Registry.CurrentUser.OpenSubKey(@"Software\HTC\HTCSENSOR\GSensor\WhiteList", true)) - { - if(Config != null) - { - string gmapnet = Config.GetValue("GMapNET", null) as string; - if(string.IsNullOrEmpty(gmapnet)) - { - Config.SetValue("GMapNET", "#NETCF_AGL_BASE_"); - } - } - } - } - } - catch(Exception ex) - { - Debug.WriteLine(ex.ToString()); - } - } - - void gps_LocationChanged(object sender, GpsPosition position) - { - try - { - if(position != null) - { - count++; - - //Debug.WriteLine("LocationChanged: " + DateTime.Now.ToLongTimeString() + " -> " + count); - - if(position.Time.HasValue && position.Latitude.HasValue && position.Longitude.HasValue) - { - //Debug.WriteLine("Location: " + position.Latitude.Value + "|" + position.Longitude.Value); - - // first time - if(!TimeUTC.HasValue) - { - TimeUTC = position.Time; - Lat = position.Latitude; - Lng = position.Longitude; - } - - if(TimeUTC.HasValue && position.Time - TimeUTC.Value >= delay) - { - Delta = gps.GetDistance(position.Latitude.Value, position.Longitude.Value, Lat.Value, Lng.Value); - Total += Delta; - Lat = position.Latitude; - Lng = position.Longitude; - TimeUTC = position.Time; - - AddToLogCurrentInfo(position); - } - } - else - { - Lat = position.Latitude; - Lng = position.Longitude; - TimeUTC = position.Time; - } - - // do not update if user is idling - if(IsVisible) - { - lock(Satellites) - { - Satellites.Clear(); - Satellites.AddRange(position.GetSatellitesInView()); - Satellites.TrimExcess(); - } - - Invoke(updateDataHandler, position); - } - } - } - catch(Exception ex) - { - Debug.WriteLine("gps_LocationChanged: " + ex); - } - } - - void gps_DeviceStateChanged(object sender, GpsDeviceState args) - { - device = args; - - if(IsVisible) - { - Invoke(updateDataHandler); - } - } - - private void MainForm_Closed(object sender, EventArgs e) - { - hook.Stop(); - - if(gps.Opened) - { - gps.Close(); - } - - SetOffGPSPower(); - - if(cn != null) - { - TryCommitData(); - - if(cn.State == ConnectionState.Open) - { - cn.Close(); - } - cn.Dispose(); - cn = null; - } - if(cmd != null) - { - cmd.Dispose(); - cmd = null; - } - } - - void SetOnGPSPower() - { - // Keep the GPS and device alive - bool power = Native.PowerPolicyNotify(Native.PPN_UNATTENDEDMODE, true); - if(!power) - { - Debug.WriteLine("PowerPolicyNotify failed for PPN_UNATTENDEDMODE"); - } - else - { - if(gpsPowerHandle == IntPtr.Zero) - { - gpsPowerHandle = Native.SetPowerRequirement("gps0:", Native.CedevicePowerStateState.D0, Native.POWER_NAME | Native.POWER_FORCE, null, 0); - if(gpsPowerHandle == IntPtr.Zero) - { - Debug.WriteLine("SetPowerRequirement failed for GPS"); - } - } - } - } - - void SetOffGPSPower() - { - if(gpsPowerHandle != IntPtr.Zero) - { - Native.ReleasePowerRequirement(gpsPowerHandle); - gpsPowerHandle = IntPtr.Zero; - } - Native.PowerPolicyNotify(Native.PPN_UNATTENDEDMODE, false); - } - - ~MainForm() - { - MainForm_Closed(null, null); - } - - void UpdateData(object sender, System.EventArgs args) - { - try - { - var lastData = sender as GpsPosition; - - // update signals - if(Controls.Contains(pageGps)) - { - pageGps.panelSignals.Invalidate(); - - string str = Environment.NewLine; - - str += "GPS: " + device.DeviceState + ", Driver: " + device.ServiceState + ", " + count + " | " + countReal + "\n"; - - if(lastData != null) - { - if(lastData.Time.HasValue && lastData.Longitude.HasValue && lastData.Longitude.HasValue) - { - int deltaClock = ((int) (DateTime.UtcNow - lastData.Time.Value).TotalSeconds); - - str += "Time(UTC): " + lastData.Time.Value.ToLongTimeString() + ", delay: " + deltaClock + "s \n"; - str += "Delta: " + string.Format("{0:0.00}m, total: {1:0.00km}\n", Delta * 1000.0, Total); - str += "Latitude: " + lastData.Latitude.Value + "\n"; - str += "Longitude: " + lastData.Longitude.Value + "\n\n"; - - if(Math.Abs(deltaClock) > 5) // 5s - { - UpdateTime(lastData.Time.Value); - } - } - else - { - str += "Time(UTC): -" + "\n"; - str += "Delta: - \n"; - str += "Latitude: -" + "\n"; - str += "Longitude: -" + "\n\n"; - } - - if(lastData.Speed.HasValue) - { - str += "Speed: " + string.Format("{0:0.0}km/h | {1:0.0}m/s, head: {2}\n", lastData.Speed, lastData.Speed / 3.6, (int) (lastData.Heading.HasValue ? lastData.Heading.Value : 0)); - } - else - { - str += "Speed: -\n"; - } - - if(lastData.SeaLevelAltitude.HasValue) - { - str += "SeaLevelAltitude: " + string.Format("{0:0.00}m\n", lastData.SeaLevelAltitude); - } - else - { - str += "SeaLevelAltitude: -\n"; - } - - if(lastData.PositionDilutionOfPrecision.HasValue) - { - str += "PositionDilutionOfPrecision: " + string.Format("{0:0.00}\n", lastData.PositionDilutionOfPrecision); - } - else - { - str += "PositionDilutionOfPrecision: -\n"; - } - - if(lastData.HorizontalDilutionOfPrecision.HasValue) - { - str += "HorizontalDilutionOfPrecision: " + string.Format("{0:0.00}\n", lastData.HorizontalDilutionOfPrecision); - } - else - { - str += "HorizontalDilutionOfPrecision: -\n"; - } - - if(lastData.VerticalDilutionOfPrecision.HasValue) - { - str += "VerticalDilutionOfPrecision: " + string.Format("{0:0.00}\n", lastData.VerticalDilutionOfPrecision); - } - else - { - str += "VerticalDilutionOfPrecision: -\n"; - } - - if(lastData.SatellitesInViewCount.HasValue) - { - str += "SatellitesInView: " + lastData.SatellitesInViewCount + "\n"; - } - else - { - str += "SatellitesInView: -" + "\n"; - } - - if(lastData.SatelliteCount.HasValue) - { - str += "SatelliteCount: " + lastData.SatelliteCount + "\n"; - } - else - { - str += "SatelliteCount: -" + "\n"; - } - } - pageGps.status.Text = str; - } - else if(Controls.Contains(MainMap)) - { - if(lastData != null) - { - if(lastData.Time.HasValue && lastData.Longitude.HasValue && lastData.Longitude.HasValue) - { - // center map - if(menuItemGPSenabled.Checked) - { - if(menuItemSnapToGps.Checked && !MainMap.IsDragging) - { - var newPos = new PointLatLng(lastData.Latitude.Value, lastData.Longitude.Value); - - if(menuItemshowDestination.Checked) - { - UpdateDestinationRoute(false, newPos); - } - - MainMap.Position = newPos; - } - else - { - gpsPos.Position = new PointLatLng(lastData.Latitude.Value, lastData.Longitude.Value); - - if(menuItemshowDestination.Checked) - { - UpdateDestinationRoute(true, gpsPos.Position); - } - } - } - } - } - } - } - catch(Exception ex) - { - pageGps.status.Text = "\n" + ex.ToString(); - } - } - - int ShortestTimeoutInterval() - { - int retVal = 1000; - - try - { - RegistryKey key = Registry.LocalMachine.OpenSubKey(@"\SYSTEM\CurrentControlSet\Control\Power"); - object oBatteryTimeout = key.GetValue("BattPowerOff"); - object oACTimeOut = key.GetValue("ExtPowerOff"); - object oScreenPowerOff = key.GetValue("ScreenPowerOff"); - key.Close(); - - if(oBatteryTimeout is int) - { - int v = (int) oBatteryTimeout; - if(v > 0) - retVal = Math.Min(retVal, v); - } - if(oACTimeOut is int) - { - int v = (int) oACTimeOut; - if(v > 0) - retVal = Math.Min(retVal, v); - } - if(oScreenPowerOff is int) - { - int v = (int) oScreenPowerOff; - if(v > 0) - retVal = Math.Min(retVal, v); - } - } - catch(Exception ex) - { - Debug.WriteLine("ShortestTimeoutInterval: " + ex.ToString()); - } - - return retVal * 9 / 10; - } - - private void menuItemEnableGrid_Click(object sender, EventArgs e) - { - menuItemEnableGrid.Checked = !menuItemEnableGrid.Checked; - MainMap.ShowTileGridLines = menuItemEnableGrid.Checked; - } - - private void timerKeeperOfLife_Tick(object sender, EventArgs e) - { - Native.SystemIdleTimerReset(); - } - - private void menuItemDisableAutoSleep_Click(object sender, EventArgs e) - { - menuItemDisableAutoSleep.Checked = !menuItemDisableAutoSleep.Checked; - timerKeeperOfLife.Enabled = menuItemDisableAutoSleep.Checked; - } - - private void MainForm_Activated(object sender, EventArgs e) - { - timerKeeperOfLife.Enabled = menuItemDisableAutoSleep.Checked; - IsVisible = true; - hook.Start(); - } - - private void menuItem32_Click(object sender, EventArgs e) - { - this.Hide(); - } - - internal void menuItemGotoMap_Click(object sender, EventArgs e) - { - menuItemGotoMap.Checked = true; - menuItemGotoGps.Checked = false; - menuItemGotoTransport.Checked = false; - menuItemSearch.Checked = false; - - this.SuspendLayout(); - this.Controls.Clear(); - this.Controls.Add(this.MainMap); - this.ResumeLayout(false); - } - - private void menuItemGotoGps_Click(object sender, EventArgs e) - { - menuItemGotoGps.Checked = true; - menuItemGotoTransport.Checked = false; - menuItemGotoMap.Checked = false; - menuItemSearch.Checked = false; - - this.SuspendLayout(); - this.Controls.Clear(); - this.pageGps.Dock = DockStyle.Fill; - this.Controls.Add(pageGps); - this.ResumeLayout(false); - - pageGps.panelSignals.Invalidate(); - } - - internal void menuItemGotoTransport_Click(object sender, EventArgs e) - { - menuItemGotoTransport.Checked = true; - menuItemGotoMap.Checked = false; - menuItemGotoGps.Checked = false; - menuItemSearch.Checked = false; - - this.SuspendLayout(); - this.Controls.Clear(); - this.pageTransport.Dock = DockStyle.Fill; - this.Controls.Add(pageTransport); - this.ResumeLayout(false); - } - - private void menuItemSearch_Click(object sender, EventArgs e) - { - menuItemSearch.Checked = true; - menuItemGotoTransport.Checked = false; - menuItemGotoMap.Checked = false; - menuItemGotoGps.Checked = false; - - this.SuspendLayout(); - this.Controls.Clear(); - this.pageSearch.Dock = DockStyle.Fill; - this.Controls.Add(pageSearch); - this.ResumeLayout(false); - } - - private void menuItem35_Click(object sender, EventArgs e) - { - ZoomToFitMarkers(); - } - - private void menuItem31_Click(object sender, EventArgs e) - { - MainMap.Zoom = MainMap.MinZoom; - } - - private void menuItem33_Click(object sender, EventArgs e) - { - MainMap.Zoom = MainMap.MaxZoom; - } - - // clear markers - private void menuItem37_Click(object sender, EventArgs e) - { - objects.Markers.Clear(); - } - - private struct SYSTEMTIME - { - public short Year; - public short Month; - public short DayOfWeek; - public short Day; - public short Hour; - public short Minute; - public short Second; - public short Milliseconds; - } - - [DllImport("coredll.dll")] - private static extern bool SetSystemTime(ref SYSTEMTIME time); - - private void UpdateTime(DateTime gpsTime) - { - SYSTEMTIME s = new SYSTEMTIME(); - s.Year = (short) gpsTime.Year; - s.Month = (short) gpsTime.Month; - s.DayOfWeek = (short) gpsTime.DayOfWeek; - s.Day = (short) gpsTime.Day; - s.Hour = (short) gpsTime.Hour; - s.Minute = (short) gpsTime.Minute; - s.Second = (short) gpsTime.Second; - s.Milliseconds = (short) gpsTime.Millisecond; - - bool t = SetSystemTime(ref s); - Debug.WriteLine("SetSystemTime: " + t); - } - - private void menuItemSnapToGps_Click(object sender, EventArgs e) - { - menuItemSnapToGps.Checked = !menuItemSnapToGps.Checked; - if(!menuItemSnapToGps.Checked) - { - gpsPos.Position = MainMap.Position; - } - } - - private void menuItemSetDestination_Click(object sender, EventArgs e) - { - { - destinationPoint = MainMap.Position; - - if(menuItemshowDestination.Checked) - { - UpdateDestinationRoute(true, menuItemSnapToGps.Checked ? MainMap.Position : gpsPos.Position); - } - } - } - - internal GMapRoute destinationRoute; - - private void menuItemshowDestination_Click(object sender, EventArgs e) - { - menuItemshowDestination.Checked = !menuItemshowDestination.Checked; - - if(menuItemshowDestination.Checked) - { - if(MainMap.panel == null) - { - MainMap.panel = this; - } - UpdateDestinationRoute(true, menuItemSnapToGps.Checked ? MainMap.Position : gpsPos.Position); - } - - if(destinationRoute != null) - { - destinationRoute.IsVisible = menuItemshowDestination.Checked; - } - } - - void UpdateDestinationRoute(bool forceUpdate, PointLatLng startPoint) - { - if(destinationRoute == null) - { - destinationRoute = new GMapRoute("destination route"); - - destinationRoute.Stroke.Color = Color.Red; - destinationRoute.Stroke.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; - destinationRoute.Stroke.Width = 1.0f; - - objects.Routes.Add(destinationRoute); - } - else - { - destinationRoute.Points.Clear(); - } - - destinationRoute.Points.Add(startPoint); - destinationRoute.Points.Add(destinationPoint); - if(forceUpdate) - { - MainMap.UpdateRouteLocalPosition(destinationRoute); - MainMap.Invalidate(); - } - } - } - - public class Map : GMapControl - { - readonly Brush screenBrush = new SolidBrush(Color.Navy); - readonly Font screenFont = new Font(FontFamily.GenericSansSerif, 7, FontStyle.Regular); - - public MainForm panel; - - protected override void OnPaintOverlays(Graphics g) - { - base.OnPaintOverlays(g); - - if(panel != null && panel.menuItemshowDestination.Checked) - { - g.DrawString(string.Format("destination: {0:0.00} km", panel.destinationRoute.Distance), screenFont, screenBrush, screenFont.Size, screenFont.Size); - } - } - } -} \ No newline at end of file diff --git a/Demo.WindowsMobile/Forms/MainForm.resx b/Demo.WindowsMobile/Forms/MainForm.resx deleted file mode 100644 --- a/Demo.WindowsMobile/Forms/MainForm.resx +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 151, 17 - - - Pocket_PC_Phone_VGA - - - Pocket_PC_Phone_VGA - - - False - - \ No newline at end of file diff --git a/Demo.WindowsMobile/Forms/Search.cs b/Demo.WindowsMobile/Forms/Search.cs deleted file mode 100644 --- a/Demo.WindowsMobile/Forms/Search.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using GMap.NET; -using GMap.NET.WindowsForms; -using GMap.NET.WindowsForms.Markers; -using GMap.NET.MapProviders; - -namespace Demo.WindowsMobile -{ - public partial class Search : UserControl - { - MainForm Main; - - public Search(MainForm main) - { - InitializeComponent(); - Main = main; - } - - private void button1_Click(object sender, EventArgs e) - { - try - { - GeoCoderStatusCode status = GeoCoderStatusCode.Unknow; - { - PointLatLng? pos = GMapProviders.GoogleMap.GetPoint(textAddress.Text, out status); - if(pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) - { - GMapMarker address = new GMapMarkerTransparentGoogleGreen(pos.Value); - address.ToolTipMode = MarkerTooltipMode.Always; - address.ToolTipText = textAddress.Text; - Main.objects.Markers.Add(address); - - Main.MainMap.Position = address.Position; - Main.menuItemGotoMap_Click(null, null); - } - else - { - labelstatus.Text = status.ToString(); - } - } - } - catch(Exception ex) - { - labelstatus.Text = ex.ToString(); - } - } - } -} diff --git a/Demo.WindowsMobile/Forms/Search.designer.cs b/Demo.WindowsMobile/Forms/Search.designer.cs deleted file mode 100644 --- a/Demo.WindowsMobile/Forms/Search.designer.cs +++ /dev/null @@ -1,89 +0,0 @@ -namespace Demo.WindowsMobile -{ - partial class Search - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if(disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.textAddress = new System.Windows.Forms.TextBox(); - this.labelstatus = new System.Windows.Forms.Label(); - this.button1 = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // textAddress - // - this.textAddress.BackColor = System.Drawing.Color.Navy; - this.textAddress.Dock = System.Windows.Forms.DockStyle.Top; - this.textAddress.Font = new System.Drawing.Font("Tahoma", 22F, System.Drawing.FontStyle.Regular); - this.textAddress.ForeColor = System.Drawing.Color.AliceBlue; - this.textAddress.Location = new System.Drawing.Point(0, 0); - this.textAddress.Multiline = true; - this.textAddress.Name = "textAddress"; - this.textAddress.Size = new System.Drawing.Size(239, 199); - this.textAddress.TabIndex = 4; - this.textAddress.Text = "Lithuania, Vilnius"; - // - // labelstatus - // - this.labelstatus.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelstatus.Location = new System.Drawing.Point(0, 199); - this.labelstatus.Name = "labelstatus"; - this.labelstatus.Size = new System.Drawing.Size(239, 127); - // - // button1 - // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.button1.BackColor = System.Drawing.Color.Blue; - this.button1.ForeColor = System.Drawing.Color.White; - this.button1.Location = new System.Drawing.Point(19, 242); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(197, 53); - this.button1.TabIndex = 7; - this.button1.Text = "Search Address"; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // Search - // - this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.Controls.Add(this.button1); - this.Controls.Add(this.labelstatus); - this.Controls.Add(this.textAddress); - this.Name = "Search"; - this.Size = new System.Drawing.Size(239, 326); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.TextBox textAddress; - private System.Windows.Forms.Label labelstatus; - private System.Windows.Forms.Button button1; - - } -} diff --git a/Demo.WindowsMobile/Forms/Search.resx b/Demo.WindowsMobile/Forms/Search.resx deleted file mode 100644 --- a/Demo.WindowsMobile/Forms/Search.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Pocket_PC_Phone - - - Pocket_PC_Phone - - \ No newline at end of file diff --git a/Demo.WindowsMobile/Forms/Transport.Designer.cs b/Demo.WindowsMobile/Forms/Transport.Designer.cs deleted file mode 100644 --- a/Demo.WindowsMobile/Forms/Transport.Designer.cs +++ /dev/null @@ -1,155 +0,0 @@ -namespace Demo.WindowsMobile -{ - partial class Transport - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if(disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.textBoxTrolley = new System.Windows.Forms.TextBox(); - this.checkBoxTrolley = new System.Windows.Forms.CheckBox(); - this.checkBoxBus = new System.Windows.Forms.CheckBox(); - this.textBoxBus = new System.Windows.Forms.TextBox(); - this.checkBoxRefresh = new System.Windows.Forms.CheckBox(); - this.timerRefresh = new System.Windows.Forms.Timer(); - this.labelstatus = new System.Windows.Forms.Label(); - this.button1 = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // textBoxTrolley - // - this.textBoxTrolley.BackColor = System.Drawing.Color.Navy; - this.textBoxTrolley.Dock = System.Windows.Forms.DockStyle.Top; - this.textBoxTrolley.Font = new System.Drawing.Font("Tahoma", 26F, System.Drawing.FontStyle.Regular); - this.textBoxTrolley.ForeColor = System.Drawing.Color.AliceBlue; - this.textBoxTrolley.Location = new System.Drawing.Point(0, 48); - this.textBoxTrolley.Name = "textBoxTrolley"; - this.textBoxTrolley.Size = new System.Drawing.Size(310, 59); - this.textBoxTrolley.TabIndex = 0; - this.textBoxTrolley.Text = "13,17"; - // - // checkBoxTrolley - // - this.checkBoxTrolley.Checked = true; - this.checkBoxTrolley.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxTrolley.Dock = System.Windows.Forms.DockStyle.Top; - this.checkBoxTrolley.Font = new System.Drawing.Font("Tahoma", 18F, System.Drawing.FontStyle.Regular); - this.checkBoxTrolley.Location = new System.Drawing.Point(0, 0); - this.checkBoxTrolley.Name = "checkBoxTrolley"; - this.checkBoxTrolley.Size = new System.Drawing.Size(310, 48); - this.checkBoxTrolley.TabIndex = 2; - this.checkBoxTrolley.Text = "Trolley"; - this.checkBoxTrolley.CheckStateChanged += new System.EventHandler(this.checkBoxTrolley_CheckStateChanged); - // - // checkBoxBus - // - this.checkBoxBus.Dock = System.Windows.Forms.DockStyle.Top; - this.checkBoxBus.Font = new System.Drawing.Font("Tahoma", 18F, System.Drawing.FontStyle.Regular); - this.checkBoxBus.Location = new System.Drawing.Point(0, 107); - this.checkBoxBus.Name = "checkBoxBus"; - this.checkBoxBus.Size = new System.Drawing.Size(310, 48); - this.checkBoxBus.TabIndex = 5; - this.checkBoxBus.Text = "Bus"; - this.checkBoxBus.CheckStateChanged += new System.EventHandler(this.checkBoxBus_CheckStateChanged); - // - // textBoxBus - // - this.textBoxBus.BackColor = System.Drawing.Color.Navy; - this.textBoxBus.Dock = System.Windows.Forms.DockStyle.Top; - this.textBoxBus.Font = new System.Drawing.Font("Tahoma", 26F, System.Drawing.FontStyle.Regular); - this.textBoxBus.ForeColor = System.Drawing.Color.AliceBlue; - this.textBoxBus.Location = new System.Drawing.Point(0, 155); - this.textBoxBus.Name = "textBoxBus"; - this.textBoxBus.Size = new System.Drawing.Size(310, 59); - this.textBoxBus.TabIndex = 4; - this.textBoxBus.Text = "50"; - // - // checkBoxRefresh - // - this.checkBoxRefresh.BackColor = System.Drawing.Color.Navy; - this.checkBoxRefresh.Dock = System.Windows.Forms.DockStyle.Bottom; - this.checkBoxRefresh.Font = new System.Drawing.Font("Tahoma", 16F, System.Drawing.FontStyle.Regular); - this.checkBoxRefresh.ForeColor = System.Drawing.Color.Lime; - this.checkBoxRefresh.Location = new System.Drawing.Point(0, 388); - this.checkBoxRefresh.Name = "checkBoxRefresh"; - this.checkBoxRefresh.Size = new System.Drawing.Size(310, 59); - this.checkBoxRefresh.TabIndex = 6; - this.checkBoxRefresh.Text = "AutoRefresh 15s"; - this.checkBoxRefresh.CheckStateChanged += new System.EventHandler(this.checkBoxRefresh_CheckStateChanged); - // - // timerRefresh - // - this.timerRefresh.Interval = 15000; - this.timerRefresh.Tick += new System.EventHandler(this.timerRefresh_Tick); - // - // labelstatus - // - this.labelstatus.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelstatus.Location = new System.Drawing.Point(0, 214); - this.labelstatus.Name = "labelstatus"; - this.labelstatus.Size = new System.Drawing.Size(310, 174); - // - // button1 - // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button1.BackColor = System.Drawing.Color.Blue; - this.button1.ForeColor = System.Drawing.Color.White; - this.button1.Location = new System.Drawing.Point(237, 391); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(70, 53); - this.button1.TabIndex = 7; - this.button1.Text = "Manual"; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // Transport - // - this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.Controls.Add(this.button1); - this.Controls.Add(this.labelstatus); - this.Controls.Add(this.textBoxBus); - this.Controls.Add(this.checkBoxBus); - this.Controls.Add(this.textBoxTrolley); - this.Controls.Add(this.checkBoxTrolley); - this.Controls.Add(this.checkBoxRefresh); - this.Name = "Transport"; - this.Size = new System.Drawing.Size(310, 447); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.TextBox textBoxTrolley; - private System.Windows.Forms.CheckBox checkBoxTrolley; - private System.Windows.Forms.CheckBox checkBoxBus; - private System.Windows.Forms.TextBox textBoxBus; - private System.Windows.Forms.CheckBox checkBoxRefresh; - private System.Windows.Forms.Timer timerRefresh; - private System.Windows.Forms.Label labelstatus; - private System.Windows.Forms.Button button1; - - } -} diff --git a/Demo.WindowsMobile/Forms/Transport.cs b/Demo.WindowsMobile/Forms/Transport.cs deleted file mode 100644 --- a/Demo.WindowsMobile/Forms/Transport.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using GMap.NET; -using GMap.NET.WindowsForms; -using GMap.NET.WindowsForms.Markers; -using Demo.WindowsForms; -using System.Linq; -using System.IO; - -namespace Demo.WindowsMobile -{ - public partial class Transport : UserControl - { - MainForm Main; - int Count = 0; - - readonly List Bus = new List(); - readonly List Trolley = new List(); - - readonly List BusMarkers = new List(); - readonly List TrolleyMarkers = new List(); - - public Transport(MainForm main) - { - InitializeComponent(); - Main = main; - } - - private void checkBoxRefresh_CheckStateChanged(object sender, EventArgs e) - { - timerRefresh.Enabled = checkBoxRefresh.Checked; - labelstatus.Text = string.Empty; - Count = 0; - } - - private void checkBoxBus_CheckStateChanged(object sender, EventArgs e) - { - if(!checkBoxBus.Checked) - { - foreach(var b in BusMarkers) - { - Main.objects.Markers.Remove(b); - } - } - } - - private void checkBoxTrolley_CheckStateChanged(object sender, EventArgs e) - { - if(!checkBoxTrolley.Checked) - { - foreach(var b in TrolleyMarkers) - { - Main.objects.Markers.Remove(b); - } - } - } - - // update data - private void timerRefresh_Tick(object sender, EventArgs e) - { - timerRefresh.Enabled = false; - - try - { - DateTime tstart = DateTime.Now; - { - if(checkBoxBus.Checked) - { - foreach(var b in BusMarkers) - { - Main.objects.Markers.Remove(b); - } - - Stuff.GetVilniusTransportData(TransportType.Bus, textBoxBus.Text, Bus); - - foreach(var t in Bus) - { - if (textBoxBus.Text.Split(',').Contains(t.Line)) - { - var r = new GMapMarkerTransparent(new PointLatLng(t.Lat, t.Lng)); - { - r.ToolTipMode = MarkerTooltipMode.Always; - r.ToolTipText = "B " + t.Id + Environment.NewLine + t.Line + " @ " + t.Time; - r.Data = t; - } - Main.objects.Markers.Add(r); - BusMarkers.Add(r); - } - } - } - - if(checkBoxTrolley.Checked) - { - foreach(var b in TrolleyMarkers) - { - Main.objects.Markers.Remove(b); - } - - Stuff.GetVilniusTransportData(TransportType.TrolleyBus, textBoxTrolley.Text, Trolley); - - foreach(var t in Trolley) - { - if (textBoxTrolley.Text.Split(',').Contains(t.Line)) - { - var r = new GMapMarkerTransparent(new PointLatLng(t.Lat, t.Lng)); - { - r.ToolTipMode = MarkerTooltipMode.Always; - r.ToolTipText = "T " + t.Id + Environment.NewLine + t.Line + " @ " + t.Time; - r.Data = t; - } - Main.objects.Markers.Add(r); - TrolleyMarkers.Add(r); - } - } - } - } - labelstatus.Text = ++Count + " -> " + DateTime.Now.ToLongTimeString() + ", request: " + (DateTime.Now - tstart).TotalSeconds+ "s"; - } - catch(Exception ex) - { - labelstatus.Text = ex.ToString(); - } - timerRefresh.Enabled = checkBoxRefresh.Checked; - } - - private void button1_Click(object sender, EventArgs e) - { - labelstatus.Text = "Connecting manualy once..."; - labelstatus.Invalidate(); - timerRefresh_Tick(null, null); - Main.ZoomToFitMarkers(); - Main.menuItemGotoMap_Click(null, null); - } - } - - public class GMapMarkerTransparent : GMapMarkerTransparentGoogleGreen - { - public VehicleData Data; - - public GMapMarkerTransparent(PointLatLng p) - : base(p) - { - - } - } -} diff --git a/Demo.WindowsMobile/Forms/Transport.resx b/Demo.WindowsMobile/Forms/Transport.resx deleted file mode 100644 --- a/Demo.WindowsMobile/Forms/Transport.resx +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - Pocket_PC_Phone - - - Pocket_PC_Phone - - \ No newline at end of file diff --git a/Demo.WindowsMobile/Properties/AssemblyInfo.cs b/Demo.WindowsMobile/Properties/AssemblyInfo.cs deleted file mode 100644 --- a/Demo.WindowsMobile/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 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("Demo.WindowsMobile")] -[assembly: AssemblyDescription("Demo for GMap.NET.WindowsMobile")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Universe")] -[assembly: AssemblyProduct("Demo.WindowsMobile")] -[assembly: AssemblyCopyright("Copyright © Universe 2010")] -[assembly: AssemblyTrademark("email@radioman.lt")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("545e643b-a82a-481b-9df8-96ee8c774d5c")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] - -// Below attribute is to suppress FxCop warning "CA2232 : Microsoft.Usage : Add STAThreadAttribute to assembly" -// as Device app does not support STA thread. -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2232:MarkWindowsFormsEntryPointsWithStaThread")] diff --git a/Demo.WindowsMobile/Properties/Resources.Designer.cs b/Demo.WindowsMobile/Properties/Resources.Designer.cs deleted file mode 100644 --- a/Demo.WindowsMobile/Properties/Resources.Designer.cs +++ /dev/null @@ -1,68 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.4927 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Demo.WindowsMobile.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the Strongly Typed Resource Builder - // class via a tool like ResGen or Visual Studio.NET. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - class Resources - { - - private static System.Resources.ResourceManager _resMgr; - - private static System.Globalization.CultureInfo _resCulture; - - /*FamANDAssem*/ - internal Resources() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - public static System.Resources.ResourceManager ResourceManager - { - get - { - if((_resMgr == null)) - { - System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Demo.WindowsMobile.Properties.Resources", typeof(Resources).Assembly); - _resMgr = temp; - } - return _resMgr; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - public static System.Globalization.CultureInfo Culture - { - get - { - return _resCulture; - } - set - { - _resCulture = value; - } - } - } -} diff --git a/Demo.WindowsMobile/Properties/Resources.resx b/Demo.WindowsMobile/Properties/Resources.resx deleted file mode 100644 --- a/Demo.WindowsMobile/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Demo.WindowsMobile/Resources/ImageReady.ico b/Demo.WindowsMobile/Resources/ImageReady.ico deleted file mode 100644 index b7fee32d3a43a405ef2fce56fd05b74ec6720489..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@= 0) - { - HookEventArgs hookArgs = new HookEventArgs(); - hookArgs.Code = code; - hookArgs.wParam = wParam; - hookArgs.lParam = lParam; - KeyBoardInfo keyBoardInfo = new KeyBoardInfo(); - keyBoardInfo.vkCode = kbdllhookstruct.vkCode; - keyBoardInfo.scanCode = kbdllhookstruct.scanCode; - if(this.OnHookEvent(hookArgs, keyBoardInfo)) - { - return 1; - } - } - return CallNextHookEx(this.hookDeleg, code, wParam, lParam); - } - - public bool isRunning() - { - if(hHook == 0) - { - return false; - } - return true; - } - - protected virtual bool OnHookEvent(HookEventArgs hookArgs, KeyBoardInfo keyBoardInfo) - { - return ((this.HookEvent != null) && this.HookEvent(hookArgs, keyBoardInfo)); - } - - [DllImport("coredll.dll")] - private static extern int SetWindowsHookEx(int type, HookProc hookProc, IntPtr hInstance, int m); - public void Start() - { - if(isRunning()) - { - this.Stop(); - } - this.hookDeleg = new HookProc(this.HookProcedure); - hHook = SetWindowsHookEx(20, this.hookDeleg, GetModuleHandle(null), 0); - if(hHook == 0) - { - throw new SystemException("Failed acquiring of the hook."); - } - } - - public void Stop() - { - if(isRunning()) - { - UnhookWindowsHookEx(hHook); - hHook = 0; - } - } - - [DllImport("coredll.dll", SetLastError=true)] - private static extern int UnhookWindowsHookEx(int idHook); - - public delegate bool HookEventHandler(HookEventArgs e, KeyBoardInfo keyBoardInfo); - - public delegate int HookProc(int code, IntPtr wParam, IntPtr lParam); - - [StructLayout(LayoutKind.Sequential)] - private struct KBDLLHOOKSTRUCT - { - public int vkCode; - public int scanCode; - public int flags; - public int time; - public IntPtr dwExtraInfo; - } - } - - public class HookEventArgs : EventArgs - { - public int Code; - public IntPtr lParam; - public IntPtr wParam; - } - - public class KeyBoardInfo - { - public int flags; - public int scanCode; - public int time; - public int vkCode; - } -} - diff --git a/Demo.WindowsMobile/Source/Program.cs b/Demo.WindowsMobile/Source/Program.cs deleted file mode 100644 --- a/Demo.WindowsMobile/Source/Program.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -using System.Collections.Generic; -using System.Windows.Forms; - -namespace Demo.WindowsMobile -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [MTAThread] - static void Main() - { - Application.Run(new MainForm()); - } - } -} \ No newline at end of file diff --git a/Demo.WindowsPresentation/Controls/TrolleyTooltip.xaml b/Demo.WindowsPresentation/Controls/TrolleyTooltip.xaml deleted file mode 100644 --- a/Demo.WindowsPresentation/Controls/TrolleyTooltip.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Demo.WindowsPresentation/Controls/TrolleyTooltip.xaml.cs b/Demo.WindowsPresentation/Controls/TrolleyTooltip.xaml.cs deleted file mode 100644 --- a/Demo.WindowsPresentation/Controls/TrolleyTooltip.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Windows.Controls; -using GMap.NET; -using Demo.WindowsForms; - -namespace Demo.WindowsPresentation.Controls -{ - /// - /// Interaction logic for TrolleyTooltip.xaml - /// - public partial class TrolleyTooltip : UserControl - { - public TrolleyTooltip() - { - InitializeComponent(); - } - - public void SetValues(string type, VehicleData vl) - { - Device.Text = vl.Id.ToString(); - LineNum.Text = type + " " + vl.Line; - StopName.Text = vl.LastStop; - TrackType.Text = vl.TrackType; - TimeGps.Text = vl.Time; - Area.Text = vl.AreaName; - Street.Text = vl.StreetName; - } - } -} diff --git a/Demo.WindowsPresentation/CustomMarkers/Circle.xaml b/Demo.WindowsPresentation/CustomMarkers/Circle.xaml deleted file mode 100644 --- a/Demo.WindowsPresentation/CustomMarkers/Circle.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/Demo.WindowsPresentation/CustomMarkers/Circle.xaml.cs b/Demo.WindowsPresentation/CustomMarkers/Circle.xaml.cs deleted file mode 100644 --- a/Demo.WindowsPresentation/CustomMarkers/Circle.xaml.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using GMap.NET; - -namespace Demo.WindowsPresentation.CustomMarkers -{ - /// - /// Interaction logic for Circle.xaml - /// - public partial class Circle : UserControl - { - public Circle() - { - InitializeComponent(); - } - - public PointLatLng Center; - public PointLatLng Bound; - } -} diff --git a/Demo.WindowsPresentation/CustomMarkers/CircleVisual.cs b/Demo.WindowsPresentation/CustomMarkers/CircleVisual.cs deleted file mode 100644 --- a/Demo.WindowsPresentation/CustomMarkers/CircleVisual.cs +++ /dev/null @@ -1,333 +0,0 @@ -using System; -using System.Globalization; -using System.Windows; -using System.Windows.Controls.Primitives; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Effects; -using Demo.WindowsPresentation.Controls; -using GMap.NET.WindowsPresentation; - -namespace Demo.WindowsPresentation.CustomMarkers -{ - public class CircleVisual : FrameworkElement - { - public readonly Popup Popup = new Popup(); - public readonly TrolleyTooltip Tooltip = new TrolleyTooltip(); - public readonly GMapMarker Marker; - - public CircleVisual(GMapMarker m, Brush background) - { - Marker = m; - Marker.ZIndex = 100; - - Popup.AllowsTransparency = true; - Popup.PlacementTarget = this; - Popup.Placement = PlacementMode.Mouse; - Popup.Child = Tooltip; - Popup.Child.Opacity = 0.777; - - SizeChanged += new SizeChangedEventHandler(CircleVisual_SizeChanged); - MouseEnter += new System.Windows.Input.MouseEventHandler(CircleVisual_MouseEnter); - MouseLeave += new System.Windows.Input.MouseEventHandler(CircleVisual_MouseLeave); - Loaded += new RoutedEventHandler(OnLoaded); - - Text = "?"; - - StrokeArrow.EndLineCap = PenLineCap.Triangle; - StrokeArrow.LineJoin = PenLineJoin.Round; - - RenderTransform = scale; - - Width = Height = 22; - FontSize = (Width/1.55); - - Background = background; - Angle = null; - } - - void CircleVisual_SizeChanged(object sender, SizeChangedEventArgs e) - { - Marker.Offset = new System.Windows.Point(-e.NewSize.Width/2, -e.NewSize.Height/2); - scale.CenterX = -Marker.Offset.X; - scale.CenterY = -Marker.Offset.Y; - } - - void OnLoaded(object sender, RoutedEventArgs e) - { - UpdateVisual(true); - } - - readonly ScaleTransform scale = new ScaleTransform(1, 1); - - void CircleVisual_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) - { - if(Popup.IsOpen) - { - Popup.IsOpen = false; - } - - Marker.ZIndex -= 10000; - Cursor = Cursors.Arrow; - - this.Effect = null; - - scale.ScaleY = 1; - scale.ScaleX = 1; - } - - void CircleVisual_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) - { - if(!Popup.IsOpen) - { - Popup.IsOpen = true; - } - - Marker.ZIndex += 10000; - Cursor = Cursors.Hand; - - this.Effect = ShadowEffect; - - scale.ScaleY = 1.5; - scale.ScaleX = 1.5; - } - - public DropShadowEffect ShadowEffect; - - static readonly Typeface Font = new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Bold, FontStretches.Normal); - FormattedText FText; - - private Brush background = Brushes.Blue; - public Brush Background - { - get - { - return background; - } - set - { - if(background != value) - { - background = value; - IsChanged = true; - } - } - } - - private Brush foreground = Brushes.White; - public Brush Foreground - { - get - { - return foreground; - } - set - { - if(foreground != value) - { - foreground = value; - IsChanged = true; - - ForceUpdateText(); - } - } - } - - private Pen stroke = new Pen(Brushes.Blue, 2.0); - public Pen Stroke - { - get - { - return stroke; - } - set - { - if(stroke != value) - { - stroke = value; - IsChanged = true; - } - } - } - - private Pen strokeArrow = new Pen(Brushes.Blue, 2.0); - public Pen StrokeArrow - { - get - { - return strokeArrow; - } - set - { - if(strokeArrow != value) - { - strokeArrow = value; - IsChanged = true; - } - } - } - - public double FontSize = 16; - - private double? angle = 0; - public double? Angle - { - get - { - return angle; - } - set - { - if(!Angle.HasValue || !value.HasValue || (Angle.HasValue && value.HasValue && Math.Abs(angle.Value - value.Value) > 11)) - { - angle = value; - IsChanged = true; - } - } - } - public bool IsChanged = true; - - void ForceUpdateText() - { - FText = new FormattedText(text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Font, FontSize, Foreground); - IsChanged = true; - } - - string text; - public string Text - { - get - { - return text; - } - set - { - if(text != value) - { - text = value; - ForceUpdateText(); - } - } - } - - Visual _child; - public virtual Visual Child - { - get - { - return _child; - } - set - { - if(_child != value) - { - if(_child != null) - { - RemoveLogicalChild(_child); - RemoveVisualChild(_child); - } - - if(value != null) - { - AddVisualChild(value); - AddLogicalChild(value); - } - - // cache the new child - _child = value; - - InvalidateVisual(); - } - } - } - - public bool UpdateVisual(bool forceUpdate) - { - if(forceUpdate || IsChanged) - { - Child = Create(); - IsChanged = false; - return true; - } - - return false; - } - - int countCreate = 0; - - private DrawingVisual Create() - { - countCreate++; - - var square = new DrawingVisualFx(); - - using(DrawingContext dc = square.RenderOpen()) - { - dc.DrawEllipse(null, Stroke, new Point(Width/2, Height/2), Width/2 + Stroke.Thickness/2, Height/2 + Stroke.Thickness/2); - - if(Angle.HasValue) - { - dc.PushTransform(new RotateTransform(Angle.Value, Width/2, Height/2)); - { - PolyLineSegment polySeg = new PolyLineSegment(new Point[] { new Point(Width*0.2, Height*0.3), new Point(Width*0.8, Height*0.3) }, true); - PathFigure pathFig = new PathFigure(new Point(Width*0.5, -Height*0.22), new PathSegment[] { polySeg }, true); - PathGeometry pathGeo = new PathGeometry(new PathFigure[] { pathFig }); - dc.DrawGeometry(Brushes.AliceBlue, StrokeArrow, pathGeo); - } - dc.Pop(); - } - - dc.DrawEllipse(Background, null, new Point(Width/2, Height/2), Width/2, Height/2); - dc.DrawText(FText, new Point(Width/2 - FText.Width/2, Height/2 - FText.Height/2)); - } - - return square; - } - - #region Necessary Overrides -- Needed by WPF to maintain bookkeeping of our hosted visuals - protected override int VisualChildrenCount - { - get - { - return (Child == null ? 0 : 1); - } - } - - protected override Visual GetVisualChild(int index) - { - return Child; - } - #endregion - } - - public class DrawingVisualFx : DrawingVisual - { - public static readonly DependencyProperty EffectProperty = DependencyProperty.Register("Effect", typeof(Effect), typeof(DrawingVisualFx), - new FrameworkPropertyMetadata(null, (FrameworkPropertyMetadataOptions.AffectsRender), new PropertyChangedCallback(OnEffectChanged))); - public Effect Effect - { - get - { - return (Effect) GetValue(EffectProperty); - } - set - { - SetValue(EffectProperty, value); - } - } - - private static void OnEffectChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) - { - DrawingVisualFx drawingVisualFx = o as DrawingVisualFx; - if(drawingVisualFx != null) - { - drawingVisualFx.setMyProtectedVisualEffect((Effect) e.NewValue); - } - } - - private void setMyProtectedVisualEffect(Effect effect) - { - VisualEffect = effect; - } - } -} diff --git a/Demo.WindowsPresentation/CustomMarkers/Cross.xaml b/Demo.WindowsPresentation/CustomMarkers/Cross.xaml deleted file mode 100644 --- a/Demo.WindowsPresentation/CustomMarkers/Cross.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/Demo.WindowsPresentation/CustomMarkers/Cross.xaml.cs b/Demo.WindowsPresentation/CustomMarkers/Cross.xaml.cs deleted file mode 100644 --- a/Demo.WindowsPresentation/CustomMarkers/Cross.xaml.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Windows.Controls; - -namespace Demo.WindowsPresentation.CustomMarkers -{ - /// - /// Interaction logic for Cross.xaml - /// - public partial class Cross : UserControl - { - public Cross() - { - InitializeComponent(); - this.IsHitTestVisible = false; - } - } -} diff --git a/Demo.WindowsPresentation/CustomMarkers/CustomMarkerDemo.xaml b/Demo.WindowsPresentation/CustomMarkers/CustomMarkerDemo.xaml deleted file mode 100644 --- a/Demo.WindowsPresentation/CustomMarkers/CustomMarkerDemo.xaml +++ /dev/null @@ -1,7 +0,0 @@ - - - \ No newline at end of file diff --git a/Demo.WindowsPresentation/CustomMarkers/CustomMarkerDemo.xaml.cs b/Demo.WindowsPresentation/CustomMarkers/CustomMarkerDemo.xaml.cs deleted file mode 100644 --- a/Demo.WindowsPresentation/CustomMarkers/CustomMarkerDemo.xaml.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System.Windows; -using System.Windows.Controls; -using System.Windows.Controls.Primitives; -using System.Windows.Input; -using System.Windows.Media; -using GMap.NET.WindowsPresentation; -using System.Diagnostics; - -namespace Demo.WindowsPresentation.CustomMarkers -{ - /// - /// Interaction logic for CustomMarkerDemo.xaml - /// - public partial class CustomMarkerDemo - { - Popup Popup; - Label Label; - GMapMarker Marker; - MainWindow MainWindow; - - public CustomMarkerDemo(MainWindow window, GMapMarker marker, string title) - { - this.InitializeComponent(); - - this.MainWindow = window; - this.Marker = marker; - - Popup = new Popup(); - Label = new Label(); - - this.Unloaded += new RoutedEventHandler(CustomMarkerDemo_Unloaded); - this.Loaded += new RoutedEventHandler(CustomMarkerDemo_Loaded); - this.SizeChanged += new SizeChangedEventHandler(CustomMarkerDemo_SizeChanged); - this.MouseEnter += new MouseEventHandler(MarkerControl_MouseEnter); - this.MouseLeave += new MouseEventHandler(MarkerControl_MouseLeave); - this.MouseMove += new MouseEventHandler(CustomMarkerDemo_MouseMove); - this.MouseLeftButtonUp += new MouseButtonEventHandler(CustomMarkerDemo_MouseLeftButtonUp); - this.MouseLeftButtonDown += new MouseButtonEventHandler(CustomMarkerDemo_MouseLeftButtonDown); - - Popup.Placement = PlacementMode.Mouse; - { - Label.Background = Brushes.Blue; - Label.Foreground = Brushes.White; - Label.BorderBrush = Brushes.WhiteSmoke; - Label.BorderThickness = new Thickness(2); - Label.Padding = new Thickness(5); - Label.FontSize = 22; - Label.Content = title; - } - Popup.Child = Label; - } - - void CustomMarkerDemo_Loaded(object sender, RoutedEventArgs e) - { - if(icon.Source.CanFreeze) - { - icon.Source.Freeze(); - } - } - - void CustomMarkerDemo_Unloaded(object sender, RoutedEventArgs e) - { - this.Unloaded -= new RoutedEventHandler(CustomMarkerDemo_Unloaded); - this.Loaded -= new RoutedEventHandler(CustomMarkerDemo_Loaded); - this.SizeChanged-= new SizeChangedEventHandler(CustomMarkerDemo_SizeChanged); - this.MouseEnter -= new MouseEventHandler(MarkerControl_MouseEnter); - this.MouseLeave -= new MouseEventHandler(MarkerControl_MouseLeave); - this.MouseMove -= new MouseEventHandler(CustomMarkerDemo_MouseMove); - this.MouseLeftButtonUp -= new MouseButtonEventHandler(CustomMarkerDemo_MouseLeftButtonUp); - this.MouseLeftButtonDown -= new MouseButtonEventHandler(CustomMarkerDemo_MouseLeftButtonDown); - - Marker.Shape = null; - icon.Source = null; - icon = null; - Popup = null; - Label = null; - } - - void CustomMarkerDemo_SizeChanged(object sender, SizeChangedEventArgs e) - { - Marker.Offset = new Point(-e.NewSize.Width/2, -e.NewSize.Height); - } - - void CustomMarkerDemo_MouseMove(object sender, MouseEventArgs e) - { - if(e.LeftButton == MouseButtonState.Pressed && IsMouseCaptured) - { - Point p = e.GetPosition(MainWindow.MainMap); - Marker.Position = MainWindow.MainMap.FromLocalToLatLng((int) (p.X), (int) (p.Y)); - } - } - - void CustomMarkerDemo_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) - { - if(!IsMouseCaptured) - { - Mouse.Capture(this); - } - } - - void CustomMarkerDemo_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) - { - if(IsMouseCaptured) - { - Mouse.Capture(null); - } - } - - void MarkerControl_MouseLeave(object sender, MouseEventArgs e) - { - Marker.ZIndex -= 10000; - Popup.IsOpen = false; - } - - void MarkerControl_MouseEnter(object sender, MouseEventArgs e) - { - Marker.ZIndex += 10000; - Popup.IsOpen = true; - } - } -} \ No newline at end of file diff --git a/Demo.WindowsPresentation/CustomMarkers/CustomMarkerRed.xaml b/Demo.WindowsPresentation/CustomMarkers/CustomMarkerRed.xaml deleted file mode 100644 --- a/Demo.WindowsPresentation/CustomMarkers/CustomMarkerRed.xaml +++ /dev/null @@ -1,7 +0,0 @@ - - - \ No newline at end of file diff --git a/Demo.WindowsPresentation/CustomMarkers/CustomMarkerRed.xaml.cs b/Demo.WindowsPresentation/CustomMarkers/CustomMarkerRed.xaml.cs deleted file mode 100644 --- a/Demo.WindowsPresentation/CustomMarkers/CustomMarkerRed.xaml.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System.Windows; -using System.Windows.Controls; -using System.Windows.Controls.Primitives; -using System.Windows.Input; -using System.Windows.Media; -using GMap.NET.WindowsPresentation; - -namespace Demo.WindowsPresentation.CustomMarkers -{ - /// - /// Interaction logic for CustomMarkerDemo.xaml - /// - public partial class CustomMarkerRed - { - Popup Popup; - Label Label; - GMapMarker Marker; - MainWindow MainWindow; - - public CustomMarkerRed(MainWindow window, GMapMarker marker, string title) - { - this.InitializeComponent(); - - this.MainWindow = window; - this.Marker = marker; - - Popup = new Popup(); - Label = new Label(); - - this.Loaded += new RoutedEventHandler(CustomMarkerDemo_Loaded); - this.SizeChanged += new SizeChangedEventHandler(CustomMarkerDemo_SizeChanged); - this.MouseEnter += new MouseEventHandler(MarkerControl_MouseEnter); - this.MouseLeave += new MouseEventHandler(MarkerControl_MouseLeave); - this.MouseMove += new MouseEventHandler(CustomMarkerDemo_MouseMove); - this.MouseLeftButtonUp += new MouseButtonEventHandler(CustomMarkerDemo_MouseLeftButtonUp); - this.MouseLeftButtonDown += new MouseButtonEventHandler(CustomMarkerDemo_MouseLeftButtonDown); - - Popup.Placement = PlacementMode.Mouse; - { - Label.Background = Brushes.Blue; - Label.Foreground = Brushes.White; - Label.BorderBrush = Brushes.WhiteSmoke; - Label.BorderThickness = new Thickness(2); - Label.Padding = new Thickness(5); - Label.FontSize = 22; - Label.Content = title; - } - Popup.Child = Label; - } - - void CustomMarkerDemo_Loaded(object sender, RoutedEventArgs e) - { - if(icon.Source.CanFreeze) - { - icon.Source.Freeze(); - } - } - - void CustomMarkerDemo_SizeChanged(object sender, SizeChangedEventArgs e) - { - Marker.Offset = new Point(-e.NewSize.Width/2, -e.NewSize.Height); - } - - void CustomMarkerDemo_MouseMove(object sender, MouseEventArgs e) - { - if(e.LeftButton == MouseButtonState.Pressed && IsMouseCaptured) - { - Point p = e.GetPosition(MainWindow.MainMap); - Marker.Position = MainWindow.MainMap.FromLocalToLatLng((int) p.X, (int) p.Y); - } - } - - void CustomMarkerDemo_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) - { - if(!IsMouseCaptured) - { - Mouse.Capture(this); - } - } - - void CustomMarkerDemo_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) - { - if(IsMouseCaptured) - { - Mouse.Capture(null); - } - } - - void MarkerControl_MouseLeave(object sender, MouseEventArgs e) - { - Marker.ZIndex -= 10000; - Popup.IsOpen = false; - } - - void MarkerControl_MouseEnter(object sender, MouseEventArgs e) - { - Marker.ZIndex += 10000; - Popup.IsOpen = true; - } - } -} \ No newline at end of file diff --git a/Demo.WindowsPresentation/CustomMarkers/Test.xaml b/Demo.WindowsPresentation/CustomMarkers/Test.xaml deleted file mode 100644 --- a/Demo.WindowsPresentation/CustomMarkers/Test.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - 44 - - diff --git a/Demo.WindowsPresentation/CustomMarkers/Test.xaml.cs b/Demo.WindowsPresentation/CustomMarkers/Test.xaml.cs deleted file mode 100644 --- a/Demo.WindowsPresentation/CustomMarkers/Test.xaml.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Windows.Controls; - -namespace Demo.WindowsPresentation.CustomMarkers -{ - /// - /// Interaction logic for Test.xaml - /// - public partial class Test : UserControl - { - public Test(string txt) - { - InitializeComponent(); - - text.Text = txt; - } - } -} diff --git a/Demo.WindowsPresentation/CustomMarkers/bigMarkerGreen.png b/Demo.WindowsPresentation/CustomMarkers/bigMarkerGreen.png deleted file mode 100644 index 4aed804959cd7450939446ca75515003033a8543..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@ - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {83195AEF-0071-471C-9E8B-E67211F5D028} - WinExe - Properties - Demo.WindowsPresentation - Demo.WindowsPresentation - v3.5 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - Resources\ImageReady.ico - - - 3.5 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - - true - - - sn.snk - - - - LocalIntranet - - - true - - - - - - Properties\app.manifest - - - true - bin\Debug\ - DEBUG;TRACE - full - AnyCPU - ..\Build\Debug\Demo.WindowsPresentation.exe.CodeAnalysisLog.xml - true - GlobalSuppressions.cs - prompt - MinimumRecommendedRules.ruleset - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets - true - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules - true - - - ..\Build\Release\ - TRACE - true - AnyCPU - ..\Build\Release\Demo.WindowsPresentation.exe.CodeAnalysisLog.xml - true - GlobalSuppressions.cs - false - prompt - MinimumRecommendedRules.ruleset - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets - false - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules - true - - - - - 3.5 - - - - - - 3.0 - - - 3.0 - - - 3.0 - - - 3.0 - - - 4.0 - - - - - Source\DemoStuff.cs - - - Message.xaml - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - MSBuild:Compile - Designer - - - Properties\VersionInfo.cs - - - MainWindow.xaml - Code - - - Designer - MSBuild:Compile - - - - - TrolleyTooltip.xaml - - - Circle.xaml - - - - CustomMarkerRed.xaml - - - Cross.xaml - - - CustomMarkerDemo.xaml - - - - Code - - - True - True - Resources.resx - - - - Test.xaml - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - - - - - - - - - - - - - - - - {D0C39D9D-BED0-418B-9A5E-713176CAF40C} - GMap.NET.Core - - - {644FE7D4-0184-400F-B2D7-99CB41360658} - GMap.NET.WindowsPresentation - - - - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - - - - - \ No newline at end of file diff --git a/Demo.WindowsPresentation/Properties/AssemblyInfo.cs b/Demo.WindowsPresentation/Properties/AssemblyInfo.cs deleted file mode 100644 --- a/Demo.WindowsPresentation/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; - -// 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("Demo.WindowsPresentation")] -[assembly: AssemblyDescription("Demo for GMap.NET.WindowsPresentation")] -[assembly: AssemblyProduct("Demo.WindowsPresentation")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -//[assembly: AssemblyVersion("1.0.0.0")] -//[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Demo.WindowsPresentation/Properties/Resources.Designer.cs b/Demo.WindowsPresentation/Properties/Resources.Designer.cs deleted file mode 100644 --- a/Demo.WindowsPresentation/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.235 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Demo.WindowsPresentation.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [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 { - - 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() { - } - - /// - /// 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 (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Demo.WindowsPresentation.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 { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/Demo.WindowsPresentation/Properties/Resources.resx b/Demo.WindowsPresentation/Properties/Resources.resx deleted file mode 100644 --- a/Demo.WindowsPresentation/Properties/Resources.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Demo.WindowsPresentation/Properties/app.manifest b/Demo.WindowsPresentation/Properties/app.manifest deleted file mode 100644 --- a/Demo.WindowsPresentation/Properties/app.manifest +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Demo.WindowsPresentation/Resources/ImageReady.ico b/Demo.WindowsPresentation/Resources/ImageReady.ico deleted file mode 100644 index b7fee32d3a43a405ef2fce56fd05b74ec6720489..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@ - /// the custom map f GMapControl - /// - public class Map : GMapControl - { - public long ElapsedMilliseconds; - -#if DEBUG - DateTime start; - DateTime end; - int delta; - - private int counter; - readonly Typeface tf = new Typeface("GenericSansSerif"); - readonly System.Windows.FlowDirection fd = new System.Windows.FlowDirection(); - - /// - /// any custom drawing here - /// - /// - protected override void OnRender(DrawingContext drawingContext) - { - start = DateTime.Now; - - base.OnRender(drawingContext); - - end = DateTime.Now; - delta = (int)(end - start).TotalMilliseconds; - - FormattedText text = new FormattedText(string.Format(CultureInfo.InvariantCulture, "{0:0.0}", Zoom) + "z, " + MapProvider + ", refresh: " + counter++ + ", load: " + ElapsedMilliseconds + "ms, render: " + delta + "ms", CultureInfo.InvariantCulture, fd, tf, 20, Brushes.Blue); - drawingContext.DrawText(text, new Point(text.Height, text.Height)); - text = null; - } -#endif - } -} diff --git a/Demo.WindowsPresentation/Windows/MainWindow.xaml b/Demo.WindowsPresentation/Windows/MainWindow.xaml deleted file mode 100644 --- a/Demo.WindowsPresentation/Windows/MainWindow.xaml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - Grid - - - - - - - - lietuva vilnius - - - - - - - - - - - - - - - - - - routing - geocoding - - - - - Transport demo - Performance - None - - - - - - - place info - - - - - - - - - - - - diff --git a/Demo.WindowsPresentation/Windows/MainWindow.xaml.cs b/Demo.WindowsPresentation/Windows/MainWindow.xaml.cs deleted file mode 100644 --- a/Demo.WindowsPresentation/Windows/MainWindow.xaml.cs +++ /dev/null @@ -1,990 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Threading; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Media.Imaging; -using System.Windows.Threading; -using Demo.WindowsForms; -using Demo.WindowsPresentation.CustomMarkers; -using GMap.NET; -using GMap.NET.MapProviders; -using GMap.NET.WindowsPresentation; - -namespace Demo.WindowsPresentation -{ - public partial class MainWindow : Window - { - PointLatLng start; - PointLatLng end; - - // marker - GMapMarker currentMarker; - - // zones list - List Circles = new List(); - - public MainWindow() - { - InitializeComponent(); - - // add your custom map db provider - //MySQLPureImageCache ch = new MySQLPureImageCache(); - //ch.ConnectionString = @"server=sql2008;User Id=trolis;Persist Security Info=True;database=gmapnetcache;password=trolis;"; - //MainMap.Manager.SecondaryCache = ch; - - // set your proxy here if need - //GMapProvider.WebProxy = new WebProxy("10.2.0.100", 8080); - //GMapProvider.WebProxy.Credentials = new NetworkCredential("ogrenci@bilgeadam.com", "bilgeada"); - - // set cache mode only if no internet avaible - if(!Stuff.PingNetwork("pingtest.net")) - { - MainMap.Manager.Mode = AccessMode.CacheOnly; - MessageBox.Show("No internet connection available, going to CacheOnly mode.", "GMap.NET - Demo.WindowsPresentation", MessageBoxButton.OK, MessageBoxImage.Warning); - } - - // config map - MainMap.MapProvider = GMapProviders.OpenStreetMap; - MainMap.Position = new PointLatLng(54.6961334816182, 25.2985095977783); - - //MainMap.ScaleMode = ScaleModes.Dynamic; - - // map events - MainMap.OnPositionChanged += new PositionChanged(MainMap_OnCurrentPositionChanged); - MainMap.OnTileLoadComplete += new TileLoadComplete(MainMap_OnTileLoadComplete); - MainMap.OnTileLoadStart += new TileLoadStart(MainMap_OnTileLoadStart); - MainMap.OnMapTypeChanged += new MapTypeChanged(MainMap_OnMapTypeChanged); - MainMap.MouseMove += new System.Windows.Input.MouseEventHandler(MainMap_MouseMove); - MainMap.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(MainMap_MouseLeftButtonDown); - MainMap.MouseEnter += new MouseEventHandler(MainMap_MouseEnter); - - // get map types - comboBoxMapType.ItemsSource = GMapProviders.List; - comboBoxMapType.DisplayMemberPath = "Name"; - comboBoxMapType.SelectedItem = MainMap.MapProvider; - - // acccess mode - comboBoxMode.ItemsSource = Enum.GetValues(typeof(AccessMode)); - comboBoxMode.SelectedItem = MainMap.Manager.Mode; - - // get cache modes - checkBoxCacheRoute.IsChecked = MainMap.Manager.UseRouteCache; - checkBoxGeoCache.IsChecked = MainMap.Manager.UseGeocoderCache; - - // setup zoom min/max - sliderZoom.Maximum = MainMap.MaxZoom; - sliderZoom.Minimum = MainMap.MinZoom; - - // get position - textBoxLat.Text = MainMap.Position.Lat.ToString(CultureInfo.InvariantCulture); - textBoxLng.Text = MainMap.Position.Lng.ToString(CultureInfo.InvariantCulture); - - // get marker state - checkBoxCurrentMarker.IsChecked = true; - - // can drag map - checkBoxDragMap.IsChecked = MainMap.CanDragMap; - -#if DEBUG - checkBoxDebug.IsChecked = true; -#endif - - //validator.Window = this; - - // set current marker - currentMarker = new GMapMarker(MainMap.Position); - { - currentMarker.Shape = new CustomMarkerRed(this, currentMarker, "custom position marker"); - currentMarker.Offset = new System.Windows.Point(-15, -15); - currentMarker.ZIndex = int.MaxValue; - MainMap.Markers.Add(currentMarker); - } - - //if(false) - { - // add my city location for demo - GeoCoderStatusCode status = GeoCoderStatusCode.Unknow; - - PointLatLng? city = GMapProviders.GoogleMap.GetPoint("Lithuania, Vilnius", out status); - if(city != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) - { - GMapMarker it = new GMapMarker(city.Value); - { - it.ZIndex = 55; - it.Shape = new CustomMarkerDemo(this, it, "Welcome to Lithuania! ;}"); - } - MainMap.Markers.Add(it); - - #region -- add some markers and zone around them -- - //if(false) - { - List objects = new List(); - { - string area = "Antakalnis"; - PointLatLng? pos = GMapProviders.GoogleMap.GetPoint("Lithuania, Vilnius, " + area, out status); - if(pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) - { - objects.Add(new PointAndInfo(pos.Value, area)); - } - } - { - string area = "Senamiestis"; - PointLatLng? pos = GMapProviders.GoogleMap.GetPoint("Lithuania, Vilnius, " + area, out status); - if(pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) - { - objects.Add(new PointAndInfo(pos.Value, area)); - } - } - { - string area = "Pilaite"; - PointLatLng? pos = GMapProviders.GoogleMap.GetPoint("Lithuania, Vilnius, " + area, out status); - if(pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS) - { - objects.Add(new PointAndInfo(pos.Value, area)); - } - } - AddDemoZone(8.8, city.Value, objects); - } - #endregion - } - - if(MainMap.Markers.Count > 1) - { - MainMap.ZoomAndCenterMarkers(null); - } - } - - // perfromance test - timer.Interval = TimeSpan.FromMilliseconds(44); - timer.Tick += new EventHandler(timer_Tick); - - // transport demo - transport.DoWork += new DoWorkEventHandler(transport_DoWork); - transport.ProgressChanged += new ProgressChangedEventHandler(transport_ProgressChanged); - transport.WorkerSupportsCancellation = true; - transport.WorkerReportsProgress = true; - } - - void MainMap_MouseEnter(object sender, MouseEventArgs e) - { - MainMap.Focus(); - } - - #region -- performance test-- - public RenderTargetBitmap ToImageSource(FrameworkElement obj) - { - // Save current canvas transform - Transform transform = obj.LayoutTransform; - obj.LayoutTransform = null; - - // fix margin offset as well - Thickness margin = obj.Margin; - obj.Margin = new Thickness(0, 0, margin.Right - margin.Left, margin.Bottom - margin.Top); - - // Get the size of canvas - System.Windows.Size size = new System.Windows.Size(obj.Width, obj.Height); - - // force control to Update - obj.Measure(size); - obj.Arrange(new Rect(size)); - - RenderTargetBitmap bmp = new RenderTargetBitmap((int)size.Width, (int)size.Height, 96, 96, PixelFormats.Pbgra32); - bmp.Render(obj); - - if(bmp.CanFreeze) - { - bmp.Freeze(); - } - - // return values as they were before - obj.LayoutTransform = transform; - obj.Margin = margin; - - return bmp; - } - - double NextDouble(Random rng, double min, double max) - { - return min + (rng.NextDouble() * (max - min)); - } - - Random r = new Random(); - - int tt = 0; - void timer_Tick(object sender, EventArgs e) - { - var pos = new PointLatLng(NextDouble(r, MainMap.ViewArea.Top, MainMap.ViewArea.Bottom), NextDouble(r, MainMap.ViewArea.Left, MainMap.ViewArea.Right)); - GMapMarker m = new GMapMarker(pos); - { - var s = new Test((tt++).ToString()); - - var image = new Image(); - { - RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.LowQuality); - image.Stretch = Stretch.None; - image.Opacity = s.Opacity; - - image.MouseEnter += new System.Windows.Input.MouseEventHandler(image_MouseEnter); - image.MouseLeave += new System.Windows.Input.MouseEventHandler(image_MouseLeave); - - image.Source = ToImageSource(s); - } - - m.Shape = image; - - m.Offset = new System.Windows.Point(-s.Width, -s.Height); - } - MainMap.Markers.Add(m); - - if(tt >= 333) - { - timer.Stop(); - tt = 0; - } - } - - void image_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) - { - Image img = sender as Image; - img.RenderTransform = null; - } - - void image_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) - { - Image img = sender as Image; - img.RenderTransform = new ScaleTransform(1.2, 1.2, 12.5, 12.5); - } - - DispatcherTimer timer = new DispatcherTimer(); - #endregion - - #region -- transport demo -- - BackgroundWorker transport = new BackgroundWorker(); - - readonly List trolleybus = new List(); - readonly Dictionary trolleybusMarkers = new Dictionary(); - - readonly List bus = new List(); - readonly Dictionary busMarkers = new Dictionary(); - - bool firstLoadTrasport = true; - - void transport_ProgressChanged(object sender, ProgressChangedEventArgs e) - { - using(Dispatcher.DisableProcessing()) - { - lock(trolleybus) - { - foreach(VehicleData d in trolleybus) - { - GMapMarker marker; - - if(!trolleybusMarkers.TryGetValue(d.Id, out marker)) - { - marker = new GMapMarker(new PointLatLng(d.Lat, d.Lng)); - marker.Tag = d.Id; - marker.Shape = new CircleVisual(marker, Brushes.Red); - - trolleybusMarkers[d.Id] = marker; - MainMap.Markers.Add(marker); - } - else - { - marker.Position = new PointLatLng(d.Lat, d.Lng); - var shape = (marker.Shape as CircleVisual); - { - shape.Text = d.Line; - shape.Angle = d.Bearing; - shape.Tooltip.SetValues("TrolleyBus", d); - - if(shape.IsChanged) - { - shape.UpdateVisual(false); - } - } - } - } - } - - lock(bus) - { - foreach(VehicleData d in bus) - { - GMapMarker marker; - - if(!busMarkers.TryGetValue(d.Id, out marker)) - { - marker = new GMapMarker(new PointLatLng(d.Lat, d.Lng)); - marker.Tag = d.Id; - - var v = new CircleVisual(marker, Brushes.Blue); - { - v.Stroke = new Pen(Brushes.Gray, 2.0); - } - marker.Shape = v; - - busMarkers[d.Id] = marker; - MainMap.Markers.Add(marker); - } - else - { - marker.Position = new PointLatLng(d.Lat, d.Lng); - var shape = (marker.Shape as CircleVisual); - { - shape.Text = d.Line; - shape.Angle = d.Bearing; - shape.Tooltip.SetValues("Bus", d); - - if(shape.IsChanged) - { - shape.UpdateVisual(false); - } - } - } - } - } - - if(firstLoadTrasport) - { - firstLoadTrasport = false; - } - } - } - - void transport_DoWork(object sender, DoWorkEventArgs e) - { - while(!transport.CancellationPending) - { - try - { - lock(trolleybus) - { - Stuff.GetVilniusTransportData(TransportType.TrolleyBus, string.Empty, trolleybus); - } - - lock(bus) - { - Stuff.GetVilniusTransportData(TransportType.Bus, string.Empty, bus); - } - - transport.ReportProgress(100); - } - catch(Exception ex) - { - Debug.WriteLine("transport_DoWork: " + ex.ToString()); - } - Thread.Sleep(3333); - } - trolleybusMarkers.Clear(); - busMarkers.Clear(); - } - - #endregion - - // add objects and zone around them - void AddDemoZone(double areaRadius, PointLatLng center, List objects) - { - var objectsInArea = from p in objects - where MainMap.MapProvider.Projection.GetDistance(center, p.Point) <= areaRadius - select new - { - Obj = p, - Dist = MainMap.MapProvider.Projection.GetDistance(center, p.Point) - }; - if(objectsInArea.Any()) - { - var maxDistObject = (from p in objectsInArea - orderby p.Dist descending - select p).First(); - - // add objects to zone - foreach(var o in objectsInArea) - { - GMapMarker it = new GMapMarker(o.Obj.Point); - { - it.ZIndex = 55; - var s = new CustomMarkerDemo(this, it, o.Obj.Info + ", distance from center: " + o.Dist + "km."); - it.Shape = s; - } - - MainMap.Markers.Add(it); - } - - // add zone circle - //if(false) - { - GMapMarker it = new GMapMarker(center); - it.ZIndex = -1; - - Circle c = new Circle(); - c.Center = center; - c.Bound = maxDistObject.Obj.Point; - c.Tag = it; - c.IsHitTestVisible = false; - - UpdateCircle(c); - Circles.Add(it); - - it.Shape = c; - MainMap.Markers.Add(it); - } - } - } - - // calculates circle radius - void UpdateCircle(Circle c) - { - var pxCenter = MainMap.FromLatLngToLocal(c.Center); - var pxBounds = MainMap.FromLatLngToLocal(c.Bound); - - double a = (double)(pxBounds.X - pxCenter.X); - double b = (double)(pxBounds.Y - pxCenter.Y); - var pxCircleRadius = Math.Sqrt(a * a + b * b); - - c.Width = 55 + pxCircleRadius * 2; - c.Height = 55 + pxCircleRadius * 2; - (c.Tag as GMapMarker).Offset = new System.Windows.Point(-c.Width / 2, -c.Height / 2); - } - - void MainMap_OnMapTypeChanged(GMapProvider type) - { - sliderZoom.Minimum = MainMap.MinZoom; - sliderZoom.Maximum = MainMap.MaxZoom; - } - - void MainMap_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) - { - System.Windows.Point p = e.GetPosition(MainMap); - currentMarker.Position = MainMap.FromLocalToLatLng((int)p.X, (int)p.Y); - } - - // move current marker with left holding - void MainMap_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) - { - if(e.LeftButton == System.Windows.Input.MouseButtonState.Pressed) - { - System.Windows.Point p = e.GetPosition(MainMap); - currentMarker.Position = MainMap.FromLocalToLatLng((int)p.X, (int)p.Y); - } - } - - // zoo max & center markers - private void button13_Click(object sender, RoutedEventArgs e) - { - MainMap.ZoomAndCenterMarkers(null); - - /* - PointAnimation panMap = new PointAnimation(); - panMap.Duration = TimeSpan.FromSeconds(1); - panMap.From = new Point(MainMap.Position.Lat, MainMap.Position.Lng); - panMap.To = new Point(0, 0); - Storyboard.SetTarget(panMap, MainMap); - Storyboard.SetTargetProperty(panMap, new PropertyPath(GMapControl.MapPointProperty)); - - Storyboard panMapStoryBoard = new Storyboard(); - panMapStoryBoard.Children.Add(panMap); - panMapStoryBoard.Begin(this); - */ - } - - // tile louading starts - void MainMap_OnTileLoadStart() - { - System.Windows.Forms.MethodInvoker m = delegate() - { - progressBar1.Visibility = Visibility.Visible; - }; - - try - { - this.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, m); - } - catch - { - } - } - - // tile loading stops - void MainMap_OnTileLoadComplete(long ElapsedMilliseconds) - { - MainMap.ElapsedMilliseconds = ElapsedMilliseconds; - - System.Windows.Forms.MethodInvoker m = delegate() - { - progressBar1.Visibility = Visibility.Hidden; - groupBox3.Header = "loading, last in " + MainMap.ElapsedMilliseconds + "ms"; - }; - - try - { - this.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, m); - } - catch - { - } - } - - // current location changed - void MainMap_OnCurrentPositionChanged(PointLatLng point) - { - mapgroup.Header = "gmap: " + point; - } - - // reload - private void button1_Click(object sender, RoutedEventArgs e) - { - MainMap.ReloadMap(); - } - - // enable current marker - private void checkBoxCurrentMarker_Checked(object sender, RoutedEventArgs e) - { - if(currentMarker != null) - { - MainMap.Markers.Add(currentMarker); - } - } - - // disable current marker - private void checkBoxCurrentMarker_Unchecked(object sender, RoutedEventArgs e) - { - if(currentMarker != null) - { - MainMap.Markers.Remove(currentMarker); - } - } - - // enable map dragging - private void checkBoxDragMap_Checked(object sender, RoutedEventArgs e) - { - MainMap.CanDragMap = true; - } - - // disable map dragging - private void checkBoxDragMap_Unchecked(object sender, RoutedEventArgs e) - { - MainMap.CanDragMap = false; - } - - // goto! - private void button2_Click(object sender, RoutedEventArgs e) - { - try - { - double lat = double.Parse(textBoxLat.Text, CultureInfo.InvariantCulture); - double lng = double.Parse(textBoxLng.Text, CultureInfo.InvariantCulture); - - MainMap.Position = new PointLatLng(lat, lng); - } - catch(Exception ex) - { - MessageBox.Show("incorrect coordinate format: " + ex.Message); - } - } - - // goto by geocoder - private void textBoxGeo_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) - { - if(e.Key == System.Windows.Input.Key.Enter) - { - GeoCoderStatusCode status = MainMap.SetCurrentPositionByKeywords(textBoxGeo.Text); - if(status != GeoCoderStatusCode.G_GEO_SUCCESS) - { - MessageBox.Show("Google Maps Geocoder can't find: '" + textBoxGeo.Text + "', reason: " + status.ToString(), "GMap.NET", MessageBoxButton.OK, MessageBoxImage.Exclamation); - } - else - { - currentMarker.Position = MainMap.Position; - } - } - } - - // zoom changed - private void sliderZoom_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) - { - // updates circles on map - foreach(var c in Circles) - { - UpdateCircle(c.Shape as Circle); - } - } - - // zoom up - private void czuZoomUp_Click(object sender, RoutedEventArgs e) - { - MainMap.Zoom = ((int)MainMap.Zoom) + 1; - } - - // zoom down - private void czuZoomDown_Click(object sender, RoutedEventArgs e) - { - MainMap.Zoom = ((int)(MainMap.Zoom + 0.99)) - 1; - } - - // prefetch - private void button3_Click(object sender, RoutedEventArgs e) - { - RectLatLng area = MainMap.SelectedArea; - if(!area.IsEmpty) - { - for(int i = (int)MainMap.Zoom; i <= MainMap.MaxZoom; i++) - { - MessageBoxResult res = MessageBox.Show("Ready ripp at Zoom = " + i + " ?", "GMap.NET", MessageBoxButton.YesNoCancel); - - if(res == MessageBoxResult.Yes) - { - TilePrefetcher obj = new TilePrefetcher(); - obj.Owner = this; - obj.ShowCompleteMessage = true; - obj.Start(area, i, MainMap.MapProvider, 100); - } - else if(res == MessageBoxResult.No) - { - continue; - } - else if(res == MessageBoxResult.Cancel) - { - break; - } - } - } - else - { - MessageBox.Show("Select map area holding ALT", "GMap.NET", MessageBoxButton.OK, MessageBoxImage.Exclamation); - } - } - - // access mode - private void comboBoxMode_DropDownClosed(object sender, EventArgs e) - { - MainMap.Manager.Mode = (AccessMode)comboBoxMode.SelectedItem; - MainMap.ReloadMap(); - } - - // clear cache - private void button4_Click(object sender, RoutedEventArgs e) - { - if(MessageBox.Show("Are You sure?", "Clear GMap.NET cache?", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK) - { - try - { - MainMap.Manager.PrimaryCache.DeleteOlderThan(DateTime.Now, null); - MessageBox.Show("Done. Cache is clear."); - } - catch(Exception ex) - { - MessageBox.Show(ex.Message); - } - } - } - - // export - private void button6_Click(object sender, RoutedEventArgs e) - { - MainMap.ShowExportDialog(); - } - - // import - private void button5_Click(object sender, RoutedEventArgs e) - { - MainMap.ShowImportDialog(); - } - - // use route cache - private void checkBoxCacheRoute_Checked(object sender, RoutedEventArgs e) - { - MainMap.Manager.UseRouteCache = checkBoxCacheRoute.IsChecked.Value; - } - - // use geocoding cahce - private void checkBoxGeoCache_Checked(object sender, RoutedEventArgs e) - { - MainMap.Manager.UseGeocoderCache = checkBoxGeoCache.IsChecked.Value; - MainMap.Manager.UsePlacemarkCache = MainMap.Manager.UseGeocoderCache; - } - - // save currnt view - private void button7_Click(object sender, RoutedEventArgs e) - { - try - { - ImageSource img = MainMap.ToImageSource(); - PngBitmapEncoder en = new PngBitmapEncoder(); - en.Frames.Add(BitmapFrame.Create(img as BitmapSource)); - - Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); - dlg.FileName = "GMap.NET Image"; // Default file name - dlg.DefaultExt = ".png"; // Default file extension - dlg.Filter = "Image (.png)|*.png"; // Filter files by extension - dlg.AddExtension = true; - dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); - - // Show save file dialog box - bool? result = dlg.ShowDialog(); - - // Process save file dialog box results - if(result == true) - { - // Save document - string filename = dlg.FileName; - - using(System.IO.Stream st = System.IO.File.OpenWrite(filename)) - { - en.Save(st); - } - } - } - catch(Exception ex) - { - MessageBox.Show(ex.Message); - } - } - - // clear all markers - private void button10_Click(object sender, RoutedEventArgs e) - { - var clear = MainMap.Markers.Where(p => p != null && p != currentMarker); - if(clear != null) - { - for(int i = 0; i < clear.Count(); i++) - { - MainMap.Markers.Remove(clear.ElementAt(i)); - i--; - } - } - - if(radioButtonPerformance.IsChecked == true) - { - tt = 0; - if(!timer.IsEnabled) - { - timer.Start(); - } - } - } - - // add marker - private void button8_Click(object sender, RoutedEventArgs e) - { - GMapMarker m = new GMapMarker(currentMarker.Position); - { - Placemark? p = null; - if(checkBoxPlace.IsChecked.Value) - { - GeoCoderStatusCode status; - var plret = GMapProviders.GoogleMap.GetPlacemark(currentMarker.Position, out status); - if(status == GeoCoderStatusCode.G_GEO_SUCCESS && plret != null) - { - p = plret; - } - } - - string ToolTipText; - if(p != null) - { - ToolTipText = p.Value.Address; - } - else - { - ToolTipText = currentMarker.Position.ToString(); - } - - m.Shape = new CustomMarkerDemo(this, m, ToolTipText); - m.ZIndex = 55; - } - MainMap.Markers.Add(m); - } - - // sets route start - private void button11_Click(object sender, RoutedEventArgs e) - { - start = currentMarker.Position; - } - - // sets route end - private void button9_Click(object sender, RoutedEventArgs e) - { - end = currentMarker.Position; - } - - // adds route - private void button12_Click(object sender, RoutedEventArgs e) - { - RoutingProvider rp = MainMap.MapProvider as RoutingProvider; - if(rp == null) - { - rp = GMapProviders.GoogleMap; // use google if provider does not implement routing - } - - MapRoute route = rp.GetRoute(start, end, false, false, (int)MainMap.Zoom); - if(route != null) - { - GMapMarker m1 = new GMapMarker(start); - m1.Shape = new CustomMarkerDemo(this, m1, "Start: " + route.Name); - - GMapMarker m2 = new GMapMarker(end); - m2.Shape = new CustomMarkerDemo(this, m2, "End: " + start.ToString()); - - GMapMarker mRoute = new GMapMarker(start); - { - mRoute.Route.AddRange(route.Points); - mRoute.RegenerateRouteShape(MainMap); - - mRoute.ZIndex = -1; - } - - MainMap.Markers.Add(m1); - MainMap.Markers.Add(m2); - MainMap.Markers.Add(mRoute); - - MainMap.ZoomAndCenterMarkers(null); - } - } - - // enables tile grid view - private void checkBox1_Checked(object sender, RoutedEventArgs e) - { - MainMap.ShowTileGridLines = true; - } - - // disables tile grid view - private void checkBox1_Unchecked(object sender, RoutedEventArgs e) - { - MainMap.ShowTileGridLines = false; - } - - private void Window_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) - { - int offset = 22; - - if(MainMap.IsFocused) - { - if(e.Key == Key.Left) - { - MainMap.Offset(-offset, 0); - } - else if(e.Key == Key.Right) - { - MainMap.Offset(offset, 0); - } - else if(e.Key == Key.Up) - { - MainMap.Offset(0, -offset); - } - else if(e.Key == Key.Down) - { - MainMap.Offset(0, offset); - } - else if(e.Key == Key.Add) - { - czuZoomUp_Click(null, null); - } - else if(e.Key == Key.Subtract) - { - czuZoomDown_Click(null, null); - } - } - } - - // set real time demo - private void realTimeChanged(object sender, RoutedEventArgs e) - { - MainMap.Markers.Clear(); - - // start performance test - if(radioButtonPerformance.IsChecked == true) - { - timer.Start(); - } - else - { - // stop performance test - timer.Stop(); - } - - // start realtime transport tracking demo - if(radioButtonTransport.IsChecked == true) - { - if(!transport.IsBusy) - { - firstLoadTrasport = true; - transport.RunWorkerAsync(); - } - } - else - { - if(transport.IsBusy) - { - transport.CancelAsync(); - } - } - } - - private void Window_PreviewKeyDown(object sender, KeyEventArgs e) - { - if(e.Key == Key.A) - { - MainMap.Bearing--; - } - else if(e.Key == Key.Z) - { - MainMap.Bearing++; - } - } - } - - public class MapValidationRule : ValidationRule - { - bool UserAcceptedLicenseOnce = false; - internal MainWindow Window; - - public override ValidationResult Validate(object value, CultureInfo cultureInfo) - { - if(!(value is OpenStreetMapProviderBase)) - { - if(!UserAcceptedLicenseOnce) - { - if(File.Exists(AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "License.txt")) - { - string ctn = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "License.txt"); - int li = ctn.IndexOf("License"); - string txt = ctn.Substring(li); - - var d = new Demo.WindowsPresentation.Windows.Message(); - d.richTextBox1.Text = txt; - - if(true == d.ShowDialog()) - { - UserAcceptedLicenseOnce = true; - if(Window != null) - { - Window.Title += " - license accepted by " + Environment.UserName + " at " + DateTime.Now; - } - } - } - else - { - // user deleted License.txt ;} - UserAcceptedLicenseOnce = true; - } - } - - if(!UserAcceptedLicenseOnce) - { - return new ValidationResult(false, "user do not accepted license ;/"); - } - } - - return new ValidationResult(true, null); - } - } -} diff --git a/Demo.WindowsPresentation/Windows/Message.xaml b/Demo.WindowsPresentation/Windows/Message.xaml deleted file mode 100644 --- a/Demo.WindowsPresentation/Windows/Message.xaml +++ /dev/null @@ -1,10 +0,0 @@ - - - -