SettingsPage.xaml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <Page x:Class="ClashDotNetFramework.Pages.SettingsPage"
  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:ToggleSwitch="clr-namespace:ToggleSwitch;assembly=ToggleSwitch"
  8. mc:Ignorable="d" FontSize="14" Loaded="SettingsPage_Loaded"
  9. d:DesignHeight="750" d:DesignWidth="780"
  10. Title="SettingsPage">
  11. <Page.Resources>
  12. <Style x:Key="BorderStyle" TargetType="Border">
  13. <Setter Property="Background" Value="{DynamicResource GridBorderBackground}"/>
  14. <Setter Property="CornerRadius" Value="8"/>
  15. </Style>
  16. <Style x:Key="ButtonStyle" TargetType="Button">
  17. <Setter Property="Cursor" Value="Hand"/>
  18. <Setter Property="Width" Value="160"/>
  19. <Setter Property="Height" Value="40"/>
  20. <Setter Property="Background" Value="{DynamicResource ButtonBackground}"/>
  21. <Setter Property="Foreground" Value="{DynamicResource ButtonForeground}"/>
  22. <Setter Property="Template">
  23. <Setter.Value>
  24. <ControlTemplate TargetType="Button">
  25. <Border CornerRadius="2" Background="{TemplateBinding Background}">
  26. <ContentPresenter x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  27. </Border>
  28. </ControlTemplate>
  29. </Setter.Value>
  30. </Setter>
  31. </Style>
  32. <Style x:Key="ValueTextStyle" TargetType="TextBlock">
  33. <Setter Property="Foreground" Value="{DynamicResource GridTextForeground}"/>
  34. <Setter Property="HorizontalAlignment" Value="Center"/>
  35. <Setter Property="Margin" Value="0,20,0,0"/>
  36. </Style>
  37. <Style x:Key="UpdateButtonStyle" TargetType="Button">
  38. <Setter Property="Width" Value="40"/>
  39. <Setter Property="Foreground" Value="White"/>
  40. <Setter Property="Background" Value="#BB5151"/>
  41. <Setter Property="VerticalAlignment" Value="Center"/>
  42. <Setter Property="Margin" Value="5,0,0,15"/>
  43. <Setter Property="Template">
  44. <Setter.Value>
  45. <ControlTemplate TargetType="Button">
  46. <Border CornerRadius="2" Background="{TemplateBinding Background}">
  47. <ContentPresenter x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  48. </Border>
  49. </ControlTemplate>
  50. </Setter.Value>
  51. </Setter>
  52. </Style>
  53. <Style x:Key="ToggleSwitchStyle" TargetType="ToggleSwitch:HorizontalToggleSwitch" BasedOn="{StaticResource iOS5ToggleSwitchStyle}">
  54. <Setter Property="Margin" Value="0,20,0,0"/>
  55. </Style>
  56. <Style x:Key="SettingButtonStyle" TargetType="Button">
  57. <Setter Property="BorderThickness" Value="0"/>
  58. <Setter Property="Background" Value="Transparent"/>
  59. <Setter Property="Foreground" Value="{DynamicResource GridTextForeground}"/>
  60. <Setter Property="Cursor" Value="Hand"/>
  61. <Setter Property="Margin" Value="0,20,0,0"/>
  62. <Setter Property="Template">
  63. <Setter.Value>
  64. <ControlTemplate TargetType="Button">
  65. <Border CornerRadius="2" Background="{TemplateBinding Background}">
  66. <ContentPresenter x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  67. </Border>
  68. <ControlTemplate.Triggers>
  69. <Trigger Property="IsMouseOver" Value="True">
  70. <Setter Property="Background" Value="Transparent"/>
  71. </Trigger>
  72. </ControlTemplate.Triggers>
  73. </ControlTemplate>
  74. </Setter.Value>
  75. </Setter>
  76. </Style>
  77. <Style x:Key="RadioButtonStyle" TargetType="RadioButton" BasedOn="{StaticResource {x:Type ToggleButton}}">
  78. <Setter Property="Cursor" Value="Hand"/>
  79. <Setter Property="Foreground" Value="White"/>
  80. <Setter Property="Background" Value="{DynamicResource RadioButtonUnCheckedBackground}"/>
  81. <Setter Property="Padding" Value="4"/>
  82. <Setter Property="Template">
  83. <Setter.Value>
  84. <ControlTemplate TargetType="RadioButton">
  85. <Border Background="{TemplateBinding Background}">
  86. <ContentPresenter x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  87. </Border>
  88. <ControlTemplate.Triggers>
  89. <Trigger Property="IsChecked" Value="True">
  90. <Setter Property="Background" Value="{DynamicResource ButtonCheckedBackground}"/>
  91. </Trigger>
  92. </ControlTemplate.Triggers>
  93. </ControlTemplate>
  94. </Setter.Value>
  95. </Setter>
  96. </Style>
  97. <Style x:Key="RadioButtonLeftRoundStyle" TargetType="RadioButton" BasedOn="{StaticResource RadioButtonStyle}">
  98. <Setter Property="Template">
  99. <Setter.Value>
  100. <ControlTemplate TargetType="RadioButton">
  101. <Border CornerRadius="4,0,0,4" Background="{TemplateBinding Background}">
  102. <ContentPresenter x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  103. </Border>
  104. <ControlTemplate.Triggers>
  105. <Trigger Property="IsChecked" Value="True">
  106. <Setter Property="Background" Value="{DynamicResource ButtonCheckedBackground}"/>
  107. </Trigger>
  108. </ControlTemplate.Triggers>
  109. </ControlTemplate>
  110. </Setter.Value>
  111. </Setter>
  112. </Style>
  113. <Style x:Key="RadioButtonRightRoundStyle" TargetType="RadioButton" BasedOn="{StaticResource RadioButtonStyle}">
  114. <Setter Property="Template">
  115. <Setter.Value>
  116. <ControlTemplate TargetType="RadioButton">
  117. <Border CornerRadius="0,4,4,0" Background="{TemplateBinding Background}">
  118. <ContentPresenter x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  119. </Border>
  120. <ControlTemplate.Triggers>
  121. <Trigger Property="IsChecked" Value="True">
  122. <Setter Property="Background" Value="{DynamicResource ButtonCheckedBackground}"/>
  123. </Trigger>
  124. </ControlTemplate.Triggers>
  125. </ControlTemplate>
  126. </Setter.Value>
  127. </Setter>
  128. </Style>
  129. </Page.Resources>
  130. <Grid>
  131. <Grid.RowDefinitions>
  132. <!-- Top Panel-->
  133. <RowDefinition Height="100"/>
  134. <!--- Main Content -->
  135. <RowDefinition/>
  136. </Grid.RowDefinitions>
  137. <Grid>
  138. <Grid.ColumnDefinitions>
  139. <!-- Page Title -->
  140. <ColumnDefinition/>
  141. <!-- Reset All Settings Button -->
  142. <ColumnDefinition Width="Auto"/>
  143. </Grid.ColumnDefinitions>
  144. <!-- Page Title -->
  145. <TextBlock
  146. Text="{DynamicResource Settings}"
  147. FontSize="24"
  148. Foreground="{DynamicResource NormalTextForeground}"
  149. VerticalAlignment="Center"
  150. Margin="20,0,0,0"/>
  151. <!-- Action Button -->
  152. <Grid
  153. Grid.Column="1"
  154. Margin="0,0,20,0">
  155. <!-- Action Buttons -->
  156. <Grid.ColumnDefinitions>
  157. <!-- Check MMDB Update -->
  158. <ColumnDefinition/>
  159. <!-- Reset All Settings -->
  160. <ColumnDefinition/>
  161. </Grid.ColumnDefinitions>
  162. <!-- Check MMDB Update -->
  163. <Button
  164. Style="{StaticResource ButtonStyle}"
  165. Content="{DynamicResource CheckMMDBUpdate}"
  166. Click="CheckMMDBUpdate_Click"/>
  167. <!-- Reset All Settings -->
  168. <Button
  169. Grid.Column="1"
  170. Style="{StaticResource ButtonStyle}"
  171. Content="{DynamicResource ResetAllSettings}"
  172. Click="ResetAllSettings_Click"
  173. Margin="20,0,0,0"/>
  174. </Grid>
  175. </Grid>
  176. <Separator
  177. VerticalAlignment="Bottom"
  178. Background="{DynamicResource SeparatorBackground}"/>
  179. <Grid Grid.Row="1">
  180. <Grid.RowDefinitions>
  181. <!-- Icon & Title -->
  182. <RowDefinition Height="100"/>
  183. <!-- Settings Block -->
  184. <RowDefinition/>
  185. </Grid.RowDefinitions>
  186. <!-- Icon & Title -->
  187. <StackPanel
  188. Orientation="Horizontal"
  189. HorizontalAlignment="Center"
  190. VerticalAlignment="Center">
  191. <!-- Icon -->
  192. <Image
  193. Source="{DynamicResource AppLogo}"
  194. Stretch="Uniform"
  195. RenderOptions.BitmapScalingMode="Fant"
  196. HorizontalAlignment="Center"
  197. VerticalAlignment="Center"/>
  198. <!-- Name -->
  199. <TextBlock
  200. Text="Clash .NET Framework"
  201. Foreground="{DynamicResource NormalTextForeground}"
  202. FontSize="32"
  203. HorizontalAlignment="Center"
  204. VerticalAlignment="Center"
  205. Margin="10,0,0,0"/>
  206. <!-- Version -->
  207. <TextBlock
  208. Foreground="{DynamicResource NormalTextForeground}"
  209. FontSize="16"
  210. HorizontalAlignment="Center"
  211. VerticalAlignment="Center"
  212. Margin="20,0,0,0"
  213. x:Name="Version"/>
  214. <!-- Update Button -->
  215. <Button
  216. Style="{StaticResource UpdateButtonStyle}"
  217. Content="New"
  218. Visibility="Collapsed"
  219. Click="UpdateButton_Click"
  220. x:Name="UpdateButton"/>
  221. </StackPanel>
  222. <Grid
  223. Grid.Row="1"
  224. Margin="40,5,40,40">
  225. <!-- Row Definitions -->
  226. <Grid.RowDefinitions>
  227. <RowDefinition/>
  228. <RowDefinition/>
  229. <RowDefinition/>
  230. <RowDefinition/>
  231. </Grid.RowDefinitions>
  232. <!-- Column Definitions -->
  233. <Grid.ColumnDefinitions>
  234. <ColumnDefinition/>
  235. <ColumnDefinition/>
  236. <ColumnDefinition/>
  237. </Grid.ColumnDefinitions>
  238. <!-- Controller Port -->
  239. <Border
  240. Grid.Row="0"
  241. Grid.Column="0"
  242. Style="{StaticResource BorderStyle}"
  243. Margin="0,0,20,20">
  244. <StackPanel
  245. HorizontalAlignment="Center"
  246. VerticalAlignment="Center">
  247. <TextBlock
  248. Text="{DynamicResource ControllerPort}"
  249. Foreground="{DynamicResource GridTextForeground}"
  250. FontSize="18"/>
  251. <Button
  252. Style="{StaticResource SettingButtonStyle}"
  253. Click="ControllerPort_Click"
  254. x:Name="ControllerPort"/>
  255. </StackPanel>
  256. </Border>
  257. <!-- Mixed Port -->
  258. <Border
  259. Grid.Row="0"
  260. Grid.Column="1"
  261. Style="{StaticResource BorderStyle}"
  262. Margin="0,0,20,20">
  263. <StackPanel
  264. HorizontalAlignment="Center"
  265. VerticalAlignment="Center">
  266. <TextBlock
  267. Text="{DynamicResource MixedPort}"
  268. Foreground="{DynamicResource GridTextForeground}"
  269. FontSize="18"/>
  270. <Button
  271. Style="{StaticResource SettingButtonStyle}"
  272. Click="MixedPort_Click"
  273. x:Name="MixedPort"/>
  274. </StackPanel>
  275. </Border>
  276. <!-- Log Level -->
  277. <Border
  278. Grid.Row="0"
  279. Grid.Column="2"
  280. Style="{StaticResource BorderStyle}"
  281. Margin="0,0,0,20">
  282. <StackPanel
  283. HorizontalAlignment="Center"
  284. VerticalAlignment="Center">
  285. <TextBlock
  286. Text="{DynamicResource LogLevel}"
  287. Foreground="{DynamicResource GridTextForeground}"
  288. FontSize="18"/>
  289. <TextBlock
  290. Style="{StaticResource ValueTextStyle}"
  291. x:Name="LogLevel"/>
  292. </StackPanel>
  293. </Border>
  294. <!-- Allow LAN -->
  295. <Border
  296. Grid.Row="1"
  297. Grid.Column="0"
  298. Style="{StaticResource BorderStyle}"
  299. Margin="0,0,20,20">
  300. <StackPanel
  301. HorizontalAlignment="Center"
  302. VerticalAlignment="Center">
  303. <TextBlock
  304. Text="{DynamicResource AllowLAN}"
  305. Foreground="{DynamicResource GridTextForeground}"
  306. FontSize="18"/>
  307. <ToggleSwitch:HorizontalToggleSwitch
  308. Style="{StaticResource ToggleSwitchStyle}"
  309. Checked="AllowLAN_Checked"
  310. Unchecked="AllowLAN_Unchecked"
  311. x:Name="AllowLAN"/>
  312. </StackPanel>
  313. </Border>
  314. <!-- IPV6 -->
  315. <Border
  316. Grid.Row="1"
  317. Grid.Column="1"
  318. Style="{StaticResource BorderStyle}"
  319. Margin="0,0,20,20">
  320. <StackPanel
  321. HorizontalAlignment="Center"
  322. VerticalAlignment="Center">
  323. <TextBlock
  324. Text="IPV6"
  325. Foreground="{DynamicResource GridTextForeground}"
  326. FontSize="18"/>
  327. <ToggleSwitch:HorizontalToggleSwitch
  328. Style="{StaticResource ToggleSwitchStyle}"
  329. Checked="IPV6_Checked"
  330. Unchecked="IPV6_Unchecked"
  331. x:Name="IPV6"/>
  332. </StackPanel>
  333. </Border>
  334. <!-- Start with Windows -->
  335. <Border
  336. Grid.Row="1"
  337. Grid.Column="2"
  338. Style="{StaticResource BorderStyle}"
  339. Margin="0,0,0,20">
  340. <StackPanel
  341. HorizontalAlignment="Center"
  342. VerticalAlignment="Center">
  343. <TextBlock
  344. Text="{DynamicResource StartWithWindows}"
  345. Foreground="{DynamicResource GridTextForeground}"
  346. FontSize="18"/>
  347. <ToggleSwitch:HorizontalToggleSwitch
  348. Style="{StaticResource ToggleSwitchStyle}"
  349. Checked="StartWithWindows_Checked"
  350. Unchecked="StartWithWindows_Unchecked"
  351. x:Name="StartWithWindows"/>
  352. </StackPanel>
  353. </Border>
  354. <!-- UWP Loopback -->
  355. <Border
  356. Grid.Row="2"
  357. Grid.Column="0"
  358. Style="{StaticResource BorderStyle}"
  359. Margin="0,0,20,20">
  360. <StackPanel
  361. HorizontalAlignment="Center"
  362. VerticalAlignment="Center">
  363. <TextBlock
  364. Text="{DynamicResource UWPLoopback}"
  365. Foreground="{DynamicResource GridTextForeground}"
  366. FontSize="18"/>
  367. <Button
  368. Style="{StaticResource SettingButtonStyle}"
  369. Content="{DynamicResource LaunchHelper}"
  370. Click="UWPLoopback_Click"/>
  371. </StackPanel>
  372. </Border>
  373. <!-- NetFilter Driver -->
  374. <Border
  375. Grid.Row="2"
  376. Grid.Column="1"
  377. Style="{StaticResource BorderStyle}"
  378. Margin="0,0,20,20">
  379. <StackPanel
  380. HorizontalAlignment="Center"
  381. VerticalAlignment="Center">
  382. <TextBlock
  383. Text="{DynamicResource NetFilterDriver}"
  384. Foreground="{DynamicResource GridTextForeground}"
  385. FontSize="18"/>
  386. <Button
  387. Style="{StaticResource SettingButtonStyle}"
  388. Content="{DynamicResource Install}"
  389. Click="NetFilterSDK_Click"/>
  390. </StackPanel>
  391. </Border>
  392. <!-- Process Proxy -->
  393. <Border
  394. Grid.Row="2"
  395. Grid.Column="2"
  396. Style="{StaticResource BorderStyle}"
  397. Margin="0,0,0,20">
  398. <StackPanel
  399. HorizontalAlignment="Center"
  400. VerticalAlignment="Center">
  401. <TextBlock
  402. Text="{DynamicResource ProcessProxy}"
  403. Foreground="{DynamicResource GridTextForeground}"
  404. FontSize="18"/>
  405. <ToggleSwitch:HorizontalToggleSwitch
  406. Style="{StaticResource ToggleSwitchStyle}"
  407. Checked="ProcessProxy_Checked"
  408. Unchecked="ProcessProxy_Unchecked"
  409. x:Name="ProcessProxy"/>
  410. </StackPanel>
  411. </Border>
  412. <!-- Theme -->
  413. <Border
  414. Grid.Row="3"
  415. Grid.Column="0"
  416. Style="{StaticResource BorderStyle}"
  417. Margin="0,0,20,20">
  418. <StackPanel
  419. HorizontalAlignment="Center"
  420. VerticalAlignment="Center">
  421. <TextBlock
  422. Text="{DynamicResource Theme}"
  423. Foreground="{DynamicResource GridTextForeground}"
  424. FontSize="18"
  425. HorizontalAlignment="Center"/>
  426. <StackPanel
  427. Orientation="Horizontal"
  428. Margin="0,20,0,0">
  429. <RadioButton x:Name="ClassicTheme" Style="{StaticResource RadioButtonLeftRoundStyle}" Content="Classic" Click="ClassicTheme_Click"/>
  430. <RadioButton x:Name="ModernTheme" Style="{StaticResource RadioButtonStyle}" Content="Modern" Click="ModernTheme_Click"/>
  431. <RadioButton x:Name="DarkTheme" Style="{StaticResource RadioButtonRightRoundStyle}" Content="Dark" Click="DarkTheme_Click"/>
  432. </StackPanel>
  433. </StackPanel>
  434. </Border>
  435. <!-- Language -->
  436. <Border
  437. Grid.Row="3"
  438. Grid.Column="1"
  439. Style="{StaticResource BorderStyle}"
  440. Margin="0,0,20,20">
  441. <StackPanel
  442. HorizontalAlignment="Center"
  443. VerticalAlignment="Center">
  444. <TextBlock
  445. Text="{DynamicResource Language}"
  446. Foreground="{DynamicResource GridTextForeground}"
  447. FontSize="18"
  448. HorizontalAlignment="Center"/>
  449. <StackPanel
  450. Orientation="Horizontal"
  451. Margin="0,20,0,0">
  452. <RadioButton x:Name="EnglishLanguage" Style="{StaticResource RadioButtonLeftRoundStyle}" Content="en-US" Click="EnglishLanguage_Click"/>
  453. <RadioButton x:Name="ChineseLanguage" Style="{StaticResource RadioButtonStyle}" Content="zh-CN" Click="ChineseLanguage_Click"/>
  454. <RadioButton x:Name="JapaneseLanguage" Style="{StaticResource RadioButtonRightRoundStyle}" Content="ja-JP" Click="JapaneseLanguage_Click"/>
  455. </StackPanel>
  456. </StackPanel>
  457. </Border>
  458. <!-- System Proxy -->
  459. <Border
  460. Grid.Row="3"
  461. Grid.Column="2"
  462. Style="{StaticResource BorderStyle}"
  463. Margin="0,0,0,20">
  464. <StackPanel
  465. HorizontalAlignment="Center"
  466. VerticalAlignment="Center">
  467. <TextBlock
  468. Text="{DynamicResource SystemProxy}"
  469. Foreground="{DynamicResource GridTextForeground}"
  470. FontSize="18"/>
  471. <ToggleSwitch:HorizontalToggleSwitch
  472. Style="{StaticResource ToggleSwitchStyle}"
  473. Checked="SystemProxy_Checked"
  474. Unchecked="SystemProxy_Unchecked"
  475. x:Name="SystemProxy"/>
  476. </StackPanel>
  477. </Border>
  478. </Grid>
  479. </Grid>
  480. </Grid>
  481. </Page>