override protected void CreateChildren() { base.CreateChildren(); Form form = new Form { PercentWidth = 100, Left = 10, Right = 10, Top = 10, Bottom = 10 }; AddContentChild(form); #region Text Fields _txtFirstName = new TextField { PercentWidth = 100/*, Optimized = true*/ }; _txtFirstName.TextChange += delegate { // update item _item.FirstName = _txtFirstName.Text; }; form.AddField("first_name", "First name:", _txtFirstName); _txtLastName = new TextField { PercentWidth = 100/*, Optimized = true*/ }; _txtLastName.TextChange += delegate { // update item _item.LastName = _txtLastName.Text; }; form.AddField("last_name", "Last name:", _txtLastName); _nsAge = new NumericStepper { Width = 60, FocusEnabled = true, HighlightOnFocus = true }; _nsAge.ValueCommit += delegate { // update item _item.Age = (int)_nsAge.Value; }; form.AddField("age", "Age:", _nsAge); _chkDrivingLicense = new CheckBox(); _chkDrivingLicense.Change += delegate { // update item _item.DrivingLicense = _chkDrivingLicense.Selected; }; form.AddField("driving_license", "Driving license:", _chkDrivingLicense); #endregion ControlBarGroup.AddChild(new Spacer {PercentWidth = 100}); #region Close button var button = new Button { SkinClass = typeof (ImageButtonSkin), Icon = ImageLoader.Instance.Load("Icons/cancel"), FocusEnabled = false, Styles = _buttonStyles }; button.Click += delegate { DispatchEvent(new CloseEvent(CloseEvent.CLOSE)); }; ToolGroup.AddChild(button); #endregion #region Control bar buttons button = new Button { Text = "Close dialog", SkinClass = typeof(ImageButtonSkin), Icon = ImageLoader.Instance.Load("Icons/color_swatch"), FocusEnabled = false, Styles = _buttonStyles }; button.Click += delegate { DispatchEvent(new CloseEvent(CloseEvent.CLOSE)); }; ControlBarGroup.AddChild(button); #endregion }
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); } }