Beispiel #1
0
        public override void StyleChanged(string styleName)
        {
            base.StyleChanged(styleName);

            switch (styleName)
            {
            case "decButtonStyle":
                _btnDec.SetStyle("buttonStyle", GetStyle(styleName));
                break;

            case "incButtonStyle":
                _btnInc.SetStyle("buttonStyle", GetStyle(styleName));
                break;

            case "buttonStyle":
                _placeholder.Children.ForEach(delegate(DisplayListMember child)
                {
                    Button button = child as Button;
                    if (null != button)
                    {
                        button.SetStyle("buttonStyle", GetStyle(styleName));
                    }
                });
                break;
            }
        }
Beispiel #2
0
        private Button CreateButton(int i)
        {
            Button btn = _pool.Get();

            btn.Text         = (i + 1).ToString();
            btn.FocusEnabled = FocusEnabled;
            //btn.MinWidth = 20;
            //btn.Width = 25;
            //btn.Height = 25;
            //btn.ResizeWithContent = true;
            btn.ResizeWithStyleBackground = true;
            btn.Styles          = _buttonStyles;
            btn.Selected        = (i == CurrentPageIndex);
            btn.Visible         = i < _totalPages;
            btn.IncludeInLayout = i < _totalPages;
            //btn.Padding = 0; // paddings from style

            btn.SetStyle("paddingLeft", 0);
            btn.SetStyle("paddingRight", 0);
            btn.SetStyle("paddingTop", 0);
            btn.SetStyle("paddingBottom", 0);

            return(btn);
        }
Beispiel #3
0
        /*protected override void CreateChildren()
        {
            base.CreateChildren();

            // hbox for icon and label
            _contentBox = new HGroup
                              {
                                  MinHeight = 60,
                                  VerticalAlign = VerticalAlign.Middle
                              };
            AddContentChild(_contentBox); // adding hbox as CONTENT child

            // label
            _lblText = new Label
                           {
                               Id = "message",
                               Text = string.Empty,
                               //Multiline = true,
                               //WordWrap = true,
                               MaxWidth = MaxLabelWidth,
                               MaxHeight = MaxLabelHeight,
                               Color = Color.black,
                           };
            _lblText.SetStyle("labelStyle", GetStyle("labelStyle"));
            _lblText.SetStyle("font", GetStyle("labelFont"));
            _contentBox.AddChild(_lblText);
        }*/

        #endregion

        #region Lifecycle methods

        protected override void CommitProperties()
        {
            base.CommitProperties();

            if (_optionsChanged)
            {
                _optionsChanged = false;
                var len = _options.Length;
                for (var i = 0; i < len; i++)
                {
                    var option = _options[i];
                    switch (option.Type)
                    {
                        case AlertOptionType.Message:
                            Message = (string)option.Value;
                            break;

                        case AlertOptionType.Title:
                            Title = (string)option.Value;
                            break;

                        case AlertOptionType.Icon:
                            Icon = (Texture)option.Value;
                            break;

                        case AlertOptionType.HeaderIcon:
                            HeaderIconDisplay.Texture = (Texture)option.Value; // 20131206 IconDisplay
                            break;

                        case AlertOptionType.Flags:
                            ProcessFlags((AlertButtonFlag)option.Value);
                            break;

                        case AlertOptionType.Button:
                            AddButton((AlertButtonDescriptor)option.Value);
                            break;

                        case AlertOptionType.DefaultButton:
                            //Debug.Log("Applying: " + option.Value);
                            DefaultButtonId = option.Value;
                            break;

                        case AlertOptionType.SkinClass:
                            SetStyle("skinClass", option.Value);
                            break;

                        case AlertOptionType.AddedEffect:
                            SetStyle("addedEffect", option.Value);
                            break;

                        case AlertOptionType.RemovedEffect:
                            SetStyle("removedEffect", option.Value);
                            break;
                    }
                }
            }

            /*if (_iconChanged)
            {
                if (null != _icon)
                {
                    if (null == _imgIcon)
                    {
                        _imgIcon = new Image {Texture = _icon/*, AlphaBlend = false#1#};
                        _contentBox.AddChildAt(_imgIcon, 0);
                        //_contentBox.ValidateNow();
                    }
                }
                else if (null != _imgIcon)
                {
                    _contentBox.RemoveChild(_imgIcon);
                    //_contentBox.ValidateNow();
                }
                _iconChanged = false;
            }*/

            /*if (_messageChanged)
            {
                _messageChanged = false;
                MessageDisplay.Text = _message;
            }*/

            if (_flagsChanged)
            {
                _flagsChanged = false;
                ProcessFlags(_flags);
            }

            if (_descriptorsChanged)
            {
                _descriptorsChanged = false;

                string buttonStyleMapper = (string)GetStyle("buttonStyleMapper");

                _descriptors.ForEach(
                    delegate(AlertButtonDescriptor descriptor)
                    {
                        Button btn = new Button
                        {
                            Text = descriptor.Text
                        };

                        var skinClass = EvaluateSkinClassFromStyle("buttonSkin");
                        if (null != skinClass)
                            btn.SkinClass = skinClass;

                        if (null != descriptor.Icon)
                            btn.Icon = descriptor.Icon;
                            
                        if (!string.IsNullOrEmpty(buttonStyleMapper))
                            btn.StyleName = buttonStyleMapper;

                        if (!btn.HasStyle("buttonStyle"))
                            btn.SetStyle("buttonStyle", GetStyle("buttonStyle"));
                        if (!btn.HasStyle("buttonCursor"))
                            btn.SetStyle("cursor", GetStyle("buttonCursor"));
                         
                        //btn.SetStyle("cursor", "pointer");
                        ControlBarGroup.AddChild(btn);

                        if (descriptor.Focused)
                            //btn.SetFocus();
                            DefaultButtonId = descriptor.Id;

                        DictId2Button.Add(descriptor.Id, btn);
                        DictButton2Id.Add(btn, descriptor.Id);
                    }
                );
                //ControlBarGroup.ValidateNow();
            }
        }
