public override void Execute(object parameter) { if (browseDialog == null) { browseDialog = new AddContentDialog() { DataSourceProvider = GetDataSourceProvider(), ConnectionsProvider = GetConnectionsProvider(), Width = 300, Margin = new Thickness(10), Map = MapApplication.Current.Map }; browseDialog.LayerAdded += browseDialog_LayerAdded; browseDialog.LayerAddFailed += browseDialog_LayerAddFailed; } else { browseDialog.Reset(); } double height = GetViewHeight() - 100; if (height < 100) { height = 100; } browseDialog.Height = height > 300 ? 300 : height; MapApplication.Current.ShowWindow(Resources.Strings.SelectLayerToAdd, browseDialog, false, null, null); }
public override void OnApplyTemplate() { if (MapContentLayerConfigurationHost != null) { MapContentLayerConfigurationHost.LayerSelectionChanged -= MapContentsControl_LayerSelectionChanged; } if (SidePanelTabControl != null) { SidePanelTabControl.SelectionChanged -= SidePanelTabControl_SelectionChanged; } if (AddContentDialog != null) { AddContentDialog.LayerAdded -= AddContentDialog_LayerAdded; AddContentDialog.LayerAddFailed -= AddContentDialog_LayerAddFailed; } #if SILVERLIGHT if (SearchControl != null) { SearchControl.LayerSelectedForAdd -= SearchControl_LayerSelectedForAdd; SearchControl.NoteSelectedForAdd -= SearchControl_NoteSelectedForAdd; } #endif base.OnApplyTemplate(); MapContentLayerConfigurationHost = GetTemplateChild(PART_MAPCONTENTSCONTROL) as MapContentLayerConfigurationHost; if (MapContentLayerConfigurationHost != null) { MapContentLayerConfigurationHost.LayerSelectionChanged += MapContentsControl_LayerSelectionChanged; } SidePanelTabControl = GetTemplateChild(PART_SIDEPANELTABCONTROL) as TabControl; if (SidePanelTabControl != null) { SidePanelTabControl.SelectionChanged += SidePanelTabControl_SelectionChanged; } AddContentDialog = GetTemplateChild(PART_ADDCONTENTCONTROL) as AddContentDialog; if (AddContentDialog != null) { AddContentDialog.DataSourceProvider = DataSourceProvider; AddContentDialog.ConnectionsProvider = ConnectionsProvider; AddContentDialog.Map = Map; AddContentDialog.LayerAdded += AddContentDialog_LayerAdded; AddContentDialog.LayerAddFailed += AddContentDialog_LayerAddFailed; } #if SILVERLIGHT SearchControl = GetTemplateChild("SearchControl") as ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.SearchControl; if (SearchControl != null) { SearchControl.LayerSelectedForAdd += SearchControl_LayerSelectedForAdd; SearchControl.NoteSelectedForAdd += SearchControl_NoteSelectedForAdd; } #endif }
public override void OnApplyTemplate() { if (MapContentLayerConfigurationHost != null) { MapContentLayerConfigurationHost.LayerSelectionChanged -= MapContentsControl_LayerSelectionChanged; } if (SidePanelTabControl != null) SidePanelTabControl.SelectionChanged -= SidePanelTabControl_SelectionChanged; if (AddContentDialog != null) { AddContentDialog.LayerAdded -= AddContentDialog_LayerAdded; AddContentDialog.LayerAddFailed -= AddContentDialog_LayerAddFailed; } #if SILVERLIGHT if (SearchControl != null) { SearchControl.LayerSelectedForAdd -= SearchControl_LayerSelectedForAdd; SearchControl.NoteSelectedForAdd -= SearchControl_NoteSelectedForAdd; } #endif base.OnApplyTemplate(); MapContentLayerConfigurationHost = GetTemplateChild(PART_MAPCONTENTSCONTROL) as MapContentLayerConfigurationHost; if (MapContentLayerConfigurationHost != null) { MapContentLayerConfigurationHost.LayerSelectionChanged += MapContentsControl_LayerSelectionChanged; } SidePanelTabControl = GetTemplateChild(PART_SIDEPANELTABCONTROL) as TabControl; if (SidePanelTabControl != null) SidePanelTabControl.SelectionChanged += SidePanelTabControl_SelectionChanged; AddContentDialog = GetTemplateChild(PART_ADDCONTENTCONTROL) as AddContentDialog; if (AddContentDialog != null) { AddContentDialog.DataSourceProvider = DataSourceProvider; AddContentDialog.ConnectionsProvider = ConnectionsProvider; AddContentDialog.Map = Map; AddContentDialog.LayerAdded += AddContentDialog_LayerAdded; AddContentDialog.LayerAddFailed += AddContentDialog_LayerAddFailed; } #if SILVERLIGHT SearchControl = GetTemplateChild("SearchControl") as ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.SearchControl; if (SearchControl != null) { SearchControl.LayerSelectedForAdd += SearchControl_LayerSelectedForAdd; SearchControl.NoteSelectedForAdd += SearchControl_NoteSelectedForAdd; } #endif }
public void BrowseForLayer(EventHandler<BrowseForLayerCompletedEventArgs> onComplete, object userState = null) { AddContentDialog browseDialog = new AddContentDialog() { MaxHeight = Application.Current.RootVisual.RenderSize.Height - 200, Height = 600, Width = 500, }; browseDialog.ConnectionsProvider = View.Instance.ConnectionsProvider; browseDialog.LayerAdded += new EventHandler<LayerAddedEventArgs>(browseDialog_LayerAdded); browseDialog.Tag = new object[] { onComplete, userState }; MapApplication.Current.ShowWindow(ESRI.ArcGIS.Mapping.Builder.Resources.Strings.BrowseForResource, browseDialog, true); }
public override void Execute(object parameter) { if (browseDialog == null) { browseDialog = new AddContentDialog() { DataSourceProvider = GetDataSourceProvider(), ConnectionsProvider = GetConnectionsProvider(), Width = 300, Margin = new Thickness(10), Map = MapApplication.Current.Map }; browseDialog.LayerAdded += browseDialog_LayerAdded; browseDialog.LayerAddFailed +=browseDialog_LayerAddFailed; } else browseDialog.Reset(); double height = GetViewHeight() - 100; if (height < 100) height = 100; browseDialog.Height = height > 300 ? 300 : height; MapApplication.Current.ShowWindow(Resources.Strings.SelectLayerToAdd, browseDialog, false, null, null); }
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(); }