1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-25 14:46: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("1.0.*")]
[assembly: AssemblyVersion("3.1.1.0")] [assembly: AssemblyVersion("3.1.2.0")]
[assembly: AssemblyFileVersion("3.1.1.0")] [assembly: AssemblyFileVersion("3.1.2.0")]

View File

@ -14,7 +14,7 @@
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="200" /> <ColumnDefinition Width="220" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TabControl Grid.Column="0" <TabControl Grid.Column="0"
@ -106,6 +106,9 @@
</TabControl> </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> </Grid>
</metro:MetroWindow> </metro:MetroWindow>

View File

@ -1,4 +1,5 @@
using ProxySU_Core.Models; using Microsoft.Win32;
using ProxySU_Core.Models;
using ProxySU_Core.ViewModels; using ProxySU_Core.ViewModels;
using QRCoder; using QRCoder;
using System; using System;
@ -36,14 +37,6 @@ namespace ProxySU_Core.Views.ClientInfo
DataContext = this; 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) private void BuildQrCode(object sender, SelectionChangedEventArgs e)
{ {
@ -51,10 +44,24 @@ namespace ProxySU_Core.Views.ClientInfo
var item = (tabControl.SelectedItem as TabItem); var item = (tabControl.SelectedItem as TabItem);
if (item == null) return; if (item == null) return;
var type = (XrayType)item.Tag; var type = (XrayType)item.Tag;
if (type == null) return;
BuildQrCode(type); 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) private void BuildQrCode(XrayType type)
{ {
string shareLink = string.Empty; string shareLink = string.Empty;
@ -115,6 +122,7 @@ namespace ProxySU_Core.Views.ClientInfo
image.StreamSource = new MemoryStream(bytes); image.StreamSource = new MemoryStream(bytes);
image.EndInit(); image.EndInit();
QrImage.Source = image; QrImage.Source = image;
QrImage.Tag = type.ToString();
} }
} }
} }