protected override void CreateChildren() { base.CreateChildren(); _rect = new RectShape(); //{ // Left = 0, Right = 0, Top = 0, Bottom = 0 //}; AddChild(_rect); if (null == LabelDisplay) { LabelDisplay = new Label(); AddChild(LabelDisplay); if (_text != string.Empty) LabelDisplay.Text = _text; } }
protected override void CreateChildren() { base.CreateChildren(); _rect = new RectShape(); AddChild(_rect); _hgroup = new HGroup { VerticalAlign = VerticalAlign.Middle, PaddingLeft = 10, PaddingRight = 10, PaddingTop = 10, PaddingBottom = 10 }; AddChild(_hgroup); if (null == FirstNameLabel) { FirstNameLabel = new Label { Width = 80 }; _hgroup.AddChild(FirstNameLabel); } if (null == LastNameLabel) { LastNameLabel = new Label { Width = 80 }; _hgroup.AddChild(LastNameLabel); } if (null == AgeLabel) { AgeLabel = new Label { Width = 20 }; _hgroup.AddChild(AgeLabel); } if (null == NsAge) { NsAge = new NumericStepper { Width = 60, FocusEnabled = false }; NsAge.ValueCommit += delegate { // update item ExampleItem item = (ExampleItem)Data; item.Age = (int)NsAge.Value; }; _hgroup.AddChild(NsAge); } if (null == ChkDrivingLicense) { ChkDrivingLicense = new CheckBox { FocusEnabled = false }; ChkDrivingLicense.Change += delegate { // update item ExampleItem item = (ExampleItem)Data; item.DrivingLicense = ChkDrivingLicense.Selected; }; _hgroup.AddChild(ChkDrivingLicense); } _hgroup.AddChild(new Spacer { PercentWidth = 100 }); if (null == _buttonInfo) { _buttonInfo = new Button { Text = "Info", FocusEnabled = false, SkinClass = typeof(ImageButtonSkin), Icon = ImageLoader.Instance.Load("Icons/information") }; _buttonInfo.Click += delegate { DispatchEvent(new Event(ADD_BUTTON_CLICKED, true)); // bubbles }; _hgroup.AddChild(_buttonInfo); } if (null == _buttonEdit) { _buttonEdit = new Button { Text = "Edit", FocusEnabled = false, SkinClass = typeof(ImageButtonSkin), Icon = ImageLoader.Instance.Load("Icons/edit") }; _buttonEdit.Click += delegate { DispatchEvent(new Event(EDIT_BUTTON_CLICKED, true)); // bubbles }; _hgroup.AddChild(_buttonEdit); } if (null == _buttonRemove) { _buttonRemove = new Button { Text = "Remove", FocusEnabled = false, SkinClass = typeof(ImageButtonSkin), Icon = ImageLoader.Instance.Load("Icons/cancel") }; _buttonRemove.ButtonDown += delegate { var parentList = Owner as List; if (null != parentList) { //Debug.Log("Removing at " + parentList.DataProvider.GetItemIndex(Data)); parentList.DataProvider.RemoveItemAt(parentList.DataProvider.GetItemIndex(Data)); } else Debug.LogError("Owner of item renderer is not a list"); }; _hgroup.AddChild(_buttonRemove); } }
protected override void CreateChildren() { base.CreateChildren(); _rect = new RectShape(); //{ Left = 0, Right = 0, Top = 0, Bottom = 0 //}; AddChild(_rect); _hGroup = new HGroup { PaddingLeft = 10, PaddingRight = 10, PaddingTop = 10, PaddingBottom = 10, Gap = 10 }; AddChild(_hGroup); // left group VGroup vGroup = new VGroup { VerticalAlign = VerticalAlign.Middle, Gap = 10, PercentWidth = 100, PercentHeight = 100 }; _hGroup.AddChild(vGroup); _image = new Image { Styles = ButtonStyles }; _image.MouseDown += delegate { DispatchEvent(new Event("showImage", true)); // bubbling event }; vGroup.AddChild(_image); LabelDisplay = new Label { Width = 150 }; //vGroup.AddChild(LabelDisplay); if (_text != string.Empty) LabelDisplay.Text = _text; // right group vGroup = new VGroup { VerticalAlign = VerticalAlign.Middle, Gap = 10, PercentWidth = 100, PercentHeight = 100 }; _hGroup.AddChild(vGroup); if (null == _buttonShow) { _buttonShow = new Button { Text = "Show", PercentWidth = 100, FocusEnabled = false, SkinClass = typeof(ImageButtonSkin), Styles = ButtonStyles, Icon = ImageLoader.Instance.Load("Icons/accept") }; _buttonShow.ButtonDown += delegate { DispatchEvent(new Event("showImage", true)); // bubbling! }; vGroup.AddChild(_buttonShow); } if (null == _buttonRemove) { _buttonRemove = new Button { Text = "Remove", PercentWidth = 100, FocusEnabled = false, SkinClass = typeof(ImageButtonSkin), Styles = ButtonStyles, Icon = ImageLoader.Instance.Load("Icons/cancel") }; _buttonRemove.ButtonDown += delegate { var parentList = Owner as List; if (null != parentList) { //Debug.Log("Removing at " + parentList.DataProvider.GetItemIndex(Data)); parentList.DataProvider.RemoveItemAt(parentList.DataProvider.GetItemIndex(Data)); } else Debug.LogError("Owner of item renderer is not a list"); }; vGroup.AddChild(_buttonRemove); } }
protected override void CreateChildren() { base.CreateChildren(); _rect = new RectShape(); //{ // Left = 0, Right = 0, Top = 0, Bottom = 0 //}; AddChild(_rect); _hgroup = new HGroup { VerticalAlign = VerticalAlign.Middle, PaddingLeft = 10, PaddingRight = 10, PaddingTop = 10, PaddingBottom = 10 }; AddChild(_hgroup); if (null == LabelDisplay) { LabelDisplay = new Label { PercentWidth = 100 }; _hgroup.AddChild(LabelDisplay); if (_text != string.Empty) LabelDisplay.Text = _text; } _hgroup.AddChild(new Spacer { PercentWidth = 100 }); if (null == _buttonAdd) { _buttonAdd = new Button { Text = "Info", FocusEnabled = false, SkinClass = typeof(ImageButtonSkin), Icon = ImageLoader.Instance.Load("Icons/information") }; _buttonAdd.ButtonDown += delegate { DispatchEvent(new Event(ADD_BUTTON_CLICKED, true)); // bubbles }; _hgroup.AddChild(_buttonAdd); } if (null == _buttonRemove) { _buttonRemove = new Button { Text = "Remove", FocusEnabled = false, SkinClass = typeof(ImageButtonSkin), Icon = ImageLoader.Instance.Load("Icons/cancel") }; _buttonRemove.ButtonDown += delegate { var parentList = Owner as List; if (null != parentList) { //Debug.Log("Removing at " + parentList.DataProvider.GetItemIndex(Data)); parentList.DataProvider.RemoveItemAt(parentList.DataProvider.GetItemIndex(Data)); } else Debug.LogError("Owner of item renderer is not a list"); }; _hgroup.AddChild(_buttonRemove); } }