public static EsriMapContents.MapContents GetMapContentsControl() { if (mapContentsControl == null) mapContentsControl = MapApplication.Current.FindObjectInLayout(ControlNames.MAPCONTENTS_CONTROL_NAME) as EsriMapContents.MapContents; return mapContentsControl; }
public static EsriMapContents.MapContents GetMapContentsControl() { if (mapContentsControl == null) { mapContentsControl = MapApplication.Current.FindObjectInLayout(ControlNames.MAPCONTENTS_CONTROL_NAME) as EsriMapContents.MapContents; } return(mapContentsControl); }
public static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { MapContents source = d as MapContents; if (source != null) { source.HandleLayersChangedSubscription(e); source.OnMapChanged(); } }
public override void OnApplyTemplate() { MapContentControlContainer = GetTemplateChild(PART_MAP_CONTENT_CONTAINER_CONTROL) as ContentControl; if (MapContentControlContainer != null) { MapContentControl = new MapContents(); MapContentControl.Name = PART_MAP_CONTENT_CONTROL; MapContentControl.Map = View.Map; MapContentControl.Configuration = new MapContentsConfiguration { ContextMenuToolPanelName = "EditModeLayerConfigurationContextMenu", Mode=Mode.TopLevelLayersOnly }; if (MapContentControlContainer.Resources != null) { MapContentControl.ScrollViewerStyle = MapContentControlContainer.Resources["BuilderMapContentsScrollViewerStyle"] as Style; MapContentControl.SelectionColorBrush = MapContentControlContainer.Resources["BuilderSelectedLayerColorBrush"] as Brush; MapContentControl.SelectionOutlineColorBrush = MapContentControlContainer.Resources["BuilderSelectedLayerOutlineColorBrush"] as Brush; MapContentControl.ToggleButtonStyle = MapContentControlContainer.Resources["MapContentsControlNodeToggleButton"] as Style; } // Push foreground and background to map contents Binding b = new Binding("Foreground") { Source = this }; MapContentControl.SetBinding(MapContents.ForegroundProperty, b); b = new Binding("Background") { Source = this }; MapContentControl.SetBinding(MapContents.BackgroundProperty, b); MapContentControlContainer.Content = MapContentControl; } layerConfigurationLayout = GetTemplateChild(PART_CONFIGURE_LAYER_CONTROL_LAYOUT) as Grid; LayerConfiguration = GetTemplateChild("LayerConfigurationDialog") as LayerConfiguration; if (LayerConfiguration != null) LayerConfiguration.View = View.Instance; mapContentLayerConfigurationLayout = GetTemplateChild(PART_MAP_CONTENTS_LAYER_CONFIGURATION_LAYOUT) as Grid; if (mapContentLayerConfigurationLayout != null) { mapContentLayerConfigurationLayout.Loaded -= mapContentLayerConfigurationLayout_Loaded; mapContentLayerConfigurationLayout.Loaded += mapContentLayerConfigurationLayout_Loaded; mapContentLayerConfigurationLayout.SizeChanged -= mapContentLayerConfigurationLayout_SizeChanged; mapContentLayerConfigurationLayout.SizeChanged += mapContentLayerConfigurationLayout_SizeChanged; } mapContentsLayout = GetTemplateChild(PART_MAP_CONTENT_CONTROL_LAYOUT) as Grid; btnConfigurationComplete = GetTemplateChild(PART_CONFIGURE_COMPLETE_BUTTON) as Button; _layerConfigToolbar = GetTemplateChild(PART_TOOLPANEL) as ToolPanel; _allLayersConfigToolbar = GetTemplateChild(PART_ALLLAYERSTOOLPANEL) as ToolPanel; _mapContentsContenxtMenuToolbar = GetTemplateChild(PART_EDIT_MODE_LAYER_CONFIGURATION_CONTEXT_MENU) as ToolPanel; _layerConfigPanel = GetTemplateChild(PART_LAYERCONFIGPANEL) as FrameworkElement; InitializeToolbars(); // hide the layer configuration elements until we need them RemoveLayerConfigurationVisualElements(); }
public static void ShowMapContents() { mapContentsControl = mapContentsControl ?? GetMapContentsControl(); if (mapContentsControl != null) { mapContentsControl.Visibility = Visibility.Visible; } Control sidePanelContainer = MapApplication.Current.FindObjectInLayout(ControlNames.SIDEPANELCONTAINER) as Control; if (sidePanelContainer is TabControl) { TabControl sidePanel = sidePanelContainer as TabControl; if (mapContentsTabIndex == -1) { for (int i = 0; i < sidePanel.Items.Count; i++) { TabItem tab = sidePanel.Items[i] as TabItem; if (tab.Name == ControlNames.MAPCONTENTSTABITEM) { mapContentsTabIndex = i; break; } } } sidePanel.SelectedIndex = mapContentsTabIndex; } else if (sidePanelContainer is Accordion) { Accordion accordion = sidePanelContainer as Accordion; if (mapContentsTabIndex == -1) { for (int i = 0; i < accordion.Items.Count; i++) { AccordionItem accItem = accordion.Items[i] as AccordionItem; if (accItem.Name == ControlNames.MAPCONTENTSTABITEM) { mapContentsTabIndex = i; break; } } } accordion.SelectedIndex = mapContentsTabIndex; } }
public static void ShowMapContents() { mapContentsControl = mapContentsControl ?? GetMapContentsControl(); if (mapContentsControl != null) mapContentsControl.Visibility = Visibility.Visible; Control sidePanelContainer = MapApplication.Current.FindObjectInLayout(ControlNames.SIDEPANELCONTAINER) as Control; if (sidePanelContainer is TabControl) { TabControl sidePanel = sidePanelContainer as TabControl; if (mapContentsTabIndex == -1) { for (int i = 0; i < sidePanel.Items.Count; i++) { TabItem tab = sidePanel.Items[i] as TabItem; if (tab.Name == ControlNames.MAPCONTENTSTABITEM) { mapContentsTabIndex = i; break; } } } sidePanel.SelectedIndex = mapContentsTabIndex; } else if (sidePanelContainer is Accordion) { Accordion accordion = sidePanelContainer as Accordion; if (mapContentsTabIndex == -1) { for (int i = 0; i < accordion.Items.Count; i++) { AccordionItem accItem = accordion.Items[i] as AccordionItem; if (accItem.Name == ControlNames.MAPCONTENTSTABITEM) { mapContentsTabIndex = i; break; } } } accordion.SelectedIndex = mapContentsTabIndex; } }
public void ApplyLayout(LayoutEventArgs e) { if (e == null) return; this.Content = e.Content; Map = e.Map; if (e.AttributeTableContainer != null) { if (e.AttributeTableContainer.Content == null) { AttributeDisplay = new AttributeDisplay() { FeatureDataGrid = new FeatureDataGrid(), AutoScrollToGraphic = AutoScrollRowOnMouseOver, FilterFeaturesByMapExtent = FilterFeaturesOnMapExtentChanged, }; e.AttributeTableContainer.Content = AttributeDisplay; } else { FeatureDataGrid featureDataGrid = e.AttributeTableContainer.Content as FeatureDataGrid; if (featureDataGrid != null) { e.AttributeTableContainer.Content = null; // remove from parent AttributeDisplay = new AttributeDisplay() { FeatureDataGrid = featureDataGrid, AutoScrollToGraphic = AutoScrollRowOnMouseOver, FilterFeaturesByMapExtent = FilterFeaturesOnMapExtentChanged, }; e.AttributeTableContainer.Content = AttributeDisplay; } } if (AttributeDisplay != null && AttributeDisplay.FeatureDataGrid != null) { try { Binding binding = XamlReader.Load("<Binding xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:extensibility=\"http://schemas.esri.com/arcgis/client/extensibility/2010\" Path=\"GraphicsLayer.(extensibility:LayerProperties.IsEditable)\" />") as Binding; binding.Converter = new ReverseBooleanConverter(); binding.Source = AttributeDisplay; BindingOperations.SetBinding(AttributeDisplay.FeatureDataGrid, DataGrid.IsReadOnlyProperty, binding); } catch { //Swallow } // workaround to avoid issue where initial load of attribute table (DataGrid) crashes // Silverlight when table includes columns with numeric field names. GraphicsLayer layer = AttributeDisplay.FeatureDataGrid.GraphicsLayer; AttributeDisplay.FeatureDataGrid.GraphicsLayer = null; ToggleTableCommand cmd = new ToggleTableCommand(); RoutedEventHandler loaded = null; loaded = (o, args) => { cmd.Execute(null); AttributeDisplay.FeatureDataGrid.Loaded -= loaded; AttributeDisplay.FeatureDataGrid.GraphicsLayer = layer; }; AttributeDisplay.FeatureDataGrid.Loaded += loaded; cmd.Execute(null); } } if (e.ScaleBarContainer != null && e.ScaleBarContainer.Content == null) { e.ScaleBarContainer.Content = ScaleBar = new ScaleBar() { TargetWidth = 150, MapUnit = MapUnit.Undefined, }; } if (e.ProgressIndicatorContainer != null && e.ProgressIndicatorContainer.Content == null) { e.ProgressIndicatorContainer.Content = ProgressGauge = new ProgressGauge(); } if (e.AttributionDisplayContainer != null && e.AttributionDisplayContainer.Content == null) { e.AttributionDisplayContainer.Content = AttributionDisplayControl = new AttributionDisplayControl() { Foreground = e.AttributionDisplayContainer.Foreground, }; AttributionDisplayControl.SetBinding(FrameworkElement.VisibilityProperty, new System.Windows.Data.Binding("Visibility") { Source = e.AttributionDisplayContainer, Mode = System.Windows.Data.BindingMode.TwoWay }); } Editor = MapApplication.Current.FindObjectInLayout(ControlNames.EDITORWIDGET) as EditorWidget; if (e.EditorConfigContainer != null && e.EditorConfigContainer.Content == null) { EditorConfigControl = new GenericConfigControl(); EditorConfigControl.Name = "EditorConfiguration"; EditorConfigControl.Title = Controls.Resources.Strings.ConfigureEditorWidget; EditorConfigControl.Command = new ConfigureEditorCommand() { Map = Map }; ElementExtensions.SetIsConfigurable(EditorConfigControl, true); object[] attributes = typeof(ToggleEditCommand).GetCustomAttributes(typeof(DisplayNameAttribute), false); if (attributes.Length > 0 && !string.IsNullOrEmpty(((DisplayNameAttribute)attributes[0]).Name)) ElementExtensions.SetDisplayName(EditorConfigControl, ((DisplayNameAttribute)attributes[0]).Name); e.EditorConfigContainer.Content = EditorConfigControl; // When done in XAML the binding doesn't work properly until the editorwidget is made visible. if (Editor != null) { BindingOperations.SetBinding(Editor, EditorWidget.AlwaysDisplayDefaultTemplatesProperty, new Binding("DataContext.AlwaysDisplayDefaultTemplates") { Source = e.EditorConfigContainer }); BindingOperations.SetBinding(Editor, EditorWidget.AutoCompleteProperty, new Binding("DataContext.AutoComplete") { Source = e.EditorConfigContainer, Mode = BindingMode.TwoWay }); BindingOperations.SetBinding(Editor, EditorWidget.AutoSelectProperty, new Binding("DataContext.AutoSelect") { Source = e.EditorConfigContainer }); BindingOperations.SetBinding(Editor, EditorWidget.ContinuousProperty, new Binding("DataContext.Continuous") { Source = e.EditorConfigContainer }); BindingOperations.SetBinding(Editor, EditorWidget.EditVerticesEnabledProperty, new Binding("DataContext.EditVerticesEnabled") { Source = e.EditorConfigContainer }); BindingOperations.SetBinding(Editor, EditorWidget.FreehandProperty, new Binding("DataContext.Freehand") { Source = e.EditorConfigContainer, Mode = BindingMode.TwoWay }); BindingOperations.SetBinding(Editor, EditorWidget.MaintainAspectRatioProperty, new Binding("DataContext.MaintainAspectRatio") { Source = e.EditorConfigContainer }); BindingOperations.SetBinding(Editor, EditorWidget.MoveEnabledProperty, new Binding("DataContext.MoveEnabled") { Source = e.EditorConfigContainer }); BindingOperations.SetBinding(Editor, EditorWidget.RotateEnabledProperty, new Binding("DataContext.RotateEnabled") { Source = e.EditorConfigContainer }); BindingOperations.SetBinding(Editor, EditorWidget.ScaleEnabledProperty, new Binding("DataContext.ScaleEnabled") { Source = e.EditorConfigContainer }); BindingOperations.SetBinding(Editor, EditorWidget.LayerIDsProperty, new Binding("DataContext.LayerIds") { Source = e.EditorConfigContainer }); } } ContentControl container = MapApplication.Current.FindObjectInLayout(ControlNames.ADDCONTENTCONTROLCONTAINER) as ContentControl; if (container != null) { AddContentDialog addContentDialog = new AddContentDialog() { DataSourceProvider = DataSourceProvider, ConnectionsProvider = ConnectionsProvider, BorderThickness = new Thickness(0), Map = Map, }; addContentDialog.LayerAdded += AddContentDialog_LayerAdded; addContentDialog.LayerAddFailed += AddContentDialog_LayerAddFailed; container.Content = addContentDialog; } container = MapApplication.Current.FindObjectInLayout(ControlNames.MAPCONTENTS_CONTROL_CONTAINER_NAME) as ContentControl; if (container != null) { MapContents = new EsriMapContents.MapContents(); MapContents.Name = ControlNames.MAPCONTENTS_CONTROL_NAME; ElementExtensions.SetIsConfigurable(MapContents, true); object[] attributes = typeof(ToggleMapContentsCommand).GetCustomAttributes(typeof(DisplayNameAttribute), false); if (attributes.Length > 0 && !string.IsNullOrEmpty(((DisplayNameAttribute)attributes[0]).Name)) ElementExtensions.SetDisplayName(MapContents, ((DisplayNameAttribute)attributes[0]).Name); MapContents.Map = Map; container.Content = MapContents; // Push container foreground and background to Map Contents Binding b = new Binding("Foreground") { Source = container }; MapContents.SetBinding(EsriMapContents.MapContents.ForegroundProperty, b); b = new Binding("Background") { Source = container }; MapContents.SetBinding(EsriMapContents.MapContents.BackgroundProperty, b); } if (Editor != null) Editor.Map = Map; WindowManager.FloatingWindowStyle = LayoutStyleHelper.Instance.GetStyle(WindowManager.FloatingWindowStyleKey); // Set the logic to be executed when an authentication challenge occurs IdentityManager.Current.ChallengeMethod = OnChallenge; if (!listeningToCredentials) { // Listen for changes in the application environment's set of credentials, setting a flag to // ensure that this is only done once. listeningToCredentials = true; UserManagement.Current.Credentials.CollectionChanged += Credentials_CollectionChanged; } AttachToControlEvents(); SubscribeToSymbolConfigProviderEvents(); }
public static void Reset() { mapContentsControl = null; mapContentsTabIndex = -1; }
void AssociatedObject_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { MapContents cont = ControlTreeHelper.FindAncestorOfType <MapContents>(AssociatedObject); if (cont == null) { return; } MapContentsConfiguration conf = cont.DataContext as MapContentsConfiguration; if (conf == null) { return; } if (ToolPanels.Current != null && !string.IsNullOrWhiteSpace(conf.ContextMenuToolPanelName)) { _toolPanel = ToolPanels.Current[conf.ContextMenuToolPanelName]; } if (_toolPanel == null) { return; } _contextMenu = new ContextMenu(); if (ContextMenuStyle != null) { _contextMenu.Style = ContextMenuStyle; } // Bind background and foreground properties to context menu Binding b = new Binding("ContextMenuBackground") { Source = this }; _contextMenu.SetBinding(ContextMenu.BackgroundProperty, b); b = new Binding("ContextMenuForeground") { Source = this }; _contextMenu.SetBinding(ContextMenu.ForegroundProperty, b); // set the control to the current culture settings (LTR/RTL) RTLHelper helper = System.Windows.Application.Current.Resources["RTLHelper"] as RTLHelper; Debug.Assert(helper != null); if (helper != null) { _contextMenu.FlowDirection = helper.FlowDirection; } foreach (FrameworkElement button in _toolPanel.ToolPanelItems) { System.Windows.Controls.Primitives.ButtonBase btnBase = button as System.Windows.Controls.Primitives.ButtonBase; if (btnBase != null) { MenuItem item = new MenuItem(); ButtonDisplayInfo info = btnBase.DataContext as ButtonDisplayInfo; if (info != null) { item.Header = info.Label; if (!string.IsNullOrEmpty(info.Icon)) { Image image = new Image(); Binding binding = new Binding("Icon") { Converter = _urlResolver }; image.SetBinding(Image.SourceProperty, binding); image.DataContext = info; item.Icon = image; } item.Command = btnBase.Command; _contextMenu.Items.Add(item); } } else { _contextMenu.Items.Add(new Separator()); } } Point point = e.GetPosition(null); if (point != null) { _contextMenu.HorizontalOffset = point.X; _contextMenu.VerticalOffset = point.Y; } LayerItemViewModel layerViewModel = AssociatedObject.DataContext as LayerItemViewModel; if (layerViewModel != null && layerViewModel.Layer != null) { if (!CoreExtensions.GetIsSelected(layerViewModel.Layer)) { SetSelectedLayer(layerViewModel.Layer); } } if (_contextMenu.Items.Count > 0) { _contextMenu.IsOpen = true; if (_contextMenu.FlowDirection == FlowDirection.RightToLeft) { // Now that the popup is open, we can update the layout measurements so that // the ActualWidth is available. _contextMenu.UpdateLayout(); _contextMenu.HorizontalOffset -= _contextMenu.ActualWidth; } } }