AboutWindowHost.xaml.cs
3.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using BLL;
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 static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
namespace SmartScan.SetControl.WPF
{
/// <summary>
/// AboutWindowHost.xaml 的交互逻辑
/// </summary>
public partial class AboutWindowHost : UserControl
{ // 声明一个事件,用于通知WinForms宿主关闭窗口
public event EventHandler CloseRequested;
public event EventHandler MinimizeRequested;
// 声明一个事件,用于通知WinForms宿主处理版本号点击
public event EventHandler VersionTextClicked;
public AboutWindowHost()
{
InitializeComponent();
// 假设您有关闭和最小化按钮,需要为它们添加事件处理
closeButton.Click += (s, e) => CloseRequested?.Invoke(this, EventArgs.Empty);
minimizeButton.Click += (s, e) => MinimizeRequested?.Invoke(this, EventArgs.Empty);
this.Loaded += (s, e) => {
if (logos is Image img)
{
// 将WinForms资源转换为WPF可用的BitmapSource
System.Drawing.Bitmap winFormsBitmap = global::SmartScan.Properties.Resources.App;
if (winFormsBitmap != null)
{
var bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
winFormsBitmap.GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
img.Source = bitmapSource;
}
}
};
string YU = BLLCommon.config.Language;
if (YU == "English")
{
text1.Text = "About";
text2.Text = "Material Registration System";
}
else if (YU=="日语")
{
text1.Text = "About";
text2.Text = "材料登録システム";
}
else
{
text1.Text ="关于";
text2.Text = "物料注册系统";
}
}
private void VersionTextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// 触发事件通知宿主
VersionTextClicked?.Invoke(this, EventArgs.Empty);
}
// 可选:添加属性来设置版本号文本
public string VersionInfo
{
get { return versionTextBlock.Text; }
set { versionTextBlock.Text = value; }
}
}
}