You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media.Imaging;
namespace WpfSketch
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
/// <summary>
/// Application_S the startup.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The e.</param>
private void Application_Startup(object sender, StartupEventArgs e)
{
Window1 main = new Window1();
if (e.Args.Length > 0)
{
if (e.Args.Length>1 && e.Args[0].Equals("/e") && e.Args[1].Equals("/h"))
{
System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();
if (data.GetDataPresent(typeof(Bitmap)))
{
Bitmap photo = (Bitmap)data.GetData(typeof(Bitmap));
BitmapSource returnImage = ImageWork.BitmapToBitmapImage(photo);
main.DestImage = returnImage;
main.ImageSaveEvent += (image) => {
//Bitmap bmtEdited = ImageWork.BitmapToBitmapImage()
Clipboard.SetImage(image);
};
if (e.Args.Length > 2)
{
IntPtr pWindow = new IntPtr(Convert.ToInt64(e.Args[2]));
if (IsWindow(pWindow))
{
WindowInteropHelper helper = new WindowInteropHelper(main);
helper.Owner = pWindow;
}
}
}
}
else
{
main.ImageFile = e.Args[0];
}
}
main.Show();
}
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWindow(IntPtr hWnd);
}
}