zxing.net引用 更新

This commit is contained in:
艾竹
2023-01-25 17:04:56 +08:00
parent b7af3534a2
commit b857151bdc
3 changed files with 22 additions and 25 deletions

View File

@@ -127,12 +127,6 @@
<ProjectReference Include="..\AIStudio.Wpf.SFC\AIStudio.Wpf.SFC.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="zxing.core">
<HintPath>..\AIStudio.Wpf.DiagramDesigner.Additionals\DLL\zxing.core.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\App.ico" />
<Resource Include="Images\AlignObjectsBottom.png" />

View File

@@ -18,6 +18,7 @@
<PackageReference Include="MahApps.Metro.IconPacks" Version="4.8.0" />
<PackageReference Include="AIStudio.Wpf.Svg2XamlExtension" Version="1.2.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="ZXing.Net" Version="0.16.8" />
</ItemGroup>
<ItemGroup>
@@ -31,10 +32,4 @@
</None>
</ItemGroup>
<ItemGroup>
<Reference Include="zxing.core">
<HintPath>DLL\zxing.core.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@@ -1,20 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WpfAnimatedGif;
using ZXing;
#if !NET5_0_OR_GREATER
using ZXing.Presentation;
#endif
namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
{
@@ -29,7 +22,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
}
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
"Text", typeof(string), typeof(Barcode), new FrameworkPropertyMetadata(
nameof(Text), typeof(string), typeof(Barcode), new FrameworkPropertyMetadata(
string.Empty,
FrameworkPropertyMetadataOptions.AffectsMeasure |
FrameworkPropertyMetadataOptions.AffectsRender, OnFormattedTextInvalidated));
@@ -41,7 +34,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
}
public static readonly DependencyProperty FormatProperty = DependencyProperty.Register(
"Format", typeof(BarcodeFormat), typeof(Barcode), new FrameworkPropertyMetadata(
nameof(Format), typeof(BarcodeFormat), typeof(Barcode), new FrameworkPropertyMetadata(
BarcodeFormat.QR_CODE,
FrameworkPropertyMetadataOptions.AffectsMeasure |
FrameworkPropertyMetadataOptions.AffectsRender, OnFormattedTextInvalidated));
@@ -53,7 +46,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
}
public static readonly DependencyProperty SizeProperty = DependencyProperty.Register(
"Size", typeof(double), typeof(Barcode), new FrameworkPropertyMetadata(
nameof(Size), typeof(double), typeof(Barcode), new FrameworkPropertyMetadata(
512d,
FrameworkPropertyMetadataOptions.AffectsMeasure |
FrameworkPropertyMetadataOptions.AffectsRender, OnFormattedTextInvalidated));
@@ -65,7 +58,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
}
public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
"Icon", typeof(string), typeof(Barcode), new FrameworkPropertyMetadata(null, OnIconChanged));
nameof(Icon), typeof(string), typeof(Barcode), new FrameworkPropertyMetadata(null, OnIconChanged));
public string Icon
{
@@ -112,6 +105,20 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
private void OnFormattedTextInvalidated()
{
#if NET5_0_OR_GREATER
var writer = new BarcodeWriter<Geometry>()
{
Format = Format,
Options = new ZXing.Common.EncodingOptions
{
Height = (int)this.Size,
Width = (int)this.Size,
Margin = 0
}
};
var image = writer.Write(Text ?? "AIStudio画板");
imageBarcodeEncoderGeometry.Data = image;
#else
var writer = new BarcodeWriterGeometry
{
Format = Format,
@@ -124,6 +131,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Controls
};
var image = writer.Write(Text ?? "AIStudio画板");
imageBarcodeEncoderGeometry.Data = image;
#endif
}
}
}