/// <summary> /// 取得指定索引的色彩畫筆 /// </summary> /// <param name="colorID">色彩索引</param> /// <returns>取得畫筆</returns> public Pen GetPen(string colorID) { DrawColor drawColor; if (_DrawColor.TryGetValue(colorID, out drawColor)) { if (drawColor.Pen == null) { Color penColor = ColorFix.GetColor(drawColor.Color, Opacity, RFix, GFix, BFix); drawColor.Pen = DrawPool.GetPen(penColor); } return(drawColor.Pen); } return(_PenNull); }
/// <summary> /// 取得指定索引的色彩筆刷 /// </summary> /// <param name="colorID">色彩索引</param> /// <returns>取得筆刷</returns> public SolidBrush GetBrush(string colorID) { DrawColor drawColor; if (_DrawColor.TryGetValue(colorID, out drawColor)) { if (drawColor.Brush == null) { Color brushColor = ColorFix.GetColor(drawColor.Color, Opacity, RFix, GFix, BFix); drawColor.Brush = DrawPool.GetBrush(brushColor); } return(drawColor.Brush); } return(_BrushNull); }
/// <summary> /// 繪製到Graphics /// </summary> /// <param name="g">Graphics物件</param> /// <param name="rectangle">繪製區域</param> protected override void OnDraw(Graphics g, Rectangle rectangle) { Rectangle drawRectangle = GetScaleRectangle(rectangle); if (Angle != 0) { float baseX = drawRectangle.Left + drawRectangle.Width / 2; float baseY = drawRectangle.Top + drawRectangle.Height / 2; var oldTransform = g.Transform; g.TranslateTransform(baseX, baseY); g.RotateTransform(Angle); g.TranslateTransform(-baseX, -baseY); ColorFix.DrawImage(g, Image, drawRectangle, Colors.Opacity, Colors.RFix, Colors.GFix, Colors.BFix); g.Transform.Dispose(); g.Transform = oldTransform; } else { ColorFix.DrawImage(g, Image, drawRectangle, Colors.Opacity, Colors.RFix, Colors.GFix, Colors.BFix); } }