pull/3315/head
小仙女 2 years ago
parent 8285688ec9
commit ee61363c31

@ -42,7 +42,7 @@ namespace v2rayN.Base
}
}
public static string TrimEx(this string value)
public static string TrimEx(this string? value)
{
return value == null ? string.Empty : value.Trim();
}

@ -185,12 +185,12 @@ namespace v2rayN.Views
return;
}
if (network.Equals(Global.DefaultNetwork))
if (network == Global.DefaultNetwork)
{
cmbHeaderType.Items.Add(Global.None);
cmbHeaderType.Items.Add(Global.TcpHeaderHttp);
}
else if (network.Equals("kcp") || network.Equals("quic"))
else if (network is "kcp" or "quic")
{
cmbHeaderType.Items.Add(Global.None);
Global.kcpHeaderTypes.ForEach(it =>
@ -198,7 +198,7 @@ namespace v2rayN.Views
cmbHeaderType.Items.Add(it);
});
}
else if (network.Equals("grpc"))
else if (network == "grpc")
{
cmbHeaderType.Items.Add(Global.GrpcgunMode);
cmbHeaderType.Items.Add(Global.GrpcmultiMode);
@ -222,37 +222,34 @@ namespace v2rayN.Views
tipPath.Text =
tipHeaderType.Text = string.Empty;
if (network.Equals(Global.DefaultNetwork))
switch (network)
{
case Global.DefaultNetwork:
tipRequestHost.Text = ResUI.TransportRequestHostTip1;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip1;
}
else if (network.Equals("kcp"))
{
break;
case "kcp":
tipHeaderType.Text = ResUI.TransportHeaderTypeTip2;
tipPath.Text = ResUI.TransportPathTip5;
}
else if (network.Equals("ws"))
{
break;
case "ws":
tipRequestHost.Text = ResUI.TransportRequestHostTip2;
tipPath.Text = ResUI.TransportPathTip1;
}
else if (network.Equals("h2"))
{
break;
case "h2":
tipRequestHost.Text = ResUI.TransportRequestHostTip3;
tipPath.Text = ResUI.TransportPathTip2;
}
else if (network.Equals("quic"))
{
break;
case "quic":
tipRequestHost.Text = ResUI.TransportRequestHostTip4;
tipPath.Text = ResUI.TransportPathTip3;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip3;
}
else if (network.Equals("grpc"))
{
break;
case "grpc":
tipPath.Text = ResUI.TransportPathTip4;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip4;
labHeaderType.Visibility = Visibility.Hidden;
break;
}
}

@ -85,19 +85,19 @@ namespace v2rayN.Views
if (item.Control)
{
keys += $"{Forms.Keys.Control.ToString()} + ";
keys += $"{Forms.Keys.Control} + ";
}
if (item.Alt)
{
keys += $"{Forms.Keys.Alt.ToString()} + ";
keys += $"{Forms.Keys.Alt} + ";
}
if (item.Shift)
{
keys += $"{Forms.Keys.Shift.ToString()} + ";
keys += $"{Forms.Keys.Shift} + ";
}
if (item.KeyCode != null)
{
keys += $"{item.KeyCode.ToString()}";
keys += $"{item.KeyCode}";
}
SetText($"txtGlobalHotkey{k}", keys);
@ -148,11 +148,11 @@ namespace v2rayN.Views
{
foreach (UIElement element in gridText.Children)
{
if (element is TextBox)
if (element is TextBox box)
{
if (((TextBox)element).Name == name)
if (box.Name == name)
{
((TextBox)element).Text = txt;
box.Text = txt;
}
}
}

@ -359,6 +359,7 @@
Margin="4,0"
materialDesign:HintAssist.Hint="{x:Static resx:ResUI.MsgServerTitle}"
materialDesign:TextFieldAssist.HasClearButton="True"
VerticalContentAlignment="Center"
Style="{StaticResource DefTextBox}" />
</WrapPanel>

@ -197,13 +197,13 @@ namespace v2rayN.Views
{
if (action == "AdjustMainLvColWidth")
{
Application.Current.Dispatcher.Invoke((Action)(() =>
Application.Current.Dispatcher.Invoke(() =>
{
foreach (var it in lstProfiles.Columns)
{
it.Width = new DataGridLength(1, DataGridLengthUnitType.Auto);
}
}));
});
}
else if (action == "ProfilesFocus")
{
@ -355,7 +355,7 @@ namespace v2rayN.Views
}
else
{
if (e.Key == Key.Enter || e.Key == Key.Return)
if (e.Key is Key.Enter or Key.Return)
{
ViewModel?.SetDefaultServer();
}
@ -471,9 +471,8 @@ namespace v2rayN.Views
}
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
if (sender is MenuItem)
if (sender is MenuItem item)
{
MenuItem item = (MenuItem)sender;
Utils.ProcessStart(item.Tag.ToString());
}
}
@ -482,7 +481,7 @@ namespace v2rayN.Views
#endregion
#region Drag and Drop
private Point startPoint = new Point();
private Point startPoint = new();
private int startIndex = -1;
private string formatData = "ProfileItemModel";
@ -523,8 +522,7 @@ namespace v2rayN.Views
Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
{
// Get the dragged Item
var listView = sender as DataGrid;
if (listView == null) return;
if (sender is not DataGrid listView) return;
var listViewItem = FindAnchestor<DataGridRow>((DependencyObject)e.OriginalSource);
if (listViewItem == null) return; // Abort
// Find the data behind the ListViewItem
@ -532,7 +530,7 @@ namespace v2rayN.Views
if (item == null) return; // Abort
// Initialize the drag & drop operation
startIndex = lstProfiles.SelectedIndex;
DataObject dragData = new DataObject(formatData, item);
DataObject dragData = new(formatData, item);
DragDrop.DoDragDrop(listViewItem, dragData, DragDropEffects.Copy | DragDropEffects.Move);
}
}
@ -550,8 +548,7 @@ namespace v2rayN.Views
if (e.Data.GetDataPresent(formatData) && sender == e.Source)
{
// Get the drop Item destination
var listView = sender as DataGrid;
if (listView == null) return;
if (sender is not DataGrid listView) return;
var listViewItem = FindAnchestor<DataGridRow>((DependencyObject)e.OriginalSource);
if (listViewItem == null)
{

@ -76,13 +76,12 @@ namespace v2rayN.Views
//fill fonts
try
{
var dir = new DirectoryInfo(Utils.GetFontsPath());
var files = dir.GetFiles("*.ttf");
var files = Directory.GetFiles(Utils.GetFontsPath(), "*.ttf");
var culture = _config.uiItem.currentLanguage.Equals(Global.Languages[0]) ? "zh-cn" : "en-us";
var culture2 = "en-us";
foreach (var it in files)
foreach (var ttf in files)
{
var families = Fonts.GetFontFamilies(Utils.GetFontsPath(it.Name));
var families = Fonts.GetFontFamilies(Utils.GetFontsPath(ttf));
foreach (FontFamily family in families)
{
var typefaces = family.GetTypefaces();

Loading…
Cancel
Save