コード例 #1
0
        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
            }
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
 void setMapServiceLayerDataContext(Collection <LayerInformation> layerInfos)
 {
     if (layerInfos.Count > 0)
     {
         #region Set data context
         MapTipsConfigInfo info = new MapTipsConfigInfo()
         {
             LayerSelectionVisibility = true,
             SupportsOnClick          = true,
             Layer = Layer,
         };
         setFromWebMap(info);
         info.IsPopupEnabled   = ESRI.ArcGIS.Client.Extensibility.LayerProperties.GetIsPopupEnabled(Layer);
         info.Layers           = layerInfos;
         info.SelectedItem     = layerInfos[0];
         this.DataContext      = info;
         info.PropertyChanged += info_PropertyChanged;
         #endregion
     }
 }
コード例 #4
0
 void info_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "PopUpsEnabled")
     {
         MapTipsConfigInfo info     = sender as MapTipsConfigInfo;
         Collection <int>  layerIds = new Collection <int>();
         if (info != null && info.Layers != null)
         {
             foreach (LayerInformation layer in info.Layers)
             {
                 if (layer.PopUpsEnabled)
                 {
                     layerIds.Add(layer.ID);
                 }
             }
             if (Layer != null)
             {
                 if (layerIds.Count < 1)
                 {
                     Layer.ClearValue(LayerExtensions.IdentifyLayerIdsProperty);
                 }
                 else
                 {
                     LayerExtensions.SetIdentifyLayerIds(Layer, layerIds);
                 }
             }
             onPropertyChanged("IdentifyLayerIds");
         }
         mapTipsLayerConfig.BindUI();
     }
     else if (e.PropertyName == "PopUpsOnClick")
     {
         MapTipsConfigInfo info  = sender as MapTipsConfigInfo;
         GraphicsLayer     layer = Layer as GraphicsLayer;
         if (info != null && layer != null)
         {
             if (!(info.PopUpsOnClick.Value))
             {
                 LayerExtensions.SetPopUpsOnClick(layer, false);
             }
             else
             {
                 LayerExtensions.SetPopUpsOnClick(layer, true);
                 #region if no display field, set to default
                 if (info.Layers != null && info.Layers.Count == 1 && info.Layers[0] != null)
                 {
                     if (string.IsNullOrEmpty(info.Layers[0].DisplayField) ||
                         info.Layers[0].DisplayField == ESRI.ArcGIS.Mapping.Core.LocalizableStrings.NoneInAngleBraces)
                     {
                         info.Layers[0].DisplayField = FieldInfo.GetDefaultDisplayField(info.Layers[0].Fields as IEnumerable <FieldInfo>);
                         if (!string.IsNullOrEmpty(info.Layers[0].DisplayField))
                         {
                             LayerExtensions.SetDisplayField(layer, info.Layers[0].DisplayField);
                         }
                     }
                 }
                 #endregion
             }
             LayerExtensions.SetIsMapTipDirty(layer, true);
             mapTipsLayerConfig.BindUI();
             onPropertyChanged("PopUpsOnClick");
         }
     }
     else if (e.PropertyName == "FromWebMap")
     {
         MapTipsConfigInfo info = sender as MapTipsConfigInfo;
         if (info != null)
         {
             LayerExtensions.SetUsePopupFromWebMap(Layer, info.FromWebMap);
             if (Layer is GraphicsLayer)
             {
                 LayerExtensions.SetIsMapTipDirty(Layer as GraphicsLayer, true);
             }
             onPropertyChanged("FromWebMap");
         }
     }
     else if (e.PropertyName == "IsPopupEnabled")
     {
         MapTipsConfigInfo info = sender as MapTipsConfigInfo;
         ESRI.ArcGIS.Client.Extensibility.LayerProperties.SetIsPopupEnabled(Layer, info.IsPopupEnabled);
         if (Layer is GraphicsLayer)
         {
             LayerExtensions.SetIsMapTipDirty(Layer as GraphicsLayer, true);
         }
         onPropertyChanged("IsPopupEnabled");
     }
     if (!(Layer is GraphicsLayer))
     {
         onPropertyChanged("LayerInfos");
     }
 }
コード例 #5
0
        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
            }
        }
コード例 #6
0
 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;
     }
 }
コード例 #7
0
        void setMapServiceLayerDataContext(Collection<LayerInformation> layerInfos)
        {
            if (layerInfos.Count > 0)
            {
                #region Set data context
                MapTipsConfigInfo info = new MapTipsConfigInfo()
                {
                    LayerSelectionVisibility = true,
                    SupportsOnClick = true,
                    Layer = Layer,
                };
                setFromWebMap(info);
				info.IsPopupEnabled = ESRI.ArcGIS.Client.Extensibility.LayerProperties.GetIsPopupEnabled(Layer);
                info.Layers = layerInfos;
                info.SelectedItem = layerInfos[0];
                this.DataContext = info;
                info.PropertyChanged += info_PropertyChanged;
                #endregion
            }
        }