mirror of https://github.com/2dust/v2rayN
Optimize code
parent
6762f35ade
commit
3c4703ad85
|
@ -2,15 +2,19 @@
|
|||
using QRCoder.Xaml;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace v2rayN.Handler
|
||||
namespace v2rayN
|
||||
{
|
||||
/// <summary>
|
||||
/// 含有QR码的描述类和包装编码和渲染
|
||||
/// </summary>
|
||||
public class QRCodeHelper
|
||||
{
|
||||
public static DrawingImage? GetQRCode(string strContent)
|
||||
public static DrawingImage? GetQRCode(string? strContent)
|
||||
{
|
||||
if (strContent is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
QRCodeGenerator qrGenerator = new();
|
|
@ -1,4 +1,5 @@
|
|||
using System.Windows;
|
||||
using Microsoft.Win32;
|
||||
using System.Windows;
|
||||
|
||||
namespace v2rayN
|
||||
{
|
||||
|
@ -20,5 +21,24 @@ namespace v2rayN
|
|||
{
|
||||
return MessageBox.Show(msg, caption, MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
}
|
||||
|
||||
public static bool? OpenFileDialog(out string fileName, string filter)
|
||||
{
|
||||
fileName = string.Empty;
|
||||
|
||||
var fileDialog = new OpenFileDialog
|
||||
{
|
||||
Multiselect = false,
|
||||
Filter = filter
|
||||
};
|
||||
|
||||
if (fileDialog.ShowDialog() != true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
fileName = fileDialog.FileName;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
using Microsoft.Win32;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using ReactiveUI.Validation.Helpers;
|
||||
|
@ -104,20 +103,16 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
UI.Show(ResUI.CustomServerTips);
|
||||
|
||||
OpenFileDialog fileDialog = new()
|
||||
{
|
||||
Multiselect = false,
|
||||
Filter = "Config|*.json|YAML|*.yaml;*.yml|All|*.*"
|
||||
};
|
||||
if (fileDialog.ShowDialog() != true)
|
||||
if (UI.OpenFileDialog(out string fileName,
|
||||
"Config|*.json|YAML|*.yaml;*.yml|All|*.*") != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string fileName = fileDialog.FileName;
|
||||
if (Utils.IsNullOrEmpty(fileName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var item = LazyConfig.Instance.GetProfileItem(SelectedSource.indexId);
|
||||
item ??= SelectedSource;
|
||||
item.address = fileName;
|
||||
|
|
|
@ -3,7 +3,6 @@ using DynamicData.Binding;
|
|||
using MaterialDesignColors;
|
||||
using MaterialDesignColors.ColorManipulation;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Microsoft.Win32;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
|
@ -1397,16 +1396,11 @@ namespace v2rayN.ViewModels
|
|||
|
||||
private void ImportOldGuiConfig()
|
||||
{
|
||||
OpenFileDialog fileDialog = new()
|
||||
{
|
||||
Multiselect = false,
|
||||
Filter = "guiNConfig|*.json|All|*.*"
|
||||
};
|
||||
if (fileDialog.ShowDialog() != true)
|
||||
if (UI.OpenFileDialog(out string fileName,
|
||||
"guiNConfig|*.json|All|*.*") != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string fileName = fileDialog.FileName;
|
||||
if (Utils.IsNullOrEmpty(fileName))
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using DynamicData.Binding;
|
||||
using Microsoft.Win32;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
|
@ -264,20 +263,16 @@ namespace v2rayN.ViewModels
|
|||
|
||||
private void ImportRulesFromFile()
|
||||
{
|
||||
OpenFileDialog fileDialog = new OpenFileDialog
|
||||
{
|
||||
Multiselect = false,
|
||||
Filter = "Rules|*.json|All|*.*"
|
||||
};
|
||||
if (fileDialog.ShowDialog() != true)
|
||||
if (UI.OpenFileDialog(out string fileName,
|
||||
"Rules|*.json|All|*.*") != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string fileName = fileDialog.FileName;
|
||||
if (Utils.IsNullOrEmpty(fileName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string result = Utils.LoadResource(fileName);
|
||||
if (Utils.IsNullOrEmpty(result))
|
||||
{
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Microsoft.Win32;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Reactive.Disposables;
|
||||
|
@ -205,13 +204,5 @@ namespace v2rayN.Views
|
|||
this.Close();
|
||||
}
|
||||
|
||||
private void btnBrowse_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
var openFileDialog1 = new OpenFileDialog();
|
||||
openFileDialog1.Filter = "tunConfig|*.json|All|*.*";
|
||||
openFileDialog1.ShowDialog();
|
||||
|
||||
// txtCustomTemplate.Text = openFileDialog1.FileName;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using Microsoft.Win32;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
@ -131,11 +130,13 @@ namespace v2rayN.Views
|
|||
|
||||
private void btnBrowse_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
var openFileDialog1 = new OpenFileDialog();
|
||||
openFileDialog1.Filter = "PNG,ICO|*.png;*.ico";
|
||||
openFileDialog1.ShowDialog();
|
||||
if (UI.OpenFileDialog(out string fileName,
|
||||
"PNG,ICO|*.png;*.ico") != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
txtCustomIcon.Text = openFileDialog1.FileName;
|
||||
txtCustomIcon.Text = fileName;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue