public static long Snap(System.Diagnostics.Stopwatch sw, dbugCounterAction codeRgn) { sw.Stop(); sw.Reset(); sw.Start(); codeRgn(); sw.Stop(); //return sw.ElapsedMilliseconds; return sw.ElapsedTicks; }
/// <summary> /// Return a stopwatch to the pool. /// </summary> /// <param name="stopwatch"></param> private void RetireStopwatch(ref System.Diagnostics.Stopwatch stopwatch) { if (stopwatch != null) { lock (_stopwatches) { stopwatch.Reset(); _stopwatches.Push(stopwatch); } stopwatch = null; } }
private static bool GotoItem(System.Windows.Forms.UnsafeNativeMethods.IEnumVariant iev, int index, IntPtr variantPtr) { int[] pceltFetched = new int[1]; System.Windows.Forms.IntSecurity.UnmanagedCode.Assert(); try { iev.Reset(); iev.Skip(index); iev.Next(1, variantPtr, pceltFetched); } finally { CodeAccessPermission.RevertAssert(); } return (pceltFetched[0] == 1); }
/// <summary> /// Resets the specified GraphicsPath object and adds an arc to it with the speficied values. /// </summary> /// <param name="arc2DPath">The GraphicsPath object to reset.</param> /// <param name="x">The x coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.</param> /// <param name="y">The y coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.</param> /// <param name="height">The height of the rectangular region that defines the ellipse from which the arc is drawn.</param> /// <param name="width">The width of the rectangular region that defines the ellipse from which the arc is drawn.</param> /// <param name="start">The starting angle of the arc measured in degrees.</param> /// <param name="extent">The angular extent of the arc measured in degrees.</param> /// <param name="arcType">The closure type for the arc.</param> public static void SetArc(System.Drawing.Drawing2D.GraphicsPath arc2DPath, float x, float y, float height, float width, float start, float extent, int arcType) { arc2DPath.Reset(); switch (arcType) { case OPEN: arc2DPath.AddArc(x, y, height, width, start * -1, extent * -1); break; case CLOSED: arc2DPath.AddArc(x, y, height, width, start * -1, extent * -1); arc2DPath.CloseFigure(); break; case PIE: arc2DPath.AddPie(x, y, height, width, start * -1, extent * -1); break; default: break; } }
/// <summary> /// Resets the specified GraphicsPath object an adds a line to it. /// </summary> /// <param name="linePath">The GraphicsPath object to reset.</param> /// <param name="newLinePath">The line to add.</param> public static void SetLine(System.Drawing.Drawing2D.GraphicsPath linePath, System.Drawing.Drawing2D.GraphicsPath newLinePath) { linePath.Reset(); linePath.AddPath(newLinePath, false); }
/// <summary> /// Resets the specified GraphicsPath object an adds a line to it with the specified values. /// </summary> /// <param name="linePath">The GraphicsPath object to reset.</param> /// <param name="p1">The starting point of the line.</param> /// <param name="p2">The endpoint of the line.</param> public static void SetLine(System.Drawing.Drawing2D.GraphicsPath linePath, System.Drawing.PointF p1, System.Drawing.PointF p2) { linePath.Reset(); linePath.AddLine(p1, p2); }
/// <summary> /// Resets the specified GraphicsPath object an adds a line to it with the specified values. /// </summary> /// <param name="linePath">The GraphicsPath object to reset.</param> /// <param name="x1">The x-coordinate of the starting point of the line.</param> /// <param name="y1">The y-coordinate of the starting point of the line.</param> /// <param name="x2">The x-coordinate of the endpoint of the line.</param> /// <param name="y2">The y-coordinate of the endpoint of the line.</param> public static void SetLine(System.Drawing.Drawing2D.GraphicsPath linePath, float x1, float y1, float x2, float y2) { linePath.Reset(); linePath.AddLine(x1, y1, x2, y2); }
/*******************************/ /// <summary> /// Adds the X and Y coordinates to the current graphics path. /// </summary> /// <param name="graphPath"> The current Graphics path</param> /// <param name="xCoordinate">The x coordinate to be added</param> /// <param name="yCoordinate">The y coordinate to be added</param> public static void AddPointToGraphicsPath(System.Drawing.Drawing2D.GraphicsPath graphPath, int x, int y) { System.Drawing.PointF[] tempPointArray = new System.Drawing.PointF[graphPath.PointCount + 1]; byte[] tempPointTypeArray = new byte[graphPath.PointCount + 1]; if (graphPath.PointCount == 0) { tempPointArray[0] = new System.Drawing.PointF(x, y); System.Drawing.Drawing2D.GraphicsPath tempGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath(tempPointArray, new byte[]{(byte)System.Drawing.Drawing2D.PathPointType.Start}); graphPath.AddPath(tempGraphicsPath, false); } else { graphPath.PathPoints.CopyTo(tempPointArray, 0); tempPointArray[graphPath.PointCount] = new System.Drawing.Point(x, y); graphPath.PathTypes.CopyTo(tempPointTypeArray, 0); tempPointTypeArray[graphPath.PointCount] = (byte) System.Drawing.Drawing2D.PathPointType.Line; System.Drawing.Drawing2D.GraphicsPath tempGraphics = new System.Drawing.Drawing2D.GraphicsPath(tempPointArray, tempPointTypeArray); graphPath.Reset(); graphPath.AddPath(tempGraphics, false); graphPath.CloseFigure(); } }
/// <summary> /// Resets the height of the ellipse path contained in the specified GraphicsPath object. /// </summary> /// <param name="ellipsePath">The GraphicsPath object that will be set.</param> /// <param name="height">The new height.</param> public static void SetHeight(System.Drawing.Drawing2D.GraphicsPath ellipsePath, float height) { System.Drawing.RectangleF rectangle = ellipsePath.GetBounds(); rectangle.Height = height; ellipsePath.Reset(); ellipsePath.AddEllipse(rectangle); }
/// <summary> /// Resets the width of the ellipse path contained in the specified GraphicsPath object. /// </summary> /// <param name="ellipsePath">The GraphicsPath object that will be set.</param> /// <param name="width">The new width.</param> public static void SetWidth(System.Drawing.Drawing2D.GraphicsPath ellipsePath, float width) { System.Drawing.RectangleF rectangle = ellipsePath.GetBounds(); rectangle.Width = width; ellipsePath.Reset(); ellipsePath.AddEllipse(rectangle); }
/// <summary> /// Resets the y-coordinate of the ellipse path contained in the specified GraphicsPath object. /// </summary> /// <param name="ellipsePath">The GraphicsPath object that will be set.</param> /// <param name="y">The new y-coordinate.</param> public static void SetY(System.Drawing.Drawing2D.GraphicsPath ellipsePath, float y) { System.Drawing.RectangleF rectangle = ellipsePath.GetBounds(); rectangle.Y = y; ellipsePath.Reset(); ellipsePath.AddEllipse(rectangle); }