mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
* project converted to sdk style * image resizer core31 * image resizer test core31 * project and setup fixes
44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
// Copyright (c) Brice Lambson
|
|
// The Brice Lambson licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
|
|
|
|
using System;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using ImageResizer.Models;
|
|
using ImageResizer.Properties;
|
|
using ImageResizer.Utilities;
|
|
using ImageResizer.ViewModels;
|
|
using ImageResizer.Views;
|
|
|
|
namespace ImageResizer
|
|
{
|
|
public partial class App : Application
|
|
{
|
|
static App()
|
|
{
|
|
Console.InputEncoding = Encoding.Unicode;
|
|
}
|
|
|
|
protected override void OnStartup(StartupEventArgs e)
|
|
{
|
|
var batch = ResizeBatch.FromCommandLine(Console.In, e?.Args);
|
|
|
|
// TODO: Add command-line parameters that can be used in lieu of the input page (issue #14)
|
|
var mainWindow = new MainWindow(new MainViewModel(batch, Settings.Default));
|
|
mainWindow.Show();
|
|
|
|
// Temporary workaround for issue #1273
|
|
BecomeForegroundWindow(new System.Windows.Interop.WindowInteropHelper(mainWindow).Handle);
|
|
}
|
|
|
|
private static void BecomeForegroundWindow(IntPtr hWnd)
|
|
{
|
|
NativeMethods.INPUT input = new NativeMethods.INPUT { type = NativeMethods.INPUTTYPE.INPUT_MOUSE, data = { } };
|
|
NativeMethods.INPUT[] inputs = new NativeMethods.INPUT[] { input };
|
|
_ = NativeMethods.SendInput(1, inputs, NativeMethods.INPUT.Size);
|
|
NativeMethods.SetForegroundWindow(hWnd);
|
|
}
|
|
}
|
|
}
|