ThinkGeo Cloud
ThinkGeo UI Controls
ThinkGeo Open Source
Help and Support
External Resources
ThinkGeo Cloud
ThinkGeo UI Controls
ThinkGeo Open Source
Help and Support
External Resources
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace SilverlightApplication { public partial class App : Application { public App() { this.Startup += this.Application_Startup; this.Exit += this.Application_Exit; this.UnhandledException += this.Application_UnhandledException; InitializeComponent(); } private void Application_Startup(object sender, StartupEventArgs e) { this.RootVisual = new MainPage(); } private void Application_Exit(object sender, EventArgs e) { } private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { // If the app is running outside of the debugger then report the exception using // the browser's exception mechanism. On IE this will display it a yellow alert // icon in the status bar and Firefox will display a script error. if (!System.Diagnostics.Debugger.IsAttached) { // NOTE: This will allow the application to continue running after an exception has been thrown // but not handled. // For production applications this error handling should be replaced with something that will // report the error to the website and stop the application. e.Handled = true; Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); }); } } private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e) { try { string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace; errorMsg = errorMsg.Replace('"', '\//).Replace("\r\n", @"\n"); System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");"); } catch (Exception) { } } } }
using System; using System.Windows; using System.Windows.Browser; using System.Windows.Controls; using System.Windows.Media; using ThinkGeo.MapSuite.SilverlightCore; using ThinkGeo.MapSuite.SilverlightEdition; namespace SilverlightApplication { [ScriptableTypeAttribute] public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); this.Loaded += new RoutedEventHandler(MainPage_Loaded); } void MainPage_Loaded(object sender, RoutedEventArgs e) { Map1.MapUnit = GeographyUnit.DecimalDegree; NewServerLayerOverlay serverLayerOverlay = new NewServerLayerOverlay("NativeServer", "SilverlightMapConnector1"); ProgressBar bar = new ProgressBar(); bar.IsIndeterminate = true; bar.BorderBrush = new SolidColorBrush(Colors.Black); bar.BorderThickness = new Thickness(2d); bar.Foreground = new SolidColorBrush(Colors.Orange); bar.Minimum = 0; bar.Maximum = 100; bar.Width = 400; bar.Height = 30; serverLayerOverlay.LoadingCanvas.Width = 400; serverLayerOverlay.LoadingCanvas.Children.Add(bar); serverLayerOverlay.IsStretchEffectDisabled = true; Map1.Overlays.Add(serverLayerOverlay); Map1.CurrentExtent = new RectangleShape(-135.7, 83.6, 113.5, -53); } } public class NewServerLayerOverlay : ServerLayerOverlay { private Canvas loadingCanvas; private int tileCount; public NewServerLayerOverlay() : base() { } public NewServerLayerOverlay(string id, string connectorId) : base(id, connectorId) { loadingCanvas = new Canvas(); } public Canvas LoadingCanvas { get { return loadingCanvas; } set { loadingCanvas = value; } } protected override void InitializeCore() { base.InitializeCore(); Canvas overlayCanvas = (Canvas)OverlayElement; loadingCanvas.SetValue(Canvas.ZIndexProperty, 9999); if (!double.IsNaN(overlayCanvas.Height)) { loadingCanvas.SetValue(Canvas.TopProperty, overlayCanvas.Height / 2); } if (!double.IsNaN(overlayCanvas.Width)) { double left = overlayCanvas.Width / 2; if (!double.IsNaN(loadingCanvas.ActualWidth)) { left -= loadingCanvas.ActualWidth / 2; } loadingCanvas.SetValue(Canvas.LeftProperty, left); } overlayCanvas.Children.Add(loadingCanvas); } protected override void DrawCore(RectangleShape worldExtent) { base.DrawCore(worldExtent); loadingCanvas.Visibility = Visibility.Visible; tileCount = 0; Canvas overlayCanvas = (Canvas)OverlayElement; foreach (UIElement element in overlayCanvas.Children) { Canvas canvas = element as Canvas; if (canvas != null) { foreach (UIElement child in canvas.Children) { Image image = child as Image; if (image != null) { tileCount++; image.ImageOpened += new EventHandler<RoutedEventArgs>(image_ImageOpened); } } } } } void image_ImageOpened(object sender, RoutedEventArgs e) { tileCount--; if (tileCount <= 0) { loadingCanvas.Visibility = Visibility.Collapsed; } } } }
using System; using System.Web.UI; using ThinkGeo.MapSuite.Core; using ThinkGeo.MapSuite.SilverlightEdition; namespace SilverlightApplication { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(MapPath("~/app_data/cntry02.shp")); worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 243, 239, 228), GeoColor.FromArgb(255, 218, 193, 163), 1); worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; ServerLayerOverlay layerOverlay = new ServerLayerOverlay("NativeServer"); layerOverlay.Layers.Add(worldLayer); SilverlightMapConnector1.ServerLayerOverlays.Add(layerOverlay); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace CenterMapBasedOnLatLong.UC { public partial class Footer : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } } }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace CenterMapBasedOnLatLong.UC { public partial class Header : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } } }
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SilverlightApplication._Default" %> <%@ Register Assembly="SilverlightMapConnector" Namespace="ThinkGeo.MapSuite.SilverlightEdition" TagPrefix="cc1" %> <%@ Register Src="UC/Footer.ascx" TagName="Footer" TagPrefix="uc1" %> <%@ Register Src="UC/Header.ascx" TagName="Header" TagPrefix="uc2" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <link href="Theme/css.css" rel="stylesheet" type="text/css" /> <title>UseProgressBar</title> </head> <body> <form id="form1" runat="server" style="height: 100%"> <table border="0px" width="100%" cellpadding="0px" cellspacing="0px" style="height: 100%;"> <tr> <td style="height: 82px;"> <uc2:Header ID="Header1" runat="server" /> </td> </tr> <tr> <td style="height: 100%; border-top: solid 1px #ece9d8;"> <div id="silverlightControlHost"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <cc1:SilverlightMapConnector ID="SilverlightMapConnector1" runat="server" Windowless="true" Width="100%" Height="100%" Source="~/ClientBin/SilverlightApplication.xap"> </cc1:SilverlightMapConnector> <div id="sourceDiv" style="position: absolute; left: 253px; top: 119px; display: none;"> <iframe id="sourceFrame" width="100%" height="100%"></iframe> </div> </div> </td> </tr> <tr> <td style="height: 50px; border-top: outset 0px #666666; background-color: #ece9d8;"> <uc1:Footer ID="Footer1" runat="server" /> </td> </tr> </table> </form> </body> </html>