User Tools

Site Tools


source_code_wpfeditionsample_showalegend_cs_110520.zip

Source Code WpfEditionSample ShowALegend CS 110520.zip

App.xaml.cs

 using System.Windows;  
 
 /// <summary>  
 /// Interaction logic for App.xaml  
 /// </summary>  
 namespace DisplayASimpleMap  
 {  
     public partial class App : Application  
     {  
     }  
 }  
 
 

Banner.xaml.cs

 using System;  
 using System.ComponentModel;  
 using System.Management;  
 using System.Windows;  
 using System.Windows.Controls;  
 using System.Windows.Media.Imaging;  
 using System.Windows.Threading;  
 
 namespace DisplayASimpleMap  
 {  
     /// <summary>  
     /// Interaction logic for SampleBanner.xaml  
     /// </summary>  
     public partial class Banner : UserControl  
     {  
         DispatcherTimer adsRotatorTimer = new DispatcherTimer();  
 
         public Banner()  
         {  
             InitializeComponent();  
 
             if (!DesignerProperties.GetIsInDesignMode(this))  
             {  
                 adsRotatorImage.Visibility = Visibility.Collapsed;  
                 AdRotatorHost.Visibility = Visibility.Visible;  
                 adsRotatorTimer.Tick += new EventHandler(timer_Tick);  
                 adsRotatorTimer.Interval = TimeSpan.FromSeconds(20);  
 
                 adsRotatorBrowser.Navigate(new Uri("http://gis.thinkgeo.com/Default.aspx?tabid=640"));  
 
                 if (IsNetworkAlive())  
                 {  
                     adsRotatorTimer.Start();  
                 }  
             }  
         }  
 
         void timer_Tick(object sender, EventArgs e)  
         {  
             adsRotatorBrowser.Navigate("http://gis.thinkgeo.com/Default.aspx?tabid=640&random=" + Guid.NewGuid().ToString());  
         }  
 
         private static bool IsNetworkAlive()  
         {  
             ObjectQuery objectQuery = new ObjectQuery("select * from Win32_NetworkAdapter where NetConnectionStatus=2");  
             ManagementObjectSearcher searcher = new ManagementObjectSearcher(objectQuery);  
             return (searcher.Get().Count > 0);  
         }  
     }  
 }  
 

Footer.xaml.cs

 using System;  
 using System.Windows.Controls;  
 using System.Windows.Input;  
 using System.Windows.Media.Imaging;  
 
 namespace DisplayASimpleMap  
 {  
     /// <summary>  
     /// Interaction logic for SampleFooter.xaml  
     /// </summary>  
     public partial class Footer : UserControl  
     {  
         public Footer()  
         {  
             InitializeComponent();  
         }  
 
         private void Products_MouseDown(object sender, MouseButtonEventArgs e)  
         {  
             System.Diagnostics.Process.Start("http://gis.thinkgeo.com/Default.aspx?tabid=802");  
         }  
 
         private void Products_MouseEnter(object sender, MouseEventArgs e)  
         {  
             Product.Source = new BitmapImage(new Uri("/Resources/btn_active_map_suite_products.png", UriKind.RelativeOrAbsolute));  
         }  
 
         private void Products_MouseLeave(object sender, MouseEventArgs e)  
         {  
             Product.Source = new BitmapImage(new Uri("/Resources/btn_inactive_map_suite_products.png", UriKind.RelativeOrAbsolute));  
         }  
 
         private void Support_MouseDown(object sender, MouseButtonEventArgs e)  
         {  
             System.Diagnostics.Process.Start("http://gis.thinkgeo.com/supportcenter");  
         }  
 
         private void Support_MouseEnter(object sender, MouseEventArgs e)  
         {  
             Support.Source = new BitmapImage(new Uri("/Resources/btn_active_support_center.png", UriKind.RelativeOrAbsolute));  
         }  
 
         private void Support_MouseLeave(object sender, MouseEventArgs e)  
         {  
             Support.Source = new BitmapImage(new Uri("/Resources/btn_inactive_support_center.png", UriKind.RelativeOrAbsolute));  
         }  
 
         private void Discussion_MouseDown(object sender, MouseButtonEventArgs e)  
         {  
             System.Diagnostics.Process.Start("http://gis.thinkgeo.com/Support/DiscussionForums/tabid/143/afv/topicsview/aff/39/Default.aspx");  
         }  
 
         private void Discussion_MouseEnter(object sender, MouseEventArgs e)  
         {  
             Discussion.Source = new BitmapImage(new Uri("/Resources/btn_active_discussion_forums.png", UriKind.RelativeOrAbsolute));  
         }  
 
         private void Discussion_MouseLeave(object sender, MouseEventArgs e)  
         {  
             Discussion.Source = new BitmapImage(new Uri("/Resources/btn_inactive_discussion_forums.png", UriKind.RelativeOrAbsolute));  
         }  
 
         private void Wiki_MouseDown(object sender, MouseButtonEventArgs e)  
         {  
             System.Diagnostics.Process.Start("http://wiki.thinkgeo.com/wiki/Map_Suite_Wpf_Desktop_Edition");  
         }  
 
         private void Wiki_MouseEnter(object sender, MouseEventArgs e)  
         {  
             Wiki.Source = new BitmapImage(new Uri("/Resources/btn_active_thinkgeo_wiki.png", UriKind.RelativeOrAbsolute));  
         }  
 
         private void Wiki_MouseLeave(object sender, MouseEventArgs e)  
         {  
             Wiki.Source = new BitmapImage(new Uri("/Resources/btn_inactive_thinkgeo_wiki.png", UriKind.RelativeOrAbsolute));  
         }  
 
         private void Contact_MouseDown(object sender, MouseButtonEventArgs e)  
         {  
             System.Diagnostics.Process.Start("http://gis.thinkgeo.com/Default.aspx?tabid=147");  
         }  
 
         private void Contact_MouseEnter(object sender, MouseEventArgs e)  
         {  
             Contact.Source = new BitmapImage(new Uri("/Resources/btn_active_contact_us.png", UriKind.RelativeOrAbsolute));  
         }  
 
         private void Contact_MouseLeave(object sender, MouseEventArgs e)  
         {  
             Contact.Source = new BitmapImage(new Uri("/Resources/btn_inactive_contact_us.png", UriKind.RelativeOrAbsolute));  
         }  
     }  
 }  
 

Sample.xaml.cs

 using System.Windows;  
 using ThinkGeo.MapSuite.Core;  
 using ThinkGeo.MapSuite.WpfDesktopEdition;  
 using System.Windows.Media.Imaging;  
 using System;  
 using System.IO;  
 
 namespace DisplayASimpleMap  
 {  
     public partial class Sample : Window  
     {  
         public Sample()  
         {  
             InitializeComponent();  
         }  
 
         private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)  
         {  
             Map1.MapUnit = GeographyUnit.DecimalDegree;  
             Map1.MapTools.Logo.IsEnabled = true;  
             Map1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);  
 
             WorldMapKitWmsWpfOverlay worldMapKitWmsWpfOverlay = new WorldMapKitWmsWpfOverlay();  
             Map1.Overlays.Add(worldMapKitWmsWpfOverlay);  
 
             BuildLegend();  
 
             Map1.CurrentExtent = new RectangleShape(-125, 42, -110, 35);  
             Map1.Refresh();  
         }  
 
         private void BuildLegend()  
         {  
             //****************************************  
             // Note:  Hard-coded styles were used in the LegendItems below to simplify the sample.  
             //        Typically, a LegendItem's ImageStyle property will be set to a style that is already  
             //        set on a layer in the map.  
             // Example:  
             //        legendItem.ImageStyle = Map1.FindFeatureLayer("myLayerName").ZoomLevelSet.ZoomLevel01.DefaultAreaStyle;  
             //  
             //****************************************  
 
             // Create a legend item for the title.  
             LegendItem title = new LegendItem();  
             title.TextStyle = new TextStyle("Map Legend", new GeoFont("Arial", 10, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.SimpleColors.Black));  
 
             // Create a legend item for the state borders.  This example uses a modified LineStyle.  
             LegendItem legendItem1 = new LegendItem();  
             LineStyle stateBorderStyle = new LineStyle();  
             stateBorderStyle.OuterPen.DashStyle = LineDashStyle.Dash;  
             stateBorderStyle.OuterPen.Width = 2;  
             stateBorderStyle.OuterPen.Color = GeoColor.FromArgb(255,156,155,154);  
             legendItem1.ImageStyle = stateBorderStyle;  
             legendItem1.TextStyle = new TextStyle("State Borders", new GeoFont("Arial", 8), new GeoSolidBrush(GeoColor.SimpleColors.Black));  
 
             // Create a legend item for the state borders.  This example uses a simple AreaStyle.  
             LegendItem legendItem2 = new LegendItem();  
             legendItem2.ImageStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 167, 204, 149));  
             legendItem2.TextStyle = new TextStyle("Forests", new GeoFont("Arial", 8), new GeoSolidBrush(GeoColor.SimpleColors.Black));  
 
             // Create A legend item for the airports.  This example uses a .png file.  
             LegendItem legendItem3 = new LegendItem();  
             legendItem3.ImageStyle = new PointStyle(new GeoImage(@"..\..\Resources\airport_small_size3.png"));  
             legendItem3.TextStyle = new TextStyle("Airports", new GeoFont("Arial", 8), new GeoSolidBrush(GeoColor.SimpleColors.Black));  
 
             // Create the LegendAdornmentLayer and add the LegendItems.  
             LegendAdornmentLayer legendLayer = new LegendAdornmentLayer();  
             legendLayer.BackgroundMask = AreaStyles.CreateLinearGradientStyle(new GeoColor(255, 255, 255, 255), new GeoColor(255, 230, 230, 230), 90, GeoColor.SimpleColors.Black);  
             legendLayer.LegendItems.Add(legendItem1);  
             legendLayer.LegendItems.Add(legendItem2);  
             legendLayer.LegendItems.Add(legendItem3);  
             legendLayer.Height = 125;  
             legendLayer.Title = title;  
             legendLayer.Location = AdornmentLocation.LowerLeft;  
 
             AdornmentOverlay adornmentOverlay = new AdornmentOverlay();  
             //adornmentOverlay.IsBase = true;  
 
             adornmentOverlay.Layers.Add("LengendLayer", legendLayer);  
             Map1.Overlays.Add(adornmentOverlay);  
         }  
     }  
 }  
 
 

InstructionPanel.cs

 using System.Windows.Controls;  
 
 namespace DisplayASimpleMap  
 {  
     public class InstructionPanel : ContentControl  
     {  
         public InstructionPanel()  
             : base()  
         {  
             DefaultStyleKey = typeof(InstructionPanel);  
         }  
     }  
 }  
 
source_code_wpfeditionsample_showalegend_cs_110520.zip.txt · Last modified: 2015/09/08 05:20 by admin