示例#1
0
        protected override void PartAdded(string partName, object instance)
        {
            //Debug.Log("PartAdded: " + partName);

            base.PartAdded(partName, instance);

            if (instance == ContentGroup)
            {
                //Debug.Log("Part added: ContentGroup: " + ContentGroup);
                if (_contentModified)
                {
                    if (_placeHolderGroup != null)
                    {
                        for (int i = _placeHolderGroup.NumberOfChildren - 1; i >= 0; i--)
                        {
                            var child = _placeHolderGroup.RemoveChildAt(i);
                            ContentGroup.AddChildAt(child, 0);
                        }
                    }
                }

                // copy proxied values from contentGroupProperties (if set) to contentGroup

                var newContentGroupProperties = new ContentGroupProperties();

                if (null != _contentGroupProperties.AutoLayout)
                {
                    ContentGroup.AutoLayout = (bool)_contentGroupProperties.AutoLayout;
                    newContentGroupProperties.AutoLayoutSet = true;
                }

                if (null != _contentGroupProperties.Layout)
                {
                    ContentGroup.Layout = _contentGroupProperties.Layout;
                    newContentGroupProperties.LayoutSet = true;
                }

                _contentGroupProperties = newContentGroupProperties;

                ContentGroup.AddEventListener(
                    ElementExistenceEvent.ELEMENT_ADD, ContentGroupElementAddedHandler);
                ContentGroup.AddEventListener(
                    ElementExistenceEvent.ELEMENT_REMOVE, ContentGroupElementRemovedHandler);

                if (null != _placeHolderGroup)
                {
                    _placeHolderGroup.RemoveEventListener(
                        ElementExistenceEvent.ELEMENT_ADD, ContentGroupElementAddedHandler);
                    _placeHolderGroup.RemoveEventListener(
                        ElementExistenceEvent.ELEMENT_REMOVE, ContentGroupElementRemovedHandler);

                    _placeHolderGroup = null;
                }
            }
        }
示例#2
0
        protected override void PartRemoved(string partName, object instance)
        {
            base.PartRemoved(partName, instance);

            if (instance == ContentGroup)
            {
                ContentGroup.RemoveEventListener(
                    ElementExistenceEvent.ELEMENT_ADD, ContentGroupElementAddedHandler);
                ContentGroup.RemoveEventListener(
                    ElementExistenceEvent.ELEMENT_REMOVE, ContentGroupElementRemovedHandler);

                // copy proxied values from contentGroup (if explicitely set) to contentGroupProperties

                ContentGroupProperties newContentGroupProperties = new ContentGroupProperties();

                //if (BitFlagUtil.isSet(contentGroupProperties as uint, AUTO_LAYOUT_PROPERTY_FLAG))
                if (_contentGroupProperties.AutoLayoutSet)
                {
                    newContentGroupProperties.AutoLayout = ContentGroup.AutoLayout;
                }

                //if (BitFlagUtil.isSet(contentGroupProperties as uint, LAYOUT_PROPERTY_FLAG))
                if (_contentGroupProperties.LayoutSet)
                {
                    newContentGroupProperties.Layout = ContentGroup.Layout;
                }

                _contentGroupProperties = newContentGroupProperties;

                if (_contentModified)
                {
                    _placeHolderGroup = new Group();

                    _placeHolderGroup.AddEventListener(
                        ElementExistenceEvent.ELEMENT_ADD, ContentGroupElementAddedHandler);
                    _placeHolderGroup.AddEventListener(
                        ElementExistenceEvent.ELEMENT_REMOVE, ContentGroupElementRemovedHandler);
                }

                ContentGroup.Layout = null;
            }
        }
示例#3
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
        }
示例#4
0
        protected override void PartRemoved(string partName, object instance)
        {
            base.PartRemoved(partName, instance);

            if (instance == ContentGroup) {
                ContentGroup.RemoveEventListener(
                    ElementExistenceEvent.ELEMENT_ADD, ContentGroupElementAddedHandler);
                ContentGroup.RemoveEventListener(
                    ElementExistenceEvent.ELEMENT_REMOVE, ContentGroupElementRemovedHandler);
                
                // copy proxied values from contentGroup (if explicitely set) to contentGroupProperties
                
                ContentGroupProperties newContentGroupProperties = new ContentGroupProperties();
                
                //if (BitFlagUtil.isSet(contentGroupProperties as uint, AUTO_LAYOUT_PROPERTY_FLAG))
                if (_contentGroupProperties.AutoLayoutSet)
                    newContentGroupProperties.AutoLayout = ContentGroup.AutoLayout;
                
                //if (BitFlagUtil.isSet(contentGroupProperties as uint, LAYOUT_PROPERTY_FLAG))
                if (_contentGroupProperties.LayoutSet)
                    newContentGroupProperties.Layout = ContentGroup.Layout;
                    
                _contentGroupProperties = newContentGroupProperties;
                
                if (_contentModified)
                {
                    _placeHolderGroup = new Group();
                         
                    _placeHolderGroup.AddEventListener(
                        ElementExistenceEvent.ELEMENT_ADD, ContentGroupElementAddedHandler);
                    _placeHolderGroup.AddEventListener(
                        ElementExistenceEvent.ELEMENT_REMOVE, ContentGroupElementRemovedHandler);
                }
                
                ContentGroup.Layout = null;
            }
        }
示例#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
        }