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