Select to view content in your preferred language

Restricting tools in the editor widget...??

3672
11
10-27-2011 02:31 PM
JerryBiedenbender
Emerging Contributor
Is it possible to restrict some of the tools in the editor widget? I would like to take away the delete tool and other ones that are not ever going to be used by my users.

Thanks,
Jerry
0 Kudos
11 Replies
ChristineZeller
Occasional Contributor
Jerry,

If you have Blend you can copy the editor resource and create a new resource style for it.  Then in blend you can just delete the tools you want.  Or after you create a copy you can go back in V.S. and edit the xaml directly.  Here's a copy of a EditorWidgetStyle, which is called EditorWidgetStyle1.  You could just drop this code in your V.S. under Resources and then ref it in your xaml where your editor tools are declared.  I highlighted the buttons code in red so you could quickly easy find them and delete the ones you don't want.


I'll have to post the code on two different post because it is too long...sorry!



 <Style x:Key="EditorWidgetStyle1" TargetType="esriWidgets:EditorWidget">
         <Setter Property="Background">
          <Setter.Value>
           <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FFFDFDFD" Offset="0"/>
            <GradientStop Color="#FFEFF1F3" Offset="0.5"/>
            <GradientStop Color="#FFCCD3D8" Offset="1"/>
           </LinearGradientBrush>
          </Setter.Value>
         </Setter>
         <Setter Property="Template">
          <Setter.Value>
           <ControlTemplate TargetType="esriWidgets:EditorWidget">
            <StackPanel Margin="0,0,0,0">
             <StackPanel.Resources>
              <Style x:Key="ButtonStyle" TargetType="Button">
               <Setter Property="Margin" Value="2"/>
               <Setter Property="HorizontalAlignment" Value="Stretch"/>
               <Setter Property="VerticalAlignment" Value="Stretch"/>
               <Setter Property="HorizontalContentAlignment" Value="Center"/>
               <Setter Property="VerticalContentAlignment" Value="Center"/>
               <Setter Property="Background" Value="Transparent"/>
               <Setter Property="Padding" Value="0"/>
               <Setter Property="Template">
                <Setter.Value>
                 <ControlTemplate TargetType="Button">
                  <Grid Cursor="Hand" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="2,0,2,0" RenderTransformOrigin="0.5,0.5" VerticalAlignment="{TemplateBinding VerticalAlignment}">
                   <Grid.RenderTransform>
                    <ScaleTransform x:Name="handScale"/>
                   </Grid.RenderTransform>
                   <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                     <VisualState x:Name="Normal">
                      <Storyboard>
                       <DoubleAnimation Duration="0:0:0.4" FillBehavior="HoldEnd" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="brushLight"/>
                       <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.1" To="1" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="handScale"/>
                       <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.1" To="1" Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="handScale"/>
                      </Storyboard>
                     </VisualState>
                     <VisualState x:Name="MouseOver">
                      <Storyboard>
                       <DoubleAnimation Duration="0:0:0.1" FillBehavior="HoldEnd" To="0.75" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="brushLight"/>
                       <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.1" To="1.5" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="handScale"/>
                       <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.1" To="1.5" Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="handScale"/>
                      </Storyboard>
                     </VisualState>
                     <VisualState x:Name="Disabled">
                      <Storyboard>
                       <DoubleAnimation Duration="0:0:0.4" FillBehavior="HoldEnd" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="brushLight"/>
                       <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.1" To="0.7" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="handScale"/>
                       <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.1" To="0.7" Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="handScale"/>
                       <DoubleAnimation Duration="0:0:0.4" FillBehavior="HoldEnd" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="contentPresenter"/>
                      </Storyboard>
                     </VisualState>
                    </VisualStateGroup>
                   </VisualStateManager.VisualStateGroups>
                   <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Rectangle x:Name="backGlow" IsHitTestVisible="False" Margin="-10">
                     <Rectangle.Fill>
                      <RadialGradientBrush x:Name="brushLight" Center="0.5, 0.5" RadiusY="0.5">
                       <GradientStop Color="#AAFFFFFF" Offset="0"/>
                       <GradientStop Color="#00FFFFFF" Offset="0.98"/>
                      </RadialGradientBrush>
                     </Rectangle.Fill>
                    </Rectangle>
                    <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                   </Grid>
                  </Grid>
                 </ControlTemplate>
                </Setter.Value>
               </Setter>
              </Style>
              <Style x:Key="BorderStyle" TargetType="Border">
               <Setter Property="Margin" Value="5,0,0,0"/>
               <Setter Property="Padding" Value="3"/>
               <Setter Property="CornerRadius" Value="5"/>
               <Setter Property="BorderThickness" Value="1"/>
              </Style>
              <Style x:Key="ToggleButtonStyle" TargetType="ToggleButton">
               <Setter Property="Template">
                <Setter.Value>
                 <ControlTemplate TargetType="ToggleButton">
                  <Grid Background="Transparent" Cursor="Hand" Margin="0,0,0,0" RenderTransformOrigin="0.5,0.5">
                   <Grid.RenderTransform>
                    <ScaleTransform x:Name="handScale"/>
                   </Grid.RenderTransform>
                   <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                     <VisualState x:Name="Normal">
                      <Storyboard>
                       <DoubleAnimation Duration="0:0:0.4" FillBehavior="HoldEnd" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="brushLight"/>
                       <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.1" To="1" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="handScale"/>
                       <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.1" To="1" Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="handScale"/>
                      </Storyboard>
                     </VisualState>
                     <VisualState x:Name="MouseOver">
                      <Storyboard>
                       <DoubleAnimation Duration="0:0:0.1" FillBehavior="HoldEnd" To="0.75" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="brushLight"/>
                       <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.1" To="1.5" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="handScale"/>
                       <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.1" To="1.5" Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="handScale"/>
                      </Storyboard>
                     </VisualState>
                     <VisualState x:Name="Disabled">
                      <Storyboard>
                       <DoubleAnimation Duration="0:0:0.4" FillBehavior="HoldEnd" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="brushLight"/>
                       <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.1" To="0.7" Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="handScale"/>
                       <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.1" To="0.7" Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="handScale"/>
                      </Storyboard>
                     </VisualState>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="CheckStates">
                     <VisualState x:Name="Checked"/>
                     <VisualState x:Name="Unchecked"/>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="FocusStates">
                     <VisualState x:Name="Focused"/>
                     <VisualState x:Name="Unfocused"/>
                    </VisualStateGroup>
                   </VisualStateManager.VisualStateGroups>
                   <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Rectangle x:Name="backGlow" IsHitTestVisible="False" Margin="-10">
                     <Rectangle.Fill>
                      <RadialGradientBrush x:Name="brushLight" Center="0.5, 0.5" RadiusY="0.5">
                       <GradientStop Color="#AAFFFFFF" Offset="0"/>
                       <GradientStop Color="#00FFFFFF" Offset="0.98"/>
                      </RadialGradientBrush>
            
