Addressed the Window.CommandBindings TODO.
* Similar amount of code, but does seem like a more natural/extensible approach.
This commit is contained in:
Родитель
3f584e01c7
Коммит
db699255b8
|
@ -185,23 +185,11 @@ namespace BabySmash
|
|||
|
||||
public void ProcessKey(FrameworkElement uie, KeyEventArgs e)
|
||||
{
|
||||
bool Alt = (Keyboard.Modifiers & ModifierKeys.Alt) != 0;
|
||||
bool Control = (Keyboard.Modifiers & ModifierKeys.Control) != 0;
|
||||
bool Shift = (Keyboard.Modifiers & ModifierKeys.Shift) != 0;
|
||||
|
||||
if (uie.IsMouseCaptured)
|
||||
{
|
||||
uie.ReleaseMouseCapture();
|
||||
}
|
||||
|
||||
//TODO: Might be able to remove this: http://www.ageektrapped.com/blog/using-commands-in-babysmash/
|
||||
if (Alt && Control && Shift && e.Key == Key.O)
|
||||
{
|
||||
ShowOptionsDialog();
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
char displayChar = GetDisplayChar(e.Key);
|
||||
AddFigure(uie, displayChar);
|
||||
}
|
||||
|
@ -514,7 +502,7 @@ namespace BabySmash
|
|||
}
|
||||
}
|
||||
|
||||
private void ShowOptionsDialog()
|
||||
public void ShowOptionsDialog()
|
||||
{
|
||||
bool foo = Settings.Default.TransparentBackground;
|
||||
isOptionsDialogShown = true;
|
||||
|
|
|
@ -1,30 +1,37 @@
|
|||
<Window x:Class="BabySmash.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:BabySmash"
|
||||
xmlns:local="clr-namespace:BabySmash"
|
||||
Title="Baby Smash by Scott Hanselman - http://www.hanselman.com/babysmash"
|
||||
Height="500" Width="500" WindowStyle="None" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
AllowsTransparency="True">
|
||||
AllowsTransparency="True">
|
||||
|
||||
<Window.Resources>
|
||||
<Storyboard x:Key="Timeline1" Timeline.DesiredFrameRate="10">
|
||||
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="Forever"
|
||||
<Window.Resources>
|
||||
<Storyboard x:Key="Timeline1" Timeline.DesiredFrameRate="10">
|
||||
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="Forever"
|
||||
AutoReverse="True" Storyboard.TargetName="UpdateGlow"
|
||||
Storyboard.TargetProperty="GlowColor" >
|
||||
<SplineColorKeyFrame Value="#FFCDCDCD" KeyTime="00:00:00"/>
|
||||
<SplineColorKeyFrame Value="#FFB92121" KeyTime="00:00:01"/>
|
||||
<SplineColorKeyFrame Value="#FF2921B9" KeyTime="00:00:02"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</Window.Resources>
|
||||
<SplineColorKeyFrame Value="#FFCDCDCD" KeyTime="00:00:00"/>
|
||||
<SplineColorKeyFrame Value="#FFB92121" KeyTime="00:00:01"/>
|
||||
<SplineColorKeyFrame Value="#FF2921B9" KeyTime="00:00:02"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</Window.Resources>
|
||||
|
||||
<Window.Triggers>
|
||||
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
|
||||
<BeginStoryboard Storyboard="{StaticResource Timeline1}"/>
|
||||
</EventTrigger>
|
||||
<EventTrigger RoutedEvent="FrameworkElement.Loaded"/>
|
||||
</Window.Triggers>
|
||||
<Window.CommandBindings>
|
||||
<CommandBinding Command="Properties" Executed="Properties_Executed"/>
|
||||
</Window.CommandBindings>
|
||||
|
||||
<Window.InputBindings>
|
||||
<KeyBinding Gesture="CTRL+ALT+SHIFT+O" Command="{x:Static ApplicationCommands.Properties}" />
|
||||
</Window.InputBindings>
|
||||
|
||||
<Window.Triggers>
|
||||
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
|
||||
<BeginStoryboard Storyboard="{StaticResource Timeline1}"/>
|
||||
</EventTrigger>
|
||||
<EventTrigger RoutedEvent="FrameworkElement.Loaded"/>
|
||||
</Window.Triggers>
|
||||
|
||||
<!--<Window.Triggers>
|
||||
<EventTrigger RoutedEvent="Window.Loaded">
|
||||
|
@ -71,29 +78,29 @@
|
|||
</Window.Background>-->
|
||||
|
||||
<Grid Name="mainGrid">
|
||||
<StackPanel>
|
||||
<StackPanel>
|
||||
<TextBlock x:Name="infoLabel" Margin="15,15,0,0" FontSize="12" Visibility="Hidden">
|
||||
<TextBlock.BitmapEffect>
|
||||
<BitmapEffectGroup>
|
||||
<OuterGlowBitmapEffect GlowColor="Yellow" GlowSize="3"/>
|
||||
</BitmapEffectGroup>
|
||||
</TextBlock.BitmapEffect>
|
||||
<Bold>BabySmash!</Bold> by Scott Hanselman <Italic>with community contributions!</Italic> - http://www.babysmash.com
|
||||
<TextBlock.BitmapEffect>
|
||||
<BitmapEffectGroup>
|
||||
<OuterGlowBitmapEffect GlowColor="Yellow" GlowSize="3"/>
|
||||
</BitmapEffectGroup>
|
||||
</TextBlock.BitmapEffect>
|
||||
<Bold>BabySmash!</Bold> by Scott Hanselman <Italic>with community contributions!</Italic> - http://www.babysmash.com
|
||||
<LineBreak/>
|
||||
<Bold>Ctrl-Shift-Alt-O</Bold> for options, <Bold>ALT-F4</Bold> to exit
|
||||
</TextBlock>
|
||||
<Bold>Ctrl-Shift-Alt-O</Bold> for options, <Bold>ALT-F4</Bold> to exit
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="UpdateAvailableLabel" Visibility="Hidden" Margin="15,10,0,0" FontSize="12">
|
||||
<TextBlock.BitmapEffect>
|
||||
<BitmapEffectGroup>
|
||||
<OuterGlowBitmapEffect x:Name="UpdateGlow" GlowColor="Red" GlowSize="3"/>
|
||||
</BitmapEffectGroup>
|
||||
</TextBlock.BitmapEffect>
|
||||
<TextBlock.BitmapEffect>
|
||||
<BitmapEffectGroup>
|
||||
<OuterGlowBitmapEffect x:Name="UpdateGlow" GlowColor="Red" GlowSize="3"/>
|
||||
</BitmapEffectGroup>
|
||||
</TextBlock.BitmapEffect>
|
||||
<Bold>Updating BabySmash in the background...</Bold>
|
||||
<ProgressBar HorizontalAlignment="Left" x:Name="updateProgress" Value="0" Minimum="0" Maximum="100" Margin="0,0,0,0" Height="10" Width="130"/>
|
||||
</TextBlock>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<Canvas Name="figuresCanvas"/>
|
||||
<Canvas Name="mouseDragCanvas"/>
|
||||
<Canvas Name="mouseCursorCanvas"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
|
@ -113,5 +113,10 @@ namespace BabySmash
|
|||
//we can die here if we ALT-F4 while in the Options Dialog
|
||||
}
|
||||
}
|
||||
|
||||
private void Properties_Executed(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
controller.ShowOptionsDialog();
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче