private void bindUI() { if (graphicsLayer == null) { this.IsEnabled = false; return; } GeometryType goemType = LayerExtensions.GetGeometryType(graphicsLayer); //Point layers only if (goemType != GeometryType.Point) { this.IsEnabled = false; return; } this.IsEnabled = true; FlareClusterer clusterer = graphicsLayer.Clusterer as FlareClusterer; if (clusterer == null) { bindClustererToUI(new FlareClusterer());//bind to defaults from new clusterer } else { bindClustererToUI(clusterer); } }
protected override void WriteAttributes(Layer layer) { base.WriteAttributes(layer); ArcGISImageServiceLayer imageServiceLayer = layer as ArcGISImageServiceLayer; if (imageServiceLayer != null) { WriteAttribute("Url", imageServiceLayer.Url); if (!LayerExtensions.GetUsesProxy(layer)) { if (!string.IsNullOrEmpty(imageServiceLayer.ProxyURL)) { WriteAttribute("ProxyURL", imageServiceLayer.ProxyURL); } if (!string.IsNullOrEmpty(imageServiceLayer.Token)) { WriteAttribute("Token", imageServiceLayer.Token); } } WriteAttribute("ImageFormat", imageServiceLayer.ImageFormat.ToString()); if (imageServiceLayer.BandIds != null && imageServiceLayer.BandIds.Length > 0) { WriteAttribute("BandIds", string.Join(",", imageServiceLayer.BandIds)); } } }
public LayerAutoUpdateHelper() { _delayTimer.Interval = new TimeSpan(0, 0, SettingsChangedDelay); _delayTimer.Tick += (s, e) => { _delayTimer.Stop(); bool immediateUpdate = UpdateNow; UpdateNow = false; if (FilteredLayer != null) { Interval = (int)LayerExtensions.GetAutoUpdateInterval(FilteredLayer); if (IsEnabled) { StopRefreshTimer(); if (immediateUpdate) { UpdateLayer(FilteredLayer); } if (Interval > 0) { StartRefreshTimer(); } } } }; }
protected override void WriteAttributes(Layer layer) { base.WriteAttributes(layer); KmlLayer kmlLayer = layer as KmlLayer; if (kmlLayer != null) { if (kmlLayer.Url != null) { writer.WriteAttributeString("Url", kmlLayer.Url.OriginalString); } if (!LayerExtensions.GetUsesProxy(layer) && !string.IsNullOrEmpty(kmlLayer.ProxyUrl)) { WriteAttribute("ProxyUrl", kmlLayer.ProxyUrl); } writer.WriteAttributeString("DisableClientCaching", kmlLayer.DisableClientCaching.ToString()); if (kmlLayer.RefreshInterval != null) { writer.WriteAttributeString("RefreshInterval", kmlLayer.RefreshInterval.ToString()); } IEnumerable <int> visibleLayerIDs = kmlLayer.GenerateVisibilityIDs(); if (visibleLayerIDs.Count() > 0) { writer.WriteElementString(Constants.esriMappingPrefix, "KmlLayerExtensions.VisibleLayerIDs", Constants.esriMappingNamespace, visibleLayerIDs.Select(p => p.ToString()).Aggregate((id1, id2) => id1 + "," + id2)); } } }
public void Unmask(int objectLayer) { if (LayerExtensions.IsLayerNumberValid(objectLayer)) { _layerMask &= ~(1 << objectLayer); } }
/// <summary> /// Adds a suffix to a graphics layer indicating the type of geometry the layer contains /// </summary> /// <param name="layer">The layer to add the suffix to</param> /// <remarks> /// The method will not append the suffix of the layer name already ends with it, provided the /// original name is stored in the WebMapDisplayName attached property. /// </remarks> internal static void AppendGeometryToLayerName(this GraphicsLayer layer) { string currentName = ESRI.ArcGIS.Client.Extensibility.MapApplication.GetLayerName(layer); string originalName = MapExtensions.GetWebMapDisplayName(layer); string nameAsResourceString = originalName != null?currentName.Replace(originalName, "{0}") : currentName; if (nameAsResourceString != esriControlsResources.Strings.AreaNotesLayer && nameAsResourceString != esriControlsResources.Strings.LineNotesLayer && nameAsResourceString != esriControlsResources.Strings.PointNotesLayer) { string currentNameWithGeometry = currentName; GeometryType geometryType = LayerExtensions.GetGeometryType(layer); switch (geometryType) { case GeometryType.Point: currentNameWithGeometry = string.Format(esriControlsResources.Strings.PointNotesLayer, currentName); break; case GeometryType.Polyline: currentNameWithGeometry = string.Format(esriControlsResources.Strings.LineNotesLayer, currentName); break; case GeometryType.Polygon: currentNameWithGeometry = string.Format(esriControlsResources.Strings.AreaNotesLayer, currentName); break; } MapExtensions.SetWebMapDisplayName(layer, currentName); ESRI.ArcGIS.Client.Extensibility.MapApplication.SetLayerName(layer, currentNameWithGeometry); layer.DisplayName = currentNameWithGeometry; } }
// set hide delay for added GraphicsLayers private void LayersCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.OldItems != null) { // stop all auto-updates for layers that have been removed from the View's collection foreach (var layer in e.OldItems) { if (layer is GraphicsLayer && LayerExtensions.GetAutoUpdateInterval((GraphicsLayer)layer) > 0) { LayerExtensions.SetAutoUpdateInterval((GraphicsLayer)layer, 0); } } } if (AssociatedObject == null || AssociatedObject.Layers == null || AssociatedObject.Layers.Count <= 0) { return; } // we don't care what type of change happened to the layers collection, we only want // the current existing FeatureLayers/DynamicLayers in the Map List <Layer> filteredList = GetMapFilteredLayers(); SetLayerAutoUpdate(filteredList); }
void ToggleAllVisibilityButton_Click(object sender, RoutedEventArgs e) { bool visible = !isClearAllState; if (LayerInfo == null || LayerInfo.Fields == null) { return; } IEnumerable <FieldInfo> fields = LayerInfo.Fields as IEnumerable <FieldInfo>; if (fields == null) { return; } foreach (FieldInfo field in fields) { field.VisibleOnMapTip = visible; } isClearAllState = !isClearAllState; VisualStateManager.GoToState(this, isClearAllState ? "ClearAllState" : "SelectAllState", false); // For feature layers - add the name of the field to the OutFields collection FeatureLayer featureLayer = Layer as FeatureLayer; if (featureLayer == null) { return; } reBuildOutFields(featureLayer, fields); LayerExtensions.SetIsMapTipDirty(featureLayer, true); }
private void AssociatedObject_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (!doubleClick) //single click { timer.Start(); doubleClick = true; //mark as doubleclick until timer ellapses if (this.AssociatedObject != null) { LayerItemViewModel layerViewModel = AssociatedObject.DataContext as LayerItemViewModel; if (layerViewModel != null) { if ((MapApplication.Current != null && !MapApplication.Current.IsEditMode) || layerViewModel.Layer == null || (layerViewModel.Layer != null && LayerExtensions.GetInitialUpdateFailed(layerViewModel.Layer))) { return; } isSelected = MapApplication.Current != null ? MapApplication.Current.SelectedLayer == layerViewModel.Layer : false;//has already been selected programmatically (non-user selection) if (layerViewModel.Layer != null) { lazyClick = isSelected; //if user selects between multiple layers on map contents, reset lazyclick } } } } else //double click { lazyClick = false; } }
protected override void WriteAttributes(Layer layer) { base.WriteAttributes(layer); ArcGISTiledMapServiceLayer tiledLayer = layer as ArcGISTiledMapServiceLayer; if (tiledLayer != null) { WriteAttribute("Url", tiledLayer.Url); if (!LayerExtensions.GetUsesProxy(layer)) { if (!string.IsNullOrEmpty(tiledLayer.ProxyURL)) { WriteAttribute("ProxyURL", tiledLayer.ProxyURL); } if (!string.IsNullOrEmpty(tiledLayer.Token)) { WriteAttribute("Token", tiledLayer.Token); } } if (!double.IsInfinity(tiledLayer.MaximumResolution) && !double.IsNaN(tiledLayer.MaximumResolution)) { WriteAttribute("MaximumResolution", tiledLayer.MaximumResolution); } if (!double.IsInfinity(tiledLayer.MinimumResolution) && !double.IsNaN(tiledLayer.MinimumResolution)) { WriteAttribute("MinimumResolution", tiledLayer.MinimumResolution); } } }
private void SetFeatureLayerPropsFromLayerInfo(FeatureLayer fLayer) { if (fLayer == null || fLayer.LayerInfo == null) { return; } if (string.IsNullOrWhiteSpace(LayerExtensions.GetDisplayUrl(fLayer))) { fLayer.SetValue(LayerExtensions.DisplayUrlProperty, fLayer.Url); } if (!string.IsNullOrWhiteSpace(fLayer.LayerInfo.DisplayField) && string.IsNullOrWhiteSpace(LayerExtensions.GetDisplayField(fLayer))) { fLayer.SetValue(LayerExtensions.DisplayFieldProperty, fLayer.LayerInfo.DisplayField); } if (LayerExtensions.GetGeometryType(fLayer) == GeometryType.Unknown) { if (fLayer.LayerInfo.GeometryType == ESRI.ArcGIS.Client.Tasks.GeometryType.Point) { fLayer.SetValue(LayerExtensions.GeometryTypeProperty, GeometryType.Point); } if (fLayer.LayerInfo.GeometryType == ESRI.ArcGIS.Client.Tasks.GeometryType.MultiPoint) { fLayer.SetValue(LayerExtensions.GeometryTypeProperty, GeometryType.MultiPoint); } else if (fLayer.LayerInfo.GeometryType == ESRI.ArcGIS.Client.Tasks.GeometryType.Polyline) { fLayer.SetValue(LayerExtensions.GeometryTypeProperty, GeometryType.Polyline); } else if (fLayer.LayerInfo.GeometryType == ESRI.ArcGIS.Client.Tasks.GeometryType.Polygon) { fLayer.SetValue(LayerExtensions.GeometryTypeProperty, GeometryType.Polygon); } } if (fLayer.LayerInfo.Fields != null) { Collection <FieldInfo> layerFields = LayerExtensions.GetFields(fLayer); if (layerFields.Count == 0) // fields not determined yet { Collection <FieldInfo> fieldInfos = new Collection <FieldInfo>(); foreach (ESRI.ArcGIS.Client.Field field in fLayer.LayerInfo.Fields) { if (FieldHelper.IsFieldFilteredOut(field.Type)) { continue; } FieldInfo f = ESRI.ArcGIS.Mapping.Core.FieldInfo.FieldInfoFromField(fLayer, field); fieldInfos.Add(f); } fLayer.SetValue(LayerExtensions.FieldsProperty, fieldInfos); } } }
void onLayerInfosCompleted(LayerInfosEventArgs e) { LayerExtensions.SetLayerInfos(Layer, e.LayerInfos); if (GetLayerInfosCompleted != null) { GetLayerInfosCompleted(this, e); } }
public static Symbol GetDefaultSymbolClone(this GraphicsLayer layer) { if (layer != null) { GeometryType type = LayerExtensions.GetGeometryType(layer); return(GetDefaultSymbolClone(layer.Renderer, type)); } return(null); }
private void RenderLayerMaskEntries() { List <string> allLayerNames = LayerExtensions.GetAllAvailableLayerNames(); foreach (string layerName in allLayerNames) { RenderLayerMaskEntry(layerName); } }
public AttackController(ReactiveCollection <Info> bullets) { m_Bullets = bullets; m_AsteroidLayer = LayerExtensions.GetLayer(LayerExtensions.Layers.Enemy); m_Bullets .ObserveAdd() .Subscribe(AddToCollection); }
private void UpdateOnExtentChanged_Checked(object sender, RoutedEventArgs e) { if (!LayerAutoUpdateBehavior.IsLayerAutoUpdateCapable(Layer)) { return; } LayerExtensions.SetAutoUpdateOnExtentChanged(Layer, true); }
public AttackController(ReactiveCollection <Info> enemies) { m_Enemies = enemies; m_Enemies .ObserveAdd() .Subscribe(AddToCollection); m_PlayerLayer = LayerExtensions.GetLayer(LayerExtensions.Layers.Player); m_AsteroidLayer = LayerExtensions.GetLayer(LayerExtensions.Layers.Enemy); }
private void bindUIToLayer() { if (!(LayerAutoUpdateBehavior.IsLayerAutoUpdateCapable(Layer))) { IsEnabled = false; return; } IsEnabled = true; // Get the layer settings from LayerExtensions attached properties double interval = Math.Max(0, LayerExtensions.GetAutoUpdateInterval(Layer)); bool autoUpdatesEnabled = (interval > 0.0d); if (PollForUpdates != null) { PollForUpdates.IsChecked = autoUpdatesEnabled; } if (PollInterval != null && IntervalType != null) { _uiChanging = true; try { if (autoUpdatesEnabled) { // if the interval > 60000, we need to display the interval in minutes if (interval >= 60000d) { IntervalType.SelectedIndex = 1; // minutes PollInterval.Value = ((int)(interval / 60000d)); } else { IntervalType.SelectedIndex = 0; PollInterval.Value = ((int)(interval / 1000d)); } } else { IntervalType.SelectedIndex = 0; PollInterval.Value = 0; } } finally { _uiChanging = false; } } if (UpdateOnExtentChanged != null) { UpdateOnExtentChanged.IsChecked = LayerExtensions.GetAutoUpdateOnExtentChanged(Layer); } }
public void RemoveObjectsFromLayer(List <GameObject> gameObjects, int objectLayer) { if (objectLayer == LayerExtensions.GetDefaultLayer()) { return; } List <GameObject> gameObjectsInLayer = gameObjects.FindAll(item => item.layer == objectLayer); GameObjectExtensions.AssignGameObjectsToLayer(gameObjectsInLayer, LayerExtensions.GetDefaultLayer(), true); }
private void IntervalType_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (_uiChanging || PollInterval == null || IntervalType == null || !(LayerAutoUpdateBehavior.IsLayerAutoUpdateCapable(Layer))) { return; } double interval = GetIntervalFromUi(); LayerExtensions.SetAutoUpdateInterval(Layer, interval); }
private void PollInterval_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (_uiChanging || PollInterval == null || IntervalType == null || !LayerAutoUpdateBehavior.IsLayerAutoUpdateCapable(Layer)) { return; } double interval = GetIntervalFromUi(); LayerExtensions.SetAutoUpdateInterval(Layer, interval); }
/*TODO: Serialize the following * * public bool DisableClientCaching { get; set; } * public Geometry Geometry { get; set; } * */ private void WriteHeatMapFeatureLayer(HeatMapFeatureLayer layer) { WriteAttribute("Url", layer.Url); if (!string.IsNullOrEmpty(layer.Where)) { WriteAttribute("Where", layer.Where); } if (!LayerExtensions.GetUsesProxy(layer)) { if (!string.IsNullOrEmpty(layer.ProxyUrl)) { WriteAttribute("ProxyUrl", layer.ProxyUrl); } if (!string.IsNullOrEmpty(layer.Token)) { WriteAttribute("Token", layer.Token); } } if (!string.IsNullOrEmpty(layer.Text)) { WriteAttribute("Text", layer.Text); } if (layer.MinimumResolution > double.Epsilon) { WriteAttribute("MinimumResolution", layer.MinimumResolution); } if (layer.MaximumResolution < double.MaxValue) { WriteAttribute("MaximumResolution", layer.MaximumResolution); } if (!double.IsNaN(layer.Intensity)) { WriteAttribute("Intensity", layer.Intensity); } if (layer.MapSpatialReference != null) { WriteSpatialReferenceAsAttribute("MapSpatialReference", layer.MapSpatialReference); } if (layer.Gradient != null) { writer.WriteStartElement("HeatMapFeatureLayer.Gradient", Namespaces[Constants.esriMappingPrefix]); writer.WriteStartElement("GradientStopCollection"); new BrushXamlWriter(writer, Namespaces).WriteGradientStops(layer.Gradient); writer.WriteEndElement(); writer.WriteEndElement(); } WriteBaseElementContents(layer); }
private void bindToGraphicsLayer(GraphicsLayer graphicsLayer) { object fields = graphicsLayer.GetValue(LayerExtensions.FieldsProperty); if (fields is IEnumerable <FieldInfo> ) { string displayField = LayerExtensions.GetDisplayField(graphicsLayer); if (string.IsNullOrEmpty(displayField)) { displayField = FieldInfo.GetDefaultDisplayField(fields as IEnumerable <FieldInfo>); if (!string.IsNullOrEmpty(displayField)) { LayerExtensions.SetDisplayField(graphicsLayer, displayField); } } #region Set data context MapTipsConfigInfo info = new MapTipsConfigInfo() { LayerSelectionVisibility = false, PopUpsOnClick = LayerExtensions.GetPopUpsOnClick(graphicsLayer), IsPopupEnabled = ESRI.ArcGIS.Client.Extensibility.LayerProperties.GetIsPopupEnabled(graphicsLayer), Layer = graphicsLayer, }; setFromWebMap(info); info.SupportsOnClick = true; info.Layers = new Collection <LayerInformation>(); LayerInformation item = new LayerInformation(); item.PopUpsEnabled = true; item.ID = 0; item.Name = LayerExtensions.GetTitle(Layer); item.DisplayField = displayField; item.Fields = fields as Collection <FieldInfo>; if (graphicsLayer is FeatureLayer) { foreach (FieldInfo field in item.Fields) { if (field.DomainSubtypeLookup == DomainSubtypeLookup.NotDefined) { field.DomainSubtypeLookup = FieldInfo.GetDomainSubTypeLookup(graphicsLayer, field); } } } info.Layers.Add(item); info.SelectedItem = item; info.PropertyChanged += info_PropertyChanged; this.DataContext = info; #endregion } }
private void setFromWebMap(MapTipsConfigInfo info) { IDictionary <int, string> webMapTemplates = LayerExtensions.GetWebMapPopupDataTemplates(Layer); if (webMapTemplates != null && webMapTemplates.Count > 0) { info.FromWebMap = LayerExtensions.GetUsePopupFromWebMap(Layer); info.WebMapPopupVisibility = System.Windows.Visibility.Visible; } else { info.FromWebMap = false; info.WebMapPopupVisibility = System.Windows.Visibility.Collapsed; } }
public override Client.TiledMapServiceLayer CreateBaseMapLayer(BaseMapInfo baseMapInfo) { ArcGISTiledMapServiceLayer agsLayer = new ArcGISTiledMapServiceLayer() { Url = baseMapInfo.Url }; // Apply proxy if necessary if (baseMapInfo.UseProxy) { agsLayer.ProxyURL = ProxyUrl; LayerExtensions.SetUsesProxy(agsLayer, true); } return(agsLayer); }
void OnMapExtentChanged(object sender, ExtentEventArgs e) { // Run thru all the layers being tracked, and if any have autoUpdate turned // on and the update when map extent changes event turned on, update the // layer immediately. foreach (var helper in _autoUpdateHelpersDict.Values) { Layer layer = helper.FilteredLayer; if (layer != null && LayerExtensions.GetAutoUpdateOnExtentChanged(layer)) { helper.UpdateNow = true; // The helper filters the events with a timer so that we only have one // update for a series of extent changed events within a short time. helper.SettingsHaveChanged(); } } }
internal void FieldInfo_MapTipVisiblityChecked(FieldInfo fieldInfo) { if (fieldInfo == null) { return; } GraphicsLayer graphicsLayer = Layer as GraphicsLayer; if (graphicsLayer != null) { LayerExtensions.SetIsMapTipDirty(graphicsLayer, true); } bool visible = !isClearAllState; IEnumerable <FieldInfo> fields = LayerInfo.Fields; if (fields == null) { return; } // For feature layers - add the name of the field to the OutFields collection FeatureLayer featureLayer = Layer as FeatureLayer; if (featureLayer != null) { if (featureLayer.OutFields.Count == 1 && featureLayer.OutFields[0] == "*") { reBuildOutFields(featureLayer, fields); } else { if (!featureLayer.OutFields.Contains(fieldInfo.Name)) { featureLayer.OutFields.Add(fieldInfo.Name); } } } CheckToggleButtonState(fields); }
internal void FieldInfo_MapTipVisibilityUnChecked(FieldInfo fieldInfo) { if (fieldInfo == null) { return; } GraphicsLayer graphicsLayer = Layer as GraphicsLayer; if (graphicsLayer != null) { LayerExtensions.SetIsMapTipDirty(graphicsLayer, true); } bool visible = !isClearAllState; IEnumerable <FieldInfo> fields = LayerInfo.Fields; if (fields == null) { return; } // For feature layers - remove the name of the field to the OutFields collection FeatureLayer featureLayer = Layer as FeatureLayer; if (featureLayer != null) { if (featureLayer.OutFields.Count == 1 && featureLayer.OutFields[0] == "*") { reBuildOutFields(featureLayer, fields); } else { // in not also visible in attribute display and not the renderer field = remove it if (!fieldInfo.VisibleInAttributeDisplay && !isRendererField(fieldInfo)) { featureLayer.OutFields.Remove(fieldInfo.Name); } } } CheckToggleButtonState(fields); }
void HeaderCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (LayerInfo != null && HeaderCombo.SelectedItem is FieldInfo) { LayerInfo.DisplayField = (HeaderCombo.SelectedItem as FieldInfo).Name; GraphicsLayer layer = Layer as GraphicsLayer; if (layer != null) { if (HeaderCombo.SelectedItem is FieldInfo) { LayerExtensions.SetDisplayField(layer, LayerInfo.DisplayField); } } if (DisplayFieldChanged != null) { DisplayFieldChanged(this, null); } } }
void AssociatedObject_LostFocus(object sender, RoutedEventArgs e) { StackPanel sp = AssociatedObject.Parent as StackPanel; if (sp == null) { return; } LayerItemViewModel model = sp.DataContext as LayerItemViewModel; if (model == null || model.Layer == null || (model != null && model.Layer != null && LayerExtensions.GetInitialUpdateFailed(model.Layer))) { return; } model.Layer.SetValue(MapApplication.LayerNameProperty, AssociatedObject.Text); sp.SetValue(CoreExtensions.IsEditProperty, false); }