0 Kudos
ChristineZeller
Occasional Contributor


</Rectangle.Fill>
                    </Rectangle>
                    <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    <Rectangle x:Name="DisabledVisualElement" Fill="#AAFFFFFF" IsHitTestVisible="false" Opacity="0" RadiusY="3" RadiusX="3"/>
                    <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Margin="1" Opacity="0" RadiusY="2" RadiusX="2" Stroke="#FF6DBDD1" StrokeThickness="1"/>
                   </Grid>
                  </Grid>
                 </ControlTemplate>
                </Setter.Value>
               </Setter>
              </Style>
             </StackPanel.Resources>
             <esriWidgets:TemplatePicker x:Name="TemplatePicker" AlwaysDisplayDefaultTemplates="{TemplateBinding AlwaysDisplayDefaultTemplates}" AutoSelect="{TemplateBinding AutoSelect}" AutoComplete="{Binding AutoComplete}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Continuous="{TemplateBinding Continuous}" Freehand="{Binding Freehand}" GeometryServiceUrl="{TemplateBinding GeometryServiceUrl}" LayerIDs="{TemplateBinding LayerIDs}" Map="{TemplateBinding Map}" ShowAttributesOnAdd="{TemplateBinding ShowAttributesOnAdd}">
              <esriWidgets:TemplatePicker.Template>
               <ControlTemplate TargetType="esriWidgets:TemplatePicker">
                <Border BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" HorizontalAlignment="Center" Style="{StaticResource BorderStyle}">
                 <esriToolkitPrimitives:TemplatePanel ItemTemplate="{TemplateBinding ItemTemplate}" StackCount="2" StackDirection="Horizontal" Templates="{TemplateBinding Templates}"/>
                </Border>
               </ControlTemplate>
              </esriWidgets:TemplatePicker.Template>
             </esriWidgets:TemplatePicker>
             <Border x:Name="ToolsContainer" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" HorizontalAlignment="Center" Height="40" Style="{StaticResource BorderStyle}" VerticalAlignment="Top">
              <StackPanel Orientation="Horizontal">
               <Button x:Name="NewSelect" CommandParameter="New" Command="{Binding Select}" Style="{StaticResource ButtonStyle}" ToolTipService.ToolTip="New selection">
                <Image Source="/ESRI.ArcGIS.Client.Toolkit;component/Images/NewSelection.png" Stretch="None"/>
               </Button>
               <Button x:Name="AddSelect" CommandParameter="Add" Command="{Binding Select}" Style="{StaticResource ButtonStyle}" ToolTipService.ToolTip="Add to selection">
                <Image Source="/ESRI.ArcGIS.Client.Toolkit;component/Images/AddToSelection.png" Stretch="None"/>
               </Button>
               <Button x:Name="RemoveSelect" CommandParameter="Remove" Command="{Binding Select}" Style="{StaticResource ButtonStyle}" ToolTipService.ToolTip="Remove from selection">
                <Image Source="/ESRI.ArcGIS.Client.Toolkit;component/Images/RemoveFromSelection.png" Stretch="None"/>
               </Button>
               <Button x:Name="ClearSelect" Command="{Binding ClearSelection}" Style="{StaticResource ButtonStyle}" ToolTipService.ToolTip="Clear selection">
                <Image Source="/ESRI.ArcGIS.Client.Toolkit;component/Images/Clear.png" Stretch="None"/>
               </Button>
               <Button x:Name="DeleteSelect" Command="{Binding DeleteSelected}" Style="{StaticResource ButtonStyle}" ToolTipService.ToolTip="Delete selected features">
                <Image Source="/ESRI.ArcGIS.Client.Toolkit;component/Images/deleteFeature.png" Stretch="None"/>
               </Button>
               <Button x:Name="EditGeometry" Command="{Binding EditVertices}" Style="{StaticResource ButtonStyle}" ToolTipService.ToolTip="Edit Geometry">
                <Image Source="/ESRI.ArcGIS.Client.Toolkit;component/Images/showVertices.png" Stretch="None"/>
               </Button>
               <Button x:Name="Reshape" Command="{Binding Reshape}" Style="{StaticResource ButtonStyle}" ToolTipService.ToolTip="Reshape">
                <Image Source="/ESRI.ArcGIS.Client.Toolkit;component/Images/reshape.png" Stretch="None"/>
               </Button>
               <Button x:Name="Union" Command="{Binding Union}" Style="{StaticResource ButtonStyle}" ToolTipService.ToolTip="Union features">
                <Image Source="/ESRI.ArcGIS.Client.Toolkit;component/Images/union.png" Stretch="None"/>
               </Button>
               <Button x:Name="Cut" Command="{Binding Cut}" Style="{StaticResource ButtonStyle}" ToolTipService.ToolTip="Cut features">
                <Image Source="/ESRI.ArcGIS.Client.Toolkit;component/Images/cut.png" Stretch="None"/>
               </Button>
               <Button x:Name="Save" Command="{Binding Save}" Style="{StaticResource ButtonStyle}" ToolTipService.ToolTip="Save edits">
                <Image Source="/ESRI.ArcGIS.Client.Toolkit;component/Images/commit.png" Stretch="None"/>
               </Button>
               <Button x:Name="DisplayAttribute" IsEnabled="True" Style="{StaticResource ButtonStyle}" ToolTipService.ToolTip="Display attributes">
                <Image Source="/ESRI.ArcGIS.Client.Toolkit;component/Images/attributes.png" Stretch="None"/>
               </Button>
                                 
                                    <Grid Margin="5,0,0,0">
                <ToggleButton x:Name="Options" Content="..." Style="{StaticResource ToggleButtonStyle}"/>
                <Popup HorizontalOffset="-120" IsOpen="{Binding IsChecked, ElementName=Options}" Visibility="{Binding Visibility, ElementName=Options}" VerticalOffset="40">
                 <Border x:Name="PopupBorder" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Style="{StaticResource BorderStyle}">
                  <StackPanel>
                   <TextBlock Text="Add options"/>
                   <StackPanel Margin="10,5">
                    <CheckBox Content="Freehand draw" IsChecked="{Binding Freehand, Mode=TwoWay}" ToolTipService.ToolTip="for polylines and polygons"/>
                    <CheckBox Content="Autocomplete" IsChecked="{Binding AutoComplete, Mode=TwoWay}" ToolTipService.ToolTip="for polygons"/>
                   </StackPanel>
                  </StackPanel>
                 </Border>
                </Popup>
               </Grid>
              </StackPanel>
             </Border>
            </StackPanel>
           </ControlTemplate>
          </Setter.Value>
         </Setter>
        </Style>
        
       





