Click here to Skip to main content
15,885,141 members
Home / Discussions / C#
   

C#

 
GeneralRe: Can not compare a file and same file stored in mysql - sha256 Pin
wilcodk30-Apr-20 1:32
wilcodk30-Apr-20 1:32 
AnswerRe: Can not compare a file and same file stored in mysql - sha256 Pin
Mycroft Holmes29-Apr-20 12:18
professionalMycroft Holmes29-Apr-20 12:18 
GeneralRe: Can not compare a file and same file stored in mysql - sha256 Pin
wilcodk30-Apr-20 1:28
wilcodk30-Apr-20 1:28 
AnswerRe: Can not compare a file and same file stored in mysql - sha256 Pin
Eddy Vluggen30-Apr-20 6:34
professionalEddy Vluggen30-Apr-20 6:34 
QuestionCompare string time to timer time (noobie) Pin
Member 1481029228-Apr-20 5:36
Member 1481029228-Apr-20 5:36 
AnswerRe: Compare string time to timer time (noobie) Pin
Gerry Schmitz28-Apr-20 6:48
mveGerry Schmitz28-Apr-20 6:48 
QuestionResize and move a drawn rectangle in win forms Pin
Member 1223285027-Apr-20 12:23
Member 1223285027-Apr-20 12:23 
AnswerRe: Resize and move a drawn rectangle in win forms Pin
Luc Pattyn27-Apr-20 13:17
sitebuilderLuc Pattyn27-Apr-20 13:17 
Hi,

unfortunately your code already contains a lot of details, making it hard to pinpoint what exactly is the problem. IMHO one should always work on smaller pieces and get them to run satisfactorily before adding to them.

So I will limit my reply to a number of comments, which taken together really indicate I'm not so happy with the current code:

1.
It seems you want a hovering mouse to show what would happen if the mouse were clicked in its current position; that should consist of:
- deciding which if any rectangle is hovered over;
- deciding how it is hit (i.e. in the size handles or in the body).

As size handles overlap the actual rectangle, one must be careful in what order the Contains() logic is applied. I would probably use a slightly larger rectangle and check that first, assuming a move is intended, and on a hit then check whether any of the size handles is hit (which would overrule the move).

2.
Once the mouse goes down, the decision (from #1) should be frozen, and data should be set up to initiate the actual move/resize.

3.
Back in the mouse move handler, the actual action should happen until mouse up is reached.

4.
As a consequence:
- the MouseMove handler should have two completely distinct halves, one for the decision process (mouse still up), one for the execution (mouse down); a single bool (set/cleared by MouseDown/MouseUp) would decide between the halves.
- the MouseDown handler shouldn't do much at all.

5.
If I were creating something like this, I would start from scratch, and initially keep it as simple as possible.
I would also choose variable and method names carefully, e.g. DrawResizableRectNode isn't OK as it does not draw at all.


Added later, two smaller issues I forgot to mention:

6.
There is no need to create a Graphics object explicitly; you get it for free as one of the properties of the PaintEventArgs in a Paint handler.

7.
You should keep Paint handlers as lean as possible, in particular you should create the drawing objects (Pens, Fonts, ...) you need only once, and save them in class level variables for reuse. In your case, that applies to rectPen.

And if you fail to keep them around, it is your duty to dispose of them (by calling their Dispose method or applying a using statement), in order to avoid Windows problems such as handle shortages.


Hope this helps,

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum


modified 27-Apr-20 20:15pm.

GeneralRe: Resize and move a drawn rectangle in win forms Pin
Member 1223285027-Apr-20 19:38
Member 1223285027-Apr-20 19:38 
GeneralRe: Resize and move a drawn rectangle in win forms Pin
Luc Pattyn28-Apr-20 4:50
sitebuilderLuc Pattyn28-Apr-20 4:50 
GeneralRe: Resize and move a drawn rectangle in win forms Pin
Member 1223285028-Apr-20 17:56
Member 1223285028-Apr-20 17:56 
GeneralRe: Resize and move a drawn rectangle in win forms Pin
Luc Pattyn29-Apr-20 2:30
sitebuilderLuc Pattyn29-Apr-20 2:30 
QuestionDate compare Pin
Carlos5827-Apr-20 10:42
Carlos5827-Apr-20 10:42 
AnswerRe: Date compare Pin
Luc Pattyn27-Apr-20 11:00
sitebuilderLuc Pattyn27-Apr-20 11:00 
GeneralRe: Date compare Pin
Carlos5827-Apr-20 12:31
Carlos5827-Apr-20 12:31 
GeneralRe: Date compare Pin
Luc Pattyn27-Apr-20 12:48
sitebuilderLuc Pattyn27-Apr-20 12:48 
GeneralRe: Date compare Pin
Carlos5828-Apr-20 2:19
Carlos5828-Apr-20 2:19 
GeneralRe: Date compare Pin
Luc Pattyn28-Apr-20 2:24
sitebuilderLuc Pattyn28-Apr-20 2:24 
SuggestionRe: Date compare Pin
Richard Deeming28-Apr-20 0:40
mveRichard Deeming28-Apr-20 0:40 
AnswerRe: Date compare Pin
Carlos5828-Apr-20 2:23
Carlos5828-Apr-20 2:23 
QuestionRename files in WinScp Directory using C# Pin
Sriram Valluri27-Apr-20 1:13
Sriram Valluri27-Apr-20 1:13 
AnswerRe: Rename files in WinScp Directory using C# Pin
ZurdoDev27-Apr-20 1:21
professionalZurdoDev27-Apr-20 1:21 
GeneralRe: Rename files in WinScp Directory using C# Pin
Sriram Valluri27-Apr-20 2:15
Sriram Valluri27-Apr-20 2:15 
GeneralRe: Rename files in WinScp Directory using C# Pin
ZurdoDev27-Apr-20 2:27
professionalZurdoDev27-Apr-20 2:27 
AnswerRe: Rename files in WinScp Directory using C# Pin
Jin Vincent Necesario27-Apr-20 2:36
professionalJin Vincent Necesario27-Apr-20 2:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.