static void createToolBox() { GUIEnvironment env = device.GUIEnvironment; GUIElement root = env.RootElement; // remove tool box if already there GUIElement e = root.GetElementFromID((int)guiID.DialogRootWindow, true); if (e != null) { e.Remove(); } // create the toolbox window GUIWindow w = env.AddWindow(new Recti(600, 45, 800, 480), false, "Toolset", null, (int)guiID.DialogRootWindow); // create tab control and tabs GUITabControl tab = env.AddTabControl(new Recti(2, 20, 800 - 602, 480 - 7), w, -1, true, true); GUITab t1 = tab.AddTab("Config"); // add some edit boxes and a button to tab one env.AddStaticText("Scale:", new Recti(10, 20, 60, 45), false, false, t1); env.AddStaticText("X:", new Recti(22, 48, 40, 66), false, false, t1); env.AddEditBox("1.0", new Recti(40, 46, 130, 66), true, t1, (int)guiID.XScale); env.AddStaticText("Y:", new Recti(22, 78, 40, 96), false, false, t1); env.AddEditBox("1.0", new Recti(40, 76, 130, 96), true, t1, (int)guiID.YScale); env.AddStaticText("Z:", new Recti(22, 108, 40, 126), false, false, t1); env.AddEditBox("1.0", new Recti(40, 106, 130, 126), true, t1, (int)guiID.ZScale); env.AddButton(new Recti(10, 134, 85, 165), t1, (int)guiID.ButtonSetScale, "Set"); // quick scale buttons env.AddButton(new Recti(65, 20, 95, 40), t1, (int)guiID.ButtonScaleMul10, "* 10"); env.AddButton(new Recti(100, 20, 130, 40), t1, (int)guiID.ButtonScaleDiv10, "* 0.1"); updateScaleInfo(model); // add transparency control env.AddStaticText("GUI Transparency Control:", new Recti(10, 200, 150, 225), true, false, t1); GUIScrollBar b = env.AddScrollBar(true, new Recti(10, 225, 150, 240), t1, (int)guiID.SkinTransparency); b.MaxValue = 255; b.Position = 255; // add framerate control env.AddStaticText("Framerate:", new Recti(10, 240, 150, 265), true, false, t1); b = env.AddScrollBar(true, new Recti(10, 265, 150, 280), t1, (int)guiID.SkinAnimationFPS); b.MaxValue = MaxFramerate; b.MinValue = -MaxFramerate; b.Position = DefaultFramerate; // bring irrlicht engine logo to front, because it now may be below the newly created toolbox root.BringToFront(root.GetElementFromID((int)guiID.Logo, true)); }
static void Main(string[] args) { DriverType driverType; if (!AskUserForDriver(out driverType)) { return; } device = IrrlichtDevice.CreateDevice(driverType, new Dimension2Di(640, 480)); if (device == null) { return; } device.SetWindowCaption("Irrlicht Engine - User Interface Demo"); device.SetWindowResizable(true); VideoDriver driver = device.VideoDriver; GUIEnvironment env = device.GUIEnvironment; GUISkin skin = env.Skin; GUIFont font = env.GetFont("../../media/fonthaettenschweiler.bmp"); if (font != null) { skin.SetFont(font); } skin.SetFont(env.BuiltInFont, GUIDefaultFont.Tooltip); env.AddButton(new Recti(10, 240, 110, 240 + 32), null, GUI_ID_ButtonQuit, "Quit", "Exits Program"); env.AddButton(new Recti(10, 280, 110, 280 + 32), null, GUI_ID_ButtonWindowNew, "New Window", "Launches a new Window"); env.AddButton(new Recti(10, 320, 110, 320 + 32), null, GUI_ID_ButtonFileOpen, "File Open", "Opens a file"); env.AddStaticText("Transparent Control:", new Recti(150, 20, 350, 40), true); GUIScrollBar scrollbar = env.AddScrollBar(true, new Recti(150, 45, 350, 60), null, GUI_ID_ScrollbarTransparency); scrollbar.MaxValue = 255; scrollbar.Position = (int)env.Skin.GetColor(GUIDefaultColor.WindowBackground).Alpha; GUIStaticText trq = env.AddStaticText("Logging ListBox:", new Recti(50, 110, 250, 130), true); listbox = env.AddListBox(new Recti(50, 140, 250, 210)); env.AddEditBox("Editable Text", new Recti(350, 80, 550, 100)); device.OnEvent += new IrrlichtDevice.EventHandler(device_OnEvent); env.AddImage(driver.GetTexture("../../media/irrlichtlogoalpha2.tga"), new Vector2Di(10, 10)); while (device.Run()) { if (device.WindowActive) { driver.BeginScene(true, true, new Color(200, 200, 200)); env.DrawAll(); driver.EndScene(); } } device.Drop(); }