backend-services-push-windows/MainPage.xaml

433 строки
28 KiB
XML

<Page
x:Class="WindowsPushSample.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WindowsPushSample"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<local:InverseBooleanConverter x:Name="inverseBooleanConverter" />
<ControlTemplate x:Key="ButtonControlTemplate1" TargetType="Button">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="#112C3D4F" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="#B22C3D4F" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="#FF2C3D4F" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="#192C3D4F" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="Border"
Storyboard.TargetProperty="Opacity"
To="0.5"
Duration="0" />
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Unfocused" />
<VisualState x:Name="PointerFocused" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="Border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Margin="3">
<ContentPresenter x:Name="ContentPresenter"
Content="{TemplateBinding Content}"
ContentTransitions="{TemplateBinding ContentTransitions}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
<Rectangle x:Name="FocusVisualWhite"
IsHitTestVisible="False"
Stroke="{StaticResource FocusVisualWhiteStrokeThemeBrush}"
StrokeEndLineCap="Square"
StrokeDashArray="1,1"
Opacity="0"
StrokeDashOffset="1.5" />
<Rectangle x:Name="FocusVisualBlack"
IsHitTestVisible="False"
Stroke="{StaticResource FocusVisualBlackStrokeThemeBrush}"
StrokeEndLineCap="Square"
StrokeDashArray="1,1"
Opacity="0"
StrokeDashOffset="0.5" />
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="TextBoxControlTemplate1" TargetType="TextBox">
<Grid>
<Grid.Resources>
<Style x:Name="DeleteButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPointerOverBackgroundThemeBrush}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPointerOverBorderThemeBrush}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPointerOverForegroundThemeBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPressedBackgroundThemeBrush}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPressedBorderThemeBrush}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPressedForegroundThemeBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="BackgroundElement"
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0" />
<DoubleAnimation Storyboard.TargetName="BorderElement"
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="BorderElement"
BorderBrush="{StaticResource TextBoxButtonBorderThemeBrush}"
BorderThickness="{TemplateBinding BorderThickness}"/>
<Border x:Name="BackgroundElement"
Background="{StaticResource TextBoxButtonBackgroundThemeBrush}"
Margin="{TemplateBinding BorderThickness}">
<TextBlock x:Name="GlyphElement"
Foreground="{StaticResource TextBoxButtonForegroundThemeBrush}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Text="&#xE0A4;"
FontFamily="{StaticResource SymbolThemeFontFamily}"/>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="BorderElement"
Storyboard.TargetProperty="Opacity"
To="0.2" Duration="0" />
<DoubleAnimation Storyboard.TargetName="BackgroundElement"
Storyboard.TargetProperty="Opacity"
To="0.2" Duration="0" />
<!--<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxDisabledBackgroundThemeBrush}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxDisabledBorderThemeBrush}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement"
Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxDisabledForegroundThemeBrush}" />
</ObjectAnimationUsingKeyFrames>-->
</Storyboard>
</VisualState>
<VisualState x:Name="Normal">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="BackgroundElement"
Storyboard.TargetProperty="Opacity"
Duration="0"
To="{StaticResource TextControlBackgroundThemeOpacity}" />
<DoubleAnimation Storyboard.TargetName="BorderElement"
Storyboard.TargetProperty="Opacity"
Duration="0"
To="{StaticResource TextControlBorderThemeOpacity}" />
</Storyboard>
</VisualState>
<VisualState x:Name="PointerOver">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="BackgroundElement"
Storyboard.TargetProperty="Opacity"
Duration="0"
To="{StaticResource TextControlPointerOverBackgroundThemeOpacity}" />
<DoubleAnimation Storyboard.TargetName="BorderElement"
Storyboard.TargetProperty="Opacity"
Duration="0"
To="{StaticResource TextControlPointerOverBorderThemeOpacity}" />
</Storyboard>
</VisualState>
<VisualState x:Name="Focused" />
</VisualStateGroup>
<VisualStateGroup x:Name="ButtonStates">
<VisualState x:Name="ButtonVisible">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DeleteButton"
Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="ButtonCollapsed" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Border x:Name="BackgroundElement"
Background="{TemplateBinding Background}"
Margin="{TemplateBinding BorderThickness}"
Grid.ColumnSpan="2"/>
<Border x:Name="BorderElement"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Grid.ColumnSpan="2"/>
<ScrollViewer x:Name="ContentElement"
HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
Margin="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
IsTabStop="False"
ZoomMode="Disabled" />
<Button x:Name="DeleteButton"
Style="{StaticResource DeleteButtonStyle}"
BorderThickness="{TemplateBinding BorderThickness}"
IsTabStop="False"
Grid.Column="1"
Visibility="Collapsed"
FontSize="{TemplateBinding FontSize}"
VerticalAlignment="Stretch"/>
</Grid>
</ControlTemplate>
<Style x:Key="buttonStyle" TargetType="Button">
<Setter Property="Foreground" Value="#FF2C3D4F" />
<Setter Property="BorderBrush" Value="#FF2C3D4F" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FontFamily" Value="Open-Sans" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Template" Value="{StaticResource ButtonControlTemplate1}" />
</Style>
<Style x:Key="textBoxStyle" TargetType="TextBox">
<Setter Property="Foreground" Value="#FF2C3D4F" />
<Setter Property="BorderBrush" Value="#FFDBE3E4" />
<Setter Property="BorderThickness" Value="2" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Height" Value="35" />
<Setter Property="Template" Value="{StaticResource TextBoxControlTemplate1}" />
</Style>
<Style x:Key="textBlockStyleBold" TargetType="TextBlock">
<Setter Property="FontSize" Value="16" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Foreground" Value="#FF2C3D4F" />
<Setter Property="Margin" Value="3, 0, 0, 0" />
</Style>
<Style x:Key="textBlockStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="13" />
<Setter Property="Foreground" Value="#FF2C3D4F" />
<Setter Property="FontFamily" Value="Open-Sans" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Margin" Value="3, 7, 0, 7" />
<Setter Property="Padding" Value="3" />
</Style>
</Page.Resources>
<Grid Background="White" Width="1280" Height="900"
HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="150" />
<RowDefinition Height="40" />
<RowDefinition Height="120" />
<RowDefinition Height="40" />
<RowDefinition Height="70" />
<RowDefinition Height="20" />
<RowDefinition Height="270" />
<RowDefinition Height="150" />
</Grid.RowDefinitions>
<!--header row-->
<StackPanel Grid.Row="0" Orientation="Horizontal" Background="#2D3F51">
<Image x:Name="headerLogo" Source="Assets/logo24x24.png" Margin="20, 0, 0, 0" Height="24" Width="24"/>
<TextBlock Text="Windows Push Sample" Margin="10, 0, 0, 0" VerticalAlignment="Center" FontSize="14"/>
</StackPanel>
<!--Application Management region-->
<Border BorderBrush="#FFDBE3E4" BorderThickness="1" Width="800" Height="110" VerticalAlignment="Bottom"
Grid.Row="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2.9*" />
<ColumnDefinition Width="0.1*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left"
Margin="30, 0, 0, 0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Text="Application management" Grid.Row="0"
FontSize="20" Foreground="#FF2C3D4F"
FontFamily="Open-Sans" FontWeight="Light"/>
<TextBlock Text="You have to register your device before you can start sending push notifications."
Grid.Row="1" Margin="0, 5, 0, 0" TextWrapping="Wrap" LineHeight="18"
FontSize="13" Foreground="#B22C3D4F"/>
</Grid>
<Grid Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right"
Margin="5, 0, 30, 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="Register" Click="OnRegisterClick"
Height="35" Padding="7, 0, 7, 0" Width="120"
Style="{StaticResource buttonStyle}"
IsEnabled="{Binding IsDeviceRegistered, Converter={StaticResource inverseBooleanConverter}}"/>
<Button Grid.Column="1" Content="Unregister" Click="OnUnregisterClick"
Height="35" Margin="2, 0, 0, 0"
Padding="7, 0, 7, 0" Width="120"
Style="{StaticResource buttonStyle}"
IsEnabled="{Binding IsDeviceRegistered}"/>
</Grid>
</Grid>
</Border>
<!--Toast message region-->
<StackPanel Grid.Row="3" Width="800" HorizontalAlignment="Center">
<TextBlock Text="Toast message:" Style="{StaticResource textBlockStyleBold}"/>
<TextBox x:Name="pushNotificationMessage"
Margin="3, 7, 0, 7" Padding="3"
HorizontalAlignment="Stretch"
Text="My first Windows Push Notification!"
Style="{StaticResource textBoxStyle}" IsEnabled="{Binding IsDeviceRegistered}"
/>
<Button Content="Send Push Notification" Click="OnSendClick" Margin="0, 10, 0, 0"
Width="170" Padding="5" Style="{StaticResource buttonStyle}" IsEnabled="{Binding IsDeviceRegistered}"
/>
</StackPanel>
<!--Second tile settings region-->
<StackPanel Grid.Row="5" Width="800" HorizontalAlignment="Center">
<TextBlock Text="Second Tile Settings" Style="{StaticResource textBlockStyleBold}"/>
<Grid Margin="0, 10, 0, 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal" >
<Button Content="Pin Second Tile" Click="OnPinSecondTileClick"
Width="170" Style="{StaticResource buttonStyle}" IsEnabled="{Binding IsSecondaryTilePinned, Converter={StaticResource inverseBooleanConverter}}"/>
<Button Content="Register Second Tile" Click="OnRegisterSecondTileClick"
Width="170" Style="{StaticResource buttonStyle}" IsEnabled="{Binding ShowRegisterSecondTileButton}"
Margin="4, 0, 0, 0" />
</StackPanel>
<Button Content="Unpin Second Tile" Grid.Column="1" Click="OnUnpinSecondTileClick"
Width="170" Padding="5" Style="{StaticResource buttonStyle}"
HorizontalAlignment="Right" Template="{StaticResource ButtonControlTemplate1}"
IsEnabled="{Binding IsSecondaryTilePinned}"/>
</Grid>
</StackPanel>
<!--Second tile data region-->
<Grid Grid.Row="7" Width="800" HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Text="Image:" Grid.Column="0" Grid.Row="0" Style="{StaticResource textBlockStyle}"/>
<TextBox x:Name="image1" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch"
Style="{StaticResource textBoxStyle}" Text=".\Assets\logo150x150.png"
IsEnabled="{Binding IsSecondaryTileRegistered}"/>
<TextBlock Text="Text1:" Grid.Column="0" Grid.Row="1" Style="{StaticResource textBlockStyle}"/>
<TextBlock Text="Text2:" Grid.Column="0" Grid.Row="2" Style="{StaticResource textBlockStyle}"/>
<TextBlock Text="Text3:" Grid.Column="0" Grid.Row="3" Style="{StaticResource textBlockStyle}"/>
<TextBlock Text="Text4:" Grid.Column="0" Grid.Row="4" Style="{StaticResource textBlockStyle}"/>
<TextBox x:Name="text1" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Stretch"
Style="{StaticResource textBoxStyle}"
Text="WindowsPushSample" IsEnabled="{Binding IsSecondaryTileRegistered}"/>
<TextBox x:Name="text2" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Stretch"
Style="{StaticResource textBoxStyle}"
Text="Text2" IsEnabled="{Binding IsSecondaryTileRegistered}"/>
<TextBox x:Name="text3" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Stretch"
Style="{StaticResource textBoxStyle}"
Text="Text3" IsEnabled="{Binding IsSecondaryTileRegistered}"/>
<TextBox x:Name="text4" Grid.Column="1" Grid.Row="4" HorizontalAlignment="Stretch"
Style="{StaticResource textBoxStyle}"
Text="Text4" IsEnabled="{Binding IsSecondaryTileRegistered}"/>
<Button Content="Send Push Second Tile" Click="OnSendPushToSecondTileClick"
Margin="0, 10, 0, 0" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="5"
Width="170" Padding="5" HorizontalAlignment="Left" Style="{StaticResource buttonStyle}"
IsEnabled="{Binding IsSecondaryTileRegistered}"/>
</Grid>
<TextBlock x:Name="statusText" Grid.Row="8" Margin="10" FontSize="16" Padding="5"
VerticalAlignment="Bottom"/>
<Image x:Name="logo" Grid.Row="8"
Source="Assets/logo150x150.png"
Margin="0, 0, 10, 0"
VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="150" Height="150"/>
</Grid>
</Page>