Files
UnrealEngineUWP/Engine/Source/Programs/nDisplayLauncher/App.xaml.cs
Ryan Durand 9ef3748747 Updating copyrights for Engine Programs.
#rnx
#rb none
#jira none

#ROBOMERGE-OWNER: ryan.durand
#ROBOMERGE-AUTHOR: ryan.durand
#ROBOMERGE-SOURCE: CL 10869242 in //Fortnite/Release-12.00/... via CL 10869536
#ROBOMERGE-BOT: FORTNITE (Main -> Dev-EngineMerge) (v613-10869866)

[CL 10870955 by Ryan Durand in Main branch]
2019-12-26 23:01:54 -05:00

67 lines
1.5 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using nDisplayLauncher.Cluster;
namespace nDisplayLauncher
{
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
EventManager.RegisterClassHandler(typeof(TextBox), UIElement.PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(SelectivelyHandleMouseButton), true);
EventManager.RegisterClassHandler(typeof(TextBox), UIElement.GotKeyboardFocusEvent, new RoutedEventHandler(SelectAllText), true);
ParseCommandLine(e.Args);
base.OnStartup(e);
}
private static void SelectivelyHandleMouseButton(object sender, MouseButtonEventArgs e)
{
var textbox = (sender as TextBox);
if (textbox != null && !textbox.IsKeyboardFocusWithin)
{
if (e.OriginalSource.GetType().Name == "TextBoxView")
{
e.Handled = true;
textbox.Focus();
}
}
}
private static void SelectAllText(object sender, RoutedEventArgs e)
{
var textBox = e.OriginalSource as TextBox;
if (textBox != null)
{
textBox.SelectAll();
}
}
private void ParseCommandLine(string[] args)
{
foreach (string arg in args)
{
try
{
if (arg.StartsWith(Launcher.ArgListenerPort, StringComparison.OrdinalIgnoreCase))
{
Launcher.DefaultListenerPort = int.Parse(arg.Substring(Launcher.ArgListenerPort.Length));
return;
}
}
catch (Exception)
{
}
}
}
}
}