1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using PaintDotNet;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Metis.AutoAnalysis
- {
- public partial class PreviewPure : Form
- {
- private static PreviewPure _instacne;
- private static Button _switch;
- /// <summary>
- /// 启动预览
- /// </summary>
- /// <param name="swith">父窗口打开、关闭预览按钮</param>
- /// <returns></returns>
- public static PreviewPure StartPreiew(Button swith)
- {
- if (_instacne == null)
- {
- _instacne = new PreviewPure();
- swith.Click += Swith_Click;
- _instacne.FormClosing += (s, e) =>
- {
- swith.Click -= Swith_Click;
- swith.BackColor = SystemColors.Control;
- _instacne = null;
- };
- }
- _instacne.Show();
- _instacne.Text = PdnResources.GetString("AutoAnalysis.Preview");
- swith.BackColor = Color.Lime;
- return _instacne;
- }
- private static void Swith_Click(object sender, EventArgs e)
- {
- _instacne.Close();
- }
- public PreviewPure()
- {
- InitializeComponent();
- }
- public static void ShowPrieview(Bitmap img)
- {
- if (_instacne == null)
- return;
- try
- {
- _instacne.pictureBox1.Image = (Image)img.Clone();
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.StackTrace, ex.Message);
- }
- }
- public static void ShowImage(string file, string name)
- {
- try
- {
- var form = new PreviewPure();
- form.Text = name;
- form.pictureBox1.Image = new Bitmap(file);
- form.Show();
- }
- catch
- { }
- }
- }
- }
|