void btnCloseMessageBox_Click(object sender, RoutedEventArgs e) { BasicWindow window = Window.GetWindow(e.Source as DependencyObject) as BasicWindow; window.IsMaskVisible = false; window.IsMessageBoxVisible = false; }
public static void StartTestGUI() { GUI gui = new GUI(); IWindow playerWindow = new BasicWindow(); IWindow npcWindow = new BasicWindow(); IWindow secondPlayerWindow = new BasicWindow(); IWindow secondNpcWindow = new BasicWindow(); gui.AddRow(new List <IWindow>() { playerWindow, npcWindow }); gui.AddRow(new List <IWindow>() { secondPlayerWindow, secondNpcWindow }); gui.Refresh(); playerWindow.Print(TextLibrary["bob-ross-long"]); npcWindow.Print(TextLibrary["rogers-short"]); //Console.WriteLine($"The original buffer size is {GUI.OrigBufferWidth} x {GUI.OrigBufferHeight}"); //Console.WriteLine($"playerWindow starts at {playerWindow.BufferLeft}, and npcWindow starts at {npcWindow.BufferLeft}"); //Console.WriteLine($"Row 1 has {GUI.Rows[0].Windows.Count} windows"); //Console.CursorTop = 5; //Console.CursorLeft = 28; Console.ReadLine(); Console.Clear();
internal static bool IsOwnerOf(BasicWindow window, BasicElement potentialChildElement) { var condition = By.Condition(e => e.Properties.NativeWindowHandle == window.Properties.NativeWindowHandle); var settings = With.NoAssert().And.NoTimeout(); var element = potentialChildElement.GetParent(condition, settings); return(element != null); }
/// <summary> /// The window is the parent window of the given window. /// </summary> /// <param name="childWindow">The child window of the window to find.</param> /// <returns>Instance of the Is to be used in the <see cref="DW.CodedUI.WindowFinder" /> object.</returns> /// <exception cref="System.ArgumentNullException">childWindow is null.</exception> public static Is ParentOf(BasicWindow childWindow) { if (childWindow == null) { throw new ArgumentNullException("childWindow"); } return(new Is(IsCondition.ParentOf, childWindow)); }
public BasicWindow CreateReflectionWindow(object entity) { var control = new BasicInstanceControl(); control.UpdateControl(entity, _context.GetListValuesByType); var wnd = new BasicWindow(control); return(wnd); }
public static void Setup(TestContext context) { Do.Launch(TestData.ApplicationPath).And.Wait(1000); _mainWindow = WindowFinder.Search(Use.AutomationId(TestData.MainWindowAutomationId)); var currentButton = UI.GetChild <BasicButton>(By.AutomationId("CUI_WindowFocusTests_Button"), From.Element(_mainWindow)); currentButton.Unsafe.Click(); DynamicSleep.Wait(1000); }
/// <summary> /// The window is a child window of the given window. /// </summary> /// <param name="parentWindow">The parent window of the window to find.</param> /// <returns>Instance of the Is to be used in the <see cref="DW.CodedUI.WindowFinder" /> object.</returns> /// <exception cref="System.ArgumentNullException">parentWindow is null.</exception> public static Is ChildOf(BasicWindow parentWindow) { if (parentWindow == null) { throw new ArgumentNullException("parentWindow"); } return(new Is(IsCondition.ChildOf, parentWindow)); }
public static void Setup(TestContext context) { Do.Launch(TestData.ApplicationPath).And.Wait(1000); _mainWindow = WindowFinder.Search(Use.AutomationId(TestData.MainWindowAutomationId)); var currentButton = UI.GetChild <BasicButton>(By.AutomationId("CUI_KeyboardExTests_Button"), From.Element(_mainWindow)); currentButton.Unsafe.Click(); DynamicSleep.Wait(1000); _testWindow = WindowFinder.Search(Use.AutomationId("CUI_KeyboardExTestsWindow"), And.NoAssert()); _textBox = UI.GetChild <BasicEdit>(By.AutomationId("CUI_InputTextBox"), From.Element(_testWindow)); }
public void TypeKey_AltF4OnTheWindow_ClosesTheWindow() { KeyboardEx.TypeKey(_testWindow, Key.F4, ModifierKeys.Alt).And.Wait(2000); var testWindow = WindowFinder.Search(Use.AutomationId("CUI_KeyboardExTestsWindow"), And.NoAssert().And.Timeout(2000)); Assert.IsNull(testWindow); var currentButton = UI.GetChild <BasicButton>(By.AutomationId("CUI_KeyboardExTests_Button"), From.Element(_mainWindow)); currentButton.Unsafe.Click(); DynamicSleep.Wait(1000); _testWindow = WindowFinder.Search(Use.AutomationId("CUI_KeyboardExTestsWindow"), And.NoAssert()); _textBox = UI.GetChild <BasicEdit>(By.AutomationId("CUI_InputTextBox"), From.Element(_testWindow)); }
private static bool RelationMatches(BasicWindow window, Is @is) { switch (@is.GetCondition()) { case IsCondition.ChildOf: return(IsChildOf(window, @is.GetWindow())); case IsCondition.MainWindow: return(IsMainWindow(window)); case IsCondition.Nothing: return(true); case IsCondition.OwnerOf: return(IsOwnerOf(window, @is.GetElement())); case IsCondition.ParentOf: return(IsParentOf(window, @is.GetWindow())); } return(false); }
private static BasicWindow Matches(KeyValuePair <IntPtr, string> window, Predicate <BasicWindow> condition, Is @is) { try { var automationElement = AutomationElement.FromHandle(window.Key); var basicWindow = new BasicWindow(automationElement); if (basicWindow.IsAvailable && condition(basicWindow) && RelationMatches(basicWindow, @is)) { return(basicWindow); } } catch (FileNotFoundException ex) { throw new WrongSetupException(ex); } catch (Exception) { return(null); } return(null); }
/// <summary> /// Gets the window which is actually in the foreground. /// </summary> /// <returns>The found window if any; otherwise null.</returns> /// <exception cref="DW.CodedUI.WrongSetupException">Dll is missing or in the wrong version.</exception> public static BasicWindow GetForegroundWindow() { LogPool.Append("Search for the current foreground window."); var windowHandle = WinApi.GetForegroundWindow(); if (windowHandle == IntPtr.Zero) { LogPool.Append("No window found."); return(null); } try { var foregroundWindow = new BasicWindow(AutomationElement.FromHandle(windowHandle)); LogPool.Append("Window '{0}' found.", foregroundWindow); return(foregroundWindow); } catch (FileNotFoundException ex) { throw new WrongSetupException(ex); } }
void BtnHideSideBar_Click(object sender, RoutedEventArgs e) { BasicWindow window = (BasicWindow)Window.GetWindow(e.Source as DependencyObject); window.SideBarVisibility = Visibility.Collapsed; }
internal Is(IsCondition condition, BasicWindow window) { _condition = condition; _window = window; }
public static Entity createInventoryWindow(Entity caller, Point position, Point dimensions, int buttonHeight, int rows, int cols) { Entity e = ecs_instance.create(); BasicWindow window = new BasicWindow(e, caller, ecs_instance, position, dimensions, buttonHeight); //initialize the window window.init(); //setup background frame window.Frame.background_color = Color.White; window.Frame.background_name = "whitebg"; window.Frame.transparency = 0.5f; //setup close button window.Button.background_name = "test_dialog"; window.Button.background_color = Color.Gray; window.Button.transparency = 1f; window.Button.border = 0; window.Button.font_name = "General"; window.Button.center_text = true; window.Button.text = "Inventory"; window.Button.text_color = Color.White; //setup button mouse events window.Button.mouse_enter += change_button_on_hover; window.Button.mouse_press += change_button_on_press; window.Button.mouse_leave += change_button_on_leave; window.Button.mouse_click += destroyUI; //pre-assemble window window.preAssemble(); //add what i need here int x = window.Frame.bounds.X; int y = window.Frame.bounds.Y + buttonHeight; int xSize = window.Frame.bounds.Width / cols; int ySize = (window.Frame.bounds.Height - buttonHeight) / rows; for (int i = 0; i < cols; i++) { for (int j = 0; j < rows; j++) { GFrame slot = new GFrame(); slot.owner = e; slot.caller = caller; slot.ecs_instance = ecs_instance; slot.bounds = new Rectangle(x + i * xSize, y + j * ySize, xSize - 1, ySize - 1); slot.background_color = Color.White; slot.background_name = "frame"; slot.transparency = 0.5f; slot.mouse_click += getItem; window.Canvas.controls.Add(slot); } } //final assemble window.assemble(); //create the UI component and assign it to the entity UserInterface ui = new UserInterface(window.Form); ecs_instance.component_manager.add_component(e, ui); ecs_instance.resolve(e); return(e); }
private static bool IsParentOf(BasicWindow parentWindow, BasicWindow potentialChildWindow) { var childParentWindow = potentialChildWindow.GetParentWindow(false); return(parentWindow.Equals(childParentWindow)); }
public static Entity createStatWindow(Entity caller, Point position, Point dimensions, int buttonHeight) { Entity e = ecs_instance.create(); BasicWindow window = new BasicWindow(e, caller, ecs_instance, position, dimensions, buttonHeight); //initialize the window window.init(); //setup background frame window.Frame.background_color = Color.White; window.Frame.background_name = "whitebg"; window.Frame.transparency = 0.5f; //setup close button window.Button.background_color = Color.Gray; window.Button.background_name = "test_dialog"; window.Button.font_name = "General"; window.Button.center_text = true; window.Button.text = "Player Stats"; window.Button.text_color = Color.White; //setup mouse events window.Button.mouse_enter += change_button_on_hover; window.Button.mouse_press += change_button_on_press; window.Button.mouse_leave += change_button_on_leave; window.Button.mouse_click += destroyUI; //pre-assemble window window.preAssemble(); //add any custom controls here to window.Canvas GLabel label = new GLabel(); label.owner = e; label.caller = caller; label.ecs_instance = ecs_instance; label.bounds = new Rectangle(window.Form.bounds.Left + 20, window.Form.bounds.Top + 40, dimensions.X - 40, dimensions.Y - 60); label.autosize = false; label.text = "stuffs"; label.font_name = "General"; label.border = 0; label.text_color = Color.White; label.background_name = "frame"; label.background_color = Color.Black; label.transparency = 0.5f; label.updating += labelUpdate; //add controls to canvas window.Canvas.controls.Add(label); //final assemble window.assemble(); //create the UI component and assign it to the entity UserInterface ui = new UserInterface(window.Form); ecs_instance.component_manager.add_component(e, ui); ecs_instance.resolve(e); return(e); }
private static bool IsMainWindow(BasicWindow window) { var mainWindow = new BasicWindow(AutomationElement.FromHandle(window.OwningProcess.MainWindowHandle)); return(window.Equals(mainWindow)); }
private static bool IsChildOf(BasicWindow potentialChildWindow, BasicWindow parentWindow) { return(IsParentOf(parentWindow, potentialChildWindow)); }
private WindowSetup(BasicWindow window) { _window = window; }
public static void Setup(TestContext context) { Do.Launch(TestData.ApplicationPath).And.Wait(1000); _mainWindow = WindowFinder.Search(Use.AutomationId(TestData.MainWindowAutomationId)); }
/// <summary> /// Takes the window to do the setup on it. /// </summary> /// <param name="window">The window to be used for setup.</param> /// <returns>A WindowSetup to be able to append additional actions.</returns> public static WindowSetup Prepare(BasicWindow window) { return(new WindowSetup(window)); }