Skip to content

Commit

Permalink
Disabling lock focus button until 3D is enabled once (#142)
Browse files Browse the repository at this point in the history
Fixes #140
  • Loading branch information
Gary Sheppard authored Jan 2, 2018
1 parent 7886f34 commit dfa9e21
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ ArcGIS Runtime also supports 3D visualization. Everyone loves 3D! To conclude th
private bool threeD = false;
```
11. In MainWindow.xaml we need to add a click event to the button to toggle to a 3D view. Visual Studio will create the for you when start typeing the Click= and you can tab to have the event handler created automatically.
11. In MainWindow.xaml we need to add a click event to the button to toggle to a 3D view. Visual Studio will create the for you when start typing the Click= and you can tab to have the event handler created automatically.
```
<Button x:Name="ViewButton" Click="ViewButton_Click" Width="50" Height="50" Padding="1" Margin="0,5,5,5" HorizontalAlignment="Right" RenderTransformOrigin="4.054,-0.693" Content="{DynamicResource 3D}"/>
Expand All @@ -120,7 +120,7 @@ ArcGIS Runtime also supports 3D visualization. Everyone loves 3D! To conclude th
{
}
```
12. Next let's add the code to change the image on the button and toogle the the threeD variable to be true or false:
12. Next let's add the code to change the image on the button and toggle the threeD variable to be true or false:
```
private void ViewButton_Click(object sender, RoutedEventArgs e)
{
Expand Down
19 changes: 14 additions & 5 deletions runtime-workshop/exercises/dotNETWPF/Exercise 2 Zoom Buttons.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,24 @@ This portion of the exercise will teach you how to use _camera controllers_ in A
<Image x:Key="LockFocusSelected" Source="images/lock_selected.png" Stretch="Fill"/>
```
1. Next we need to creat a new button and put it on the UI. So in MainWindow.xml, in the <Grid></Grid> add a new area to put the next set of buttons in on the UI. We will want a border, stackpanel, and a new button using the images we added above.:
1. Next we need to create a new button and put it on the UI. So in MainWindow.xaml, in the <Grid></Grid> add a new area to put the next set of buttons in on the UI. We will want a border, stackpanel, and a new button using the images we added above. Set the button's `IsEnabled` property to false so that it can't be clicked until the user has toggled to 3D at some point. Here is the code to insert in MainWindow.xaml:
```
<Border VerticalAlignment="Bottom"
Margin="0,0,65,0" Width="67" Height="180" HorizontalAlignment="Right">
<StackPanel Margin="0" Width="72" VerticalAlignment="Top">
<Button x:Name="LockButton" Click="LockButton_Click" Width="50" Height="50" Padding="1" Margin="0,5,5,5" HorizontalAlignment="Right" RenderTransformOrigin="4.054,-0.693" Content="{DynamicResource LockFocus}"/>
</StackPanel>
</Border>
<StackPanel Margin="0" Width="72" VerticalAlignment="Top">
<Button x:Name="LockButton" Click="LockButton_Click" Width="50" Height="50"
Padding="1" Margin="0,5,5,5" HorizontalAlignment="Right"
RenderTransformOrigin="4.054,-0.693"
Content="{DynamicResource LockFocus}" IsEnabled="False"/>
</StackPanel>
</Border>
```
1. In your 2D/3D toggle button listener, which we called `ViewButton_Click` in Exercise 1, you probably have an `if` block that means the user is toggling from 2D to 3D. If it is the first time that 3D has been enabled, you have a code block that creates a new `Scene`. In that same block, enable your new lock focus button:
```
LockButton.IsEnabled = true;
```
1. Add a click event to the button called LockButton_Click and in the MainWindow.cs it looks like this:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<Border VerticalAlignment="Bottom"
Margin="0,0,65,0" Width="67" Height="180" HorizontalAlignment="Right">
<StackPanel Margin="0" Width="72" VerticalAlignment="Top">
<Button x:Name="LockButton" Click="LockButton_Click" Width="50" Height="50" Padding="1" Margin="0,5,5,5" HorizontalAlignment="Right" RenderTransformOrigin="4.054,-0.693" Content="{DynamicResource LockFocus}"/>
<Button x:Name="LockButton" Click="LockButton_Click" Width="50" Height="50" Padding="1" Margin="0,5,5,5" HorizontalAlignment="Right" RenderTransformOrigin="4.054,-0.693" Content="{DynamicResource LockFocus}" IsEnabled="False"/>
</StackPanel>
</Border>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ private void ViewButton_Click(object sender, RoutedEventArgs e)
sceneSurface.ElevationSources.Add(elevationSource);
// apply the surface to the scene
sceneView.Scene.BaseSurface = sceneSurface;

// Exercise 2: Enable the lock focus button
LockButton.IsEnabled = true;
}
//Once the scene has been created hide the mapView and show the sceneView
mapView.Visibility = Visibility.Hidden;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<Border VerticalAlignment="Bottom"
Margin="0,0,65,0" Width="67" Height="180" HorizontalAlignment="Right">
<StackPanel Margin="0" Width="72" VerticalAlignment="Top">
<Button x:Name="LockButton" Click="LockButton_Click" Width="50" Height="50" Padding="1" Margin="0,5,5,5" HorizontalAlignment="Right" RenderTransformOrigin="4.054,-0.693" Content="{DynamicResource LockFocus}"/>
<Button x:Name="LockButton" Click="LockButton_Click" Width="50" Height="50" Padding="1" Margin="0,5,5,5" HorizontalAlignment="Right" RenderTransformOrigin="4.054,-0.693" Content="{DynamicResource LockFocus}" IsEnabled="False"/>
</StackPanel>
</Border>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ private void ViewButton_Click(object sender, RoutedEventArgs e)
sceneView.Scene.BaseSurface = sceneSurface;
sceneView.Scene = myScene;

// Exercise 2: Enable the lock focus button
LockButton.IsEnabled = true;

_sceneLayer = new ArcGISSceneLayer(new Uri(SCENE_SERVICE_URL));
myScene.OperationalLayers.Add(_sceneLayer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<Border VerticalAlignment="Bottom"
Margin="0,0,65,0" Width="67" Height="180" HorizontalAlignment="Right">
<StackPanel Margin="0" Width="72" VerticalAlignment="Top">
<Button x:Name="LockButton" Click="LockButton_Click" Width="50" Height="50" Padding="1" Margin="0,5,5,5" HorizontalAlignment="Right" RenderTransformOrigin="4.054,-0.693" Content="{DynamicResource LockFocus}"/>
<Button x:Name="LockButton" Click="LockButton_Click" Width="50" Height="50" Padding="1" Margin="0,5,5,5" HorizontalAlignment="Right" RenderTransformOrigin="4.054,-0.693" Content="{DynamicResource LockFocus}" IsEnabled="False"/>
</StackPanel>
</Border>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ private void ViewButton_Click(object sender, RoutedEventArgs e)
sceneView.Scene.BaseSurface = sceneSurface;
sceneView.Scene = myScene;

// Exercise 2: Enable the lock focus button
LockButton.IsEnabled = true;

_sceneLayer = new ArcGISSceneLayer(new Uri(SCENE_SERVICE_URL));
myScene.OperationalLayers.Add(_sceneLayer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<Border VerticalAlignment="Bottom"
Margin="0,0,65,0" Width="67" Height="180" HorizontalAlignment="Right">
<StackPanel Margin="0" Width="72" VerticalAlignment="Top">
<Button x:Name="LockButton" Click="LockButton_Click" Width="50" Height="50" Padding="1" Margin="0,5,5,5" HorizontalAlignment="Right" RenderTransformOrigin="4.054,-0.693" Content="{DynamicResource LockFocus}"/>
<Button x:Name="LockButton" Click="LockButton_Click" Width="50" Height="50" Padding="1" Margin="0,5,5,5" HorizontalAlignment="Right" RenderTransformOrigin="4.054,-0.693" Content="{DynamicResource LockFocus}" IsEnabled="False"/>
</StackPanel>
</Border>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ private void ViewButton_Click(object sender, RoutedEventArgs e)
// apply the surface to the scene
sceneView.Scene.BaseSurface = sceneSurface;

// Exercise 2: Enable the lock focus button
LockButton.IsEnabled = true;

sceneView.Scene = myScene;

_sceneLayer = new ArcGISSceneLayer(new Uri(SCENE_SERVICE_URL));
Expand Down

0 comments on commit dfa9e21

Please sign in to comment.