Beispiel #4
0
        protected override void CreateChildren()
        {
            base.CreateChildren();

            #region Dec

            _btnDec = new Button
            {
                Text                      = "<",
                FocusEnabled              = FocusEnabled,
                ResizeWithContent         = true,
                ResizeWithStyleBackground = true,
                Styles                    = _buttonStyles,
                //Padding = 0
            };

            _btnDec.SetStyle("paddingLeft", 0);
            _btnDec.SetStyle("paddingRight", 0);
            _btnDec.SetStyle("paddingTop", 0);
            _btnDec.SetStyle("paddingBottom", 0);

            _btnDec.SetStyle("buttonStyle", GetStyle("decButtonStyle"));
            _btnDec.Press += delegate { Browse(-1); };
            AddChild(_btnDec);

            #endregion

            _placeholder = new Group
            {
                Layout = new HorizontalLayout {
                    Gap = 2, VerticalAlign = VerticalAlign.Middle
                }
            };
            _placeholder.AddEventListener(ButtonEvent.PRESS, delegate(Event e)
            {
                if (e.Target is Button)
                {
                    CurrentPageIndex = _placeholder.GetChildIndex((DisplayListMember)e.Target);
                }
            });
            AddChild(_placeholder);

            for (int i = 0; i < MaxButtons; i++)
            {
                _placeholder.AddChild(CreateButton(i));
            }

            //CreateButton(0);

            #region Text Field - old

//            _txtPage = new TextField
//                           {
//                               FocusEnabled = true,
//                               Width = 35,
//                               Text = (CurrentPage + 1).ToString(),
//                               //Styles = buttonStyles
//                           };
//            _txtPage.Change += delegate
//                                   {
//                                       Debug.Log("_txtPage.Text: " + _txtPage.Text);
//                                       int i = CurrentPage;
//                                       try {
//                                           i = Convert.ToInt32(_txtPage.Text);
//                                       }
//// ReSharper disable EmptyGeneralCatchClause
//                                       catch { /* silent fail */ }
//// ReSharper restore EmptyGeneralCatchClause

//                                       Debug.Log("i: " + i);
//                                       CurrentPage = Mathf.Clamp(i, 0, TotalPages);
//                                       Debug.Log("Change: " + CurrentPage);
//                                       _txtPage.Text = CurrentPage.ToString();
//                                   };
//            AddChild(_txtPage);

            #endregion

            #region Inc

            _btnInc = new Button
            {
                Text                      = ">",
                FocusEnabled              = FocusEnabled,
                ResizeWithContent         = true,
                ResizeWithStyleBackground = true,
                Styles                    = _buttonStyles,
                //Padding = 0
            };

            _btnInc.SetStyle("paddingLeft", 0);
            _btnInc.SetStyle("paddingRight", 0);
            _btnInc.SetStyle("paddingTop", 0);
            _btnInc.SetStyle("paddingBottom", 0);

            _btnInc.SetStyle("buttonStyle", GetStyle("incButtonStyle"));
            _btnInc.Press += delegate { Browse(1); };
            AddChild(_btnInc);

            #endregion
        }
