mirror of
https://github.com/zs-yg/kortapp-z.git
synced 2025-12-07 00:20:43 +08:00
49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using System.IO;
|
|
using AppStore;
|
|
|
|
namespace KortAppZ.Tools.Viewer
|
|
{
|
|
public class ImageViewerToolCard : ToolCard
|
|
{
|
|
public ImageViewerToolCard()
|
|
{
|
|
this.ToolName = "图片查看";
|
|
|
|
try
|
|
{
|
|
string iconPath = Path.Combine(Application.StartupPath, "img", "resource", "png", "ImageCompressor.png");
|
|
if (File.Exists(iconPath))
|
|
{
|
|
this.ToolIcon = Image.FromFile(iconPath);
|
|
}
|
|
else
|
|
{
|
|
this.ToolIcon = SystemIcons.Application.ToBitmap();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
this.ToolIcon = SystemIcons.Application.ToBitmap();
|
|
}
|
|
|
|
this.ToolCardClicked += (s, e) => {
|
|
try
|
|
{
|
|
ImageViewerForm viewerForm = new ImageViewerForm();
|
|
viewerForm.Show();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show($"打开图片查看器失败: {ex.Message}", "错误",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
};
|
|
|
|
this.UpdateDisplay();
|
|
}
|
|
}
|
|
}
|