1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-21 20:56:08 +03:00
This commit is contained in:
next-autumn 2021-04-19 16:51:43 +08:00
parent b4ad1bde74
commit 83962fe0f0
3 changed files with 26 additions and 15 deletions

View File

@ -51,5 +51,5 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.1.1.0")]
[assembly: AssemblyFileVersion("3.1.1.0")]
[assembly: AssemblyVersion("3.1.2.0")]
[assembly: AssemblyFileVersion("3.1.2.0")]

View File

@ -14,7 +14,7 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="200" />
<ColumnDefinition Width="220" />
</Grid.ColumnDefinitions>
<TabControl Grid.Column="0"
@ -63,7 +63,7 @@
Header="VLESS-gRPC">
<local:VLESS_gRPC_Control />
</TabItem>-->
<TabItem Width="200" Height="40"
Tag="{x:Static models:XrayType.VMESS_TCP}"
IsEnabled="{Binding Settings.Checked_VMESS_TCP}"
@ -106,6 +106,9 @@
</TabControl>
<Image Grid.Column="1" Width="150" Height="150" x:Name="QrImage" />
<StackPanel Grid.Column="1" >
<Image Width="200" Height="200" x:Name="QrImage" />
<Button Click="SaveImage" Width="100" Content="另存为" />
</StackPanel>
</Grid>
</metro:MetroWindow>

View File

@ -1,4 +1,5 @@
using ProxySU_Core.Models;
using Microsoft.Win32;
using ProxySU_Core.Models;
using ProxySU_Core.ViewModels;
using QRCoder;
using System;
@ -36,14 +37,6 @@ namespace ProxySU_Core.Views.ClientInfo
DataContext = this;
}
private void SelectDefault(object sender, SelectionChangedEventArgs e)
{
var tabControl = e.Source as TabControl;
var item = (tabControl.SelectedItem as TabItem);
var itemControl = item.Content as ContentControl;
if (itemControl == null) return;
Console.WriteLine(itemControl.Tag);
}
private void BuildQrCode(object sender, SelectionChangedEventArgs e)
{
@ -51,10 +44,24 @@ namespace ProxySU_Core.Views.ClientInfo
var item = (tabControl.SelectedItem as TabItem);
if (item == null) return;
var type = (XrayType)item.Tag;
if (type == null) return;
BuildQrCode(type);
}
private void SaveImage(object sender, RoutedEventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName += QrImage.Tag;
sfd.Filter = "Image Files (*.bmp, *.png, *.jpg)|*.bmp;*.png;*.jpg | All Files | *.*";
sfd.RestoreDirectory = true;//保存对话框是否记忆上次打开的目录
if (sfd.ShowDialog() == true)
{
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create((BitmapSource)QrImage.Source));
using (FileStream stream = new FileStream(sfd.FileName, FileMode.Create))
encoder.Save(stream);
}
}
private void BuildQrCode(XrayType type)
{
string shareLink = string.Empty;
@ -115,6 +122,7 @@ namespace ProxySU_Core.Views.ClientInfo
image.StreamSource = new MemoryStream(bytes);
image.EndInit();
QrImage.Source = image;
QrImage.Tag = type.ToString();
}
}
}