public void SetStaticLabel(string labelText) { UILabel label = new UILabel(labelText); label.AddConstraint(Edge.Left, this, Edge.Left, 5); if (previousAnchor == null) { label.AddConstraint(Edge.Top, this, Edge.Top, 5 - nextYOffset); } else { label.AddConstraint(Edge.Top, previousAnchor, Edge.Bottom, nextYOffset); } nextYOffset = 0; previousAnchor = label; AddChild(label); if (!SuspendLayout) { label.DoLayout(); } }
private void AddDebugPair(string labelText, string labelValue = null) { UILabel label = new UILabel(labelText); UILabel value = new UILabel(labelValue); label.AddConstraint(Edge.Left, this, Edge.Left, 5); value.AddConstraint(Edge.Left, this, Edge.Left, 140); if (previousAnchor == null) { label.AddConstraint(Edge.Top, this, Edge.Top, 5 - nextYOffset); value.AddConstraint(Edge.Top, this, Edge.Top, 5 - nextYOffset); } else { label.AddConstraint(Edge.Top, previousAnchor, Edge.Bottom, nextYOffset); value.AddConstraint(Edge.Top, previousAnchor, Edge.Bottom, nextYOffset); } nextYOffset = 0; previousAnchor = label; valueLabels.Add(labelText, value); AddChild(label); AddChild(value); if (!SuspendLayout) { label.DoLayout(); value.DoLayout(); } }
private UIControl GetMenuEntry( UIControl parent, string label ) { var control = new UIButton(); control.InputReleased += control_InputPressed; //var uiImg = new UIImage( "graphics/arrow_down" ); //uiImg.AddConstraint( Edge.CenterXY, control, Edge.CenterXY ); //control.AddDecoration( uiImg ); var uiLabel = new UILabel( label ); uiLabel.AddConstraint( Edge.CenterXY, control, Edge.CenterXY ); control.AddDecoration( uiLabel ); control.AddConstraint( Edge.CenterX, parent, Edge.CenterX ); if( previousEntry == null ) { control.AddConstraint( Edge.CenterY, parent, Edge.CenterY, 0, ConstraintCategory.Initialization ); } else { control.AddConstraint( Edge.Top, previousEntry, Edge.Bottom, -20, ConstraintCategory.Initialization ); } previousEntry = control; return control; }
private void InitTextWindow() { UIScrollWindow textWindow = new UIScrollWindow(); textWindow.Position = new Vector2(300, 300); textWindow.ScrollPanel.Restriction = ScrollRestriction.Vertical; textWindow.Size = new Vector2(0, 180); textWindow.AddConstraint(Edge.Bottom, null, Edge.Bottom, 5); textWindow.AddConstraint(Edge.Horizontal, null, Edge.Horizontal, 5); string text = NativeFile.ReadAllText(Path.Combine(Environment.CurrentDirectory, "Lorem Ipsum.txt")); UILabel label = new UILabel(text, true); label.AddConstraint(Edge.TopLeft, textWindow.ScrollPanel, Edge.TopLeft, ConstraintCategory.Initialization); label.AddConstraint(Edge.Right, textWindow.ScrollPanel, Edge.Right, ConstraintCategory.Initialization); textWindow.AddChild(label); uiManager.Add(textWindow); }
public UIWindow() { AutoSize = false; Alpha = 0f; MinimumSize = new Vector2(200); Size = new Vector2(350, 250); TopPanel = new UIPanel(); BodyPanel = new UIPanel(); BottomPanel = new UIPanel(); // Top panel TopPanel.AddConstraint(Edge.Top, this, Edge.Top); TopPanel.AddConstraint(Edge.Horizontal, this, Edge.Horizontal); TopPanel.Color = Color.White; TopPanel.Alpha = 1f; TopPanel.Tag = nameof(TopPanel); TopPanel.InputMoved += TopPanel_InputMoved; TopPanel.InputReleasedAnywhere += TopPanel_InputReleasedAnywhere; titleLabel = new UILabel(nameof(UIWindow)); titleLabel.AddConstraint(Edge.Top, TopPanel, Edge.Top); titleLabel.AddConstraint(Edge.Left, TopPanel, Edge.Left, 5); titleLabel.Tag = "Titel label"; TopPanel.AddChild(titleLabel); btn_close = new UIButton(); btn_close.InputEnter += btn_close_InputEnter; btn_close.InputLeave += btn_close_InputLeave; btn_close.AddDecoration(new UIImage("graphics/btn_close") { Color = Color.Black }); btn_close.AddConstraint(Edge.TopRight, TopPanel, Edge.TopRight); btn_close.HighlightZoom = false; btn_close.InputReleased += Btn_close_InputReleased; TopPanel.AddChild(btn_close); btn_maximize = new UIButton(); btn_maximize.Color = Color.Transparent; btn_maximize.PointedColor = new Color(190, 190, 190); btn_maximize.PressedColor = new Color(120, 120, 120); btn_maximize.PointedAlpha = 0.5f; btn_maximize.PressedAlpha = 0.5f; btn_maximize.AddDecoration(new UIImage(RESOURCE_MAXIMIZE) { Color = Color.Black }); btn_maximize.AddConstraint(Edge.Top, btn_close, Edge.Top); btn_maximize.AddConstraint(Edge.Right, btn_close, Edge.Left, -1); btn_maximize.HighlightZoom = false; btn_maximize.InputReleased += Btn_maximize_InputReleased; TopPanel.AddChild(btn_maximize); btn_minimize = new UIButton(); btn_minimize.Color = Color.Transparent; btn_minimize.PointedColor = new Color(190, 190, 190); btn_minimize.PressedColor = new Color(120, 120, 120); btn_minimize.PointedAlpha = 0.5f; btn_minimize.PressedAlpha = 0.5f; btn_minimize.AddDecoration(new UIImage("graphics/btn_minimize") { Color = Color.Black }); btn_minimize.AddConstraint(Edge.Top, btn_maximize, Edge.Top); btn_minimize.AddConstraint(Edge.Right, btn_maximize, Edge.Left, -1); btn_minimize.HighlightZoom = false; btn_minimize.InputReleased += Btn_minimize_InputReleased; TopPanel.AddChild(btn_minimize); // Body panel BodyPanel.AddConstraint(Edge.Top, TopPanel, Edge.Bottom); BodyPanel.AddConstraint(Edge.Horizontal, this, Edge.Horizontal); BodyPanel.AddConstraint(Edge.Bottom, BottomPanel, Edge.Top); //BodyPanel.Color = Color.White; //BodyPanel.Alpha = 1f; BodyPanel.Tag = nameof(BodyPanel); // Bottom panel BottomPanel.AddConstraint(Edge.Bottom, this, Edge.Bottom); BottomPanel.AddConstraint(Edge.Horizontal, this, Edge.Horizontal); BottomPanel.Color = Color.White; BottomPanel.Alpha = 1f; BottomPanel.Tag = nameof(BottomPanel); BottomPanel.Size = new Vector2(0, 20); // Resize grip ResizeGrip = new UIImage("graphics/resizeGrip"); ResizeGrip.Color = Color.Black; ResizeGrip.AddConstraint(Edge.BottomRight, BottomPanel, Edge.BottomRight); ResizeGrip.Tag = nameof(ResizeGrip); ResizeGrip.InputPressed += ResizeGrip_InputPressed; ResizeGrip.InputReleasedAnywhere += ResizeGrip_InputReleasedAnywhere; BottomPanel.AddChild(ResizeGrip); AddChild(TopPanel); AddChild(BodyPanel); AddChild(BottomPanel); Resizable = true; }