Frame object?

HARRY

Active Member
Licensed User
Longtime User
Hi,

I am looking for the possibility to do the following.

The display shows an image. The program puts on user request a frame (rectangle with program defined dimensions) on the image. With the finger or pen the user moves the frame to any place wanted. Then, on the mouse up event of the frame the program does something, based on the position of the frame. The frame should be transparant.

Does somebody know how to realize this?

Harry
 

HARRY

Active Member
Licensed User
Longtime User
Hi Klaus,

Thanks for your information. I was thinking myself of the ForeGround layer, but I used it already for other purposes and erasing it just for the rectangle would be too much for my device, qua processing and rebuilding,.

I didn't know of the transparant colour and I do not really understand it, but , most important, it works quite well. Sometimes one or more lines of the rectangle remains, but that is not a serious problem.


Thanks again,

Regards,

Harry
 

klaus

Expert
Licensed User
Longtime User
Attached a version without the remaining lines.
Added 4 lines at the beginning of the btnSearch_Click routine to set the current rectangle coordinates to the default ones.

The transparent color means the following:
- you can define an arbitrary color as the transparent color, in the sample program I use RGB(240,240,240) it's almost white but not true white.
- when you draw onto the forelayer all the pixels with that transparent color show the form's background color at he same position and not the color.
- when you draw, for example, a line onto the form's forelayer with any color, you will see the line with this color.
- if now you draw the same line with the transparent color, the line will be erased, this is what I am using in the MouseMove routine.

What kind of information do you already have on the forelyer ?

Best regards.
 

Attachments

  • MoveRect.sbp
    1.3 KB · Views: 230

HARRY

Active Member
Licensed User
Longtime User
Hi Clause,

I was a little bit too enthousiastic on the solution you gave me. When I move the rectangle the information on the Forelayer where the rectangle passes, gets lost.

As I expected redrawing everything on each move event takes too much from the processor, at least on the device. On the desktop it works well, but on the device it takes sometimes seconds to get everyting done.

The forelayer contains more than 100 circles indicating something like points of interest. I want that rectangle to indicate the area which should be enlarged as sometimes with the present resolution the circles overlap . The backlayer contains a part of a google map.

I think that an acceptable solution would be to postpone redrawing the circles until the mouse up event. I will exercise a little bit with that, unless you have a better solution.

Regards,

Harry
 

klaus

Expert
Licensed User
Longtime User
How is your Google map displayed onto the screen ?
Do you have a bitmap containing the map and you copy a part of onto the screen ?
I would suggest you to draw the circles representing the points of interest directly onto the map bitmap. In that case when you move the map, the points of interest move also so no need to redraw them and you free the forelayer. Each time you get a new map you should draw the circles.​


Best regards.​
 

HARRY

Active Member
Licensed User
Longtime User
Hi Clause,

I found the following acceptable solution.

I introduced a timer (100Msec). On each move event the timer is disabled and enabled. When the user holds the rectangle on the same place for 100 msec, so there are no move events, a tick event is raised and repainting of all circles is done.

In this way I prevent an long stream of repainting requests, the user can quickly see whether the rectangle is on the right position and I can still use the mouse up event for other purposes.

The google map has the same size as my screen. When I show the map enlarged, then I have to recalculate the position of all circles. Moreover repainting is done also as a consequence of other user actions. Still, I will invest your suggestion.

Regards,

Harry
 

klaus

Expert
Licensed User
Longtime User
Hi Harry,
I'm not convinced with your the Timer solution !?
I'm convinced that drawing onto the bitmap would probably be the most efficient solution, the only point could be the consequences of other user actions.
Moreover repainting is done also as a consequence of other user actions.
If you only need to add something just, add it onto the bitmap. If something has changed, load the original map again and redraw the new data.

When I show the map enlarged, then I have to recalculate the position of all circles.
Does this mean zooming ? Even then drawing onto the bitmap would more efficient.

In the ScaledMaps program I had tried different solutions, and found that drawing onto the map bitmap was the most efficient one.

Best regards.
 

HARRY

Active Member
Licensed User
Longtime User
Hi Klaus,

You have convinced me!

I realized that only the color of one or two circles is changed as a result of user action. Now I put all circles on the BackLayer and write the circle(s) from which the colour changes also on the Forelayer after a FErase. This solution is fast enough, also on the device. So redrawing all circles is avoided and moving the rectangle does not destroy the circles.

Thanks,

Harry
 
Top