Local Server Management

This sample demonstrates how to use the ArcGIS Runtime SDK for WPF to manage the Local Server and how to start and stop Local Services.
Download Sample Application<UserControl x:Class="ArcGISWPFSDK.LocalServerManagement" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:esri="http://schemas.esri.com/arcgis/client/2009" xmlns:local="clr-namespace:ArcGISWPFSDK"> <Grid Background="#FFE3E3E3"> <Grid.Resources> <local:getServiceTypeConverter x:Key="converter" /> <LinearGradientBrush x:Key="PanelGradient" EndPoint="0.5,1" StartPoint="0.5,0"> <LinearGradientBrush.RelativeTransform> <TransformGroup> <ScaleTransform CenterY="0.5" CenterX="0.5"/> <SkewTransform CenterY="0.5" CenterX="0.5"/> <RotateTransform Angle="176" CenterY="0.5" CenterX="0.5"/> <TranslateTransform/> </TransformGroup> </LinearGradientBrush.RelativeTransform> <GradientStop Color="#FF145787" Offset="0.16"/> <GradientStop Color="#FF3D7FAC" Offset="0.502"/> <GradientStop Color="#FF88C5EF" Offset="0.984"/> </LinearGradientBrush> </Grid.Resources> <Grid HorizontalAlignment="Center" MaxWidth="800" MaxHeight="320"> <Rectangle Fill="{StaticResource PanelGradient}" Stroke="Black" StrokeThickness="1" RadiusX="10" RadiusY="10" Margin="-5,-5,-5,-5"> <Rectangle.Effect> <DropShadowEffect/> </Rectangle.Effect> </Rectangle> <Grid> <Grid.RowDefinitions> <RowDefinition Height="25"/> <RowDefinition Height="25"/> <RowDefinition Height="5"/> <RowDefinition Height="25"/> <RowDefinition Height="10"/> <RowDefinition Height="80"/> <RowDefinition Height="15"/> <RowDefinition Height="10"/> <RowDefinition Height="10"/> <RowDefinition Height="100"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="200"/> <ColumnDefinition Width="400"/> </Grid.ColumnDefinitions> <TextBlock Grid.Row="0" Grid.Column="0" Text="LocalServer Controls" FontWeight="Bold" VerticalAlignment="Center" /> <Button x:Name="ButtonStart" Grid.Row="1" Content="Start Local Server" Margin="0,0,6,0" Width="194" Click="ButtonStart_Click" /> <Button x:Name="ButtonStop" Grid.Row="3" Content="Stop Local Server" Margin="0,0,6,0" Width="194" Click="ButtonStop_Click" /> <TextBlock Grid.Row="0" Grid.Column="1" Text="Local Services Controls" FontWeight="Bold" VerticalAlignment="Center"/> <ComboBox x:Name="ServiceComboBox" Grid.Row="1" Grid.Column="1" HorizontalContentAlignment="Left" SelectionChanged="ServiceComboBox_SelectionChanged"/> <Button x:Name="StartService" Grid.Row="3" Grid.Column="1" Content="Start Service" HorizontalAlignment="Left" Width="200" Click="StartService_Click" /> <Button x:Name="StopService" Grid.Row="3" Grid.Column="1" Content="Stop Service" HorizontalAlignment="Right" Width="194" Click="StopService_Click" /> <ListBox Grid.Row="5" Grid.ColumnSpan="2" > <TextBlock> <Run x:Name="LocalServerStatusText" Foreground="Gray" /> <TextBlock x:Name="Caption" Foreground="Gray" /> <Button x:Name="UrlHyperlink" Cursor="Hand" Click="UrlButton_Click" > <Button.Template> <ControlTemplate TargetType="Button"> <TextBlock TextDecorations="Underline"> <ContentPresenter /> </TextBlock> </ControlTemplate> </Button.Template> <Button.Style> <Style TargetType="Button"> <Setter Property="Foreground" Value="Blue" /> <Style.Triggers> <Trigger Property="IsMouseOver" Value="true"> <Setter Property="Foreground" Value="Red" /> </Trigger> </Style.Triggers> </Style> </Button.Style> </Button> </TextBlock> </ListBox> <TextBlock Grid.Row="7" Grid.ColumnSpan="2" Text="Local Services" FontWeight="Bold" VerticalAlignment="Center" /> <ListBox Grid.Row="9" Grid.ColumnSpan="2" ItemsSource="{Binding Source={x:Static esri:LocalServer.Services}}" VerticalAlignment="Stretch" Height="100"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock> <Run Foreground="Gray" Text="{Binding Path=Name, Converter={StaticResource converter}}"/> <Run Foreground="Gray" Text="{Binding Status, Mode=OneWay}"/> <Run Foreground="Gray" Text="... "/> </TextBlock> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Grid> </Grid> </Grid> </UserControl>
5/16/2014