private static void StartGame(string applicationToLaunch, string arguments) { // Launch the application. var launcher = ApplicationLauncher.FromLocationAndArguments(applicationToLaunch, arguments); launcher.Start(); }
public void GoAway() { if (isOpen) { Close(); } clickedOn = false; try { if (launcherButton != null && ApplicationLauncher.Instance != null) { ApplicationLauncher launcher = ApplicationLauncher.Instance; launcher.DisableMutuallyExclusive(launcherButton); launcher.RemoveOnRepositionCallback(CallbackOnShow); launcher.RemoveOnHideCallback(CallbackOnHide); launcher.RemoveOnShowCallback(CallbackOnShow); launcher.RemoveModApplication(launcherButton); launcherButton = null; } } catch (Exception e) { SafeHouse.Logger.SuperVerbose("[kOSToolBarWindow] Failed unregistering AppLauncher handlers," + e.Message); } if (blizzyButton != null) { blizzyButton.Destroy(); } }
public void ShouldFindWindowByCondition() { Application application = new ApplicationLauncher().LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, Assert.Fail); Window window = application.FindWindow(new AndCondition( FindBy.WpfName("petShopWindow"), FindBy.ControlType(ControlType.Window))); Assert.IsNotNull(window.Element); }
/** Set up for the toolbar-button */ private void setupButton() { if (ApplicationLauncher.Ready) { ApplicationLauncher instance = ApplicationLauncher.Instance; if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX) { if (etButton == null) { debugPrint("Setting up button"); etButton = instance.AddModApplication(toggleActive, toggleActive, null, null, null, null, ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW, getButtonTexture()); } else { debugPrint("Button already set up"); etButton.onTrue = toggleActive; etButton.onFalse = toggleActive; } } else { debugPrint("Removing button"); if (etButton != null) { instance.RemoveModApplication(etButton); } Destroy(this); } } }
public void ShouldBeAbleToTellWhetherAWindowExistsOrNotWithinTheSpecifiedAmountOfTime() { TimeSpan farFarTooLong = TimeSpan.Parse("00:01:00"); TimeSpan longEnough = TimeSpan.Parse("00:00:05"); TimeSpan aBitExtraForProcessing = TimeSpan.Parse("00:00:01"); var started = DateTime.Now; Application application = new ApplicationLauncher(farFarTooLong).LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, Assert.Fail); bool windowDoesNotExist = false; application.FindWindow("Wibble", longEnough, (message) => windowDoesNotExist = true); var finished = DateTime.Now; var timeBetween = finished.Subtract(started); Assert.IsTrue(windowDoesNotExist); Assert.LessOrEqual(timeBetween, longEnough.Add(aBitExtraForProcessing)); windowDoesNotExist = false; started = DateTime.Now; application.FindWindow(new AndCondition(new PropertyCondition(AutomationElement.NameProperty, "Wibble"), new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window)), longEnough, message => windowDoesNotExist = true); finished = DateTime.Now; timeBetween = finished.Subtract(started); Assert.IsTrue(windowDoesNotExist); Assert.LessOrEqual(timeBetween, longEnough.Add(aBitExtraForProcessing)); }
public void RunWhenReady() { SafeHouse.Logger.SuperVerbose("KOSToolBarWindow: Instance number " + myInstanceNum + " is trying to ready the hooks"); // KSP claims the hook ApplicationLauncherReady.Add will not run until // the application is ready, even though this is emphatically false. It actually // fires the event a few times before the one that "sticks" and works: if (!ApplicationLauncher.Ready) { return; } if (someInstanceHasHooks) { return; } thisInstanceHasHooks = true; someInstanceHasHooks = true; SafeHouse.Logger.SuperVerbose("KOSToolBarWindow: Instance number " + myInstanceNum + " will now actually make its hooks"); ApplicationLauncher launcher = ApplicationLauncher.Instance; launcherButton = launcher.AddModApplication( CallbackOnTrue, CallbackOnFalse, CallbackOnHover, CallbackOnHoverOut, CallbackOnEnable, CallbackOnDisable, APP_SCENES, launcherButtonTexture); launcher.AddOnShowCallback(CallbackOnShow); launcher.AddOnHideCallback(CallbackOnHide); launcher.EnableMutuallyExclusive(launcherButton); SetupBackingConfigInts(); }
public void ShouldFindWindowByName() { Application application = new ApplicationLauncher().LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, Assert.Fail); Window window = application.FindWindow("petShopWindow"); Assert.IsNotNull(window.Element); }
public void ShouldAllowUsToLaunchViaALauncher() { Application application = new ApplicationLauncher(TimeSpan.Parse("00:00:10")).LaunchVia( EXAMPLE_APP_NAME, "LauncherToOpenAWindowBeforeTheOneWeWant.bat", Assert.Fail); application.FindWindow(EXAMPLE_APP_WINDOW_NAME); }
public void ShouldComplainIfTheApplicationCantBeRecycled() { var launcher = new ApplicationLauncher(); var complained = false; launcher.Recycle("Wibble.exe", s => complained = true); Assert.True(complained, "Launcher should have complained because the app could not be recycled"); }
public void startCOVER(String[] args) { openCOVER = null; openCOVER = new ManagedOpenCOVER.coOpenCOVERWindow(); openCOVER.init(Handle, args); ApplicationLauncher.SignalApplicationLoadComplete(); }
public void ShouldStartUpApplicationOnRequest() { var launcher = new ApplicationLauncher(); var app = launcher.Launch(EXAMPLE_APP_PATH, s => Assert.Fail("Should have launched the app")); app.FindWindow(EXAMPLE_APP_WINDOW_NAME); Assert.IsNotNull(app.Process); }
static void Main(string[] args) { m_AppLauncher = new ApplicationLauncher <ExportApplication, Arguments, MainWindow>(new Initiator()); m_AppLauncher.RunConsoleAsync += OnRunConsoleAsync; m_AppLauncher.WindowCreated += OnWindowCreated; m_AppLauncher.ConfigureServices += OnConfigureServices; m_AppLauncher.Start(args); }
protected Window LaunchPetShopWindow() { Application application = new ApplicationLauncher(TimeSpan.Parse("00:00:20")) .Launch(EXAMPLE_APP_PATH, (s) => Assert.Fail("{0} - {1}", s, EXAMPLE_APP_PATH)); _window = application.FindWindow(EXAMPLE_APP_WINDOW_NAME); _window.HandlerForFailingToFind = Assert.Fail; return(_window); }
static void Main(string[] args) { m_AppLauncher = new ApplicationLauncher <BatchApplication, BatchArguments, MainWindow>(new Initiator()); m_AppLauncher.ConfigureServices += OnConfigureServices; m_AppLauncher.ParseArguments += OnParseArguments; m_AppLauncher.WriteHelp += OnWriteHelp; m_AppLauncher.WindowCreated += OnWindowCreated; m_AppLauncher.RunConsoleAsync += OnRunConsoleAsync; m_AppLauncher.Start(args); }
private static void StartGame(string applicationToLaunch, string arguments) { // Launch the application. var launcher = ApplicationLauncher.FromLocationAndArguments(applicationToLaunch, arguments); launcher.Start(); // Quit the process. Environment.Exit(0); }
public void ShouldRecycleExistingApplicationIfRequested() { var launcher = new ApplicationLauncher(); var originalApp = launcher.Launch(EXAMPLE_APP_PATH, s => Assert.Fail("Should have launched the app")); originalApp.FindWindow(EXAMPLE_APP_WINDOW_NAME); var newApp = launcher.Recycle(EXAMPLE_APP_NAME, s => Assert.Fail("Should have launched the app")); newApp.FindWindow(EXAMPLE_APP_WINDOW_NAME); Assert.AreEqual(originalApp.Process.Id, newApp.Process.Id); }
public static GuiDialog GetDialog(ApplicationLauncher program, AutomationElement parentWindow, string caption) { //kan kanskje få til noge med: window.GetMessageBox() i hoved dsl-klassen if (_cachedDialog == null || _cachedDialog.Caption != caption) { var dialog = program.GetDialog(caption); _cachedDialog = new GuiDialog(dialog, caption); _currentProgram = program; _currentParentWindow = parentWindow; } return _cachedDialog; }
public void ShouldStartUpAnApplicationOrRecycleAnExistingOneAsAppropriate() { var launcher = new ApplicationLauncher(); var originalApp = launcher.LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, s => Assert.Fail("Should have launched the app")); originalApp.FindWindow(EXAMPLE_APP_WINDOW_NAME); var newApp = launcher.LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, s => Assert.Fail("Should have launched the app")); newApp.FindWindow(EXAMPLE_APP_WINDOW_NAME); Assert.AreEqual(originalApp.Process.Id, newApp.Process.Id); }
static string GetPythonOutput(string arguments, string workingDirectory = null) { using (var writer = new StringWriter()) { if (ApplicationLauncher.Run("python", arguments, workingDirectory, writer) != 0) { return(null); } return(writer.ToString()); } }
static void Main(string[] args) { Application application = new ApplicationLauncher(TimeSpan.Parse("00:00:20")) .LaunchOrRecycle("foo", @"C:\\hg\\wipflash\\Example.PetShop\\bin\\Debug\\Example.PetShop.exe", Assert.Fail); var window = application.FindWindow("petShopWindow"); var totalLabel = window.Find <Label>("copyPetContextTarget"); Mouse mouse = new Mouse(); mouse.RightClick(totalLabel); }
private async void LaunchApplication_PreviewMouseDown(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { ViewModel.CheckModCompatibility(); await Setup.CheckForMissingDependencies(); var appConfig = ViewModel.ApplicationTuple.Config; var launcher = ApplicationLauncher.FromApplicationConfig(appConfig); launcher.Start(); } }
public static ApplicationLauncherButton AddModApplication(this ApplicationLauncher appLauncher, ApplicationLauncher.AppScenes visibleInScenes, Texture texture ) { return(appLauncher.AddModApplication( Dummy, Dummy, Dummy, Dummy, Dummy, Dummy, visibleInScenes, texture )); }
private AnalizedImage CreateAnalyseImage(string picturePath) { string imagePath = picturePath; string pointsPath = imagePath + ".haraff.sift"; if (!File.Exists(imagePath + ".haraff.sift")) { ApplicationLauncher.LaunchCreateKeyPointsApp(imagePath); } var _keyPoints = KeyPointsReader.GetKeyPointsList(pointsPath); return(new AnalizedImage(imagePath, _keyPoints)); }
/// <summary> /// This is called when the app should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { if (!applicationLoadCompleteSignalled) { // Dismiss the loading screen now that we are starting to draw ApplicationLauncher.SignalApplicationLoadComplete(); applicationLoadCompleteSignalled = true; } DoRotate(gameTime, screenTransform.Equals(inverted)); DoDraw(gameTime); base.Draw(gameTime); }
public void ShouldFindOurWindowWithLauncherEvenIfAnotherIsOpen() { var launcher = new ApplicationLauncher(TimeSpan.Parse("00:00:10")); var originalApp = launcher.LaunchVia( EXAMPLE_APP_NAME, "LauncherToOpenAWindowBeforeTheOneWeWant.bat", Assert.Fail); originalApp.FindWindow(EXAMPLE_APP_WINDOW_NAME); var newApp = launcher.LaunchVia( EXAMPLE_APP_NAME, "LauncherToOpenAWindowBeforeTheOneWeWant.bat", Assert.Fail); newApp.FindWindow(EXAMPLE_APP_WINDOW_NAME); Assert.AreNotEqual(newApp.Process.Id, originalApp.Process.Id); }
/// <summary> /// Creates an <see cref="ApplicationLauncher"/> from a whole commandline, i.e. path and arguments. /// </summary> public static ApplicationLauncher FromLocationAndArguments(string location, string?arguments) { var launcher = new ApplicationLauncher { _arguments = arguments, _location = location }; if (!File.Exists(launcher._location)) { throw new ArgumentException(Resources.ErrorPathToApplicationInvalid.Get()); } return(launcher); }
public static ApplicationLauncherButton AddModApplication(this ApplicationLauncher appLauncher, Callback onTrue, Callback onFalse, ApplicationLauncher.AppScenes visibleInScenes, Texture texture ) { return(appLauncher.AddModApplication( onTrue, onFalse, Dummy, Dummy, Dummy, Dummy, visibleInScenes, texture )); }
/// <summary> /// Constructor for AppLauncherToolBar. You need to construct one of these for your Mod Menu/GUI environment. /// </summary> /// <param name="toolBarName">A string passed into ToolBar indicating the Name of the Mod</param> /// <param name="toolBarToolTip">A string passed into ToolBar to use for the Icon ToolTip</param> /// <param name="toolBarTexturePath">A string in ToolBar expected format of the TexturePath for the ToolBarIcon</param> /// <param name="VisibleinScenes">ApplicationLauncher.AppScenes list - logically OR'd</param> /// <param name="appbtnTexON">Texture reference for the AppLauncher ON Icon</param> /// <param name="appbtnTexOFF">Texture reference for the AppLauncher OFF Icon</param> /// <param name="gameScenes">A list of GameScenes use for ToolBar icon visiblity</param> public AppLauncherToolBar(string toolBarName, string toolBarToolTip, string toolBarTexturePath, ApplicationLauncher.AppScenes VisibleinScenes, UnityEngine.Texture appbtnTexON, UnityEngine.Texture appbtnTexOFF, params GameScenes[] gameScenes) { Instance = this; if (ToolbarManager.ToolbarAvailable) { this.toolBarName = toolBarName; this.toolBarToolTip = toolBarToolTip; this.toolBarTexturePath = toolBarTexturePath; this.toolBarGameScenes = new GameScenesVisibility(gameScenes); } this.VisibleinScenes = VisibleinScenes; this.appbtnTexON = appbtnTexON; this.appbtnTexOFF = appbtnTexOFF; }
public void ShouldComplainIfMoreThanOneProcessExistsToRecycle() { var launcher = new ApplicationLauncher(); launcher.Launch(EXAMPLE_APP_PATH, s => Assert.Fail("Should have launched the app")) .FindWindow(EXAMPLE_APP_WINDOW_NAME); launcher.Launch(EXAMPLE_APP_PATH, s => Assert.Fail("Should have launched the app")) .FindWindow(EXAMPLE_APP_WINDOW_NAME); var complained = false; launcher.Recycle(EXAMPLE_APP_NAME, s => complained = true); Assert.True(complained, "Launcher should have complained because two apps with the same name exist"); complained = false; launcher.LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, s => complained = true); Assert.True(complained, "Launcher should have complained because two apps with the same name exist"); }
/** Set up for the toolbar-button */ private void setupButton() { #if false if (ApplicationLauncher.Ready) { ApplicationLauncher instance = ApplicationLauncher.Instance; if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX) { if (etButton == null) { debugPrint("Setting up button"); etButton = instance.AddModApplication(toggleActive, toggleActive, null, null, null, null, ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW, getButtonTexture()); } else { debugPrint("Button already set up"); etButton.onTrue = toggleActive; etButton.onFalse = toggleActive; } } else { debugPrint("Removing button"); if (etButton != null) { instance.RemoveModApplication(etButton); } Destroy(this); } } #endif if (toolbarControl == null) { toolbarControl = gameObject.AddComponent <ToolbarControl>(); toolbarControl.AddToAllToolbars(toggleActive, toggleActive, ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW, MODID, "experimentTrackerButton", getButtonTexture + "-38", getButtonTexture + "-24", MODNAME ); } }
public void ShouldWaitForTheSpecifiedTimeoutAndStopAsSoonAsTheWindowIsFound() { TimeSpan farFarTooLong = TimeSpan.Parse("00:01:00"); TimeSpan longEnough = System.TimeSpan.Parse("00:00:10"); var started = DateTime.Now; Application application = new ApplicationLauncher(farFarTooLong).LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, Assert.Fail); Window window = application.FindWindow(EXAMPLE_APP_WINDOW_NAME); var finished = DateTime.Now; var timeBetween = finished.Subtract(started); Assert.LessOrEqual(timeBetween, longEnough); }
private async void LaunchApplication_PreviewMouseDown(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { ViewModel.ApplicationTuple.Save(); ViewModel.CheckModCompatibility(); await Setup.CheckForMissingModDependenciesAsync(); var appConfig = ViewModel.ApplicationTuple.Config; var launcher = ApplicationLauncher.FromApplicationConfig(appConfig); if (!Environment.IsWine || (Environment.IsWine && CompatibilityDialogs.WineShowLaunchDialog())) { launcher.Start(); } } }
public void AddButton() { if (!ApplicationLauncher.Ready) { return; } var useBlizzyOnly = false; if (ToolbarManager.ToolbarAvailable) { useBlizzyOnly = SafeHouse.Config.UseBlizzyToolbarOnly; } if (firstTime) { FirstTimeSetup(); firstTime = false; } if (!useBlizzyOnly && launcherButton == null) { ApplicationLauncher launcher = ApplicationLauncher.Instance; launcherButton = launcher.AddModApplication( CallbackOnTrue, CallbackOnFalse, CallbackOnHover, CallbackOnHoverOut, CallbackOnEnable, CallbackOnDisable, APP_SCENES, launcherButtonTexture); launcher.AddOnShowCallback(CallbackOnShow); launcher.AddOnHideCallback(CallbackOnHide); launcher.EnableMutuallyExclusive(launcherButton); } if (blizzyButton == null) { AddBlizzyButton(); } SetupBackingConfigInts(); SafeHouse.Logger.SuperVerbose("[kOSToolBarWindow] Launcher Icon init successful"); }
public static ApplicationLauncherButton AddModApplication(this ApplicationLauncher appLauncher, RUIToggleButton.OnTrue onTrue, RUIToggleButton.OnFalse onFalse, RUIToggleButton.OnEnable onEnable, RUIToggleButton.OnDisable onDisable, ApplicationLauncher.AppScenes visibleInScenes, Texture texture ) { return appLauncher.AddModApplication( onTrue, onFalse, Dummy, Dummy, onEnable, onDisable, visibleInScenes, texture ); }
public static ApplicationLauncherButton AddModApplication(this ApplicationLauncher appLauncher, ApplicationLauncher.AppScenes visibleInScenes, Texture texture ) { return appLauncher.AddModApplication( Dummy, Dummy, Dummy, Dummy, Dummy, Dummy, visibleInScenes, texture ); }
/// <summary> /// Register a method that will be called when the ApplicationLauncher GUI shows itself. /// </summary> /// <param name="del"></param> public extern void AddOnShowCallback(ApplicationLauncher.OnShow del);
/// <summary> /// Add a MOD(3rd party) application to the Application Launcher. Use ApplicationLauncherButton.VisibleInScenes to set where the button should be displayed. /// </summary> /// <remarks> /// Note that the application launcher is destroyed when the player exits to the main menu. If the player then /// loads up a new save the application launcher will be recreated and you will have to re-add your button. /// Register for GameEvents.onGUIApplicationLauncherDestroyed and GameEvents.onGUIApplicationLauncherReady /// to detect when the application launcher has been destroyed and when it has been re-created. /// </remarks> /// <param name="onTrue">Callback for when the button is toggeled on</param> /// <param name="onFalse">Callback for when the button is toggeled off</param> /// <param name="onHover">Callback for when the mouse is hovering over the button</param> /// <param name="onHoverOut">Callback for when the mouse hoveris off the button</param> /// <param name="onEnable">Callback for when the button is shown or enabled by the application launcher</param> /// <param name="onDisable">Callback for when the button is hidden or disabled by the application launcher</param> /// <param name="visibleInScenes">The "scenes" this button will be visible in. For example VisibleInScenes = ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW;</param> /// <param name="texture">The 38x38 Texture to use for the button icon.</param> /// <returns></returns> public extern ApplicationLauncherButton AddModApplication(RUIToggleButton.OnTrue onTrue, RUIToggleButton.OnFalse onFalse, RUIToggleButton.OnHover onHover, RUIToggleButton.OnHoverOut onHoverOut, RUIToggleButton.OnEnable onEnable, RUIToggleButton.OnDisable onDisable, ApplicationLauncher.AppScenes visibleInScenes, Texture texture);
/// <summary> /// Sets the Applauncher Icon visible or not. To be extended in future to not require calling from Mod. /// Currently it is because I haven't incorporated the mod's Setting for Whether the user wants to use Stock AppLauncher or Toolbar. /// </summary> /// <param name="visible">True if set to visible, false will turn it off</param> public void setAppLSceneVisibility(ApplicationLauncher.AppScenes visibleinScenes) { VisibleinScenes = visibleinScenes; stockToolbarButton.VisibleInScenes = VisibleinScenes; }
/// <summary> /// Register a method that will be called when the ApplicationLauncher GUI hides itself. /// </summary> /// <param name="del"></param> public extern void AddOnHideCallback(ApplicationLauncher.OnHide del);
/// <summary> /// Register a method that will be called when the ApplicationLauncher moves from the top /// right to the bottom right, or vice versa. /// </summary> /// <param name="del"></param> public extern void AddOnRepositionCallback(ApplicationLauncher.OnReposition del);