+ Reply to Thread
Results 1 to 10 of 10

Thread: Symbol Resources

  1. #1
    Brian Leroux
    Join Date
    Aug 2010
    Posts
    231
    Points
    40
    Answers Provided
    12


    0

    Question Symbol Resources

    Hi- I am trying to symbolize a graphic that I am drawing. I can't seem to use the the resource I created. Am I missing something?

    Code:
    <UserControl x:Class="PolicyQuerySpatial.AddIns.QueryDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
        mc:Ignorable="d"
        d:DesignHeight="160" d:DesignWidth="325" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" Opacity="1">
    
        <Grid x:Name="LayoutRoot" Background="Transparent" Height="160" Width="325" Opacity="1" HorizontalAlignment="Right">
                            <Button Height="32" HorizontalAlignment="Left" Margin="91,44,0,0" Name="btnLine" VerticalAlignment="Top" Width="32" Click="btnDrawLine_Click">
                <Button.Content>
                    <Image Source="/PolicyQuerySpatial.AddIns;component/Images/EditingEditLine32.png" />
                </Button.Content>
            </Button>
            <Button  Height="32" HorizontalAlignment="Left" Margin="143,44,0,0" Name="btnPolygon" VerticalAlignment="Top" Width="32" Click="btnDrawPolygon_Click" >
                <Button.Content>
                    <Image Source ="/PolicyQuerySpatial.AddIns;component/Images/EditingEditShape32.png" />
                </Button.Content>
            </Button>
            <CheckBox Content="Include Policies within a distance of:" Height="16" HorizontalAlignment="Left" Margin="12,95,0,0" Name="chkBuffer" VerticalAlignment="Top" />
            <TextBlock Height="23" HorizontalAlignment="Left" Margin="116,122,0,0" Name="txtMiles" Text="Mile(s)" VerticalAlignment="Top" />
            <toolkit:NumericUpDown Height="22" HorizontalAlignment="Left" Margin="38,120,0,0" Name="numBuffer" VerticalAlignment="Top" Width="56" Maximum="500" />
        </Grid>
        <UserControl.Resources>
            <ResourceDictionary>
                <esri:SimpleMarkerSymbol x:Key="GreenMarkerSymbol" Color="Green" Size="12" Style="Circle" />
                <esri:SimpleLineSymbol x:Key="RedLineSymbol" Color="Green" Width="4" Style="Solid" />
                <esri:SimpleFillSymbol x:Key="RedFillSymbol" Fill="#66FF0000" BorderBrush="Red" BorderThickness="2" />
            </ResourceDictionary>
        </UserControl.Resources>
    
    </UserControl>
    Code:
    private void btnDrawPoint_Click(object sender, RoutedEventArgs e)
            {
                drawObject.DrawMode = DrawMode.Point;
                _activeSymbol = LayoutRoot.Resources["GreenMarkerSymbol"] as Symbol;
    
                drawObject.IsEnabled = (drawObject.DrawMode != DrawMode.None);
            }

  2. #2
    Katherine Dalton

    Join Date
    Jan 2010
    Posts
    299
    Points
    173
    Answers Provided
    22


    2
    This post is marked as the answer

    Default Re: Symbol Resources

    Hi Brian,

    When creating your GraphicsLayer are you setting the Renderer property? If that isn't set at the time the GraphicsLayer is created, the Viewer just uses the default renderer.
    Code:
    GraphicsLayer gl = new GraphicsLayer()
    {
        ID = "IdentifyResultsLayer",
        Renderer = new SimpleRenderer()
        {
              Symbol = identifyDialog.Resources["RedMarkerSymbol"] as Symbol
        }
    };
    Katy
    Katy Dalton
    Esri Product Engineer

  3. #3
    Brian Leroux
    Join Date
    Aug 2010
    Posts
    231
    Points
    40
    Answers Provided
    12


    0

    Default Re: Symbol Resources

    Thanks Katy. I was looking at that in the API Best Practices but I am having trouble referencing the resource dictionary i created. Based on my XAML above, how do i reference the resources?
    UserControl.Resources and QueryDialog.Resources does not work.

    *Update
    I figured it out. I just used Resources["SymbolKey"] and it worked. Thanks for pointing me in the right direction.
    Last edited by Bleroux; 03-22-2012 at 06:40 AM.

  4. #4
    Brian Leroux
    Join Date
    Aug 2010
    Posts
    231
    Points
    40
    Answers Provided
    12


    0

    Default Re: Symbol Resources

    When using the Resource Dictionary to define symbols I find that the highlighting a point when selected no longer works. Is this something that needs to be defined when creating the symbol? If there is a better to use the build in symbols in the viewer to maintain the selected item highlighting I am open to that. Here is how I am defining my symbols currently.

    Code:
    <UserControl.Resources>
            <ResourceDictionary>
                <esri:SimpleMarkerSymbol x:Key="BlueMarkerSymbol" Color="Blue" Size="12" Style="Circle" />
                <esri:SimpleLineSymbol x:Key="RedLineSymbol" Color="Red" Width="4" Style="Solid" />
                <esri:SimpleLineSymbol x:Key="BlueLineSymbol" Color="Blue" Width="4" Style="Solid" />
                <esri:SimpleFillSymbol x:Key="RedFillSymbol" Fill="#66FF0000" BorderBrush="Red" BorderThickness="2" />
                <esri:SimpleFillSymbol x:Key="BlueFillSymbol" Fill="#660000FF" BorderBrush="Blue" BorderThickness="2" />
                <esri:SimpleFillSymbol x:Key="WhiteFillSymbol" Fill="#AAFFFFFF" BorderBrush="#DD000000" BorderThickness="2" />
                <esri:PictureMarkerSymbol x:Key="RedStickpin"  OffsetX="16" OffsetY="32" Source="/PolicyQuerySpatial.AddIns;component/Images/RedStickpin.png" Height="32" Width="32" />
                <esri:PictureMarkerSymbol x:Key="BlueStickpin"  OffsetX="16" OffsetY="32" Source="/PolicyQuerySpatial.AddIns;component/Images/BlueStickpin.png" Height="32" Width="32" />
            </ResourceDictionary>
        </UserControl.Resources>
    Last edited by Bleroux; 04-09-2012 at 12:06 PM.

  5. #5
    Brian Leroux
    Join Date
    Aug 2010
    Posts
    231
    Points
    40
    Answers Provided
    12


    0

    Question Re: Symbol Resources

    Well after spending a day trying to get past this I am baffled. I did notice that if I use my add-in with custom symbology to add a graphics layer and then change the symbology using congiguration tool, the highlighted when selecting comes back. I can't figure out a way to reference the build in symbology from an add-in. I willing to try any ideas you may have.. Thanks.

  6. #6
    Brian Leroux
    Join Date
    Aug 2010
    Posts
    231
    Points
    40
    Answers Provided
    12


    0

    Default Re: Symbol Resources

    Well i decided to make my own symbol using the ControlTemplate and visual states. I would love to be able to recreate the same orange glow used for selected items. Would anyone at ESRI be able to provide the code used for the symbol animation?

  7. #7
    Craig Patterson
    Join Date
    Jan 2011
    Posts
    22
    Points
    1
    Answers Provided
    1


    0

    Default Re: Symbol Resources

    I struggled with the same thing, but I figured it out. What you need to do is to name your user control.

    Code:
    <UserControl x:Class="AddInDemo.AddIns.MarkUpToolSet" x:Name="MarkUpToolset"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
        mc:Ignorable="d"
        d:DesignHeight="155" d:DesignWidth="450">
    
        <UserControl.Resources>
                <esri:SimpleLineSymbol x:Key="MarkUpLineSymbol" Color="Red" Width="4" />
                <esri:SimpleFillSymbol x:Key="MarkUpFillSymbol" Fill="Red" BorderBrush="Red" BorderThickness="2" />
                <esri:SimpleMarkerSymbol x:Key="MarkUpMarkerSymbol" Color="Red" Size="12" Style="Circle" />
        </UserControl.Resources>
    Then you can refer to it in your code behind.

    Code:
            private void DrawPointButton_Click(object sender, RoutedEventArgs e)
            {
                MarkUpDrawObject.DrawMode = DrawMode.Point;
                MarkUpDrawObject.IsEnabled = true;
    
                _activeMarkUpSymbol = MarkUpToolset.Resources["MarkUpMarkerSymbol"] as Symbol;
            }
    Good Luck.

    Craig

  8. #8
    Brian Leroux
    Join Date
    Aug 2010
    Posts
    231
    Points
    40
    Answers Provided
    12


    0

    Default Re: Symbol Resources

    Craig-
    Do you happen to know if it keeps the same orange glow affect when selecting the items? Thanks.

  9. #9
    Karen Ellett
    Join Date
    Mar 2012
    Posts
    86
    Points
    20
    Answers Provided
    3


    0

    Default Re: Symbol Resources

    Brian - did you ever solve the highlighting issue?

  10. #10
    Brian Leroux
    Join Date
    Aug 2010
    Posts
    231
    Points
    40
    Answers Provided
    12


    0

    Default Re: Symbol Resources

    Not perfectly but for my needs the following woked fine for me. It gives me the orange glow on selection with animation but the glow is not ecactly the same as the default ESRI glow. I played around with it for a while to get it close as possible. You will aslo see that I added a hover animation so that I could show a label on hover. You could remove that if you didn't want it. Hope it helps you..

    Code:
    <esri:MarkerSymbol x:Name="CustomStrobeMarkerSymbol">
                    <esri:MarkerSymbol.ControlTemplate>
                        <ControlTemplate>
                            <Canvas>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="SelectionStates">
                                        <VisualState x:Name="Selected">
                                            <Storyboard RepeatBehavior="1x">
                                                <DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" From="1" To="6" Duration="00:00:00.5" />
                                                <DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" From="1" To="6" Duration="00:00:00.5" />
                                                <DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)" From="1" To="1" Duration="00:00:01" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Unselected" />
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="MouseOver">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="labelOnHover" 
                                Storyboard.TargetProperty="Visibility" 
                                Duration="0">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Visibility>Visible</Visibility>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                                <DoubleAnimation From="0" To="1" Storyboard.TargetName="labelOnHover" 
                                 Storyboard.TargetProperty="Opacity"
                                 Duration="0:0:.25" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Normal" />
                                    </VisualStateGroup>
    
                                </VisualStateManager.VisualStateGroups>
                                
                                <Ellipse Height="10" Width="10" Canvas.Left="-5" Canvas.Top="-5" RenderTransformOrigin="0.5,0.5" x:Name="ellipse" IsHitTestVisible="False">
                                    <Ellipse.RenderTransform>
                                        <ScaleTransform />
                                    </Ellipse.RenderTransform>
                                    <Ellipse.Fill>
                                        <RadialGradientBrush>
                                            <GradientStop Color="#8DFFFF00" />
                                            <GradientStop Color="#8DFFFF00" Offset=".4" />
                                            <GradientStop Color="#8DFF7600" Offset=".8" />
                                            <GradientStop Color="#00FF7600" Offset="1" />
                                            <!--<GradientStop Color="#00FF0000" Offset="1" />-->
                                        </RadialGradientBrush>
                                    </Ellipse.Fill>
                                </Ellipse>
                                <Ellipse Height="10" Width="10" Canvas.Left="-5" Canvas.Top="-5" Fill="#FFFF0000" x:Name="ellipse1" />
                                <Grid Margin="8,-8,0,0" x:Name="labelOnHover" Visibility="Collapsed"
                            HorizontalAlignment="Left" VerticalAlignment="Top" >
                                    <!--Text halo using a white blurred text-->
                                    <TextBlock Foreground="White" FontWeight="Bold" Text="{Binding Attributes[POLICY_NO]}" >
                        <TextBlock.Effect>
                                  <BlurEffect Radius="5" />
                        </TextBlock.Effect>
                                    </TextBlock>
                                    <!--Text-->
                                    <TextBlock Foreground="Black" FontWeight="Bold" Text="{Binding Attributes[POLICY_NO]}" />
                                </Grid>
    
                            </Canvas>
                        </ControlTemplate>
                    </esri:MarkerSymbol.ControlTemplate>
                    
                </esri:MarkerSymbol>

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts