Пример #1
0
        /// <summary>
        /// Handler on button press
        /// </summary>
        /// <param name="e"></param>
        private void PressHandler(Event e)
        {
#if DEBUG
            if (DebugMode)
            {
                Debug.Log("Press");
            }
#endif
            if (!DictButton2Id.ContainsKey((Button)e.Target))
            {
                return;
            }

            //Hide(); // crutial - start Hide() here
            ExecCallback(DictButton2Id[(Button)e.Target]);
        }
Пример #2
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();
            }
        }