//============================================================ // <T>开始绘制处理。</T> // // @param args 参数 //============================================================ public override void OnDrawBegin(SUiDrawArgs args) { base.OnDrawBegin(args); // 绘制文本 string label = ControlResource.Label; SIntSize2 size = ControlResource.Size; if (!RString.IsEmpty(label)) { FDxTextFormat labelFormat = _context.DefaultTextFormat; labelFormat.AlignmentCd = EDxTextAlignment.Leading; labelFormat.ParagraphAlignmentCd = EDxParagraphAlignment.Center; _context.Context.DrawText(label, _context.DefaultTextFormat, EditResource.Font.Color, new SIntRectangle(0, 0, size.Width, size.Height)); } }
//============================================================ // <T>刷新处理。</T> //============================================================ public void Refresh() { SIntSize2 size = _designFrame.Size; float scale = _context.Scale; int left = (_size.Width - (int)(size.Width * scale)) / 2; if (left < 0) { left = 0; } int top = (_size.Height - (int)(size.Height * scale)) / 2; if (top < 0) { top = 0; } _designFrame.Location.Set(left, top); }
//============================================================ // <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); } } }
//============================================================ // <T>开始绘制处理。</T> // // @param args 参数 //============================================================ public override void OnDrawBegin(SUiDrawArgs args) { base.OnDrawBegin(args); // 绘制处理 if (TestVisible()) { // 绘制背景资源 DrawResource(_groundResource); } // 绘制文本 FRcButton resource = ButtonResource; string text = resource.FormatDisplay(); if (!RString.IsEmpty(text)) { SIntSize2 size = resource.Size; FDxTextFormat labelFormat = _context.DefaultTextFormat; labelFormat.AlignmentCd = EDxTextAlignment.Center; labelFormat.ParagraphAlignmentCd = EDxParagraphAlignment.Center; _context.Context.DrawText(text, _context.DefaultTextFormat, resource.Font.Color, new SIntRectangle(0, 0, size.Width, size.Height)); } }
//============================================================ // <T>绘制层。</T> //============================================================ public void DrawLayers() { FObjects <FMbMapLayer> layers = _map.Layers; if (!layers.IsEmpty()) { int count = layers.Count; for (int n = 0; n < count; n++) { FMbMapLayer layer = layers[n]; if (layer.OptionValid) { _cellSize = layer.CellSize; _cellCount = layer.CellCount; FObjects <FMbMapCell> cells = layer.MapCell; int cellCount = cells.Count; for (int x = 0; x < cellCount; x++) { FMbMapCell cell = cells[x]; int resourceId = cell.ResourceId; if (0 == resourceId) { continue; } SIntPoint2 cellIndex = cell.Index; FMbMapTile mapTile = RMobileManager.MapTileConsole.FindMapTile(resourceId); if (null != mapTile) { DrawMapTile(mapTile, cellIndex); } } } // 绘制方格 DrawLine(); } } }
//============================================================ // <T>开始绘制处理。</T> // // @param args 参数 //============================================================ public override void OnDrawBegin(SUiDrawArgs args) { base.OnDrawBegin(args); // 绘制处理 if (TestVisible()) { // 绘制背景资源 DrawResource(_groundResource); } _context.Context.FillRectangle(0x7F888800, 2, 2, _designSize.Width - 4, 24); // 绘制文本 FRcWindow resource = WindowResource; string text = resource.Label; if (!RString.IsEmpty(text)) { SIntSize2 size = resource.Size; FDxTextFormat labelFormat = _context.DefaultTextFormat; labelFormat.AlignmentCd = EDxTextAlignment.Center; labelFormat.ParagraphAlignmentCd = EDxParagraphAlignment.Center; _context.Context.DrawText(text, _context.DefaultTextFormat, 0, new SIntRectangle(0, 0, size.Width, size.Height)); } }
//============================================================ // <T>刷新大小处理。</T> //============================================================ private void RefreshSize() { // 设置画板 SIntSize2 size = _designer.Map.Size; int width = (int)size.Width; if (width < pnlCanvasBox.Width) { width = pnlCanvasBox.Width; } int height = (int)(size.Height); if (height < pnlCanvasBox.Height) { height = pnlCanvasBox.Height; } pnlCanvas.Width = width - heightScrollBar.Width; pnlCanvas.Height = height - widthScrollBar.Height; // 改变设备大小 _device.Resize(width, height); // 改变大小 _designer.Resize(width, height); _designer.Refresh(); // 设置滚动条 widthScrollBar.Location = new Point(0, height - widthScrollBar.Height); widthScrollBar.Width = width - widthScrollBar.Height; heightScrollBar.Location = new Point(width - heightScrollBar.Width, 0); heightScrollBar.Height = height - heightScrollBar.Width; widthScrollBar.Maximum = _mapLayer.Resource.CellSize.Width * _mapLayer.Resource.CellCount.Width - pnlCanvas.Width; heightScrollBar.Maximum = _mapLayer.Resource.CellSize.Height * _mapLayer.Resource.CellCount.Height - pnlCanvas.Height; _designer.Location = new SIntPoint2(widthScrollBar.Value, heightScrollBar.Value); _designer.Paint(); }
//============================================================ // <T>绘制矩形。</T> // // @param brush 色刷 // @param location 位置 // @param size 大小 //============================================================ public void DrawRectangle(FDxBrush brush, SIntPoint2 location, SIntSize2 size) { _target.DrawRectangle(brush.Native, new Rectangle(location.X, location.Y, size.Width, size.Height)); }
//============================================================ // <T>填充矩形。</T> // // @param brush 色刷 // @param location 位置 // @param size 大小 //============================================================ public void FillRectangle(FDxBrush brush, SIntPoint2 location, SIntSize2 size) { _device.Target.FillRectangle(brush.Native, new Rectangle(location.X, location.Y, size.Width, size.Height)); }
//============================================================ // <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); }