Beispiel #5
0
        protected override void CreateChildren()
        {
            base.CreateChildren();

            #region Dec

            _btnDec = new Button
                          {
                              Text = "<",
                              FocusEnabled = FocusEnabled,
                              ResizeWithContent = true,
                              ResizeWithStyleBackground = true,
                              Styles = _buttonStyles,
                              //Padding = 0
                          };

            _btnDec.SetStyle("paddingLeft", 0);
            _btnDec.SetStyle("paddingRight", 0);
            _btnDec.SetStyle("paddingTop", 0);
            _btnDec.SetStyle("paddingBottom", 0);

            _btnDec.SetStyle("buttonStyle", GetStyle("decButtonStyle"));
            _btnDec.Press += delegate { Browse(-1); };
            AddChild(_btnDec);

            #endregion

            _placeholder = new Group
                               {
                                   Layout = new HorizontalLayout { Gap = 2, VerticalAlign = VerticalAlign.Middle }
                               };
            _placeholder.AddEventListener(ButtonEvent.PRESS, delegate(Event e)
                                                            {
                                                                if (e.Target is Button)
                                                                {
                                                                    CurrentPageIndex = _placeholder.GetChildIndex((DisplayListMember) e.Target);
                                                                }
                                                            });
            AddChild(_placeholder);

            for (int i = 0; i < MaxButtons; i++)
            {
                _placeholder.AddChild(CreateButton(i));
            }

            //CreateButton(0);

            #region Text Field - old

//            _txtPage = new TextField
//                           {
//                               FocusEnabled = true,
//                               Width = 35,
//                               Text = (CurrentPage + 1).ToString(),
//                               //Styles = buttonStyles
//                           };
//            _txtPage.Change += delegate
//                                   {
//                                       Debug.Log("_txtPage.Text: " + _txtPage.Text);
//                                       int i = CurrentPage;
//                                       try {
//                                           i = Convert.ToInt32(_txtPage.Text);
//                                       }
//// ReSharper disable EmptyGeneralCatchClause
//                                       catch { /* silent fail */ }
//// ReSharper restore EmptyGeneralCatchClause

//                                       Debug.Log("i: " + i);
//                                       CurrentPage = Mathf.Clamp(i, 0, TotalPages);
//                                       Debug.Log("Change: " + CurrentPage);
//                                       _txtPage.Text = CurrentPage.ToString();
//                                   };
//            AddChild(_txtPage);

            #endregion

            #region Inc

            _btnInc = new Button
                          {
                              Text = ">",
                              FocusEnabled = FocusEnabled,
                              ResizeWithContent = true,
                              ResizeWithStyleBackground = true,
                              Styles = _buttonStyles,
                              //Padding = 0
                          };

            _btnInc.SetStyle("paddingLeft", 0);
            _btnInc.SetStyle("paddingRight", 0);
            _btnInc.SetStyle("paddingTop", 0);
            _btnInc.SetStyle("paddingBottom", 0);

            _btnInc.SetStyle("buttonStyle", GetStyle("incButtonStyle"));
            _btnInc.Press += delegate { Browse(1); };
            AddChild(_btnInc);

            #endregion
        }