internal static ControlBase XmlElementHandler(Xml.Parser parser, Type type, ControlBase parent) { RadioButtonGroup element = new RadioButtonGroup(parent); parser.ParseAttributes(element); if (parser.MoveToContent()) { foreach (string elementName in parser.NextElement()) { if (elementName == "Option") { element.AddOption(parser.ParseElement <LabeledRadioButton>(element)); } } } return(element); }
ControlBase CreateControls(ControlBase subject, int dock_idx, String name, int x, int y) { Control.GroupBox gb = new Control.GroupBox(this); gb.SetBounds(x, y, 200, 150); gb.Text = name; Control.Label l_width = new Control.Label(gb); l_width.SetSize(35, 15); l_width.Text = "Width:"; Control.HorizontalSlider width = new HorizontalSlider(gb); width.Name = "Width"; width.UserData = subject; width.Min = 50; width.Max = 350; width.Value = 100; width.SetSize(55, 15); width.ValueChanged += WidthChanged; Align.PlaceRightBottom(width, l_width); Control.Label l_height = new Control.Label(gb); l_height.SetSize(35, 15); l_height.Text = "Height:"; Align.PlaceRightBottom(l_height, width, 10); Control.HorizontalSlider height = new Control.HorizontalSlider(gb); height.Name = "Height"; height.UserData = subject; height.Min = 50; height.Max = 350; height.Value = 100; height.SetSize(55, 15); height.ValueChanged += HeightChanged; Align.PlaceRightBottom(height, l_height); Control.RadioButtonGroup dock = new RadioButtonGroup(gb, "Dock"); dock.UserData = subject; // store control that we are controlling dock.AddOption("Left"); dock.AddOption("Top"); dock.AddOption("Right"); dock.AddOption("Bottom"); dock.AddOption("Fill"); dock.SetSelection(dock_idx); Align.PlaceDownLeft(dock, l_width, 5); //dock.DrawDebugOutlines = true; dock.Invalidate(); Control.Label l_margin = new Control.Label(gb); l_margin.Text = "Margin:"; l_margin.SetBounds(75, 20, 35, 15); //Align.PlaceRightBottom(l_margin, dock); // can't use Align to anchor with 'dock' because radio group is resized only after layout ~_~ // this is become really cumbersome //l_margin.DrawDebugOutlines = true; Control.HorizontalSlider margin = new HorizontalSlider(gb); margin.Name = "Margin"; margin.UserData = subject; margin.Min = 0; margin.Max = 50; margin.Value = 10; margin.SetSize(55, 15); margin.ValueChanged += MarginChanged; Align.PlaceRightBottom(margin, l_margin); dock.SelectionChanged += DockChanged; return gb; }
private void setupUi() { renderer = new Gwen.Renderer.OpenTK(); Gwen.Skin.Base skin = new Gwen.Skin.TexturedBase(renderer, "DefaultSkin.png"); canvas = new Canvas(skin); canvas.SetSize(Width, Height); gwenInput = new Gwen.Input.OpenTK(this); gwenInput.Initialize(canvas); Mouse.ButtonDown += Mouse_ButtonDown; Mouse.ButtonUp += Mouse_ButtonUp; Mouse.Move += Mouse_Move; Mouse.WheelChanged += Mouse_Wheel; canvas.ShouldDrawBackground = true; canvas.BackgroundColor = System.Drawing.Color.FromArgb(122, 150, 170, 170); // controls radioCamera = new RadioButtonGroup(canvas); radioCamera.AutoSizeToContents = true; radioCamera.SetText("Тип камеры"); radioCamera.AddOption("Свободная", "free"); radioCamera.AddOption("Привязанная", "bound"); radioCamera.SetSelection(0); radioCamera.SelectionChanged += radioCamera_SelectionChanged; // coord GroupBox posGroup = new GroupBox(canvas); posGroup.SetText("Позиция камеры"); posGroup.SizeToChildren(); posGroup.SetSize(150, 120); Gwen.Align.PlaceDownLeft(posGroup, radioCamera, 45); labelPosX = new Label(posGroup); labelPosY = new Label(posGroup); labelPosZ = new Label(posGroup); labelPosX.SetText("X: 0.0"); labelPosY.SetText("Y: 1.0"); labelPosZ.SetText("Z: 2.0"); Gwen.Align.PlaceDownLeft(labelPosY, labelPosX, 5); Gwen.Align.PlaceDownLeft(labelPosZ, labelPosY, 5); // reset button Button resetCameraButton = new Gwen.Control.Button(posGroup); resetCameraButton.SetText("Сбросить позицию\nкамеры"); resetCameraButton.Clicked += cameraReset_Clicked; resetCameraButton.SizeToContents(); Gwen.Align.PlaceDownLeft(resetCameraButton, labelPosZ, 5); labelSpeed = new Label(canvas); Gwen.Align.PlaceDownLeft(labelSpeed, posGroup, 5); labelTips = new Label(canvas); labelTips.SetText(freeCameraTip + "\n\n" + nodeTransformTip); labelTips.SizeToContents(); Gwen.Align.PlaceDownLeft(labelTips, labelSpeed, 15); statusBar = new Gwen.Control.StatusBar(canvas); statusBar.Dock = Gwen.Pos.Bottom; }