InsertDialog.xaml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <UserControl
  2. x:Class="PDF_Master.Views.Dialog.PageEditDialogs.InsertDialog"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:convert="clr-namespace:PDF_Master.DataConvert"
  6. xmlns:cus="clr-namespace:PDF_Master.CustomControl"
  7. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  8. xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
  9. xmlns:local="clr-namespace:PDF_Master.Views.Dialog.PageEditDialogs"
  10. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  11. xmlns:model="clr-namespace:PDF_Master.Model.PageEdit"
  12. xmlns:pageeditdialogs="clr-namespace:PDF_Master.ViewModels.Dialog.PageEditDialogs"
  13. xmlns:prism="http://prismlibrary.com/"
  14. Width="468"
  15. Height="358"
  16. d:DataContext="{d:DesignInstance Type=pageeditdialogs:InsertDialogViewModel}"
  17. d:DesignHeight="358"
  18. d:DesignWidth="468"
  19. prism:Dialog.WindowStyle="{StaticResource DialogWindowStyle}"
  20. prism:ViewModelLocator.AutoWireViewModel="True"
  21. mc:Ignorable="d">
  22. <UserControl.Resources>
  23. <ResourceDictionary>
  24. <Style x:Key="TextBoxStyle" TargetType="TextBox">
  25. <Setter Property="Height" Value="32" />
  26. <Setter Property="FontSize" Value="14" />
  27. <Setter Property="Template">
  28. <Setter.Value>
  29. <ControlTemplate TargetType="TextBox">
  30. <Border
  31. x:Name="border"
  32. Background="{TemplateBinding Background}"
  33. BorderBrush="{TemplateBinding BorderBrush}"
  34. BorderThickness="{TemplateBinding BorderThickness}"
  35. CornerRadius="5"
  36. SnapsToDevicePixels="True">
  37. <!--<TextBox
  38. Name="markText"
  39. VerticalAlignment="Center"
  40. Background="Transparent"
  41. BorderBrush="Transparent"
  42. FontSize="12"
  43. Text="{TemplateBinding Text}"
  44. Visibility="Visible" />-->
  45. </Border>
  46. <ControlTemplate.Triggers>
  47. <Trigger Property="IsEnabled" Value="false">
  48. <Setter TargetName="border" Property="Opacity" Value="0.56" />
  49. <Setter TargetName="border" Property="Background" Value="{StaticResource color.field.bg.dis}" />
  50. </Trigger>
  51. <Trigger Property="IsMouseOver" Value="true">
  52. <Setter TargetName="border" Property="BorderBrush" Value="#FF7EB4EA" />
  53. </Trigger>
  54. <Trigger Property="IsKeyboardFocused" Value="true">
  55. <Setter TargetName="border" Property="BorderBrush" Value="#FF569DE5" />
  56. </Trigger>
  57. </ControlTemplate.Triggers>
  58. </ControlTemplate>
  59. </Setter.Value>
  60. </Setter>
  61. </Style>
  62. <convert:FileToImageSourceConvert x:Key="FileToImageSourceConvert" />
  63. <DataTemplate x:Key="CustomItem" DataType="{x:Type model:CustomPageItem}">
  64. <StackPanel HorizontalAlignment="Center">
  65. <Border
  66. Name="BdBorder"
  67. Width="104"
  68. Height="64"
  69. BorderBrush="#A0A2AE"
  70. BorderThickness="1"
  71. CornerRadius="6">
  72. <Border.Background>
  73. <ImageBrush ImageSource="{Binding FilePath, Converter={StaticResource FileToImageSourceConvert}}" />
  74. </Border.Background>
  75. </Border>
  76. <Label
  77. Name="LbPageNum"
  78. Width="auto"
  79. Margin="0,4,0,0"
  80. HorizontalAlignment="Center"
  81. Background="Transparent"
  82. Content="{Binding Name}"
  83. FontSize="12" />
  84. </StackPanel>
  85. <DataTemplate.Triggers>
  86. <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
  87. <Setter TargetName="BdBorder" Property="BorderBrush" Value="#118AFF" />
  88. <Setter TargetName="BdBorder" Property="CornerRadius" Value="4" />
  89. <Setter TargetName="LbPageNum" Property="Foreground" Value="#118AFF" />
  90. </DataTrigger>
  91. </DataTemplate.Triggers>
  92. </DataTemplate>
  93. </ResourceDictionary>
  94. </UserControl.Resources>
  95. <cus:DialogContent Header="插入自定义页面">
  96. <cus:DialogContent.Content>
  97. <Grid>
  98. <Grid.RowDefinitions>
  99. <!--<RowDefinition />-->
  100. <RowDefinition Height="auto" />
  101. <RowDefinition Height="auto" />
  102. </Grid.RowDefinitions>
  103. <!-- 20230704 如果设置为Hidden,可能会导致弹窗无法打开,报 图片被占用 -->
  104. <ListBox
  105. Padding="0,16,0,0"
  106. HorizontalAlignment="Center"
  107. BorderThickness="0"
  108. ItemTemplate="{StaticResource CustomItem}"
  109. ItemsSource="{Binding Pages}"
  110. SelectedIndex="{Binding ItemSelectedIndex, Mode=TwoWay}"
  111. Visibility="Collapsed">
  112. <ListBox.ItemContainerStyle>
  113. <Style TargetType="{x:Type ListBoxItem}">
  114. <Setter Property="Template" Value="{StaticResource ListBoxItemControlTemplate}" />
  115. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  116. </Style>
  117. </ListBox.ItemContainerStyle>
  118. <ListBox.ItemsPanel>
  119. <ItemsPanelTemplate>
  120. <WrapPanel />
  121. </ItemsPanelTemplate>
  122. </ListBox.ItemsPanel>
  123. </ListBox>
  124. <StackPanel Grid.Row="0" Margin="16,5,16,12">
  125. <TextBlock
  126. FontFamily="Segoe UI"
  127. FontSize="12"
  128. FontWeight="SemiBold"
  129. Foreground="{StaticResource color.sys.text.neutral.lv2}"
  130. Text="页面大小" />
  131. <StackPanel
  132. Margin="0,10"
  133. VerticalAlignment="Bottom"
  134. Orientation="Horizontal">
  135. <RadioButton
  136. Height="32"
  137. VerticalContentAlignment="Center"
  138. Content="当前页"
  139. FontFamily="Segoe UI"
  140. FontSize="14"
  141. GroupName="PageSize"
  142. IsChecked="{Binding IsCurrentSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
  143. IsEnabled="{Binding IsCurrentIsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  144. <Label
  145. Height="32"
  146. Margin="8,0"
  147. HorizontalAlignment="Center"
  148. VerticalContentAlignment="Center"
  149. Content="{Binding CurrentPageSize}"
  150. FontFamily="Segoe UI"
  151. FontSize="14" />
  152. </StackPanel>
  153. <StackPanel Margin="0,10" Orientation="Horizontal">
  154. <RadioButton
  155. Name="RbtnStandard"
  156. VerticalAlignment="Center"
  157. Content="标准"
  158. FontFamily="Segoe UI"
  159. FontSize="14"
  160. GroupName="PageSize"
  161. IsChecked="{Binding IsStandSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  162. <ComboBox
  163. Width="228"
  164. Height="32"
  165. Margin="8,0"
  166. IsEnabled="{Binding ElementName=RbtnStandard, Path=IsChecked}"
  167. ItemsSource="{Binding PageSize}"
  168. SelectedIndex="{Binding PageSizeSelectedIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  169. </StackPanel>
  170. <StackPanel Margin="0,10" Orientation="Horizontal">
  171. <RadioButton
  172. Name="RbtnCustom"
  173. VerticalAlignment="Center"
  174. Content="自定义"
  175. FontFamily="Segoe UI"
  176. FontSize="14"
  177. GroupName="PageSize"
  178. IsChecked="{Binding IsCustomSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  179. <!--<TextBox
  180. Width="94"
  181. Height="32"
  182. Margin="8,0"
  183. VerticalContentAlignment="Center"
  184. IsEnabled="{Binding ElementName=RbtnCustom, Path=IsChecked}"
  185. Style="{StaticResource TextBoxStyle}"
  186. Text="{Binding CustomWidth, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />-->
  187. <TextBox
  188. Width="94"
  189. Height="32"
  190. Margin="8,0"
  191. Padding="8,0"
  192. HorizontalContentAlignment="Left"
  193. VerticalContentAlignment="Center"
  194. Background="{StaticResource color.field.bg.def}"
  195. BorderBrush="{StaticResource color.field.border.norm}"
  196. InputMethod.IsInputMethodEnabled="False"
  197. IsEnabled="{Binding ElementName=RbtnCustom, Path=IsChecked}"
  198. Text="{Binding CustomWidth, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
  199. <TextBox.Resources>
  200. <Style TargetType="{x:Type Border}">
  201. <Setter Property="CornerRadius" Value="4" />
  202. </Style>
  203. </TextBox.Resources>
  204. </TextBox>
  205. <TextBlock
  206. Margin="5,0"
  207. VerticalAlignment="Center"
  208. FontFamily="Segoe UI"
  209. FontSize="14"
  210. Text="X" />
  211. <!--<TextBox
  212. Width="80"
  213. Height="32"
  214. Margin="8,0"
  215. VerticalContentAlignment="Center"
  216. IsEnabled="{Binding ElementName=RbtnCustom, Path=IsChecked}"
  217. Text="{Binding CustomHeight, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />-->
  218. <TextBox
  219. Width="94"
  220. Height="32"
  221. Margin="8,0"
  222. Padding="8,0"
  223. HorizontalContentAlignment="Left"
  224. VerticalContentAlignment="Center"
  225. Background="{StaticResource color.field.bg.def}"
  226. BorderBrush="{StaticResource color.field.border.norm}"
  227. InputMethod.IsInputMethodEnabled="False"
  228. IsEnabled="{Binding ElementName=RbtnCustom, Path=IsChecked}"
  229. Text="{Binding CustomHeight, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
  230. <TextBox.Resources>
  231. <Style TargetType="{x:Type Border}">
  232. <Setter Property="CornerRadius" Value="4" />
  233. </Style>
  234. </TextBox.Resources>
  235. </TextBox>
  236. <ComboBox
  237. Width="94"
  238. Margin="8,0"
  239. VerticalContentAlignment="Center"
  240. IsEnabled="{Binding ElementName=RbtnCustom, Path=IsChecked}"
  241. ItemsSource="{Binding Units}"
  242. SelectedIndex="{Binding UnitsSelectedIndex}" />
  243. </StackPanel>
  244. </StackPanel>
  245. <StackPanel Grid.Row="1" Margin="16,0">
  246. <TextBlock
  247. FontFamily="Segoe UI"
  248. FontSize="12"
  249. FontWeight="SemiBold"
  250. Foreground="{StaticResource color.sys.text.neutral.lv2}"
  251. Text="方向" />
  252. <StackPanel Orientation="Horizontal">
  253. <RadioButton
  254. Width="86"
  255. Margin="0,12,0,16"
  256. VerticalContentAlignment="Center"
  257. Content="纵向页面"
  258. FontFamily="Segoe UI"
  259. FontSize="14"
  260. GroupName="Direction"
  261. IsChecked="{Binding IsVerticalSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
  262. Tag="Vertical" />
  263. <RadioButton
  264. Width="86"
  265. Margin="30,12,0,16"
  266. VerticalContentAlignment="Center"
  267. Content="横向页面"
  268. FontFamily="Segoe UI"
  269. FontSize="14"
  270. GroupName="Direction"
  271. IsChecked="{Binding IsHorizontalSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
  272. Tag="Horizontal" />
  273. </StackPanel>
  274. </StackPanel>
  275. </Grid>
  276. </cus:DialogContent.Content>
  277. <cus:DialogContent.BottmBar>
  278. <Grid>
  279. <Button
  280. Width="98"
  281. Height="32"
  282. Margin="16,0"
  283. HorizontalAlignment="Right"
  284. Command="{Binding CancelCommand}"
  285. Content="取消"
  286. Style="{StaticResource btn.sec}" />
  287. <Button
  288. Width="98"
  289. Height="32"
  290. Margin="124,0"
  291. HorizontalAlignment="Right"
  292. Command="{Binding InsertCommnad}"
  293. Content="插入"
  294. Style="{StaticResource Btn.cta}" />
  295. </Grid>
  296. </cus:DialogContent.BottmBar>
  297. </cus:DialogContent>
  298. </UserControl>