CheckPasswordDialog.xaml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <UserControl
  2. x:Class="PDF_Master.Views.Dialog.ToolsDialogs.SaftyDialogs.CheckPasswordDialog"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:cus="clr-namespace:PDF_Master.CustomControl"
  6. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  7. xmlns:help="clr-namespace:PDF_Master.Helper"
  8. xmlns:prism="http://prismlibrary.com/"
  9. xmlns:saftydialogs="clr-namespace:PDF_Master.ViewModels.Dialog.ToolsDialogs.SaftyDialogs"
  10. prism:Dialog.WindowStyle="{StaticResource DialogWindowStyle}"
  11. prism:ViewModelLocator.AutoWireViewModel="True"
  12. Loaded="UserControl_Loaded">
  13. <UserControl.Resources>
  14. <Style x:Key="CheckPasswordBoxStyle" TargetType="PasswordBox">
  15. <Setter Property="Height" Value="32" />
  16. <Setter Property="FontSize" Value="14" />
  17. <Setter Property="Template">
  18. <Setter.Value>
  19. <ControlTemplate TargetType="PasswordBox">
  20. <Border
  21. x:Name="border"
  22. Background="{TemplateBinding Background}"
  23. BorderBrush="{TemplateBinding BorderBrush}"
  24. BorderThickness="{TemplateBinding BorderThickness}"
  25. CornerRadius="5"
  26. SnapsToDevicePixels="True">
  27. <Grid>
  28. <Grid.ColumnDefinitions>
  29. <ColumnDefinition />
  30. <ColumnDefinition Width="24" />
  31. </Grid.ColumnDefinitions>
  32. <Grid Grid.Column="0" Margin="8,0,0,0">
  33. <TextBlock
  34. Name="markText"
  35. Grid.Column="1"
  36. VerticalAlignment="Center"
  37. FontSize="12"
  38. Foreground="#BBB"
  39. Text="{TemplateBinding help:PasswordBoxHelper.DisplayText}"
  40. Visibility="Collapsed" />
  41. <ScrollViewer
  42. x:Name="PART_ContentHost"
  43. MinHeight="20"
  44. VerticalAlignment="Center"
  45. Focusable="false"
  46. HorizontalScrollBarVisibility="Hidden"
  47. VerticalScrollBarVisibility="Hidden" />
  48. </Grid>
  49. </Grid>
  50. </Border>
  51. <ControlTemplate.Triggers>
  52. <Trigger Property="IsEnabled" Value="false">
  53. <Setter TargetName="border" Property="Opacity" Value="0.56" />
  54. </Trigger>
  55. <Trigger Property="IsMouseOver" Value="true">
  56. <Setter TargetName="border" Property="BorderBrush" Value="#FF7EB4EA" />
  57. </Trigger>
  58. <Trigger Property="IsKeyboardFocused" Value="true">
  59. <Setter TargetName="border" Property="BorderBrush" Value="#1770F4" />
  60. </Trigger>
  61. <DataTrigger Binding="{Binding Path=Password}" Value="">
  62. <Setter TargetName="markText" Property="Visibility" Value="Visible" />
  63. </DataTrigger>
  64. <DataTrigger Binding="{Binding Path=IsRightValue}" Value="false">
  65. <Setter TargetName="border" Property="BorderBrush" Value="#F3465B" />
  66. </DataTrigger>
  67. </ControlTemplate.Triggers>
  68. </ControlTemplate>
  69. </Setter.Value>
  70. </Setter>
  71. </Style>
  72. <Style x:Key="DeletePasswordButtonStyle" TargetType="Button">
  73. <Setter Property="Height" Value="14" />
  74. <Setter Property="Width" Value="14" />
  75. <Setter Property="HorizontalContentAlignment" Value="Center" />
  76. <Setter Property="VerticalContentAlignment" Value="Center" />
  77. <Setter Property="Template">
  78. <Setter.Value>
  79. <ControlTemplate TargetType="{x:Type ButtonBase}">
  80. <Grid>
  81. <Viewbox Stretch="Uniform">
  82. <Grid Background="Transparent">
  83. <Path Data="M7 14C10.866 14 14 10.866 14 7C14 3.13401 10.866 0 7 0C3.13401 0 0 3.13401 0 7C0 10.866 3.13401 14 7 14ZM10.5303 4.53038L8.06069 7L10.5303 9.46962L9.46967 10.5303L7.00002 8.06066L4.53033 10.5303L3.46967 9.46967L5.93936 7L3.46967 4.53033L4.53033 3.46967L7.00002 5.93934L9.46967 3.46971L10.5303 4.53038Z" Fill="#CED0D4" />
  84. </Grid>
  85. </Viewbox>
  86. </Grid>
  87. </ControlTemplate>
  88. </Setter.Value>
  89. </Setter>
  90. </Style>
  91. </UserControl.Resources>
  92. <cus:DialogContent FontFamily="Segoe UI" Header="{Binding PasswordDialogTitle}">
  93. <cus:DialogContent.Content>
  94. <Grid
  95. Width="400"
  96. MinHeight="106"
  97. Margin="16,0,16,0">
  98. <Grid.ColumnDefinitions>
  99. <ColumnDefinition Width="80" />
  100. <ColumnDefinition />
  101. </Grid.ColumnDefinitions>
  102. <Image Margin="0,-20,0,0" Source="pack://application:,,,/Resources/Dialog/password.png" />
  103. <Grid Grid.Column="1" Margin="8,0,0,0">
  104. <Grid.RowDefinitions>
  105. <RowDefinition MinHeight="44" />
  106. <RowDefinition Height="40" />
  107. <RowDefinition />
  108. </Grid.RowDefinitions>
  109. <Grid Grid.Row="0">
  110. <TextBlock
  111. Block.TextAlignment="Left"
  112. FontFamily="Segoe UI"
  113. FontSize="14"
  114. Text="{Binding InputPasswordMsg, Mode=TwoWay}"
  115. TextWrapping="Wrap" />
  116. </Grid>
  117. <Grid
  118. Grid.Row="1"
  119. Margin="0,8,0,0"
  120. FocusManager.FocusedElement="{Binding ElementName=InputBox}">
  121. <Grid.ColumnDefinitions>
  122. <ColumnDefinition />
  123. <ColumnDefinition Width="23" />
  124. </Grid.ColumnDefinitions>
  125. <PasswordBox
  126. Name="InputBox"
  127. Grid.ColumnSpan="2"
  128. help:PasswordBoxHelper.DisplayText="{Binding CheckPasswordMsg, Mode=TwoWay}"
  129. help:PasswordBoxHelper.IsRightValue="{Binding IsRightValue, Mode=TwoWay}"
  130. help:PasswordBoxHelper.Password="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
  131. Focusable="True"
  132. PasswordChar="*"
  133. Style="{StaticResource CheckPasswordBoxStyle}" />
  134. <Button
  135. Grid.Column="1"
  136. HorizontalAlignment="Left"
  137. Command="{Binding ClearPasswordCommand}"
  138. Style="{StaticResource DeletePasswordButtonStyle}"
  139. Visibility="{Binding ClearPasswordButtonVisibility, Mode=TwoWay}" />
  140. </Grid>
  141. <Grid Grid.Row="2" Margin="0,2,0,0">
  142. <TextBlock
  143. Foreground="#F3465B"
  144. Text="{Binding ErrorPasswordMsg, Mode=TwoWay}"
  145. TextWrapping="Wrap"
  146. Visibility="{Binding ErrorPasswordMsgVisibility, Mode=TwoWay}" />
  147. </Grid>
  148. </Grid>
  149. </Grid>
  150. </cus:DialogContent.Content>
  151. <cus:DialogContent.BottmBar>
  152. <Grid Margin="16">
  153. <StackPanel
  154. Height="32"
  155. HorizontalAlignment="Right"
  156. VerticalAlignment="Center"
  157. Orientation="Horizontal">
  158. <Button
  159. Width="67"
  160. Margin="0,0,16,0"
  161. Command="{Binding ConfirmCommand}"
  162. IsDefault="True"
  163. Style="{StaticResource Btn.cta}">
  164. <TextBlock Text="Open" />
  165. </Button>
  166. <Button
  167. Width="67"
  168. Command="{Binding CancelCommand}"
  169. Style="{StaticResource btn.sec}">
  170. <TextBlock Text="Cancel" />
  171. </Button>
  172. </StackPanel>
  173. </Grid>
  174. </cus:DialogContent.BottmBar>
  175. </cus:DialogContent>
  176. </UserControl>