示例#1
0
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_cursor != null)
         {
             _cursor.Dispose();
             _cursor = null;
         }
         if (_safeHandle != null)
         {
             _safeHandle.Dispose();
             _safeHandle = null;
         }
     }
 }
示例#2
0
        private Cursor CrossHairCursor(int w, int h)
        {
            Pen pen     = new Pen(Color.Red, 5);
            Pen thinPen = new Pen(Color.Red, 1);
            var pic     = new Bitmap(w, h);
            var gr      = Graphics.FromImage(pic);

            var pathXL = new GraphicsPath();
            var pathXR = new GraphicsPath();
            var pathX  = new GraphicsPath();

            var pathYT = new GraphicsPath();
            var pathYB = new GraphicsPath();
            var pathY  = new GraphicsPath();

            pathY.AddLine(new Point(w / 2, 0), new Point(w / 2, h));
            pathYT.AddLine(new Point(w / 2, h / 2 - 2 * 16), new Point(w / 2, h / 2 - 16));
            pathYB.AddLine(new Point(w / 2, h / 2 + 2 * 16), new Point(w / 2, h / 2 + 16));

            pathX.AddLine(new Point(0, h / 2), new Point(w, h / 2));
            pathXL.AddLine(new Point(w / 2 - 2 * 16, h / 2), new Point(w / 2 - 16, h / 2));
            pathXR.AddLine(new Point(w / 2 + 16, h / 2), new Point(w / 2 + 2 * 16, h / 2));

            gr.DrawPath(pen, pathXL);
            gr.DrawPath(pen, pathXR);
            gr.DrawPath(pen, pathYT);
            gr.DrawPath(pen, pathYB);

            gr.DrawPath(thinPen, pathX);
            gr.DrawPath(thinPen, pathY);
            var            icon       = Icon.FromHandle(pic.GetHicon());
            SafeIconHandle safeHandle = _safeHandle;

            if (safeHandle != null)
            {
                safeHandle.Dispose();
            }
            _safeHandle = new SafeIconHandle(icon.Handle);
            safeHandle  = _safeHandle;
            return(CursorInteropHelper.Create(safeHandle));
        }