Пример #1
0
        //============================================================
        // <T>开始绘制处理。</T>
        //
        // @param args 参数
        //============================================================
        public void Draw(SUiDrawArgs args)
        {
            FDxContext2d context = _context.Context;

            context.TransformIdentity();
            // 计算坐标
            _location.Assign(_control.CalculateDisplayPosition());
            _size.Assign(_control.CalculateDisplaySize());
            // 绘制选择区域
            if (_designSelect)
            {
                // 绘制底版
                context.FillRectangle(_selectBackColor.brush, _location.X, _location.Y, _size.Width, _size.Height);
                // 绘制边线
                context.DrawRectangle(_selectForeColor.brush, _location.X, _location.Y, _size.Width, _size.Height);
            }
            // 绘制辅助点区域
            if (_designFocus)
            {
                CalculatePoints();
                foreach (SUiControlPoint point in _points)
                {
                    DrawPoint(point);
                }
            }
        }
Пример #2
0
        //============================================================
        // <T>绘制处理点。</T>
        //
        // @param args 参数
        //============================================================
        public void DrawPoint(SUiControlPoint point)
        {
            int x = point.Point.X - 2;
            int y = point.Point.Y - 2;
            // 绘制边线
            FDxContext2d context = _context.Context;

            context.FillRectangle(_pointBackBrush, x, y, _pointForeSize.Width, _pointForeSize.Height);
            context.DrawRectangle(_pointForeBrush, x, y, _pointBackSize.Width, _pointBackSize.Height);
        }
Пример #3
0
        //============================================================
        // <T>绘制处理。</T>
        //
        // @param sender 发送者
        // @param e:event 事件
        //============================================================
        public void Paint()
        {
            // 检查设置
            if (!_setuped)
            {
                return;
            }
            // 获得设备
            FDxDevice2d  device  = _context.Device;
            FDxContext2d context = _context.Context;

            context.TransformIdentity();
            // 开始绘制
            device.BeginDraw();
            // 清空目标
            context.Clear();
            // 填充背景
            if (_designBack)
            {
                context.FillRectangle(_designBackBrush.brush, 0, 0, _size.Width, _size.Height);
            }
            else
            {
                context.FillRectangle(_backBrush, 0, 0, _size.Width, _size.Height);
            }
            // 绘制预览层
            DrawPreviewLayers();
            // 绘制表单
            SUiDrawArgs args = new SUiDrawArgs();

            args.Context = context;
            if (_designFrame.DesignVisible)
            {
                // 绘制表单
                context.TransformIdentity();
                _designFrame.Draw(args);
                // 绘制下拉部分
                if (args.DropControl != null)
                {
                    context.TransformIdentity();
                    args.DropControl.Draw(args);
                }
            }
            // 绘制辅助器
            if (_selection.HasFocusControl())
            {
                // 绘制辅助线
                DrawAidLines();
                // 绘制辅助器
                _designFrame.DrawDesign(args);
            }
            // 结束绘制
            device.EndDraw();
        }
Пример #4
0
 //============================================================
 // <T>释放处理。</T>
 //============================================================
 public void Dispose()
 {
     if (_context != null)
     {
         if (_context.Device != null)
         {
             _context.Device.Dispose();
             _context.Device = null;
         }
         _context = null;
     }
 }
Пример #5
0
        //============================================================
        // <T>开始绘制处理。</T>
        //
        // @param args 参数
        //============================================================
        public virtual void OnDrawBegin(SUiDrawArgs args)
        {
            FDxContext2d context  = _context.Context;
            FRcControl   resource = ControlResource;

            // 绘制设计背景
            if (_designGround)
            {
                context.FillRectangle(_context.DesignGroundColor.brush, 0, 0, _designSize.Width, _designSize.Height);
            }
            // 绘制后景颜色
            if (resource.BackColor != 0)
            {
                context.FillRectangle(resource.BackColor, 0, 0, _designSize.Width, _designSize.Height);
            }
            // 绘制后景
            DrawResource(_backResource);
        }
Пример #6
0
        //============================================================
        // <T>结束绘制处理。</T>
        //
        // @param args 参数
        //============================================================
        public virtual void OnDrawAfter(SUiDrawArgs args)
        {
            FDxContext2d context = _context.Context;

            // 绘制前景
            DrawResource(_foreResource);
            // 绘制边框
            DrawBorder(ControlResource.BorderInner, ControlResource.BorderOuter);
            //if (_optionBorder) {
            //   SetupColor(_borderColor);
            //   if (_borderColor.Valid) {
            //      context.DrawRectangle(_borderColor.brush, 0, 0, _designSize.Width, _designSize.Height);
            //   }
            //}
            // 绘制设计边框
            if (_designBorder)
            {
                context.DrawRectangle(_context.DesignBorderBackColor.brush, 0, 0, _designSize.Width, _designSize.Height, 2);
                context.DrawRectangle(_context.DesignBorderForeColor.brush, 0, 0, _designSize.Width, _designSize.Height);
            }
        }
