本文整理汇总了C#中Graphic.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Graphic.SetValue方法的具体用法?C# Graphic.SetValue怎么用?C# Graphic.SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphic
的用法示例。
在下文中一共展示了Graphic.SetValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGraphics
/// <summary>
/// Creates graphic elements and adds them to the graphics layer.
/// </summary>
/// <param name="layer">Graphics layer that will have features added to it.</param>
/// <param name="images">Dictionary of images coming from kmz content or from previous parsing</param>
public void CreateGraphics(KmlGraphicsLayer layer, IDictionary<string, ImageBrush> images)
{
if (layer == null) return;
GraphicCollection graphics = new GraphicCollection();
UniqueValueRenderer renderer = new UniqueValueRenderer(); // dummy renderer used to create the legend items (since creation of the swatches from the symbol is not that obvious)
// Process each metadata feature in the list
foreach (PlacemarkDescriptor feature in placemarks)
{
KMLStyle style = feature.Symbol.style;
if (style.ZipFile != null)
{
// Look for the image in the zip file
if (style.IconImage == null && !String.IsNullOrEmpty(style.IconHref))
{
style.IconImage = GetIconImage(style.ZipFile, style.IconHref.ToLower());
}
style.ZipFile.Dispose();
style.ZipFile = null;
}
//Define handlers upfront so we can unhook from them
#if SILVERLIGHT
EventHandler<RoutedEventArgs>
#else
EventHandler
#endif
imageCompleted = null;
#if SILVERLIGHT
EventHandler<ExceptionRoutedEventArgs>
#else
EventHandler<ExceptionEventArgs>
#endif
imageFailed = null;
// If the style has an HREF then it is associated with an image
if (style.IconImage == null && !String.IsNullOrEmpty(style.IconHref))
{
// If the image is already loaded in the image dictionary, use it
if (images.ContainsKey(style.IconHref.ToLower()))
style.IconImage = images[style.IconHref.ToLower()];
else
{
// Get the image using the HREF and store the image in the images dictionary so that if
// other features reference it, it is cached
style.IconImage = GetIconImage(style.IconHref);
if (style.IconImage != null && (style.IconImage as ImageBrush).ImageSource != null)
{
var bi = (style.IconImage as ImageBrush).ImageSource as BitmapImage;
if (bi != null)
{
imageFailed = (s, e) =>
{
var b = s as BitmapImage;
#if SILVERLIGHT
if (imageCompleted != null) b.ImageOpened -= imageCompleted;
if(imageFailed != null) b.ImageFailed -= imageFailed;
#else
if (imageCompleted != null) b.DownloadCompleted -= imageCompleted;
if (imageFailed != null) b.DownloadFailed -= imageFailed;
#endif
var key = b.GetValue(BitmapImageKeyProperty) as string;
layer.Dispatcher.BeginInvoke((Action)delegate
{
UpdateGraphicsAndRenderer(layer, renderer, key);
});
};
#if SILVERLIGHT
bi.ImageFailed += imageFailed;
#else
bi.DownloadFailed += imageFailed;
#endif
}
}
images.Add(style.IconHref.ToLower(), style.IconImage);
}
}
// Create a new graphic from the metadata and construct the symbol using polymorphism
Graphic g = new Graphic()
{
Geometry = feature.Geometry,
Symbol = feature.Symbol.CreateSymbol(),
TimeExtent = feature.TimeExtent
};
g.SetValue(FeaturePlacemarkerDescriptorProperty, feature);
// Create legend entry
string label;
string description;
GetRendererInfo(feature, style, out label, out description);
//.........这里部分代码省略.........