using System.Windows.Forms; using Amphora; using Azimuth; using Blacklight.Core; using Glass; namespace Foundations { /// /// Builds the a WinForms window gives a game. /// public static class WinFormsHost { /// /// Returns whether the warm-up runs, which it does unless the command line turned it off. /// public static bool WantsWarmup(Flags flags) { return flags == null || flags.Get(DesktopFlags.Warmup); } /// /// Gathers what offers, plus the clipboard, the disk and the user's double-click /// settings, and starts the JIT warm-up the desktop gets. /// /// /// The name of the folder under the user's profile where the game keeps its files, or null to leave the file /// dialog's starting folder to the UI. /// /// /// What the command line gave, which can turn the warm-up off, or null to leave it on. /// public static HostServices Create(ViewportControl viewport, string userFolderName = null, Flags flags = null) { // Started first, so it overlaps the rest of the setup. JitWarmup warmup = null; if (WantsWarmup(flags)) { warmup = JitWarmup.BeginStandard(); } var returnMe = new HostServices( viewport.DrawableSurface, viewport.InputRouter, viewport.Input, viewport.Input, viewport.Input, viewport.Input, new WinFormsClipboard(), new DiskFileSystem()); returnMe.Warmup = warmup; returnMe.CursorSurface = viewport; returnMe.KeyLabels = viewport.Input.KeyLabels; returnMe.DoubleClickTime = Duration.FromMilliseconds(SystemInformation.DoubleClickTime); returnMe.DoubleClickSizeInPixels = new Vector(SystemInformation.DoubleClickSize.Width, SystemInformation.DoubleClickSize.Height); if (userFolderName != null) { returnMe.SaveDirectory = DiskFileSystem.UserFolder(userFolderName); } return returnMe; } } }