mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-07 13:05:00 +03:00
Add scanning QR code from image
This commit is contained in:
@@ -32,10 +32,8 @@
|
||||
</StackPanel>
|
||||
</MenuItem.Header>
|
||||
<MenuItem x:Name="menuAddServerViaClipboard" Header="{x:Static resx:ResUI.menuAddServerViaClipboard}" />
|
||||
<MenuItem
|
||||
x:Name="menuAddServerViaScan"
|
||||
Header="{x:Static resx:ResUI.menuAddServerViaScan}"
|
||||
IsVisible="False" />
|
||||
<MenuItem x:Name="menuAddServerViaScan" Header="{x:Static resx:ResUI.menuAddServerViaScan}" />
|
||||
<MenuItem x:Name="menuAddServerViaImage" Header="{x:Static resx:ResUI.menuAddServerViaImage}" />
|
||||
<MenuItem x:Name="menuAddCustomServer" Header="{x:Static resx:ResUI.menuAddCustomServer}" />
|
||||
<Separator />
|
||||
<MenuItem x:Name="menuAddVmessServer" Header="{x:Static resx:ResUI.menuAddVmessServer}" />
|
||||
|
||||
@@ -4,6 +4,7 @@ using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Controls.Notifications;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Avalonia.Threading;
|
||||
using DialogHostAvalonia;
|
||||
@@ -60,6 +61,7 @@ namespace v2rayN.Desktop.Views
|
||||
this.BindCommand(ViewModel, vm => vm.AddCustomServerCmd, v => v.menuAddCustomServer).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.AddServerViaClipboardCmd, v => v.menuAddServerViaClipboard).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.AddServerViaScanCmd, v => v.menuAddServerViaScan).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.AddServerViaImageCmd, v => v.menuAddServerViaImage).DisposeWith(disposables);
|
||||
|
||||
//sub
|
||||
this.BindCommand(ViewModel, vm => vm.SubSettingCmd, v => v.menuSubSetting).DisposeWith(disposables);
|
||||
@@ -224,6 +226,10 @@ namespace v2rayN.Desktop.Views
|
||||
await ScanScreenTaskAsync();
|
||||
break;
|
||||
|
||||
case EViewAction.ScanImageTask:
|
||||
await ScanImageTaskAsync();
|
||||
break;
|
||||
|
||||
case EViewAction.AddServerViaClipboard:
|
||||
var clipboardData = await AvaUtils.GetClipboardData(this);
|
||||
ViewModel?.AddServerViaClipboardAsync(clipboardData);
|
||||
@@ -324,7 +330,16 @@ namespace v2rayN.Desktop.Views
|
||||
|
||||
ShowHideWindow(true);
|
||||
|
||||
//ViewModel?.ScanScreenTaskAsync(result);
|
||||
//ViewModel?.ScanScreenResult(result);
|
||||
}
|
||||
private async Task ScanImageTaskAsync()
|
||||
{
|
||||
var fileName = await UI.OpenFileDialog(this,null );
|
||||
if (fileName.IsNullOrEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
await ViewModel?.ScanImageResult(fileName);
|
||||
}
|
||||
|
||||
private void MenuCheckUpdate_Click(object? sender, RoutedEventArgs e)
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
<Image
|
||||
Name="imgQrcode"
|
||||
Width="300"
|
||||
Height="300"
|
||||
Source="/Assets/close.png" />
|
||||
Height="300" />
|
||||
|
||||
<TextBox
|
||||
x:Name="txtContent"
|
||||
@@ -29,6 +28,6 @@
|
||||
IsReadOnly="True"
|
||||
MaxLines="1" />
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
Reference in New Issue
Block a user