コード例 #1
0
        private void BaseMenuButton_SelectedButtonChange(object sender, MenuButtonChangeEventArgs e)
        {
            if (e.NewButton != null && e.OldButton != null)
            {
                LayerConfig oldLayerConfig = (LayerConfig)e.OldButton.Tag;
                LayerConfig newLayerConfig = (LayerConfig)e.NewButton.Tag;

                this.MapControl.Layers[oldLayerConfig.ID].Visible = false;
                this.MapControl.Layers[newLayerConfig.ID].Visible = true;

                BaseMapConfig baseConfig = AppConfig.MapConfig.BaseMap;
                if (baseConfig.EnableBase == ServiceSource.ArcGIS && baseConfig.ArcGISBaseMap.LabelLayer != null)
                {
                    string layerID = AppConfig.MapConfig.BaseMap.ArcGISBaseMap.LabelLayer.ID;
                    this.MapControl.Layers[layerID].Visible = (newLayerConfig as ArcGISBaseMapLayer).ShowLabel;
                }

                EventCenter.DispatchBaseMapLayerChangeEvent(this, new BaseMapLayerChangeEventArgs(newLayerConfig.ID));
            }
        }
コード例 #2
0
        protected override void InitializeControls()
        {
            if (AppConfig == null)
            {
                return;
            }
            if (AppConfig.TaskbarConfig == null)
            {
                return;
            }

            LogoImage.Style    = (this.CurrentApp.Resources.Contains("LogoImageStyle")) ? (this.CurrentApp.Resources["LogoImageStyle"] as Style) : null;
            StackToolbar.Style = (this.CurrentApp.Resources.Contains("AppToolbarStyle")) ? (this.CurrentApp.Resources["AppToolbarStyle"] as Style) : (this.CurrentApp.Resources["defaultAppToolbarStyle"] as Style);

            // Initialize Tool Buttons
            if (AppConfig.TaskbarConfig.MapToolButtons.Length > 0)
            {
                ToolMenuButton = new SwitchMenuButton()
                {
                    IsTabStop = true, MenuOpenMode = MenuOpenAction.MouseHover
                };                                                                                                      // Do not set Width and Height
                ToolMenuButton.Style             = (this.CurrentApp.Resources.Contains("SwitchMenuButtonStyle")) ? (this.CurrentApp.Resources["SwitchMenuButtonStyle"] as Style) : (this.CurrentApp.Resources["defaultSwitchMenuButtonStyle"] as Style);
                ToolMenuButton.MenuButtonChange += new MenuButtonChangeEventHandler(ToolMenuButton_SelectedButtonChange);
                StackToolbar.Children.Add(ToolMenuButton);

                foreach (MapToolButton btnTool in AppConfig.TaskbarConfig.MapToolButtons)
                {
                    if (btnTool.IsDefault)
                    {
                        this.toolMode = (MapActionMode)Enum.Parse(typeof(MapActionMode), btnTool.MapAction, true);
                    }
                    CircleMenuButton toolButton = new CircleMenuButton()
                    {
                        Width = 50, Height = 50, Text = btnTool.Title, Tag = btnTool.MapAction
                    };
                    toolButton.ImageSource = new BitmapImage(new Uri(btnTool.ButtonImage, UriKind.Relative));
                    toolButton.IsSelected  = btnTool.IsDefault;
                    ToolMenuButton.Items.Add(toolButton);
                }
            }

            // Initialize Base Map Toggle Button
            if (AppConfig.MapConfig.BaseMap != null)
            {
                LayerConfig[] lyrConfigs = null;
                BaseMapConfig baseConfig = AppConfig.MapConfig.BaseMap;

                if (baseConfig.EnableBase == ServiceSource.BING && baseConfig.BingBaseMap != null)
                {
                    lyrConfigs = baseConfig.BingBaseMap.Layers;
                }
                else if (baseConfig.ArcGISBaseMap != null)
                {
                    lyrConfigs = baseConfig.ArcGISBaseMap.Layers;
                }

                if ((lyrConfigs != null) && (lyrConfigs.Length > 1))
                {
                    BaseMenuButton = new SwitchMenuButton()
                    {
                        IsTabStop = true, MenuOpenMode = MenuOpenAction.MouseHover
                    };                                                                                                      // Do not set Width and Height
                    BaseMenuButton.Style             = (this.CurrentApp.Resources.Contains("SwitchMenuButtonStyle")) ? (this.CurrentApp.Resources["SwitchMenuButtonStyle"] as Style) : (this.CurrentApp.Resources["defaultSwitchMenuButtonStyle"] as Style);
                    BaseMenuButton.MenuButtonChange += new MenuButtonChangeEventHandler(BaseMenuButton_SelectedButtonChange);
                    StackToolbar.Children.Add(BaseMenuButton);

                    foreach (LayerConfig config in lyrConfigs)
                    {
                        SquareMenuButton baseButton = new SquareMenuButton()
                        {
                            Width = 50, Height = 50, Text = config.Title, Tag = config
                        };
                        baseButton.ImageSource = new BitmapImage()
                        {
                            UriSource = new Uri(config.IconSource, UriKind.Relative)
                        };
                        baseButton.IsSelected = config.VisibleInitial;
                        BaseMenuButton.Items.Add(baseButton);
                    }
                }
            }

            // Initialize Help Menu Button
            if (AppConfig.AppHelpMenu != null)
            {
                LinkMenuButton = new DropMenuButton()
                {
                    Text = "Help", Width = 50, Height = 50, VerticalContentAlignment = System.Windows.VerticalAlignment.Bottom, HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left
                };
                LinkMenuButton.Style          = (this.CurrentApp.Resources.Contains("DropMenuButtonStyle")) ? (this.CurrentApp.Resources["DropMenuButtonStyle"] as Style) : (this.CurrentApp.Resources["defaultDropMenuButtonStyle"] as Style);
                LinkMenuButton.ImageSource    = new BitmapImage(new Uri(AppConfig.AppHelpMenu.MenuIcon, UriKind.Relative));
                LinkMenuButton.MenuItemClick += new MenuItemClickEventHandler(LinkMenuButton_MenuItemClick);
                StackToolbar.Children.Add(LinkMenuButton);

                foreach (ApplicationLink link in AppConfig.AppHelpMenu.Links)
                {
                    ImageSource     iconSource = new BitmapImage(new Uri(link.Icon, UriKind.Relative));
                    ContextMenuItem menuItem   = new ContextMenuItem()
                    {
                        Text = link.Title, IconSource = iconSource, Tag = link.Url, UseSmallIcon = true, Margin = new Thickness(1)
                    };
                    menuItem.Background = new SolidColorBrush(Colors.Transparent);
                    LinkMenuButton.MenuItems.Add(menuItem);
                }

                if (AppConfig.AppHelpMenu.About != null)
                {
                    ImageSource     iconSource = new BitmapImage(new Uri(AppConfig.AppHelpMenu.About.Icon, UriKind.Relative));
                    ContextMenuItem menuItem   = new ContextMenuItem()
                    {
                        Text = AppConfig.AppHelpMenu.About.Title, IconSource = iconSource, Tag = "About", UseSmallIcon = true, Margin = new Thickness(1)
                    };
                    menuItem.Background = new SolidColorBrush(Colors.Transparent);
                    LinkMenuButton.MenuItems.Add(menuItem);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Initialize Base Map
        /// </summary>
        private void InitializeBaseMap(MapConfig mapConfig)
        {
            if (mapConfig == null || mapConfig.BaseMap == null)
            {
                return;
            }

            BaseMapConfig baseMapConfig = mapConfig.BaseMap;

            if (baseMapConfig.EnableBase == ServiceSource.ArcGIS)
            {
                foreach (ArcGISBaseMapLayer layerConfig in baseMapConfig.ArcGISBaseMap.Layers)
                {
                    CreateArcGISMapLayer(layerConfig, 1.0);
                }

                if (baseMapConfig.ArcGISBaseMap.LabelLayer != null)
                {
                    CreateArcGISMapLayer(baseMapConfig.ArcGISBaseMap.LabelLayer, 1.0);
                }
            }
            else if (baseMapConfig.EnableBase == ServiceSource.BING)
            {
                string     token      = baseMapConfig.BingBaseMap.Token;
                ServerType serverType = baseMapConfig.BingBaseMap.ServerType;

                if (string.IsNullOrEmpty(token))
                {
                    token      = CurrentApp.GetAppParamValue(MapApp.BING_TOKEN);
                    serverType = (ServerType)Enum.Parse(typeof(ServerType), CurrentApp.GetAppParamValue(MapApp.BING_SERVER), true);
                }

                foreach (BingBaseMapLayer layerConfig in baseMapConfig.BingBaseMap.Layers)
                {
                    TileLayer bingLayer = new TileLayer()
                    {
                        ID         = layerConfig.ID,
                        ServerType = serverType,
                        Visible    = layerConfig.VisibleInitial,
                        Opacity    = 1.0,
                        Token      = token
                    };

                    switch (layerConfig.LayerType)
                    {
                    case BingLayerType.Road:
                        bingLayer.LayerStyle = ESRI.ArcGIS.Client.Bing.TileLayer.LayerType.Road; break;

                    case BingLayerType.Aerial:
                        bingLayer.LayerStyle = ESRI.ArcGIS.Client.Bing.TileLayer.LayerType.Aerial; break;

                    case BingLayerType.AerialWithLabels:
                        bingLayer.LayerStyle = ESRI.ArcGIS.Client.Bing.TileLayer.LayerType.AerialWithLabels; break;
                    }

                    bingLayer.Initialized          += new EventHandler <EventArgs>(MapLayer_Initialized);
                    bingLayer.InitializationFailed += new EventHandler <EventArgs>(MapLayer_InitializationFailed);
                    myMap.Layers.Add(bingLayer);
                }
            }
        }