When you ref your new style it will look somehting like this. Once again look for the red code.

   <StackPanel Orientation="Vertical" HorizontalAlignment="Right" Margin="0,5,5,0" VerticalAlignment="Top" >
                    <esri:EditorWidget x:Name="MyEditorWidget"
                             Map="{Binding ElementName=Map}" 
                                      Width="300" 
                                      AutoSelect="False"
                                      AlwaysDisplayDefaultTemplates="True" 
                                      GeometryServiceUrl="http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"
                                      ShowAttributesOnAdd="True"  
                                      Loaded="EditorWidget_Loaded" Style="{StaticResource EditorWidgetStyle1}"
                                       EditCompleted="EditorWidget_EditCompleted"/>
                </StackPanel>





Christine.
0 Kudos
JerryBiedenbender
Emerging Contributor
This sounds like exactly what I need to do but I do not understand how you went about doing this. Where did you find the style and how do I "ref" it?

My code looks like the following...

<!--Editor Widget StackPanel-->
        <StackPanel  Grid.Row="1"    x:Name="EditorToolStrip" Margin="10,10,0,0" Grid.ColumnSpan="2">
           
            <Border Background="#20000B00" BorderThickness="2" CornerRadius="5"
               HorizontalAlignment="Left"  VerticalAlignment="Top"
               Padding="5" BorderBrush="Black" Height="160" Width="212">
             <Border.Effect>
                  <DropShadowEffect Color="Black" Direction="-45" BlurRadius="20" Opacity=".75" />
             </Border.Effect>
                    <StackPanel     Orientation="Vertical" HorizontalAlignment="Center" Margin="0,5,5,0" VerticalAlignment="Top" Height="139" Width="306">
                    <TextBlock x:Name="EditorTitle"  Text="Editor" Foreground="White" FontWeight="SemiBold" FontSize="14"  TextAlignment="Center" VerticalAlignment="Center"/>
                    <esri:EditorWidget  Width="300"  Map="{Binding ElementName=MyMap}" 
                                        Loaded="EditorWidget_Loaded" 
                                        x:Name="MyEditorWidget"
                                        AlwaysDisplayDefaultTemplates="false"
                                        ShowAttributesOnAdd="True"
                                        GeometryServiceUrl="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" />
                    </StackPanel>
            </Border>
        </StackPanel>





