silverlight   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了arcgis api for silverlight自定义一个Symbol大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

用Xaml写一个ControlTemplate。源码如下 <ControlTemplate      xmlns="http://scheR_510_11845@as.microsoft.com/client/2007"        xmlns:x="http://scheR_510_11845@as.microsoft.com/winfx/2006/xaml"        xmlns:sys="clr-namespace:System

用Xaml写一个ControlTemplate。源码如下

<ControlTemplate 
    xmlns="http://schemas.microsoft.com/client/2007"   
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
    xmlns:sys="clr-namespace:System;assembly=mscorlib"   
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"    >
    <Grid
        RenderTransformOrigin="0.5,0.5"       
        Height="50"       
        Width="50">
        <Grid.RenderTransform>
            <TransformGroup>
                <ScaleTransform x:Name="scale" ScaleX="1" ScaleY="1" />
                <TranslateTransform X="-25" Y="-25"/>
            </TransformGroup>
        </Grid.RenderTransform>

        <vsm:VisualStateManager.VisualStateGroups>
            <vsm:VisualStateGroup x:Name="CommonStates">
                <vsm:VisualState x:Name="Normal">
                    <Storyboard>
                        <DoubleAnimation BeginTime="0:0:0" Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleX" To="1" Duration="0:0:0.3" />
                        <DoubleAnimation BeginTime="0:0:0" Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleY" To="1" Duration="0:0:0.3" />
                    </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="MouSEOver">
                    <Storyboard>
                        <DoubleAnimation BeginTime="0:0:0" Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleX" To="2" Duration="0:0:0.3" />
                        <DoubleAnimation BeginTime="0:0:0" Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleY" To="2" Duration="0:0:0.3" />
                    </Storyboard>
                </vsm:VisualState>
            </vsm:VisualStateGroup>
            <vsm:VisualStateGroup x:Name="SELEctionStates">
                <vsm:VisualState x:Name="SELEcted" />
                <vsm:VisualState x:Name="UnSELEcted" />
            </vsm:VisualStateGroup>
        </vsm:VisualStateManager.VisualStateGroups>
        <Image           
            HorizontalAlignment="Center"           
            VerticalAlignment="Center"           
            Height="16"           
            Width="16"           
            source="Images/sym.png"  
            />
        <Image
            HorizontalAlignment="Center"           
            VerticalAlignment="Center"           
            Height="24"           
            Width="24"           
            source="Images/symout.png"/>
        <TextBlock HorizontalAlignment="Center"           
            VerticalAlignment="Center"           
            Height="20"           
            Width="40"    
            Margin="0,30"
            FontWeight="Bold"
            Foreground="Purple"
            FontSize="9"
            TEXT="mynumb"/>
    </Grid>
</ControlTemplate>

 

改变其属性生成操作”为”嵌入的资源“(这个很重要)

定义一个类OnSymbol继承自MarkerSymbol

public class OnSymbol : MarkerSymbol
    {
        public OnSymbol(String userName)
            : base()
        {
            try
            {
                String key = "Ls.PRJ2011.Tracker.onlinSymbol.xaml";
                Stream stream = typeof(OnSymbol).Assembly.GetManifestresourceStream(key);
                String template = new StreamReader(stream).ReadToEnd();
                //template = template.replace("force1.png","force" + sType.ToString() + ".png");
                //template = template.replace("comp1.png","comp" + sComp.ToString() + ".png");
                template = template.replace("mynumb",userName);
                this.ControlTemplate = (ControlTemplatE)XamlReader.Load(templatE);
            }
            catch (Exception eX)
            {
                MainPage.add_to_logger(eX);
            }
        }
    }

然后,对于图层对象的Symbol就可以直接赋值OnSymbol 实例

  tmpGraphic.Symbol = new OnSymbol(mobileName);

大佬总结

以上是大佬教程为你收集整理的arcgis api for silverlight自定义一个Symbol全部内容,希望文章能够帮你解决arcgis api for silverlight自定义一个Symbol所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。