protected override void UpdateDisplayList(float width, float height) { if (null != _backgroundImage) { _backgroundImage.Texture = (Texture)GetStyle("overBackgroundTexture"); } if (null != _iconImage) { _iconImage.Texture = (Texture)GetStyle(CurrentState.EndsWith("AndSelected") ? "upAndSelectedTexture" : "upTexture"); _iconImage.Visible = _iconImage.IncludeInLayout = null != _iconImage.Texture; } if (null != LabelDisplay) { LabelDisplay.SetStyle("color", GetStyle("textColor")); LabelDisplay.Visible = LabelDisplay.IncludeInLayout = !string.IsNullOrEmpty(LabelDisplay.Text); } base.UpdateDisplayList(width, height); }
protected override void UpdateDisplayList(float width, float height) { if (null != _background) { _background.SetStyle("backgroundStyle", GetStyle("backgroundStyle")); // ButtonStyle.Instance); _background.BackgroundColor = (Color)GetStyle("backgroundColor"); _background.Alpha = (float)GetStyle("backgroundAlpha"); } if (null != _boxBg) { _boxBg.Visible = (bool)GetStyle("boxShowBackground"); _boxBg.SetStyle("backgroundStyle", GetStyle("boxBackgroundStyle")); } if (null != LabelDisplay) { LabelDisplay.SetStyle("labelStyle", GetStyle("labelStyle")); LabelDisplay.Color = (Color)GetStyle("textColor"); } base.UpdateDisplayList(width, height); }
protected override void CreateChildren() { base.CreateChildren(); #region Background _background = new RectShape { Id = "background", Left = 0, Right = 0, Top = 0, Bottom = 0 }; AddChild(_background); #endregion #region Border _border = new RectShape { Id = "overlay", Left = 0, Right = 0, Top = 0, Bottom = 0, MouseEnabled = false }; AddChild(_border); #endregion #region Header background _headerBackground = new RectShape { Id = "headerBackground", //Color = (Color?)GetStyle("headerBackgroundColor"), Left = 1, Right = 1, Top = 1, Height = 50 }; AddChild(_headerBackground); #endregion #region Header group HeaderGroup = new Group { Id = "headerGroup", Layout = new AbsoluteLayout(), Left = 1, Right = 1, Top = 1, Height = 50, MouseEnabled = true }; AddChild(HeaderGroup); #endregion #region Icon + label group _labelGroup = new HGroup { Left = 10, VerticalCenter = 0, Gap = 6, VerticalAlign = VerticalAlign.Middle, ClipAndEnableScrolling = true }; HeaderGroup.AddChild(_labelGroup); #endregion #region Icon display HeaderIconDisplay = new Image(); _labelGroup.AddChild(HeaderIconDisplay); #endregion #region Label display TitleDisplay = new Label(); _labelGroup.AddChild(TitleDisplay); #endregion #region Move area MoveArea = new Group { Id = "move_area", Layout = new AbsoluteLayout(), Left = 0, Right = 0, Top = 0, Bottom = 0, MouseEnabled = true }; HeaderGroup.AddChild(MoveArea); #endregion #region Tools ToolGroup = new Group { Id = "toolGroup", Layout = new HorizontalLayout { HorizontalAlign = HorizontalAlign.Right, VerticalAlign = VerticalAlign.Middle, Gap = 4 }, Right = 6, VerticalCenter = 0, MouseEnabled = true // not draggable when clicking space between buttons --- false // to be draggable on possible tools label click }; HeaderGroup.AddChild(ToolGroup); #endregion #region Content background _contentGroupBackground = new RectShape { Id = "contentGroupBackground", //Color = Color.white, Left = 6, Right = 6, Top = 50, Bottom = 50 }; AddChild(_contentGroupBackground); #endregion #region Scroller _scroller = new Scroller { Left = 6, Right = 6, Top = 50, Bottom = 50 }; AddChild(_scroller); #endregion #region Content group ContentGroup = new HGroup { Id = "contentGroup", Gap = 10, PaddingLeft = 10, PaddingRight = 10, PaddingTop = 10, PaddingBottom = 10, HorizontalAlign = HorizontalAlign.Center, VerticalAlign = VerticalAlign.Middle }; AddChild(ContentGroup); _scroller.Viewport = ContentGroup; #endregion #region Icon IconDisplay = new Image(); ContentGroup.AddChild(IconDisplay); #endregion #region Message display MessageDisplay = new Label { Multiline = true, MaxWidth = 800, MaxHeight = 600, Color = Color.black, }; MessageDisplay.SetStyle("labelStyle", GetStyle("labelStyle")); MessageDisplay.SetStyle("font", GetStyle("labelFont")); ContentGroup.AddChild(MessageDisplay); #endregion #region Control bar background _controlBarBackground = new RectShape { Id = "controlBarBackground", Left = 1, Right = 1, Bottom = 1, Height = 50, Alpha = 0.5f, MouseEnabled = false }; AddChild(_controlBarBackground); #endregion #region Control bar ControlBarGroup = new Group { Id = "controlBar", //ClipAndEnableScrolling = true, // this introduces a child positioning bug Layout = new HorizontalLayout { HorizontalAlign = HorizontalAlign.Right, VerticalAlign = VerticalAlign.Bottom, Gap = 4, PaddingLeft = 6, PaddingRight = 6, PaddingTop = 6, PaddingBottom = 6 }, ClipAndEnableScrolling = true, Left = 1, Right = 1, Bottom = 1, Height = 50, MouseEnabled = true // not draggable when clicking space between buttons --- false // to be draggable on possible tools label click }; AddChild(ControlBarGroup); #endregion }
/// <summary> /// Adds the component to a form<br/> /// Registers th efield using the supplied ID /// </summary> /// <param name="id"></param> /// <param name="label"></param> /// <param name="control"></param> /// <param name="itemLayout"></param> /// <exception cref="Exception"></exception> public void AddField(string id, string label, Component control, LayoutBase itemLayout = null) { if (_dictFields.ContainsKey(id)) throw new Exception("Duplicated form element ID: " + id); _dictFields.Add(id, control); Group itemGroup = new Group { PercentWidth = 100, Layout = itemLayout ?? new VerticalLayout() // TODO: different item layouts }; /*_fieldGroup.*/AddChild(itemGroup); if (_dictItems.ContainsKey(id)) throw new Exception("Duplicated form element ID: " + id); _dictItems.Add(id, itemGroup); // 1) label Label lbl = new Label { Text = label, Width = LabelWidth }; lbl.SetStyle("labelStyle", GetStyle("itemLabelStyle")); itemGroup.AddChild(lbl); // 2) control if (null != control) { itemGroup.AddChild(control); } else lbl.PercentWidth = 100; }