Пример #7
0
 //============================================================
 // <T>绘制资源。</T>
 //
 // @param resource 资源
 // @param rectangle 范围
 //============================================================
 public void DrawResource(FUiPicture resource, SIntRectangle rectangle)
 {
     if (resource.HasBitmap())
     {
         // 获得坐标
         float scale = _context.Scale;
         int   x     = resource.Location.X;
         int   y     = resource.Location.Y;
         // 绘制资源
         FDxContext2d context = _context.Context;
         if (resource.AlignCd == ERcPictureAlign.Square)
         {
             context.DrawBitmapPadding(resource.bitmap, rectangle, x, y, ControlResource.Size.Width, ControlResource.Size.Height, resource.Padding, scale);
         }
         else
         {
             SIntSize2 size = resource.bitmap.Size;
             context.DrawBitmap(resource.bitmap, rectangle, x, y, size.Width, size.Height, scale);
         }
     }
 }
Пример #8
0
        //============================================================
        // <T>绘制处理。</T>
        //
        // @param sender 发送者
        // @param e:event 事件
        //============================================================
        public void DrawPreviewLayers()
        {
            if (!_designLayers)
            {
                return;
            }
            FUiControlLayers layers = _designFrame.PreviewLayers;

            if (!layers.IsEmpty())
            {
                float        scale    = _context.Scale;
                FDxContext2d context  = _context.Context;
                SIntPoint2   position = _designFrame.CalculateDisplayPosition();
                int          count    = layers.Count;
                for (int n = count - 1; n >= 0; n--)
                {
                    FUiControlLayer layer = layers[n];
                    if (layer.OptionVisible)
                    {
                        context.DrawBitmap(layer.Bitmap, position.X, position.Y, (int)(layer.Size.Width * scale), (int)(layer.Size.Height * scale), 1.0f);
                    }
                }
            }
        }
Пример #9
0
 //============================================================
 // <T>构造绘图板。</T>
 //
 // @param context 环境
 //============================================================
 public FUiGraphics(FDxContext2d context = null)
 {
     _context = context;
 }
Пример #10
0
        //============================================================
        // <T>绘制辅助线。</T>
        //============================================================
        public bool DrawAidLines()
        {
            // 检查状态
            FUiControl focusControl = _selection.FocusControl;

            if (focusControl == null)
            {
                return(false);
            }
            FUiControl parent = focusControl.Parent as FUiControl;

            if (parent == null)
            {
                return(false);
            }
            // 获得环境
            float        scale   = _context.Scale;
            FDxContext2d context = _context.Context;

            context.TransformIdentity();
            // 绘制对齐线
            SIntPoint2 location = focusControl.CalculateDisplayPosition();
            SIntSize2  size     = focusControl.CalculateDisplaySize();

            foreach (FUiComponent component in parent.Components)
            {
                FUiControl control = component as FUiControl;
                // 检查变量
                if (control == null)
                {
                    continue;
                }
                if (control == focusControl)
                {
                    continue;
                }
                // 计算坐标
                SIntPoint2 findLocation = control.CalculateDisplayPosition();
                SIntSize2  findSize     = control.CalculateDisplaySize();
                // 左辅助线
                if (location.X == findLocation.X)
                {
                    context.DrawLineLayer(location.X, 0, location.X, _size.Height, _lineBackBrush, _lineForeBrush, _lineWidth, _lineForeStrokeStyle);
                }
                // 上辅助线
                if (location.Y == findLocation.Y)
                {
                    context.DrawLineLayer(0, location.Y, _size.Width, location.Y, _lineBackBrush, _lineForeBrush, _lineWidth, _lineForeStrokeStyle);
                }
                // 右辅助线
                int right = findLocation.X + findSize.Width;
                if (location.X + size.Width == right)
                {
                    context.DrawLineLayer(right, 0, right, _size.Height, _lineBackBrush, _lineForeBrush, _lineWidth, _lineForeStrokeStyle);
                }
                // 下辅助线
                int bottom = findLocation.Y + findSize.Height;
                if (location.Y + size.Height == bottom)
                {
                    context.DrawLineLayer(0, bottom, _size.Width, bottom, _lineBackBrush, _lineForeBrush, _lineWidth, _lineForeStrokeStyle);
                }
            }
            return(true);
        }