Thanks,
Jerry
0 Kudos
ChristineZeller
Occasional Contributor
Jerry,

If you have Blend you can copy the editor resource and create a new resource style for it. 


Do you have Expression Blend?  In blend you can find the resource and make a copy at that point Blend will reference your new style for you and then you can either make the changes in blend or save and move back to V.S. 2010 and make your changes. 

Here's how you would reference the style.

Style="{StaticResource EditorWidgetStyle1}"


So your code would look something like this:


<!--Editor Widget StackPanel-->
        <StackPanel  Grid.Row="1"    x:Name="EditorToolStrip" Margin="10,10,0,0" Grid.ColumnSpan="2">
           
            <Border Background="#20000B00" BorderThickness="2" CornerRadius="5"
               HorizontalAlignment="Left"  VerticalAlignment="Top"
               Padding="5" BorderBrush="Black" Height="160" Width="212">
             <Border.Effect>
                  <DropShadowEffect Color="Black" Direction="-45" BlurRadius="20" Opacity=".75" />
             </Border.Effect>
                    <StackPanel     Orientation="Vertical" HorizontalAlignment="Center" Margin="0,5,5,0" VerticalAlignment="Top" Height="139" Width="306">
                    <TextBlock x:Name="EditorTitle"  Text="Editor" Foreground="White" FontWeight="SemiBold" FontSize="14"  TextAlignment="Center" VerticalAlignment="Center"/>
                    <esri:EditorWidget  Width="300"  Map="{Binding ElementName=MyMap}" 
                                        Loaded="EditorWidget_Loaded" 
                                        x:Name="MyEditorWidget"
                                        AlwaysDisplayDefaultTemplates="false"
                                        ShowAttributesOnAdd="True"
                                        GeometryServiceUrl="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" 
