Jump to content

Corrections with the selection ants and the top ruler indent


rutmir
 Share

Recommended Posts

:D Hi! Firstly, VERY GOOD WORK!

I've been using your code for 5 days only. So able to inform you for one bug only.

When you are just moving a mouse over the picture, it's taking 100% of the processor time. It's not good I think. For example because of this, the selection ants stop their moving and the top ruler indent are showed not correctly (it's jumping). I think that you should change the Value Set Property of the Ruler Class. Instead of forcing full redrawing of the rulers, place something like this:

Graphics aGraphics = this.CreateGraphics();
IntPtr hDC = aGraphics.GetHdc();
PointF pt = scaleFactor.ScalePointJustX(new PointF(ClientRectangle.Left + aOldVal - Offset, ClientRectangle.Top));
SizeF size = new SizeF(Math.Max(1, scaleFactor.ScaleScalar(1.0f)), ClientRectangle.Height);
pt.X -= 0.5f;
Rectangle aRect = Rectangle.Truncate(new RectangleF(pt, size));
API32CSharp.RECT aRECT;
aRECT.left = aRect.X; 
aRECT.top = aRect.Y;
aRECT.right = aRect.Right;
aRECT.bottom = aRect.Bottom;
API32CSharp.Gdi.InvertRect(hDC, ref aRECT);
pt = scaleFactor.ScalePointJustX(new PointF(ClientRectangle.Left + this.value - Offset, ClientRectangle.Top));
size = new SizeF(Math.Max(1, scaleFactor.ScaleScalar(1.0f)), ClientRectangle.Height);
pt.X -= 0.5f;
aRect = Rectangle.Truncate(new RectangleF(pt, size));
aRECT.left = aRect.X; 
aRECT.top = aRect.Y;
aRECT.right = aRect.Right;
aRECT.bottom = aRect.Bottom;
API32CSharp.Gdi.InvertRect(hDC, ref aRECT);
aGraphics.ReleaseHdc(hDC);
aGraphics.Dispose();

Again thanks and with best regards

Sorry for my English

Link to comment
Share on other sites

Hi! I understand that they arent drawn by inversion. But the mark (values) of your rulers can be drawn by inversion. Or, if you dont like inversion, the same effect can be easily achived with BitBlt function. After these corrections it's needed of course to delete drawing functions for Ruler Value from DrawRuler method. Anyway it's not matter what way should be used, I want to say that it's not effective to redraw all the rulers every time when an user are just moving the mouse cursor over the picture. This full redrawing on my comp effects by taking 100% of the processor time. The last, in its turn, results not correct drawing the top ruler mark + stopping the selection ants moving.

With best regards, rutmir :roll:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...