ProfilesPage.xaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <Page x:Class="ClashDotNetFramework.Pages.ProfilesPage"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:ClashDotNetFramework.Pages"
  7. xmlns:converters="clr-namespace:ClashDotNetFramework.Models.Converters"
  8. xmlns:TxtBox="clr-namespace:WatermarkControlsLib.Controls;assembly=WatermarkControlsLib"
  9. mc:Ignorable="d" FontSize="14" Loaded="ProfilesPage_Loaded"
  10. d:DesignHeight="750" d:DesignWidth="780"
  11. Title="ProfilesPage">
  12. <Page.Resources>
  13. <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
  14. <converters:DateTimeToStringConverter x:Key="DateTimeToStringConverter"/>
  15. <converters:GroupCountToStringConverter x:Key="GroupCountToStringConverter"/>
  16. <converters:ProfileTypeToStringConverter x:Key="ProfileTypeToStringConverter"/>
  17. <converters:ProxyCountToStringConverter x:Key="ProxyCountToStringConverter"/>
  18. <converters:RuleCountToStringConverter x:Key="RuleCountToStringConverter"/>
  19. <converters:StringToVisibilityConverter x:Key="StringToVisibilityConverter"/>
  20. <Style x:Key="ButtonStyle" TargetType="Button">
  21. <Setter Property="BorderThickness" Value="0"/>
  22. <Setter Property="Foreground" Value="{DynamicResource ButtonForeground}"/>
  23. <Setter Property="Background" Value="{DynamicResource ButtonBackground}"/>
  24. <Setter Property="Cursor" Value="Hand"/>
  25. <Setter Property="Width" Value="130"/>
  26. <Setter Property="Height" Value="40"/>
  27. <Setter Property="Template">
  28. <Setter.Value>
  29. <ControlTemplate TargetType="Button">
  30. <Border CornerRadius="2" Background="{TemplateBinding Background}">
  31. <ContentPresenter x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  32. </Border>
  33. </ControlTemplate>
  34. </Setter.Value>
  35. </Setter>
  36. </Style>
  37. <Style x:Key="BorderStyle" TargetType="Border">
  38. <Setter Property="CornerRadius" Value="2"/>
  39. <Setter Property="Padding" Value="4,4"/>
  40. <Setter Property="Margin" Value="0,0,5,0"/>
  41. </Style>
  42. <DataTemplate x:Key="ProfileItemTemplate" DataType="items:ProfileItem">
  43. <Grid>
  44. <Grid.RowDefinitions>
  45. <!-- Profile Name -->
  46. <RowDefinition/>
  47. <!-- Status Labels -->
  48. <RowDefinition/>
  49. </Grid.RowDefinitions>
  50. <!-- Profile Name -->
  51. <TextBlock
  52. Text="{Binding Name}"
  53. Foreground="{DynamicResource NormalTextForeground}"/>
  54. <!-- Status Labels -->
  55. <StackPanel
  56. Grid.Row="1"
  57. Orientation="Horizontal"
  58. Margin="0,5,0,10">
  59. <Border
  60. Style="{StaticResource BorderStyle}"
  61. Background="#D4302C"
  62. Visibility="{Binding Path=IsSelected, Converter={StaticResource BoolToVisibilityConverter}}">
  63. <TextBlock
  64. Text="Default"
  65. Foreground="White"/>
  66. </Border>
  67. <Border
  68. Style="{StaticResource BorderStyle}"
  69. Background="#CE8647">
  70. <TextBlock
  71. Text="{Binding Type, Converter={StaticResource ProfileTypeToStringConverter}}"
  72. Foreground="White"/>
  73. </Border>
  74. <Border
  75. Style="{StaticResource BorderStyle}"
  76. Background="#CF9F46"
  77. Visibility="{Binding Path=Host, Converter={StaticResource StringToVisibilityConverter}}">
  78. <TextBlock
  79. Text="{Binding Host}"
  80. Foreground="White"/>
  81. </Border>
  82. <Border
  83. Style="{StaticResource BorderStyle}"
  84. Background="#75AB5B">
  85. <TextBlock
  86. Text="{Binding ProxyCount, Converter={StaticResource ProxyCountToStringConverter}}"
  87. Foreground="White"/>
  88. </Border>
  89. <Border
  90. Style="{StaticResource BorderStyle}"
  91. Background="#369F71">
  92. <TextBlock
  93. Text="{Binding GroupCount, Converter={StaticResource GroupCountToStringConverter}}"
  94. Foreground="White"/>
  95. </Border>
  96. <Border
  97. Style="{StaticResource BorderStyle}"
  98. Background="#428EE4">
  99. <TextBlock
  100. Text="{Binding RuleCount, Converter={StaticResource RuleCountToStringConverter}}"
  101. Foreground="White"/>
  102. </Border>
  103. <Border
  104. Style="{StaticResource BorderStyle}"
  105. Background="#5182CC">
  106. <TextBlock
  107. Text="{Binding LastUpdate, Converter={StaticResource DateTimeToStringConverter}}"
  108. Foreground="White"/>
  109. </Border>
  110. </StackPanel>
  111. </Grid>
  112. </DataTemplate>
  113. </Page.Resources>
  114. <Grid>
  115. <Grid.RowDefinitions>
  116. <!-- Top Buttons -->
  117. <RowDefinition Height="100"/>
  118. <!-- Profile ListView -->
  119. <RowDefinition/>
  120. </Grid.RowDefinitions>
  121. <!-- Top Buttons -->
  122. <Grid
  123. Height="50"
  124. Margin="20,0">
  125. <Grid.ColumnDefinitions>
  126. <!-- UrlTextBox -->
  127. <ColumnDefinition Width="*"/>
  128. <!-- Download Button -->
  129. <ColumnDefinition Width="Auto"/>
  130. <!-- Update All Button -->
  131. <ColumnDefinition Width="Auto"/>
  132. <!-- Import Button -->
  133. <ColumnDefinition Width="Auto"/>
  134. </Grid.ColumnDefinitions>
  135. <!-- UrlTextBox -->
  136. <TxtBox:WatermarkTextBox
  137. BorderBrush="{DynamicResource TextBoxBorderBrush}"
  138. Background="{DynamicResource TextBoxBackground}"
  139. Foreground="{DynamicResource NormalTextForeground}"
  140. HorizontalAlignment="Stretch"
  141. VerticalContentAlignment="Center"
  142. x:Name="UrlTextBox">
  143. <TextBox.Resources>
  144. <Style TargetType="{x:Type Border}">
  145. <Setter Property="CornerRadius" Value="2"/>
  146. </Style>
  147. </TextBox.Resources>
  148. <TxtBox:WatermarkTextBox.Watermark>
  149. <TextBlock
  150. Text="{DynamicResource DownloadFromURL}"
  151. Foreground="{DynamicResource NormalTextForeground}"
  152. Margin="5,0,0,0"/>
  153. </TxtBox:WatermarkTextBox.Watermark>
  154. </TxtBox:WatermarkTextBox>
  155. <!-- Download Button -->
  156. <Button
  157. Grid.Column="1"
  158. Style="{StaticResource ButtonStyle}"
  159. Content="{DynamicResource Download}"
  160. Click="DownloadButton_Click"
  161. Margin="15,0,0,0"
  162. x:Name="DownloadButton"/>
  163. <!-- Update All Button -->
  164. <Button
  165. Grid.Column="2"
  166. Style="{StaticResource ButtonStyle}"
  167. Content="{DynamicResource UpdateAll}"
  168. Click="UpdateAllButton_Click"
  169. Margin="15,0,0,0"
  170. x:Name="UpdateAllButton"/>
  171. <!-- Import Button -->
  172. <Button
  173. Grid.Column="3"
  174. Style="{StaticResource ButtonStyle}"
  175. Content="{DynamicResource Import}"
  176. Click="ImportButton_Click"
  177. Margin="15,0,0,0"
  178. x:Name="ImportButton"/>
  179. </Grid>
  180. <Separator
  181. VerticalAlignment="Bottom"
  182. Background="{DynamicResource SeparatorBackground}"/>
  183. <!-- Profile ListView -->
  184. <Grid
  185. Grid.Row="1"
  186. AllowDrop="True"
  187. Drop="ProfileGrid_Drop"
  188. Margin="14,5,20,20">
  189. <ListView
  190. Background="Transparent"
  191. BorderBrush="Transparent"
  192. ScrollViewer.HorizontalScrollBarVisibility="Disabled"
  193. ScrollViewer.VerticalScrollBarVisibility="Hidden"
  194. ItemTemplate="{StaticResource ProfileItemTemplate}"
  195. SelectionMode="Single"
  196. x:Name="ProfileItemListView">
  197. <ListView.ContextMenu>
  198. <ContextMenu Style="{StaticResource IconlessContextMenuStyle}">
  199. <MenuItem Style="{StaticResource MenuItemStyle}" Header="{DynamicResource SelectProfile}" Click="SelectProfile_Click"/>
  200. <MenuItem Style="{StaticResource MenuItemStyle}" Header="{DynamicResource UpdateProfile}" Click="UpdateProfile_Click"/>
  201. <MenuItem Style="{StaticResource MenuItemStyle}" Header="{DynamicResource EditProfile}" Click="EditProfile_Click"/>
  202. <MenuItem Style="{StaticResource MenuItemStyle}" Header="{DynamicResource DuplicateProfile}" Click="DuplicateProfile_Click"/>
  203. <MenuItem Style="{StaticResource MenuItemStyle}" Header="{DynamicResource GoToURL}" Click="GoToURL_Click"/>
  204. <MenuItem Style="{StaticResource MenuItemStyle}" Header="{DynamicResource ProfileSettings}" Click="ProfileSettings_Click"/>
  205. <MenuItem Style="{StaticResource MenuItemStyle}" Header="{DynamicResource DeleteProfile}" Click="DeleteProfile_Click"/>
  206. </ContextMenu>
  207. </ListView.ContextMenu>
  208. </ListView>
  209. </Grid>
  210. </Grid>
  211. </Page>