mirror of https://github.com/2dust/v2rayN
Improve UI
parent
bc3593871b
commit
70ea21fca2
|
@ -2,6 +2,9 @@
|
|||
using Splat;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Imaging;
|
||||
using v2rayN.Enums;
|
||||
using v2rayN.Handler.CoreConfig;
|
||||
|
@ -223,5 +226,27 @@ namespace v2rayN.Handler
|
|||
HotkeyHandler.Instance.HotkeyTriggerEvent += handler;
|
||||
HotkeyHandler.Instance.Load();
|
||||
}
|
||||
|
||||
public void RegisterSystemColorSet(Config config, Window window, Action<bool> update)
|
||||
{
|
||||
var helper = new WindowInteropHelper(window);
|
||||
var hwndSource = HwndSource.FromHwnd(helper.EnsureHandle());
|
||||
hwndSource.AddHook((IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) =>
|
||||
{
|
||||
if (config.uiItem.followSystemTheme)
|
||||
{
|
||||
const int WM_SETTINGCHANGE = 0x001A;
|
||||
if (msg == WM_SETTINGCHANGE)
|
||||
{
|
||||
if (wParam == IntPtr.Zero && Marshal.PtrToStringUni(lParam) == "ImmersiveColorSet")
|
||||
{
|
||||
update(!Utils.IsLightTheme());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return IntPtr.Zero;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,72 +19,71 @@
|
|||
<converters:DelayColorConverter x:Key="DelayColorConverter" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<DockPanel>
|
||||
<ToolBarTray DockPanel.Dock="Top">
|
||||
<ToolBar
|
||||
HorizontalAlignment="Center"
|
||||
<DockPanel Margin="2">
|
||||
<WrapPanel
|
||||
Margin="8"
|
||||
VerticalAlignment="Center"
|
||||
DockPanel.Dock="Top"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
x:Name="menuProxiesReload"
|
||||
Width="30"
|
||||
Height="30"
|
||||
Margin="8,0"
|
||||
Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}">
|
||||
<materialDesign:PackIcon VerticalAlignment="Center" Kind="Reload" />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
x:Name="menuProxiesDelaytest"
|
||||
Width="30"
|
||||
Height="30"
|
||||
Margin="8,0"
|
||||
Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}">
|
||||
<materialDesign:PackIcon VerticalAlignment="Center" Kind="LightningBolt" />
|
||||
</Button>
|
||||
|
||||
<TextBlock
|
||||
Margin="8,0"
|
||||
VerticalAlignment="Center"
|
||||
ClipToBounds="True"
|
||||
Style="{StaticResource MaterialDesignToolBar}">
|
||||
<Button x:Name="menuProxiesReload">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon
|
||||
Margin="0,0,8,0"
|
||||
VerticalAlignment="Center"
|
||||
Kind="Reload" />
|
||||
<TextBlock Style="{StaticResource ToolbarTextBlock}" Text="{x:Static resx:ResUI.menuProxiesReload}" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Separator />
|
||||
<Button x:Name="menuProxiesDelaytest">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon
|
||||
Margin="0,0,8,0"
|
||||
VerticalAlignment="Center"
|
||||
Kind="LightningBolt" />
|
||||
<TextBlock Style="{StaticResource ToolbarTextBlock}" Text="{x:Static resx:ResUI.menuProxiesDelaytest}" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Separator />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.menuRulemode}" />
|
||||
<ComboBox
|
||||
x:Name="cmbRulemode"
|
||||
Width="80"
|
||||
Margin="8"
|
||||
Style="{StaticResource DefComboBox}">
|
||||
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeRule}" />
|
||||
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeGlobal}" />
|
||||
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeDirect}" />
|
||||
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeNothing}" />
|
||||
</ComboBox>
|
||||
<Separator />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbSorting}" />
|
||||
<ComboBox
|
||||
x:Name="cmbSorting"
|
||||
Width="60"
|
||||
Margin="8"
|
||||
Style="{StaticResource DefComboBox}">
|
||||
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingDelay}" />
|
||||
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingName}" />
|
||||
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingDefault}" />
|
||||
</ComboBox>
|
||||
<Separator />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbAutoRefresh}" />
|
||||
<ToggleButton
|
||||
x:Name="togAutoRefresh"
|
||||
Margin="8"
|
||||
HorizontalAlignment="Left" />
|
||||
</ToolBar>
|
||||
</ToolBarTray>
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.menuRulemode}" />
|
||||
<ComboBox
|
||||
x:Name="cmbRulemode"
|
||||
Width="80"
|
||||
Margin="8"
|
||||
Style="{StaticResource DefComboBox}">
|
||||
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeRule}" />
|
||||
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeGlobal}" />
|
||||
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeDirect}" />
|
||||
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeNothing}" />
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock
|
||||
Margin="8,0"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbSorting}" />
|
||||
<ComboBox
|
||||
x:Name="cmbSorting"
|
||||
Width="60"
|
||||
Margin="8"
|
||||
Style="{StaticResource DefComboBox}">
|
||||
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingDelay}" />
|
||||
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingName}" />
|
||||
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingDefault}" />
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock
|
||||
Margin="8,0"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbAutoRefresh}" />
|
||||
<ToggleButton
|
||||
x:Name="togAutoRefresh"
|
||||
Margin="8"
|
||||
HorizontalAlignment="Left" />
|
||||
</WrapPanel>
|
||||
<DockPanel>
|
||||
<ListView
|
||||
x:Name="lstProxyGroups"
|
||||
|
@ -150,7 +149,7 @@
|
|||
</ListView.ItemsPanel>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Width="200" Padding="0">
|
||||
<Border Width="160" Padding="0">
|
||||
<DockPanel>
|
||||
<Border
|
||||
Width="5"
|
||||
|
|
|
@ -326,8 +326,7 @@
|
|||
x:Name="togDarkMode"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Margin="8"
|
||||
IsEnabled="{Binding ElementName=followSystemTheme, Path=IsChecked, Converter={StaticResource InverseBooleanConverter}}" />
|
||||
Margin="8" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
using Splat;
|
||||
using System.ComponentModel;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
@ -141,9 +140,6 @@ namespace v2rayN.Views
|
|||
this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashUI.Visibility).DisposeWith(disposables);
|
||||
});
|
||||
|
||||
RestoreUI();
|
||||
AddHelpMenuItem();
|
||||
|
||||
var IsAdministrator = Utils.IsAdministrator();
|
||||
this.Title = $"{Utils.GetVersion()} - {(IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}";
|
||||
|
||||
|
@ -152,36 +148,14 @@ namespace v2rayN.Views
|
|||
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
|
||||
}
|
||||
|
||||
var helper = new WindowInteropHelper(this);
|
||||
var hwndSource = HwndSource.FromHwnd(helper.EnsureHandle());
|
||||
hwndSource.AddHook((IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) =>
|
||||
{
|
||||
if (_config.uiItem.followSystemTheme)
|
||||
{
|
||||
const int WM_SETTINGCHANGE = 0x001A;
|
||||
if (msg == WM_SETTINGCHANGE)
|
||||
{
|
||||
if (wParam == IntPtr.Zero && Marshal.PtrToStringUni(lParam) == "ImmersiveColorSet")
|
||||
{
|
||||
ViewModel?.ModifyTheme(!Utils.IsLightTheme());
|
||||
}
|
||||
}
|
||||
}
|
||||
MainFormHandler.Instance.RegisterSystemColorSet(_config, this, (bool bl) => { ViewModel?.ModifyTheme(bl); });
|
||||
|
||||
return IntPtr.Zero;
|
||||
});
|
||||
if (tabProfiles.Content is null)
|
||||
{
|
||||
tabProfiles.Content = new ProfilesView();
|
||||
}
|
||||
if (tabMsgView.Content is null)
|
||||
{
|
||||
tabMsgView.Content = new MsgView();
|
||||
}
|
||||
if (tabClashUI.Content is null)
|
||||
{
|
||||
tabClashUI.Content = new ClashProxiesView();
|
||||
}
|
||||
tabProfiles.Content ??= new ProfilesView();
|
||||
tabMsgView.Content ??= new MsgView();
|
||||
tabClashUI.Content ??= new ClashProxiesView();
|
||||
|
||||
RestoreUI();
|
||||
AddHelpMenuItem();
|
||||
}
|
||||
|
||||
#region Event
|
||||
|
|
|
@ -10,15 +10,12 @@
|
|||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<DockPanel Margin="2">
|
||||
<StackPanel
|
||||
<WrapPanel
|
||||
Margin="8"
|
||||
VerticalAlignment="Center"
|
||||
DockPanel.Dock="Top"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="8,0"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.MsgInformationTitle}" />
|
||||
|
||||
<ComboBox
|
||||
x:Name="cmbMsgFilter"
|
||||
Width="200"
|
||||
|
@ -28,6 +25,24 @@
|
|||
IsEditable="True"
|
||||
Style="{StaticResource DefComboBox}"
|
||||
TextBoxBase.TextChanged="cmbMsgFilter_TextChanged" />
|
||||
<Button
|
||||
x:Name="btnCopy"
|
||||
Width="30"
|
||||
Height="30"
|
||||
Margin="8,0"
|
||||
Click="menuMsgViewCopyAll_Click"
|
||||
Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}">
|
||||
<materialDesign:PackIcon VerticalAlignment="Center" Kind="ContentCopy" />
|
||||
</Button>
|
||||
<Button
|
||||
x:Name="btnClear"
|
||||
Width="30"
|
||||
Height="30"
|
||||
Margin="8,0"
|
||||
Click="menuMsgViewClear_Click"
|
||||
Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}">
|
||||
<materialDesign:PackIcon VerticalAlignment="Center" Kind="Delete" />
|
||||
</Button>
|
||||
<TextBlock
|
||||
Margin="8,0"
|
||||
VerticalAlignment="Center"
|
||||
|
@ -48,7 +63,7 @@
|
|||
Margin="8,0"
|
||||
HorizontalAlignment="Left"
|
||||
IsChecked="True" />
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
<TextBox
|
||||
Name="txtMsg"
|
||||
BorderThickness="0"
|
||||
|
|
Loading…
Reference in New Issue