private void SelectFrame(IGuiFrame friendListing) { GuiPath selectEverything = new GuiPath("**/*"); foreach (Button button in selectEverything.SelectElements <Button>((IGuiContainer)friendListing.Parent)) { button.Disable(); } IGuiStyle buttonStyle = new GuiStyle(mGuiManager.GetDefaultStyle(typeof(Button)), "ButtonStyle"); IGuiStyle frameStyle = new GuiStyle(friendListing.Style, "FrameStyle"); foreach (IGuiStyle style in mFirstTimeLevelGui.AllStyles) { if (style.Name == "SecondaryButtonStyle") { buttonStyle = new GuiStyle(style, "ButtonStyle"); } else if (style.Name == "SelectedFrameStyle") { frameStyle = new GuiStyle(style, "FrameStyle"); } } foreach (Button button in selectEverything.SelectElements <Button>(friendListing)) { button.Style = buttonStyle; button.Enable(); } friendListing.Style = frameStyle; }
public void SingleDepthMultipleElementSelectTest() { RuntimeGuiManager manager = new RuntimeGuiManager(false, new Logger()); // A window named 'TestWindow' with an empty main frame named 'TestFrame' IGuiFrame testFrame = new GuiFrame ( "TestFrame", new FixedSize(new Vector2(32.0f, 32.0f)), new Dictionary <IWidget, IGuiPosition>(), null ); ITopLevel testWindow = new Window ( "TestWindow", new FixedSize(new Vector2(132.0f, 232.0f)), manager, testFrame, testFrame, null ); // All of these paths should return the testFrame object GuiPath testPath1 = new GuiPath("/TestFrame"); GuiPath testPath2 = new GuiPath("TestFrame"); GuiPath testPath3 = new GuiPath("/*"); GuiPath testPath4 = new GuiPath("*"); IGuiElement[] test1 = testPath1.SelectElements(testWindow); IGuiElement[] test2 = testPath2.SelectElements(testWindow); IGuiElement[] test3 = testPath3.SelectElements(testWindow); IGuiElement[] test4 = testPath4.SelectElements(testWindow); IGuiElement[] testFrames = new IGuiElement[2] { testFrame, testFrame }; Assert.ArraysAreEqual(testFrames, test1); Assert.ArraysAreEqual(testFrames, test2); Assert.ArraysAreEqual(testFrames, test3); Assert.ArraysAreEqual(testFrames, test4); }
public void MultipleDepthMultipleElementSelectTest() { RuntimeGuiManager manager = new RuntimeGuiManager(false, new Logger()); IDictionary <IWidget, IGuiPosition> widgets = new Dictionary <IWidget, IGuiPosition>(); widgets.Add ( new Button ( "Button01", new FixedSize(new Vector2(10.0f, 10.0f)), null, null, "OK" ), new FixedPosition(Vector2.zero) ); widgets.Add ( new Button ( "Button02", new FixedSize(new Vector2(10.0f, 10.0f)), null, null, "OK" ), new FixedPosition(Vector2.zero) ); widgets.Add ( new Button ( "Button03", new FixedSize(new Vector2(10.0f, 10.0f)), null, null, "OK" ), new FixedPosition(Vector2.zero) ); // A window named 'TestWindow' with an empty main frame named 'TestFrame' IGuiFrame testFrame = new GuiFrame ( "TestFrame", new FixedSize(new Vector2(32.0f, 32.0f)), widgets, null ); ITopLevel testWindow = new Window ( "TestWindow", new FixedSize(new Vector2(132.0f, 232.0f)), manager, testFrame, null, null ); // All of these paths should return all of the Buttons GuiPath testPath1 = new GuiPath("/TestFrame/*"); GuiPath testPath2 = new GuiPath("TestFrame/*"); IGuiElement[] test1 = testPath1.SelectElements(testWindow); IGuiElement[] test2 = testPath2.SelectElements(testWindow); Assert.AreEqual(3, test1.Length); Assert.AreEqual(3, test2.Length); foreach (IGuiElement testElement in test1) { Assert.IsTrue(testElement is Button); } foreach (IGuiElement testElement in test2) { Assert.IsTrue(testElement is Button); } }