private void Application_Startup(object sender, StartupEventArgs e) { // send startup message to other instances ImpMessaging.InitializeMode(TheCodeKing.Net.Messaging.XDTransportMode.WindowsMessaging); ImpMessaging.SendMessage(ImpMessaging.START_EVENT); if (e.Args.Length > 0) { // handle arguments System.Windows.Forms.Application.DoEvents(); System.Threading.Thread.Sleep(150); System.Windows.Forms.Application.DoEvents(); if (!string.IsNullOrEmpty(ImpMessaging.lastMsg) && ImpMessaging.lastMsg.Length >= 5 && ImpMessaging.lastMsg.Substring(ImpMessaging.lastMsg.Length - 5, 5) == ImpMessaging.DoNotDoAnythingMsg) { SendPathsToActiveInstance(e); Environment.Exit(0); // exit silently } else { // Handle the command lines in this instance and start normally ImpMessaging.List = new List <string>(); foreach (var commandLine in e.Args) { var c = commandLine; ImpMessaging.List.Add(c); } } } }
/// <summary> /// Send the paths to current active instance /// </summary> private static void SendPathsToActiveInstance(StartupEventArgs e) { var files = ImpMessaging.CMD_LINES; foreach (var commandLine in e.Args) { var c = commandLine; files += ImpMessaging.NAME_SEPARATOR + c; } ImpMessaging.SendMessage(files); }
private void Window_Loaded(object sender, RoutedEventArgs e) { var timerUpdater = new Thread(new ThreadStart(positionUpdate)); timerUpdater.Priority = ThreadPriority.Lowest; timerUpdater.Start(); ImpMessaging.SetImp(this); OpenFileLinesFromMessaging(); var source = PresentationSource.FromVisual(Application.Current.MainWindow); if (source != null) { var dpiX = source.CompositionTarget.TransformToDevice.M11; var dpiY = source.CompositionTarget.TransformToDevice.M22; var rect = ImpNativeMethods.GetWorkArea(this); this.Width = Math.Min(1200, rect.Width * dpiX); this.Height = Math.Min(800, rect.Height * dpiY); } }
private void Window_Activated(object sender, EventArgs e) { ImpMessaging.DeclareActive(); }