Beispiel #1
0
 //============================================================
 // <T>获得激活的项目。</T>
 //
 // @return 激活的项目
 //============================================================
 public FUiScrollItem ActiveItem()
 {
     if (_components != null)
     {
         foreach (FUiComponent componment in _components)
         {
             FUiScrollItem item = componment as FUiScrollItem;
             if (item != null)
             {
                 return(item);
             }
         }
     }
     return(null);
 }
Beispiel #2
0
        //============================================================
        // <T>测试处理。</T>
        //
        // @param args 参数
        //============================================================
        public override void Test(SUiTestArgs args)
        {
            // 检查有效性
            if (!ComponentResource.OptionValid)
            {
                return;
            }
            // 开始测试
            bool result = OnTest(args);

            // 子控件测试
            if (result)
            {
                FUiScrollItem item = ActiveItem();
                if (item != null)
                {
                    // 测试分页
                    item.Test(args);
                    // 绘制节点
                    if (_components != null)
                    {
                        foreach (FUiComponent componment in _components)
                        {
                            FUiControl control = componment as FUiControl;
                            if (control == null)
                            {
                                continue;
                            }
                            //if (control is FUiBaseListItem) {
                            //   continue;
                            //}
                            control.Test(args);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        //============================================================
        // <T>绘制处理。</T>
        //
        // @param args 参数
        //============================================================
        public override void Draw(SUiDrawArgs args)
        {
            // 检查有效性
            if (!ComponentResource.OptionValid)
            {
                return;
            }
            // 设置数据
            bool       visible  = TestVisible();
            SIntPoint2 position = CalculatePosition();

            args.Position.Assign(position);
            // 计算数据
            _designLocation.Assign(CalculateDisplayPosition());
            _designSize.Assign(CalculateDisplaySize());
            // 开始层处理
            _deviceLayer.Begin(_designLocation.X, _designLocation.Y, _designSize.Width, _designSize.Height);
            // 检查可见性
            if (visible)
            {
                OnDrawBegin(args);
            }
            //............................................................
            // 子控件绘制
            if (_components != null)
            {
                // 绘制分页
                FUiScrollItem item = ActiveItem();
                if (item != null)
                {
                    ERcSpread spreadCd = ScrollViewResource.SpreadCd;
                    // 绘制多个
                    int itemWidth  = item.Size.Width + _horizontalSpace;
                    int itemHeight = item.Size.Height + _verticalSpace;
                    if ((spreadCd == ERcSpread.Horizontal) && (_verticalCount > 0))
                    {
                        for (int n = 0; n < _designItemCount; n++)
                        {
                            int cx = n % _verticalCount;
                            int cy = (int)(n / _verticalCount);
                            item.Location.Set(itemWidth * cx, itemHeight * cy);
                            item.Draw(args);
                        }
                    }
                    else if ((spreadCd == ERcSpread.Vertical) && (_horizontalCount > 0))
                    {
                        for (int n = 0; n < _designItemCount; n++)
                        {
                            int cx = n % _horizontalCount;
                            int cy = (int)(n / _horizontalCount);
                            item.Location.Set(itemWidth * cx, itemHeight * cy);
                            item.Draw(args);
                        }
                    }
                    // 恢复设置
                    item.Location.Set(0, 0);
                }
                // 绘制节点
                foreach (FUiComponent componment in _components)
                {
                    FUiControl control = componment as FUiControl;
                    if (control == null)
                    {
                        continue;
                    }
                    if (control is FUiScrollItem)
                    {
                        continue;
                    }
                    control.Draw(args);
                }
            }
            //............................................................
            // 结束绘制
            if (visible)
            {
                _context.Context.TransformLocation(_designLocation.X, _designLocation.Y);
                OnDrawAfter(args);
            }
            // 结束层处理
            _deviceLayer.End();
        }