Ads QR codes for CIDs
This commit is contained in:
parent
b1cb61b51c
commit
7b45a1171e
|
@ -8,6 +8,10 @@
|
|||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="QRCoder" Version="1.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ProjectPlugins\CodexPlugin\CodexPlugin.csproj" />
|
||||
<ProjectReference Include="..\Tools\AutoClient\AutoClient.csproj" />
|
||||
|
|
|
@ -5,14 +5,27 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:DevconBoothImages"
|
||||
mc:Ignorable="d"
|
||||
Title="DevconBoothImages" Height="450" Width="800" WindowState="Maximized">
|
||||
Title="CodexBoothImages" Height="450" Width="800" WindowState="Maximized">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Image Grid.Row="0" Name="Img" />
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Grid.Column="0" Name="Img" />
|
||||
<StackPanel Grid.Column="1">
|
||||
<TextBlock Text="Local CID:"/>
|
||||
<Image Name="ImgLocalCid" />
|
||||
<TextBlock Text="TestNet CID:"/>
|
||||
<Image Name="ImgTestnetCid" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="1">
|
||||
<TextBlock Name="Txt" HorizontalAlignment="Center" />
|
||||
<Button Content="Check Codex connections" Click="Button_Click_2" />
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
using AutoClient;
|
||||
using CodexOpenApi;
|
||||
using Logging;
|
||||
using QRCoder;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace DevconBoothImages
|
||||
|
@ -29,6 +33,7 @@ namespace DevconBoothImages
|
|||
|
||||
private async void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
// image
|
||||
Log("Getting image...");
|
||||
var file = await imageGenerator.Generate();
|
||||
|
@ -49,6 +54,33 @@ namespace DevconBoothImages
|
|||
InfoToClipboard();
|
||||
}
|
||||
|
||||
private BitmapImage GenerateQr(string text)
|
||||
{
|
||||
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
|
||||
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode(text, QRCodeGenerator.ECCLevel.Default))
|
||||
using (PngByteQRCode qrCode = new PngByteQRCode(qrCodeData))
|
||||
{
|
||||
byte[] qrCodeImage = qrCode.GetGraphic(12);
|
||||
using (var ms = new MemoryStream(qrCodeImage))
|
||||
{
|
||||
var img = Image.FromStream(ms);
|
||||
using (var ms2 = new MemoryStream())
|
||||
{
|
||||
img.Save(ms2, ImageFormat.Png);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
var bitmapImage = new BitmapImage();
|
||||
bitmapImage.BeginInit();
|
||||
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bitmapImage.StreamSource = ms2;
|
||||
bitmapImage.EndInit();
|
||||
|
||||
return bitmapImage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void Button_Click_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
InfoToClipboard();
|
||||
|
@ -115,6 +147,9 @@ namespace DevconBoothImages
|
|||
|
||||
Clipboard.SetText(msg);
|
||||
Log("CID info copied to clipboard. Paste it in Discord plz!");
|
||||
|
||||
ImgLocalCid.Source = GenerateQr(currentLocalCid);
|
||||
ImgTestnetCid.Source = GenerateQr(currentPublicCid);
|
||||
}
|
||||
|
||||
private void Log(string v)
|
||||
|
|
Loading…
Reference in New Issue