public InFill ( double x, double y ) : bool | ||
x | double | |
y | double | |
Результат | bool |
/** FAST */ public static bool CheckTextExtents(Context cr, TextExtents te, double x, double y) { bool retval = false; cr.Save (); PointD pt = cr.CurrentPoint; cr.NewPath (); cr.Rectangle (pt.X, pt.Y, te.Width, te.Height); cr.IdentityMatrix (); retval = cr.InFill (x, y); if (ShowTextExtents) { cr.Operator = Operator.Over; cr.Color = new Color (1,0.5,1,0.5); cr.LineWidth = 0.5; cr.Stroke (); } cr.Restore (); cr.MoveTo (pt.X, pt.Y); return retval; }
/** FAST */ bool ClickBreadcrumb(Context cr, uint width, double x, double y) { if (CurrentDirPath == Helpers.RootDir) return false; TextExtents te1 = Helpers.GetTextExtents (cr, BreadcrumbFontFamily, BreadcrumbFontSize, String.Join(dirSep, CurrentDirPath.Split(Helpers.DirSepC)) + dirSep); cr.Save (); double areaWidth = width-BreadcrumbMarginLeft-BreadcrumbMarginRight; cr.Rectangle (0,0,areaWidth, te1.Height); cr.Clip (); cr.Translate (Math.Min(0,areaWidth-te1.Width), -BreadcrumbMarginTop); if (areaWidth - te1.Width >= 0) cr.Translate(-(BreadcrumbMarginLeft+1), 0); cr.MoveTo (0.0, 0.0); int hitIndex = 0; string[] segments = CurrentDirPath.Split(Helpers.DirSepC); foreach (string s in segments) { string name = (s == "") ? rootChar : s+dirSep; TextExtents te = Helpers.GetTextExtents (cr, BreadcrumbFontFamily, BreadcrumbFontSize, name); te.Height += BreadcrumbMarginTop; if (s == "" && (areaWidth - te1.Width >= 0)) te.Width += BreadcrumbMarginLeft+1; if (Helpers.CheckTextExtents(cr, te, x, y)) { string newDir = String.Join(Helpers.DirSepS, segments, 0, hitIndex+1); if (newDir == "") newDir = Helpers.RootDir; if (newDir != CurrentDirPath) { SetCurrentDir (newDir); } else { ResetZoom (); UpdateLayout (); } cr.Restore (); return true; } cr.RelMoveTo( te.Width, 0 ); hitIndex += 1; } cr.IdentityMatrix (); cr.Rectangle (0,-1,width,2); if (cr.InFill(x,y)) { ResetZoom (); UpdateLayout (); } cr.Restore (); return false; }