Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I need to represent a restaurant map with tables of different sizes and location. The user should be able to resize each table and specify the location (the user designs the map). I was thinking of a set of images to represent a table (square table, circular tables, etc.), a resize function (using the mouse) and drag and drop to set the location of the table. Then, the user should be able to see the map and click on the desired table.
It's important to understand that not every screen has the same resolution so the location and size of each table should be scaled to fit the actual resolution.
I'm using C# and WinForms
Thanks in advance.
Posted

Instead of using images, you can use resizable graphics. As graphic (vector, not image) holds less data than image, operations would be faster. Take a look here for a resizable graphic with handlers

A Resizable Graphical Rectangle [^]
 
Share this answer
 
v2
Comments
fgoldenstein 17-Feb-11 14:08pm    
Thanks for your answer. I'm not sure if working with Graphics is the best approach because of user interaction. I think it's easier to work with a PictureBox because it already has events and you can change the image to whatever you want. If I use Graphics I have to draw the figure. I'm still not decided.
Sergey Alexandrovich Kryukov 17-Feb-11 16:03pm    
No, it's the best, everyone who have this experience knows.
You're nearly exhausted opportunities to get help, as you don't understand the advices.
Further arguments goes nowhere. Not using WPF is wrong (I replied to you argument agains WPF), this is the biggest mistake, but insisting on PictureBox if fatal. I'm afraid the case is closed unless you change your mind.
Sorry,
--SA
fgoldenstein 17-Feb-11 15:09pm    
I definetely prefer to use images because a graphic design can create a wide variety of tables to represent tables. Thanks anyway.
Sergey Alexandrovich Kryukov 17-Feb-11 16:05pm    
Again, absolutely invalid argument. It can be applied to Control graphics literally. PictureBox will not help here.
Sorry,
--SA
Sergey Alexandrovich Kryukov 17-Feb-11 16:10pm    
Albin, sorry I cannot find it possible to vote.

This would be a great answer if not WPF. Any WinForm opportunities for this application are so miserable that I don't want to encourage anyone to fall into it. The only valid justification would be providing the application for Windows 2000 where only Framework v.2.0 can be installed...

Respect,
--SA
This is not very difficult but need time to design and implement. You scaling problem is also trivial, so it's hard to advise anything. I could either create a complete design, but I cannot afford it unless you hire me, or I could give you instructions if I see your mistakes. So far, there are no mistakes, and I cannot see what can possibly go wrong.

So, I can give only one advice, but an important one: do not do it with System.Windows.Forms! Use WPF!
Some 70% of the problems you're only thinking about are already solved there. Scaling is already provided, vector graphics is already provided, there is no rendering (you will have to spend good time in just Forms rendering), all graphics is already presented as set of objects. Moreover, you can create vector graphics in external vector editor (a perfect third-party tool is Inkscape), convert it to XAML and put it in your restaurant. Moreover, you can even allow your user to do that during run-time! What else? Performance will be much better, screen resolution independent design is much easier (as I say scaling is inherently embedded in everything already, you can even scale whole thing with all you controls).

Given all that, I would hate even the flirting with the idea of using Windows.Forms. Some other applications — may be, but not your applications. WPF was born to handle exactly such situations.

Do you really have any convincing reason to use Forms?

—SA
 
Share this answer
 
Comments
fgoldenstein 17-Feb-11 14:14pm    
It has to be done in Winforms because the project is a Winforms project and this is only a new feature, not the entire system. The questions are:
1) How to resize a PictureBox at run-time to allow the user to decide the size
2) Drag&Drop (there're lots of articles in CodeProjects about it so it's not a problem)
3) Scaling: the user drags a PictureBox to X=1000, Y=10 (right upper corner) and it's ok. But when other users open the map in this 800x600 screen resolution he can't see the table. Scaling is necessary to avoid this problems. I have thought of a relative position (proportion) instead of an absolute position. X=1000, Y=10 could be X=90%, Y=5%. The same with the size of each object, it's not only important to adapt the location but the size too.
Thanks
Sergey Alexandrovich Kryukov 17-Feb-11 15:58pm    
This is not a serious excuse to keep using WinForms: you can easily host a WPF in WinForms application.
I already see big mistake in your WinForms development: you should not use PictureBox for this task, under no circumstances. That advice is repeating one in other Answers on CodeProject. Hence, all further questions about scaling make no sense.

I doubt can get good help on WinForms, because the idea of using this library is very discouraging. Sorry, the only incentive here is poor interest to help, so...

--SA
Sergey Alexandrovich Kryukov 17-Feb-11 15:59pm    
Do you already know that you should not post non-answers as answers? Good, please don't.
--SA
fgoldenstein 17-Feb-11 16:14pm    
I don't like hybrids, that's why I don't want to host a WPF Control in a WinForms project. Why should I avoid using PictureBox? You should give reason after saying something like that.
Scaling can be done with PictureBoxes, but you have to do it manually.
In the future I will migrate this project to WPF but now I can't.
Thanks for your interest but I would also appreciate that you give reasons when you say something.
Sergey Alexandrovich Kryukov 17-Feb-11 18:16pm    
Sorry, I simply cannot afford spending so much extra time on arguments.
I do not agree that I "should", let's assume this from the very beginning.

Let's play a fair game. Why you should not explain what is the use of PictureBox? I say: "none, not at all". Now you tell me why.
This is reasonable, just to avoid other unreasonable suggestions. One could say, I "want to use Metafile", another will say "SVG", somebody else "text of VB/Javascript rendering script". Do you think I need to disproof all that?! You suggestion is no better than all of those.

Sorry to bother you, but I need to explain: I participate only if it is interesting to me, as anyone here. I'm afraid to say you're practically exhausted the possibilities to get help.

Wish you good luck,
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900