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 { /// /// App.xaml 的交互逻辑 /// public partial class App : Application { /// /// Application_S the startup. /// /// The sender. /// The e. 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); } }