void OutlineColorSelector_ColorPicked(object sender, ColorChosenEventArgs e) { FillSymbol fillSymbol = Symbol as FillSymbol; LineSymbol lineSymbol = Symbol as LineSymbol; FSS.SimpleMarkerSymbol sms = Symbol as FSS.SimpleMarkerSymbol; if (sms != null) { SolidColorBrush brush = sms.OutlineColor as SolidColorBrush; if (brush != null) { brush.Color = e.Color; onCurrentSymbolChanged(); } } else if (fillSymbol != null) { SolidColorBrush brush = fillSymbol.BorderBrush as SolidColorBrush; if (brush != null) { brush.Color = e.Color; onCurrentSymbolChanged(); } } else if (lineSymbol != null) { SolidColorBrush brush = lineSymbol.Color as SolidColorBrush; if (brush != null) { brush.Color = e.Color; onCurrentSymbolChanged(); } } }
public static void IncreaseDefaultSymbolBorderWidth(this GraphicsLayer layer) { Symbol symbol = layer.GetDefaultSymbol(); FSS.SimpleMarkerSymbol fsSimpleMarkerSymbol; if ((fsSimpleMarkerSymbol = symbol as FSS.SimpleMarkerSymbol) != null) { fsSimpleMarkerSymbol.OutlineThickness++; } else { FillSymbol fillSymbol = symbol as FillSymbol; if (fillSymbol != null) { double newSize = fillSymbol.BorderThickness + 1; fillSymbol.BorderThickness = newSize; } else { LineSymbol lineSymbol = symbol as LineSymbol; if (lineSymbol != null) { double newSize = lineSymbol.Width + 1; lineSymbol.Width = newSize; } } } }
private static Symbol CreateDefaultSymbol(GeometryType geomType) { Symbol symbol = null; switch (geomType) { case GeometryType.Point: case GeometryType.MultiPoint: { symbol = new SimpleMarkerSymbol() { Color = new SolidColorBrush(Colors.Red) }; } break; case GeometryType.Polygon: { symbol = new FillSymbol() { BorderBrush = new SolidColorBrush(Colors.Black), Fill = new SolidColorBrush(Colors.Red) }; } break; case GeometryType.Polyline: { symbol = new LineSymbol() { Color = new SolidColorBrush(Colors.Red) }; } break; } return(symbol); }
public void WriteSymbol(Symbol symbol) { if (IsSerializable(symbol)) { FillSymbol fillSymbol = symbol as FillSymbol; if (fillSymbol != null) { WriteFillSymbol(fillSymbol); } else { LineSymbol lineSymbol = symbol as LineSymbol; if (lineSymbol != null) { WriteLineSymbol(lineSymbol); } else { MarkerSymbol markerSymbol = symbol as MarkerSymbol; if (markerSymbol != null) { WriteMarkerSymbol(markerSymbol); } else throw new NotSupportedException(symbol.GetType().FullName); } } } }
public static Color GetDefaultSymbolFillColor(this GraphicsLayer layer) { Symbol symbol = layer.GetDefaultSymbol(); SolidColorBrush solidColorBrush; FSS.SimpleMarkerSymbol fsSimpleMarkerSymbol; if ((fsSimpleMarkerSymbol = symbol as FSS.SimpleMarkerSymbol) != null) { if ((solidColorBrush = fsSimpleMarkerSymbol.Color as SolidColorBrush) != null) { return(solidColorBrush.Color); } } else { FillSymbol fillSymbol = symbol as FillSymbol; if (fillSymbol != null) { solidColorBrush = fillSymbol.Fill as SolidColorBrush; if (solidColorBrush != null) { return(solidColorBrush.Color); } } } return(Colors.Transparent); }
public static void ChangeDefaultSymbolBorderColor(this GraphicsLayer layer, Brush borderBrush) { Symbol symbol = layer.GetDefaultSymbol(); FSS.SimpleMarkerSymbol fsSimpleMarkerSymbol; if ((fsSimpleMarkerSymbol = symbol as FSS.SimpleMarkerSymbol) != null) { fsSimpleMarkerSymbol.OutlineColor = borderBrush; } else { FillSymbol fillSymbol = symbol as FillSymbol; if (fillSymbol != null) { fillSymbol.BorderBrush = borderBrush; } else { LineSymbol lineSymbol = symbol as LineSymbol; if (lineSymbol != null) { lineSymbol.Color = borderBrush; } } } }
public static void DecreaseDefaultSymbolBorderWidth(this GraphicsLayer layer) { Symbol symbol = layer.GetDefaultSymbol(); FSS.SimpleMarkerSymbol fsSimpleMarkerSymbol; if ((fsSimpleMarkerSymbol = symbol as FSS.SimpleMarkerSymbol) != null && fsSimpleMarkerSymbol.OutlineThickness > 0) { fsSimpleMarkerSymbol.OutlineThickness--; } else { FillSymbol fillSymbol = symbol as FillSymbol; if (fillSymbol != null) { if (fillSymbol.BorderThickness > 0) // make sure it isn't -ve { double newSize = fillSymbol.BorderThickness - 1; fillSymbol.BorderThickness = newSize; } } else { LineSymbol lineSymbol = symbol as LineSymbol; if (lineSymbol != null) { if (lineSymbol.Width > 0)// make sure it isn't -ve { double newSize = lineSymbol.Width - 1; lineSymbol.Width = newSize; } } } } }
private static FillSymbol cloneFillSymbol(FillSymbol fillSymbol) { if (fillSymbol == null) { return(null); } ESRI.ArcGIS.Mapping.Core.Symbols.SimpleFillSymbol mappingFillSymbol = fillSymbol as ESRI.ArcGIS.Mapping.Core.Symbols.SimpleFillSymbol; if (mappingFillSymbol != null) { ESRI.ArcGIS.Mapping.Core.Symbols.SimpleFillSymbol sfs = new ESRI.ArcGIS.Mapping.Core.Symbols.SimpleFillSymbol() { BorderBrush = CloneBrush(mappingFillSymbol.BorderBrush), BorderThickness = mappingFillSymbol.BorderThickness, ControlTemplate = mappingFillSymbol.ControlTemplate, Fill = CloneBrush(mappingFillSymbol.Fill), SelectionColor = CloneBrush(mappingFillSymbol.SelectionColor), }; return(sfs); } SimpleFillSymbol simpleFillSymbol = fillSymbol as SimpleFillSymbol; if (simpleFillSymbol != null) { SimpleFillSymbol sfs = new SimpleFillSymbol() { BorderBrush = CloneBrush(simpleFillSymbol.BorderBrush), BorderThickness = simpleFillSymbol.BorderThickness, ControlTemplate = simpleFillSymbol.ControlTemplate, Fill = CloneBrush(simpleFillSymbol.Fill), }; return(sfs); } PictureFillSymbol pictureFillSymbol = fillSymbol as PictureFillSymbol; if (pictureFillSymbol != null) { PictureFillSymbol pfs = new PictureFillSymbol() { BorderBrush = CloneBrush(pictureFillSymbol.BorderBrush), BorderThickness = pictureFillSymbol.BorderThickness, ControlTemplate = pictureFillSymbol.ControlTemplate, Fill = CloneBrush(pictureFillSymbol.Fill), Source = pictureFillSymbol.Source, }; return(pfs); } FillSymbol fs = new FillSymbol() { BorderBrush = CloneBrush(fillSymbol.BorderBrush), BorderThickness = fillSymbol.BorderThickness, ControlTemplate = fillSymbol.ControlTemplate, Fill = CloneBrush(fillSymbol.Fill), }; return(fs); }
private bool Init() { if (!InitUI()) { return(false); } if (!CreateGraphicsLayer()) { return(false); } // create the symbols _lineSymbol = new SimpleLineSymbol(System.Windows.Media.Colors.Red, 4) as LineSymbol; _fillSymbol = new SimpleFillSymbol() { //Fill = Brushes.Yellow, Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(100, 255, 255, 0)), BorderBrush = System.Windows.Media.Brushes.Green, BorderThickness = 1 } as FillSymbol; _saFillSymbol = new SimpleFillSymbol() { //Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(100, 90, 90, 90)), // gray Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(100, 255, 255, 0)), //BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Transparent), BorderBrush = System.Windows.Media.Brushes.Green, BorderThickness = 1 }; _saLineSymbol = new SimpleLineSymbol() { Color = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(100, (byte)_random.Next(0, 255), (byte)_random.Next(0, 255), (byte)_random.Next(0, 255))), Width = 1, }; // create the Geometry Service _geometryService = new GeometryService(_vm.GetPropValue("GeometryServiceUrl")); _geometryService.BufferCompleted += GeometryService_BufferCompleted; _geometryService.Failed += GeometryService_Failed; // create the route task _facilitiesGraphicsLayer = new GraphicsLayer(); _barriersGraphicsLayer = new GraphicsLayer(); _pointBarriers = new List <Graphic>(); _polylineBarriers = new List <Graphic>(); _polygonBarriers = new List <Graphic>(); string serviceAreaURL = _vm.GetPropValue("ServiceAreaServiceUrl"); _routeTask = new RouteTask(serviceAreaURL); _routeTask.SolveServiceAreaCompleted += SolveServiceArea_Completed; _routeTask.Failed += SolveServiceArea_Failed; return(true); }
private void GraphicsLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs e) { string stateName = Convert.ToString(e.Graphic.Attributes["STATE_NAME"]); foreach (Graphic g in _lastActiveGraphics) { g.Symbol = LayoutRoot.Resources["TransparentFillSymbol"] as Symbol; } _lastActiveGraphics.Clear(); if (_lastActiveGraphics.Count > 0) { for (int i = 0; i < _lastActiveGraphics.Count; i++) { if (Convert.ToString(_lastActiveGraphics[i].Attributes["STATE_NAME"]) != stateName) { ClearVideoSymbol(_lastActiveGraphics[i]); } else { return; } } } GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; Grid videoGrid = FindName("MediaGrid") as Grid; videoGrid.Children.Clear(); MediaElement stateMediaElement = new MediaElement() { Source = new Uri(String.Format("http://serverapps.esri.com/media/{0}_small.wmv", stateName), UriKind.Absolute), Stretch = Stretch.None, AutoPlay = true, IsMuted = true, Opacity = 0.0, IsHitTestVisible = false }; stateMediaElement.MediaEnded += State_Media_MediaEnded; videoGrid.Children.Add(stateMediaElement); //FillSymbol stateVideoFillSymbol = LayoutRoot.Resources["StateVideoFillSymbol"] as FillSymbol; FillSymbol stateVideoFillSymbol = LayoutRoot.Resources["RedFillSymbol"] as FillSymbol; //(stateVideoFillSymbol.Fill as VideoBrush).SetSource(stateMediaElement); e.Graphic.Symbol = stateVideoFillSymbol; _lastActiveGraphics.Add(e.Graphic); }
public static Symbol CloneSymbol(this Symbol symbol) { ICustomSymbol customSymbol = symbol as ICustomSymbol; if (customSymbol != null) { return(customSymbol.Clone()); } if (symbol is IJsonSerializable && symbol.GetType().Namespace.StartsWith("ESRI.ArcGIS.Client.FeatureService.Symbols", StringComparison.Ordinal)) { string json = GetJsonForSymbol(symbol as IJsonSerializable); if (!string.IsNullOrEmpty(json)) { if (symbol is ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol) { json = json.Replace(",\"outline\":null", string.Empty);//WORKAROUND for core bug } return(Symbol.FromJson(json)); } } FillSymbol fillSymbol = symbol as FillSymbol; if (fillSymbol != null) { return(cloneFillSymbol(fillSymbol)); } else { LineSymbol lineSymbol = symbol as LineSymbol; if (lineSymbol != null) { return(cloneLineSymbol(lineSymbol)); } else { ESRI.ArcGIS.Client.Symbols.MarkerSymbol markerSymbol = symbol as ESRI.ArcGIS.Client.Symbols.MarkerSymbol; if (markerSymbol != null) { return(cloneMarkerSymbol(markerSymbol)); } } } return(symbol); }
public DrawControl(Map map) { _drawControl = new Draw(); _drawControl.IsEnabled = false; _drawControl.Map = map; _defaultFillSymbol = new ESRI.ArcGIS.Client.Symbols.FillSymbol(); _defaultFillSymbol.BorderThickness = 3; _defaultFillSymbol.BorderBrush = new SolidColorBrush(Colors.Red); _defaultFillSymbol.Fill = new SolidColorBrush(Color.FromArgb(100, 255, 0, 0)); _drawControl.FillSymbol = _defaultFillSymbol; _defaultLineSymbo = new ESRI.ArcGIS.Client.Symbols.LineSymbol(); _defaultLineSymbo.Color = new SolidColorBrush(Colors.Red); _defaultLineSymbo.Width = 5; _drawControl.LineSymbol = _defaultLineSymbo; _drawControl.DrawComplete += _drawControl_DrawComplete; }
private void setNonSerializablePropertiesOfSymbolToNull() { // Control templates cannot be serialized Symbol.ControlTemplate = null; // Set all brushes to null - we can't serialize brushes ImageFillSymbol imageFillSymbol = Symbol as ImageFillSymbol; if (imageFillSymbol != null) { imageFillSymbol.Fill = null; imageFillSymbol.Color = null; } else { ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = Symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; if (markerSymbol != null) { markerSymbol.Color = null; } else { FillSymbol fillSymbol = Symbol as FillSymbol; if (fillSymbol != null) { fillSymbol.BorderBrush = null; fillSymbol.Fill = null; } else { LineSymbol lineSymbol = Symbol as LineSymbol; if (lineSymbol != null) { lineSymbol.Color = null; } } } } }
void SymbolBorderThickness_ThicknessValueChanged(object sender, EventArgs e) { if (SymbolBorderThickness == null) { return; } double newSize = SymbolBorderThickness.TargetThickness.Bottom; if (newSize < 0) { return; } FillSymbol fillSymbol = Symbol as FillSymbol; FSS.SimpleMarkerSymbol sms = Symbol as FSS.SimpleMarkerSymbol; if (sms != null) { sms.OutlineThickness = newSize; onCurrentSymbolChanged(); } else if (fillSymbol != null) { fillSymbol.BorderThickness = newSize; onCurrentSymbolChanged(); } else { LineSymbol lineSymbol = Symbol as LineSymbol; if (lineSymbol != null) { lineSymbol.Width = newSize; onCurrentSymbolChanged(); } } }
void BorderOpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = Symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol simpleMarkerSymbol = Symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol; FSS.SimpleMarkerSymbol sms = Symbol as FSS.SimpleMarkerSymbol; FillSymbol fillSymbol = Symbol as FillSymbol; if (fillSymbol != null) { if (fillSymbol.BorderBrush != null) { fillSymbol.BorderBrush.SetOpacity(e.NewValue); onCurrentSymbolChanged(); } } else if (sms != null) { if (sms.OutlineColor != null) { sms.OutlineColor.SetOpacity(e.NewValue); onCurrentSymbolChanged(); } } }
private static Symbol CreateDefaultSymbol(GeometryType geomType) { Symbol symbol = null; switch (geomType) { case GeometryType.Point: case GeometryType.MultiPoint: { symbol = new SimpleMarkerSymbol() { Color = new SolidColorBrush(Colors.Red) }; } break; case GeometryType.Polygon: { symbol = new FillSymbol() { BorderBrush = new SolidColorBrush(Colors.Black), Fill = new SolidColorBrush(Colors.Red) }; } break; case GeometryType.Polyline: { symbol = new LineSymbol() { Color = new SolidColorBrush(Colors.Red) }; } break; } return symbol; }
/// <summary> /// /// </summary> /// <param name="symbol"></param> public void SetSelectionFillSymbol(FillSymbol symbol) { fillSymbol = symbol; }
private static FillSymbol cloneFillSymbol(FillSymbol fillSymbol) { if (fillSymbol == null) return null; ESRI.ArcGIS.Mapping.Core.Symbols.SimpleFillSymbol mappingFillSymbol = fillSymbol as ESRI.ArcGIS.Mapping.Core.Symbols.SimpleFillSymbol; if (mappingFillSymbol != null) { ESRI.ArcGIS.Mapping.Core.Symbols.SimpleFillSymbol sfs = new ESRI.ArcGIS.Mapping.Core.Symbols.SimpleFillSymbol() { BorderBrush = CloneBrush(mappingFillSymbol.BorderBrush), BorderThickness = mappingFillSymbol.BorderThickness, ControlTemplate = mappingFillSymbol.ControlTemplate, Fill = CloneBrush(mappingFillSymbol.Fill), SelectionColor = CloneBrush(mappingFillSymbol.SelectionColor), }; return sfs; } SimpleFillSymbol simpleFillSymbol = fillSymbol as SimpleFillSymbol; if (simpleFillSymbol != null) { SimpleFillSymbol sfs = new SimpleFillSymbol() { BorderBrush = CloneBrush(simpleFillSymbol.BorderBrush), BorderThickness = simpleFillSymbol.BorderThickness, ControlTemplate = simpleFillSymbol.ControlTemplate, Fill = CloneBrush(simpleFillSymbol.Fill), }; return sfs; } PictureFillSymbol pictureFillSymbol = fillSymbol as PictureFillSymbol; if (pictureFillSymbol != null) { PictureFillSymbol pfs = new PictureFillSymbol() { BorderBrush = CloneBrush(pictureFillSymbol.BorderBrush), BorderThickness = pictureFillSymbol.BorderThickness, ControlTemplate = pictureFillSymbol.ControlTemplate, Fill = CloneBrush(pictureFillSymbol.Fill), Source = pictureFillSymbol.Source, }; return pfs; } FillSymbol fs = new FillSymbol() { BorderBrush = CloneBrush(fillSymbol.BorderBrush), BorderThickness = fillSymbol.BorderThickness, ControlTemplate = fillSymbol.ControlTemplate, Fill = CloneBrush(fillSymbol.Fill), }; return fs; }
/// <summary> /// 多边形绘制下拉控件监听事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DrawPolygon_DropDownClosed(object sender, EventArgs e) { //根据选择类型设置多边形填充样式 if (this.DrawPolygon != null) { switch (((Image)(this.DrawPolygon.SelectionBoxItem)).Tag.ToString()) { case "颜色填充": { this.fillType = FillSymbol.Solid; break; } case "斜线": { fillType = FillSymbol.Slash; break; } case "反斜线": { fillType = FillSymbol.BackSlash; break; } case "网格": { fillType = FillSymbol.Cross; break; } case "横线": { fillType = FillSymbol.Horizontal; break; } case "竖线": { fillType = FillSymbol.Vertical; break; } } this.drawingCtl.FreeDrawingType = FreeHanderType.None; //定义多边形填充样式对象 IMSSimpleFillStyle fill = new IMSSimpleFillStyle(); fill.FillSymbol = this.fillType; this.graphicsLayer.DrawingObj = fill; //设置绘制类型,监听绘制结束事件,绘制区 this.graphicsLayer.DrawingType = DrawingType.Polygon; //移除默认的绘制多边形临时对象 this.graphicsLayer.RemoveGraphics(this.graphicsLayer.DrawingObj); this.graphicsLayer.DrawingObj = fill;//设置自定义临时绘制对象 //设置临时绘制对象初始不可见 this.graphicsLayer.DrawingObj.Visibility = System.Windows.Visibility.Collapsed; //设置绘制结束事件 this.graphicsLayer.DrawingOverCallback += new DrawingEventHandler(PrePolygon); //将临时绘制对象添加到绘图层 this.graphicsLayer.AddGraphics(fill); } }
private void WriteFillSymbol(FillSymbol fillSymbol) { if (fillSymbol is ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleFillSymbol || fillSymbol is ESRI.ArcGIS.Client.FeatureService.Symbols.PictureFillSymbol) { StartType(fillSymbol, Constants.esriFSSymbolsPrefix); WriteJsonAttribute(fillSymbol as IJsonSerializable); } else { StartType(fillSymbol, Constants.esriPrefix); if (fillSymbol.BorderThickness != 1.0) WriteAttribute("BorderThickness", fillSymbol.BorderThickness); SolidColorBrush sb = fillSymbol.BorderBrush as SolidColorBrush; if (sb != null) { WriteAttribute("BorderBrush", sb.Color); } else { writer.WriteStartElement(fillSymbol.GetType().Name + ".BorderBrush", Namespaces[Constants.esriPrefix]); new BrushXamlWriter(writer, Namespaces).WriteBrush(fillSymbol.BorderBrush); writer.WriteEndElement(); } sb = fillSymbol.Fill as SolidColorBrush; if (sb != null) { WriteAttribute("Fill", sb.Color); } else { writer.WriteStartElement(fillSymbol.GetType().Name + ".Fill", Namespaces[Constants.esriPrefix]); new BrushXamlWriter(writer, Namespaces).WriteBrush(fillSymbol.Fill); writer.WriteEndElement(); } //if (fillSymbol is ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleFillSymbol) //{ // ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleFillSymbol sfs = fillSymbol as ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleFillSymbol; // WriteAttribute("Style", sfs.Style.ToString()); // WriteAttribute("BorderStyle", sfs.BorderStyle.ToString()); // WriteAttribute("Color", sfs.Color); // if (sfs.SelectionColor != null) // { // writer.WriteStartElement("SimpleFillSymbol.SelectionColor", Namespaces[Constants.esriFSSymbolsPrefix]); // new BrushXamlWriter(writer, Namespaces).WriteBrush(sfs.SelectionColor); // writer.WriteEndElement(); // } //} //else if (fillSymbol is ESRI.ArcGIS.Client.FeatureService.Symbols.PictureFillSymbol) //{ // ESRI.ArcGIS.Client.FeatureService.Symbols.PictureFillSymbol pfs = fillSymbol as ESRI.ArcGIS.Client.FeatureService.Symbols.PictureFillSymbol; // WriteAttribute("Height", pfs.Height); // WriteAttribute("Width", pfs.Width); // WriteAttribute("Opacity", pfs.Opacity); // WriteAttribute("BorderStyle", pfs.BorderStyle.ToString()); // if (pfs.Color != null) // { // writer.WriteStartElement("PictureFillSymbol.OutlineColor", Namespaces[Constants.esriFSSymbolsPrefix]); // new BrushXamlWriter(writer, Namespaces).WriteBrush(pfs.Color); // writer.WriteEndElement(); // } // if (pfs.SelectionColor != null) // { // writer.WriteStartElement("PictureFillSymbol.SelectionColor", Namespaces[Constants.esriFSSymbolsPrefix]); // new BrushXamlWriter(writer, Namespaces).WriteBrush(pfs.SelectionColor); // writer.WriteEndElement(); // } // #region Set ContentType,Url and ImageData to set Source // string json = pfs.ToJson(); // SetImageSourceRelatedProperties(pfs, json); // #endregion //} } writer.WriteEndElement(); }
void bindUIToSymbol() { if (SymbolPicker != null) { SymbolPicker.Symbol = Symbol; } ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = Symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; FSS.SimpleMarkerSymbol fsSimpleMarkerSymbol = Symbol as FSS.SimpleMarkerSymbol; FSS.SimpleLineSymbol fsSimpleLineSymbol = Symbol as FSS.SimpleLineSymbol; FSS.SimpleFillSymbol fsSimpleFillSymbol = Symbol as FSS.SimpleFillSymbol; SimpleMarkerSymbol simpleMarkerSymbol = Symbol as SimpleMarkerSymbol; FillSymbol fillSymbol = Symbol as FillSymbol; LineSymbol lineSymbol = Symbol as LineSymbol; if (Symbol != null) { #region Size if (PointThickness != null) { // we support Size property on SimpleMarkerSymbol and ImageFillSymbol ImageFillSymbol imagefillSymbol = Symbol as ImageFillSymbol; if (imagefillSymbol != null) { PointThickness.IsEnabled = true; PointThickness.TargetThickness = new Thickness(imagefillSymbol.Size); } else { if (markerSymbol != null) { PointThickness.IsEnabled = true; PointThickness.TargetThickness = new Thickness(markerSymbol.Size); } else { if (simpleMarkerSymbol != null) { PointThickness.IsEnabled = true; PointThickness.TargetThickness = new Thickness(simpleMarkerSymbol.Size); } else if (fsSimpleMarkerSymbol != null) { PointThickness.IsEnabled = true; PointThickness.TargetThickness = new Thickness(fsSimpleMarkerSymbol.Size); } else { PointThickness.IsEnabled = false; } } } } #endregion #region Border Thickness if (SymbolBorderThickness != null) { if (fillSymbol != null) { SymbolBorderThickness.IsEnabled = true; SymbolBorderThickness.TargetThickness = new Thickness(fillSymbol.BorderThickness); } else if (lineSymbol != null) { SymbolBorderThickness.IsEnabled = true; SymbolBorderThickness.TargetThickness = new Thickness(lineSymbol.Width); } else if (fsSimpleMarkerSymbol != null) { if (fsSimpleMarkerSymbol.OutlineColor != null) { SymbolBorderThickness.IsEnabled = true; SymbolBorderThickness.TargetThickness = new Thickness( double.IsNaN(fsSimpleMarkerSymbol.OutlineThickness) ? 0 : fsSimpleMarkerSymbol.OutlineThickness); } else { SymbolBorderThickness.IsEnabled = false; } } else { SymbolBorderThickness.IsEnabled = false; } } #endregion #region BorderColor if (OutlineColorSelector != null) { if (fsSimpleMarkerSymbol != null) { SolidColorBrush sb = fsSimpleMarkerSymbol.OutlineColor as SolidColorBrush; if (sb != null) { OutlineColorSelector.IsEnabled = true; OutlineColorSelector.ColorBrush = sb; } else { OutlineColorSelector.IsEnabled = false; } } else if (fillSymbol != null) { SolidColorBrush sb = fillSymbol.BorderBrush as SolidColorBrush; if (sb != null) { OutlineColorSelector.IsEnabled = true; OutlineColorSelector.ColorBrush = sb; } else { OutlineColorSelector.IsEnabled = false; } } else if (lineSymbol != null) { SolidColorBrush sb = lineSymbol.Color as SolidColorBrush; if (sb != null) { OutlineColorSelector.IsEnabled = true; OutlineColorSelector.ColorBrush = sb; } else { OutlineColorSelector.IsEnabled = false; } } else { OutlineColorSelector.IsEnabled = false; } } #endregion #region Fill Color if (FillColorSelector != null) { if (fillSymbol != null) { SolidColorBrush sb = fillSymbol.Fill as SolidColorBrush; if (sb != null) { FillColorSelector.IsEnabled = true; FillColorSelector.ColorBrush = sb; } else { FillColorSelector.IsEnabled = false; } } else { if (markerSymbol != null) { SolidColorBrush sb = markerSymbol.Color as SolidColorBrush; if (sb != null) { FillColorSelector.IsEnabled = true; FillColorSelector.ColorBrush = sb; } else { FillColorSelector.IsEnabled = false; } } else if (fsSimpleMarkerSymbol != null) { SolidColorBrush sb = fsSimpleMarkerSymbol.Color as SolidColorBrush; if (sb != null) { FillColorSelector.IsEnabled = true; FillColorSelector.ColorBrush = sb; } else { FillColorSelector.IsEnabled = false; } } else if (simpleMarkerSymbol != null) { SolidColorBrush sb = simpleMarkerSymbol.Color as SolidColorBrush; if (sb != null) { FillColorSelector.IsEnabled = true; FillColorSelector.ColorBrush = sb; } else { FillColorSelector.IsEnabled = false; } } else { FillColorSelector.IsEnabled = false; } } } #endregion #region Opacity if (OpacitySlider != null) { if (markerSymbol != null) { OpacitySlider.Value = markerSymbol.Opacity; } else if (simpleMarkerSymbol != null) { if (simpleMarkerSymbol.Color != null) { OpacitySlider.Value = simpleMarkerSymbol.Color.GetOpacity(); } } else if (fsSimpleMarkerSymbol != null) { if (fsSimpleMarkerSymbol.Color != null) { OpacitySlider.Value = fsSimpleMarkerSymbol.Color.GetOpacity(); } } else if (fsSimpleLineSymbol != null) { if (fsSimpleLineSymbol.Color != null) { OpacitySlider.Value = fsSimpleLineSymbol.Color.GetOpacity(); } } else if (fsSimpleFillSymbol != null) { if (fsSimpleFillSymbol.Color != null) { OpacitySlider.Value = fsSimpleFillSymbol.Color.A / 255d; } } else if (fillSymbol != null) { if (fillSymbol.Fill != null) { OpacitySlider.Value = fillSymbol.Fill.GetOpacity(); } } else if (lineSymbol != null) { if (lineSymbol.Color != null) { OpacitySlider.Value = lineSymbol.Color.GetOpacity(); } } } #endregion #region Border Opacity if (BorderOpacitySlider != null) { if (fillSymbol != null) { if (fillSymbol.BorderBrush != null) { BorderOpacitySlider.Visibility = System.Windows.Visibility.Visible; BorderOpacitySlider.Value = fillSymbol.BorderBrush.GetOpacity(); } else { BorderOpacitySlider.Visibility = System.Windows.Visibility.Collapsed; } } else if (fsSimpleMarkerSymbol != null && fsSimpleMarkerSymbol.OutlineColor != null) { BorderOpacitySlider.Visibility = System.Windows.Visibility.Visible; BorderOpacitySlider.Value = fsSimpleMarkerSymbol.OutlineColor.GetOpacity(); } else { BorderOpacitySlider.Visibility = System.Windows.Visibility.Collapsed; } } #endregion } }
private static geStyle ConvertToPolyStyle(FillSymbol fillSym) { gePolyStyle polyStyle; geLineStyle border; geStyle style; string hashId; hashId = fillSym.GetHashCode().ToString(); style = new geStyle(hashId); polyStyle = new gePolyStyle(); geColor color = new geColor(); color.SysColor = ((SolidColorBrush)fillSym.Fill).Color; polyStyle.Color = color; border = new geLineStyle(); geColor borderColor = new geColor(); borderColor.SysColor = ((SolidColorBrush)fillSym.BorderBrush).Color; border.Color = borderColor; style.LineStyle = border; style.PolyStyle = polyStyle; return style; }
void FillColorSelector_ColorPicked(object sender, ColorChosenEventArgs e) { FillSymbol fillSymbol = Symbol as FillSymbol; if (fillSymbol != null) { #region FSS.SFS if (fillSymbol is FSS.SimpleFillSymbol) { ((FSS.SimpleFillSymbol)fillSymbol).Color = e.Color; onCurrentSymbolChanged(); } #endregion #region FSS.PFS else if (fillSymbol is FSS.PictureFillSymbol) { FSS.PictureFillSymbol pfs = fillSymbol as FSS.PictureFillSymbol; SolidColorBrush brush = pfs.Color as SolidColorBrush; if (brush != null) { brush.Color = e.Color; onCurrentSymbolChanged(); } } #endregion #region Default else { SolidColorBrush brush = fillSymbol.Fill as SolidColorBrush; if (brush != null) { brush.Color = e.Color; onCurrentSymbolChanged(); } } #endregion } else { #region Mapping Core Marker ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = Symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; if (markerSymbol != null) { SolidColorBrush sb = markerSymbol.Color as SolidColorBrush; if (sb != null) { sb.Color = e.Color; onCurrentSymbolChanged(); } } #endregion else { #region Client SMS ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol simpleMarkerSymbol = Symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol; if (simpleMarkerSymbol != null) { SolidColorBrush sb = simpleMarkerSymbol.Color as SolidColorBrush; if (sb != null) { sb.Color = e.Color; onCurrentSymbolChanged(); } } #endregion #region FSS.SMS else { FSS.SimpleMarkerSymbol sms = Symbol as FSS.SimpleMarkerSymbol; if (sms != null) { SolidColorBrush sb = sms.Color as SolidColorBrush; if (sb != null) { sb.Color = e.Color; onCurrentSymbolChanged(); } } } #endregion } } }
public PolygonElement(FillSymbol symbol, Polygon polygon) { Symbol = symbol; Polygon = polygon; }
public PolygonElement(FillSymbol symbol, IMultiPolygon polygon) : this(symbol, AppGeo.Clients.Ags.Proxy.Polygon.FromCommon(polygon)) { }
private static void applyColorToSymbol(Symbol symbol, Color color) { if (symbol == null) { return; } FillSymbol fillSymbol = symbol as FillSymbol; if (fillSymbol != null) { byte currentAlpha = (byte)255; if (fillSymbol.Fill != null) { currentAlpha = (byte)(255 * fillSymbol.Fill.Opacity); // Preserve current opacity of symbol color } string colorHex = Color.FromArgb(currentAlpha, color.R, color.G, color.B).ToString(); Color newColor = ColorPickerUtils.FromHex(colorHex); if (fillSymbol is ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleFillSymbol) { (fillSymbol as ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleFillSymbol).Color = newColor; } else { fillSymbol.Fill = new SolidColorBrush(newColor); } } else { LineSymbol lineSymbol = symbol as LineSymbol; if (lineSymbol != null) { byte currentAlpha = (byte)255; if (lineSymbol.Color != null) { currentAlpha = (byte)(255 * lineSymbol.Color.Opacity);// Preserve current opacity of symbol color } string colorHex = Color.FromArgb(currentAlpha, color.R, color.G, color.B).ToString(); Color newColor = ColorPickerUtils.FromHex(colorHex); lineSymbol.Color = new SolidColorBrush(newColor); } else { ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; if (markerSymbol != null) { byte currentAlpha = (byte)255; if (markerSymbol.Color != null) { currentAlpha = (byte)(255 * markerSymbol.Color.Opacity);// Preserve current opacity of symbol color } string colorHex = Color.FromArgb(currentAlpha, color.R, color.G, color.B).ToString(); Color newColor = ColorPickerUtils.FromHex(colorHex); markerSymbol.Color = new SolidColorBrush(newColor); } else { ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol simpleMarkerSymbol = symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol; if (simpleMarkerSymbol != null) { byte currentAlpha = (byte)255; if (simpleMarkerSymbol.Color != null) { currentAlpha = (byte)(255 * simpleMarkerSymbol.Color.Opacity);// Preserve current opacity of symbol color } string colorHex = Color.FromArgb(currentAlpha, color.R, color.G, color.B).ToString(); Color newColor = ColorPickerUtils.FromHex(colorHex); simpleMarkerSymbol.Color = new SolidColorBrush(newColor); } else { ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol sms = symbol as ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol; if (sms != null) { byte currentAlpha = (byte)255; if (sms.Color is SolidColorBrush) { currentAlpha = (sms.Color as SolidColorBrush).Color.A; } else if (sms.Color != null) { currentAlpha = (byte)(255 * sms.Color.Opacity);// Preserve current opacity of symbol color } string colorHex = Color.FromArgb(currentAlpha, color.R, color.G, color.B).ToString(); Color newColor = ColorPickerUtils.FromHex(colorHex); sms.Color = new SolidColorBrush(newColor); if (sms.OutlineColor != null) { sms.OutlineColor = new SolidColorBrush(newColor); } } } } } } }
void OpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (Symbol is ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol) { ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol symbol = (ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol)Symbol; symbol.Opacity = e.NewValue; onCurrentSymbolChanged(); } else if (Symbol is FSS.SimpleMarkerSymbol) { FSS.SimpleMarkerSymbol symbol = (FSS.SimpleMarkerSymbol)Symbol; if (symbol.Color != null) { symbol.Color.SetOpacity(e.NewValue); onCurrentSymbolChanged(); } } else if (Symbol is FSS.SimpleLineSymbol) { FSS.SimpleLineSymbol symbol = (FSS.SimpleLineSymbol)Symbol; if (symbol.Color != null) { symbol.Color.SetOpacity(e.NewValue); onCurrentSymbolChanged(); } } else if (Symbol is FSS.SimpleFillSymbol) { FSS.SimpleFillSymbol symbol = (FSS.SimpleFillSymbol)Symbol; if (symbol.Color != null) { symbol.Color = Color.FromArgb(Convert.ToByte(255 * e.NewValue), symbol.Color.R, symbol.Color.G, symbol.Color.B); onCurrentSymbolChanged(); } } else if (Symbol is SimpleMarkerSymbol) { SimpleMarkerSymbol symbol = (SimpleMarkerSymbol)Symbol; if (symbol.Color != null) { symbol.Color.SetOpacity(e.NewValue); onCurrentSymbolChanged(); } } else if (Symbol is LineSymbol) { LineSymbol symbol = (LineSymbol)Symbol; if (symbol.Color != null) { symbol.Color.SetOpacity(e.NewValue); onCurrentSymbolChanged(); } } else if (Symbol is FillSymbol) { FillSymbol symbol = (FillSymbol)Symbol; if (symbol.Fill != null) { symbol.Fill.SetOpacity(e.NewValue); onCurrentSymbolChanged(); } } }
private bool Init() { if (!InitUI()) return false; if (!CreateGraphicsLayer()) return false; // create the symbols _lineSymbol = new SimpleLineSymbol(System.Windows.Media.Colors.Red, 4) as LineSymbol; _fillSymbol = new SimpleFillSymbol() { //Fill = Brushes.Yellow, Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(100, 255, 255, 0)), BorderBrush = System.Windows.Media.Brushes.Green, BorderThickness = 1 } as FillSymbol; _saFillSymbol = new SimpleFillSymbol() { //Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(100, 90, 90, 90)), // gray Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(100, 255, 255, 0)), //BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Transparent), BorderBrush = System.Windows.Media.Brushes.Green, BorderThickness = 1 }; _saLineSymbol = new SimpleLineSymbol() { Color = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(100, (byte)_random.Next(0, 255), (byte)_random.Next(0, 255), (byte)_random.Next(0, 255))), Width = 1, }; // create the Geometry Service _geometryService = new GeometryService(_vm.GetPropValue("GeometryServiceUrl")); _geometryService.BufferCompleted += GeometryService_BufferCompleted; _geometryService.Failed += GeometryService_Failed; // create the route task _facilitiesGraphicsLayer = new GraphicsLayer(); _barriersGraphicsLayer = new GraphicsLayer(); _pointBarriers = new List<Graphic>(); _polylineBarriers = new List<Graphic>(); _polygonBarriers = new List<Graphic>(); string serviceAreaURL = _vm.GetPropValue("ServiceAreaServiceUrl"); _routeTask = new RouteTask(serviceAreaURL); _routeTask.SolveServiceAreaCompleted += SolveServiceArea_Completed; _routeTask.Failed += SolveServiceArea_Failed; return true; }