public override bool GdiDrawString( System.Drawing.Graphics pGraphics, LOGFONT pLogFont, string pszText, System.Drawing.Rectangle rtDraw) { using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding)) { bool b = GDIPath.GetStringPath( pGraphics, pPath, pszText, pLogFont, rtDraw); if (false == b) { return(false); } using (Pen pen = new Pen(m_clrOutline, m_nThickness)) { if (m_bRoundedEdge) { pen.LineJoin = LineJoin.Round; } pGraphics.DrawPath(pen, pPath); } } return(true); }
public override bool GdiDrawString( System.Drawing.Graphics pGraphics, LOGFONT pLogFont, string pszText, System.Drawing.Rectangle rtDraw) { using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding)) { bool b = GDIPath.GetStringPath( pGraphics, pPath, pszText, pLogFont, rtDraw); if (false == b) { return(false); } if (m_bClrText) { using (SolidBrush brush = new SolidBrush(m_clrText)) { pGraphics.FillPath(brush, pPath); } } else { pGraphics.FillPath(m_brushText, pPath); } } return(true); }
public override bool GdiDrawString( System.Drawing.Graphics pGraphics, LOGFONT pLogFont, string pszText, System.Drawing.Rectangle rtDraw) { int nOffset = Math.Abs(m_nOffsetX); if (Math.Abs(m_nOffsetX) == Math.Abs(m_nOffsetY)) { nOffset = Math.Abs(m_nOffsetX); } else if (Math.Abs(m_nOffsetX) > Math.Abs(m_nOffsetY)) { nOffset = Math.Abs(m_nOffsetY); } else if (Math.Abs(m_nOffsetX) < Math.Abs(m_nOffsetY)) { nOffset = Math.Abs(m_nOffsetX); } for (int i = 0; i < nOffset; ++i) { using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding)) { bool b = GDIPath.GetStringPath( pGraphics, pPath, pszText, pLogFont, new Rectangle(rtDraw.X + ((i * (-m_nOffsetX)) / nOffset), rtDraw.Y + ((i * (-m_nOffsetY)) / nOffset), rtDraw.Width, rtDraw.Height)); if (false == b) { return(false); } using (Pen pen = new Pen(m_clrOutline, m_nThickness)) { pen.LineJoin = LineJoin.Round; pGraphics.DrawPath(pen, pPath); } if (m_bClrText) { using (SolidBrush brush = new SolidBrush(m_clrText)) { pGraphics.FillPath(brush, pPath); } } else { pGraphics.FillPath(m_brushText, pPath); } } } return(true); }
public override bool GdiDrawString( System.Drawing.Graphics pGraphics, LOGFONT pLogFont, string pszText, System.Drawing.Rectangle rtDraw) { using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding)) { bool b = GDIPath.GetStringPath( pGraphics, pPath, pszText, pLogFont, rtDraw); if (false == b) { return(false); } List <Color> list = new List <Color>(); if (m_GradientType == GradientType.Sinusoid) { CalculateCurvedGradient(m_clrOutline1, m_clrOutline2, m_nThickness, list); } else { CalculateGradient(m_clrOutline1, m_clrOutline2, m_nThickness, list); } if (m_bClrText) { using (SolidBrush brush = new SolidBrush(m_clrText)) { pGraphics.FillPath(brush, pPath); } } else { pGraphics.FillPath(m_brushText, pPath); } for (int i = m_nThickness; i >= 1; --i) { System.Drawing.Color clr = list[i - 1]; using (Pen pen = new Pen(clr, i)) { pen.LineJoin = LineJoin.Round; pGraphics.DrawPath(pen, pPath); } } } return(true); }
public bool GdiMeasureStringRealHeight( System.Drawing.Graphics pGraphics, LOGFONT pLogFont, string pszText, System.Drawing.Rectangle rtDraw, ref float pfPixelsStartX, ref float pfPixelsStartY, ref float pfDestWidth, ref float pfDestHeight) { using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding)) { bool b = GDIPath.GetStringPath( pGraphics, pPath, pszText, pLogFont, rtDraw); if (false == b) { return(false); } pfDestWidth = rtDraw.Left; pfDestHeight = rtDraw.Top; b = GDIPath.MeasureGraphicsPathRealHeight(pGraphics, pPath, ref pfPixelsStartX, ref pfPixelsStartY, ref pfDestWidth, ref pfDestHeight); if (false == b) { return(false); } float pixelThick = 0.0f; float fStartX = 0.0f; float fStartY = 0.0f; float fDestHeight = 0.0f; b = GDIPath.ConvertToPixels(pGraphics, m_nThickness, 0.0f, ref fStartX, ref fStartY, ref pixelThick, ref fDestHeight); if (false == b) { return(false); } pfDestWidth += pixelThick; pfDestHeight += pixelThick; } return(true); }
public override bool GdiDrawString( System.Drawing.Graphics pGraphics, LOGFONT pLogFont, string pszText, System.Drawing.Rectangle rtDraw) { using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding)) { bool b = GDIPath.GetStringPath( pGraphics, pPath, pszText, pLogFont, rtDraw); if (false == b) { return(false); } for (int i = m_nThickness1; i <= m_nThickness1 + m_nThickness2; ++i) { using (Pen pen = new Pen(m_clrOutline2, i)) { pen.LineJoin = LineJoin.Round; pGraphics.DrawPath(pen, pPath); } } using (Pen pen1 = new Pen(m_clrOutline1, m_nThickness1)) { pen1.LineJoin = LineJoin.Round; pGraphics.DrawPath(pen1, pPath); } if (m_bClrText) { using (SolidBrush brush = new SolidBrush(m_clrText)) { pGraphics.FillPath(brush, pPath); } } else { pGraphics.FillPath(m_brushText, pPath); } } return(true); }
public override bool GdiDrawString( System.Drawing.Graphics pGraphics, LOGFONT pLogFont, string pszText, System.Drawing.Point ptDraw) { using (GraphicsPath pPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding)) { bool b = GDIPath.GetStringPath( pGraphics, pPath, pszText, pLogFont, ptDraw); if (false == b) { return(false); } for (int i = 1; i <= m_nThickness; ++i) { Pen pen = new Pen(m_clrOutline, i); pen.LineJoin = LineJoin.Round; pGraphics.DrawPath(pen, pPath); } if (m_bOutlinetext == false) { for (int i = 1; i <= m_nThickness; ++i) { SolidBrush brush = new SolidBrush(m_clrText); pGraphics.FillPath(brush, pPath); } } else { SolidBrush brush = new SolidBrush(m_clrText); pGraphics.FillPath(brush, pPath); } } return(true); }
static public bool GetStringPath( System.Drawing.Graphics pGraphics, System.Drawing.Drawing2D.GraphicsPath ppPath, string pszText, LOGFONT plf, System.Drawing.Rectangle rtDraw) { IntPtr hDC = pGraphics.GetHdc(); int nPrevMode = SetBkMode(hDC, TRANSPARENT); // create and select it IntPtr hFont = CreateFontIndirect(plf); if (null == hFont) { return(false); } IntPtr hOldFont = (IntPtr)SelectObject(hDC, hFont); RECT rect = new RECT(rtDraw); // use a path to record how the text was drawn const uint DT_CENTER = 0x00000001; BeginPath(hDC); DrawText(hDC, pszText, pszText.Length, ref rect, DT_CENTER); EndPath(hDC); // Find out how many points are in the path. Note that // for long strings or complex fonts, this number might be // gigantic! int nNumPts = GetPath(hDC, null, null, 0); if (nNumPts == 0) { return(false); } // Allocate memory to hold points and stroke types from // the path. POINT[] lpPoints = new POINT[nNumPts]; byte[] lpTypes = new byte[nNumPts]; // Now that we have the memory, really get the path data. nNumPts = GetPath(hDC, lpPoints, lpTypes, nNumPts); // If it worked, draw the lines. Win95 and Win98 don't support // the PolyDraw API, so we use our own member function to do // similar work. If you're targeting only Windows NT, you can // use the PolyDraw() API and avoid the COutlineView::PolyDraw() // member function. if (nNumPts != -1) { PolyDraw(ppPath, lpPoints, lpTypes, nNumPts); } // Put back the old font SelectObject(hDC, hOldFont); DeleteObject(hFont); SetBkMode(hDC, nPrevMode); pGraphics.ReleaseHdc(hDC); return(true); }
public static extern IntPtr CreateFontIndirect( [In, MarshalAs(UnmanagedType.LPStruct)] LOGFONT lplf // characteristics );
public abstract bool GdiDrawString( System.Drawing.Graphics pGraphics, LOGFONT pLogFont, string pszText, System.Drawing.Rectangle rtDraw);