Style="{StaticResource EditorWidgetStyle1}" />
                    </StackPanel>
            </Border>
        </StackPanel>





Christine
0 Kudos
ChristineZeller
Occasional Contributor
Jerry,

IF you are not familiar with blend and/or templates and styles check out this video

http://resources.arcgis.com/gallery/video/arcgis-api-for-silverlightwpf/details?entryID=AEC40756-142...

Around 38:50 Morton starts to talk about templates and styles and shows how to customize these in Blend.

Hope all this helps.

Christine
0 Kudos
JenniferNery
Esri Regular Contributor
In addition to Christine's references, you can also read up about customizing your controls from this blog post: http://blogs.esri.com/Dev/blogs/silverlightwpf/archive/2010/05/28/Localizing-ArcGIS-Controls.aspx
0 Kudos
JerryBiedenbender
Emerging Contributor
I have expression blend now but whenever I try and build a project a get an error...

"The specified solution configuration "DebugBPC" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solutions.sln /p:Configuration=Debug/p:Platform="Any CPU") or leave those properties blank to use the default solution configuration."

Do I need to configure something to get this working?

Thanks,
Jerry
0 Kudos
JenniferNery
Esri Regular Contributor
0 Kudos
DanielSchatt
Regular Contributor
I'd like to do this as well but there is no editor resource to find, as far as I can tell.  I just added the Editor Widget exactly as demonstrated in the sample and it seems to work fine.  I didn't add a resource under my <Grid.Resources> tag (the sample didn't have that in the code) and no editor resource is listed when I click the Resources tab in Expression Blend.  So where is the editor resource or do I have to create it somehow and if so, how?  Thanks much, appreciate any help!

Dan
0 Kudos