SqlPageView.xaml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <UserControl
  2. x:Class="ShakerManger.View.SqlPageView"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:hc="https://handyorg.github.io/handycontrol"
  7. xmlns:local="clr-namespace:ShakerManger.View"
  8. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  9. xmlns:model="clr-namespace:Shaker.Model;assembly=Shaker"
  10. xmlns:vm="clr-namespace:ShakerManger.ViewModel"
  11. d:DataContext="{d:DesignInstance {x:Type vm:SqlPageViewModel}}"
  12. d:DesignHeight="450"
  13. d:DesignWidth="800"
  14. DataContext="{Binding SqlPage}"
  15. IsEnabled="{Binding Source={x:Static vm:LoginViewModel.Default}, Path=IsAnonymous, Converter={StaticResource Boolean2BooleanReConverter}}"
  16. mc:Ignorable="d">
  17. <UserControl.Style>
  18. <Style TargetType="UserControl">
  19. <Style.Triggers>
  20. <DataTrigger Binding="{Binding Source={x:Static vm:LoginViewModel.Default}, Path=UserType}" Value="{x:Static model:UserType.SystemAdministrator}">
  21. <Setter Property="IsEnabled" Value="True" />
  22. </DataTrigger>
  23. <DataTrigger Binding="{Binding Source={x:Static vm:LoginViewModel.Default}, Path=UserType}" Value="{x:Static model:UserType.ClientUser}">
  24. <Setter Property="IsEnabled" Value="False" />
  25. </DataTrigger>
  26. <DataTrigger Binding="{Binding Source={x:Static vm:LoginViewModel.Default}, Path=UserType}" Value="{x:Static model:UserType.SystemUser}">
  27. <Setter Property="IsEnabled" Value="False" />
  28. </DataTrigger>
  29. </Style.Triggers>
  30. </Style>
  31. </UserControl.Style>
  32. <Grid>
  33. <Grid.RowDefinitions>
  34. <RowDefinition Height="80" />
  35. <RowDefinition />
  36. <RowDefinition />
  37. </Grid.RowDefinitions>
  38. <Border Background="{StaticResource SystemItemsSelectBackColor}">
  39. <TextBlock Grid.Row="0" Margin="10">
  40. <Run
  41. FontFamily="Arial Black"
  42. FontSize="22"
  43. Foreground="{StaticResource MainBrush}"
  44. Text="数据库配置说明" />
  45. <LineBreak />
  46. <LineBreak />
  47. <Run
  48. FontSize="16"
  49. Foreground="{StaticResource MainBrush}"
  50. Text="当前试验数据存储需要使用MongoDB数据库,如数据库没有账号密码则无需填写,设置成功后需要重启软件方可生效" />
  51. </TextBlock>
  52. </Border>
  53. <Grid
  54. Grid.Row="1"
  55. Width="830"
  56. Height="324"
  57. Margin="0,20,0,0"
  58. HorizontalAlignment="Center"
  59. VerticalAlignment="Top">
  60. <Grid.RowDefinitions>
  61. <RowDefinition Height="46" />
  62. <RowDefinition Height="46" />
  63. <RowDefinition Height="46" />
  64. <RowDefinition Height="46" />
  65. <RowDefinition Height="auto" />
  66. <RowDefinition Height="46" />
  67. </Grid.RowDefinitions>
  68. <StackPanel
  69. x:Name="first"
  70. Height="34"
  71. Orientation="Horizontal">
  72. <TextBlock
  73. Width="94"
  74. HorizontalAlignment="Right"
  75. VerticalAlignment="Center"
  76. FontSize="16">
  77. <Run Foreground="Red" Text="*" />
  78. <Run Text="数据库地址:" />
  79. </TextBlock>
  80. <hc:TextBox
  81. Width="720"
  82. Margin="10,0,0,0"
  83. Background="Transparent"
  84. CaretBrush="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Foreground}"
  85. FontSize="16"
  86. TabIndex="0"
  87. Text="{Binding IP, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  88. </StackPanel>
  89. <StackPanel
  90. Grid.Row="1"
  91. Height="{Binding ElementName=first, Path=Height}"
  92. Orientation="Horizontal">
  93. <TextBlock
  94. Width="94"
  95. HorizontalAlignment="Right"
  96. VerticalAlignment="Center"
  97. FontSize="16">
  98. <Run Foreground="Red" Text="*" />
  99. <Run Text="数据库端口:" />
  100. </TextBlock>
  101. <hc:NumericUpDown
  102. Width="120"
  103. Margin="10,0,0,0"
  104. Background="Transparent"
  105. CaretBrush="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Foreground}"
  106. FontSize="16"
  107. Maximum="65535"
  108. Minimum="1"
  109. TabIndex="1"
  110. Value="{Binding Port, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  111. </StackPanel>
  112. <StackPanel
  113. Grid.Row="2"
  114. Height="{Binding ElementName=first, Path=Height}"
  115. Orientation="Horizontal">
  116. <TextBlock
  117. Width="94"
  118. HorizontalAlignment="Right"
  119. VerticalAlignment="Center"
  120. FontSize="16">
  121. <Run Foreground="Red" Text="*" />
  122. <Run Text="数据库名:" />
  123. </TextBlock>
  124. <TextBox
  125. Width="720"
  126. Margin="10,0,0,0"
  127. Background="Transparent"
  128. CaretBrush="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Foreground}"
  129. FontSize="16"
  130. TabIndex="2"
  131. Text="{Binding DbName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  132. </StackPanel>
  133. <CheckBox
  134. Grid.Row="3"
  135. Content="匿名登录"
  136. FontSize="16"
  137. IsChecked="{Binding Anonymous}"
  138. TabIndex="3" />
  139. <Grid
  140. Grid.Row="4"
  141. Height="92"
  142. Visibility="{Binding Anonymous, Converter={StaticResource Boolean2VisibilityReConverter}}">
  143. <Grid.RowDefinitions>
  144. <RowDefinition />
  145. <RowDefinition />
  146. </Grid.RowDefinitions>
  147. <StackPanel
  148. Grid.Row="0"
  149. Height="{Binding ElementName=first, Path=Height}"
  150. Orientation="Horizontal">
  151. <TextBlock
  152. Width="94"
  153. HorizontalAlignment="Right"
  154. VerticalAlignment="Center"
  155. FontSize="16">
  156. <Run Foreground="Red" Text="*" />
  157. <Run Text="数据库账号:" />
  158. </TextBlock>
  159. <TextBox
  160. Width="720"
  161. Margin="10,0,0,0"
  162. Background="Transparent"
  163. CaretBrush="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Foreground}"
  164. FontSize="16"
  165. TabIndex="4"
  166. Text="{Binding UserName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  167. </StackPanel>
  168. <StackPanel
  169. Grid.Row="1"
  170. Height="{Binding ElementName=first, Path=Height}"
  171. Orientation="Horizontal">
  172. <Label
  173. Width="94"
  174. Padding="0"
  175. HorizontalAlignment="Right"
  176. VerticalAlignment="Center"
  177. HorizontalContentAlignment="Right"
  178. Background="Transparent"
  179. BorderBrush="Transparent"
  180. BorderThickness="0"
  181. Content="数据库密码:"
  182. FontSize="16" />
  183. <hc:PasswordBox
  184. Width="720"
  185. Margin="10,0,0,0"
  186. Background="Transparent"
  187. CaretBrush="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Foreground}"
  188. FontSize="16"
  189. IsSafeEnabled="True"
  190. TabIndex="5"
  191. UnsafePassword="{Binding UserName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  192. </StackPanel>
  193. </Grid>
  194. <UniformGrid
  195. Grid.Row="5"
  196. Columns="2"
  197. Rows="1">
  198. <Button
  199. Width="120"
  200. Height="34"
  201. hc:IconElement.Geometry="{StaticResource TestGeometry}"
  202. hc:IconElement.Height="20"
  203. hc:IconElement.Width="20"
  204. Command="{Binding TestConnectCommand}"
  205. Content="测试连接"
  206. FontSize="16"
  207. Style="{StaticResource HasIconButton}"
  208. TabIndex="6" />
  209. <Button
  210. Width="160"
  211. Height="34"
  212. hc:IconElement.Geometry="{StaticResource SaveGeometry}"
  213. hc:IconElement.Height="20"
  214. hc:IconElement.Width="20"
  215. Command="{Binding SaveCommand}"
  216. Content="保存配置并重启"
  217. FontSize="16"
  218. Style="{StaticResource HasIconButton}"
  219. TabIndex="7" />
  220. </UniformGrid>
  221. </Grid>
  222. </Grid>
  223. </UserControl>