예제 #1
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (CurrentApp.AppConfig != null)
            {
                InitializeBaseMap(CurrentApp.AppConfig.MapConfig);
                InitializeLiveMaps(CurrentApp.AppConfig.MapConfig);

                //Load widgets after map layers are added to ensuer graphcis layer on the top
                LoadWidgets(CurrentApp.AppConfig.WidgetsConfig);

                if (!string.IsNullOrEmpty(CurrentApp.AppConfig.OverviewMapConfigFile))
                {
                    OverviewMapWidget overviewWidget = new OverviewMapWidget()
                    {
                        Margin = new Thickness(0, 0, 0, 0)
                    };
                    overviewWidget.ConfigFile = CurrentApp.AppConfig.OverviewMapConfigFile;
                    overviewWidget.MapControl = this.myMap;
                    LayoutRoot.Children.Add(overviewWidget);
                }

                if (this.CurrentApp.Resources.Contains("NavigatorStyle"))
                {
                    myNavigator.Style = this.CurrentApp.Resources["NavigatorStyle"] as Style;
                }

                if (this.CurrentApp.Resources.Contains("TaskbarStyle"))
                {
                    myTaskbarWidget.Style = this.CurrentApp.Resources["TaskbarStyle"] as Style;
                }
            }
        }
예제 #2
0
        private static void TargetElement_Loaded(object sender, RoutedEventArgs e)
        {
            if (sender == null)
            {
                return;
            }

            if (sender is WidgetBase)
            {
                WidgetBase targetElement = sender as WidgetBase;

                // Get the value of our attached property
                MapBindingProperties bindingProperties = GetBinding(targetElement);

                // Find the Map control on the Page
                if (targetElement.CurrentPage != null)
                {
                    ESRI.ArcGIS.Client.Map sourceElement = targetElement.CurrentPage.FindName(bindingProperties.SourceElement) as ESRI.ArcGIS.Client.Map;
                    targetElement.MapControl = sourceElement;

                    //string targetPropertyName = bindingProperties.TargetProperty + "Property";
                    //FieldInfo[] targetFields = targetElement.GetType().GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
                    //FieldInfo targetPropertyField = targetFields.First(f => f.Name == targetPropertyName);
                    //DependencyProperty targetDependencyProperty = targetPropertyField.GetValue(null) as DependencyProperty;

                    // Bind the Map to the target property
                    //targetElement.SetValue(targetDependencyProperty, sourceElement);
                }
            }
            else if (sender is TaskbarBase)
            {
                TaskbarBase          targetElement     = sender as TaskbarBase;
                MapBindingProperties bindingProperties = GetBinding(targetElement);

                // Find the Map control on the Page
                if (targetElement.CurrentPage != null)
                {
                    ESRI.ArcGIS.Client.Map sourceElement = targetElement.CurrentPage.FindName(bindingProperties.SourceElement) as ESRI.ArcGIS.Client.Map;
                    targetElement.MapControl = sourceElement;
                }
            }
            else if (sender is OverviewMapWidget)
            {
                OverviewMapWidget    targetElement     = sender as OverviewMapWidget;
                MapBindingProperties bindingProperties = GetBinding(targetElement);

                // Find the Map control on the Page
                if (targetElement.CurrentPage != null)
                {
                    ESRI.ArcGIS.Client.Map sourceElement = targetElement.CurrentPage.FindName(bindingProperties.SourceElement) as ESRI.ArcGIS.Client.Map;
                    targetElement.MapControl = sourceElement;
                }
            }
        }