I'm trying to make a small program where the user could resize the controls by dragging the border.
Much like many editing software, such as Office, Paint 3D, or even VS itself, would do.
I learned how to do it from this article.
But how can I make it more "professional looking"?
Because in all the editing software, "little square dragging handles" will appear once you select the control, just like the following picture.
I had thought about maybe change the background image upon mouse enter, but then I thought, "since VS have all that functionality when you making a form, there must be a way to employ it directly, right"!?
But unfortunately I can not find any documents online related to it! Probably because this is "not" something most of the people would do and requires more professional knowledges.
So, could somebody please be so kind and help me out!?
Probably through some using or importing some dll or something, much appreciated!
Related
I have a C# application that has an existing WinForm that I now need to display upside down.
The application will be displayed on a touchscreen Windows 7 device. If two people are using the device, one person is viewing it right-side-up while another user will be simultaneously viewing it upside-down. I will need to have one control displayed right-side-up while another control is displayed upside-down, each duplicate forms. Both need to be functional. It is not necessary for the title bar and Windows close, maximize, and minimize to be rotated.
Is there a way to easily rotate this Form and all of its contents without having to rewrite it from scratch?
Unfortunately, rotating controls is not directly possible in WinForms.
At least, not if you want them to retain their functionality. It would be relatively simple to draw the control into a bitmap, rotate the bitmap, and then draw that back to the desired location on the form. But you would obviously lose the ability to interact with the controls. They would just be static representatives of their original selves.
But making functional upside-down controls just isn't going to happen. I mean, you could try to write a bunch of custom drawing code for owner-drawn controls, but you'll still run into a bunch of bugs, corner cases, and compatibility problems. The Win32 controls that WinForms is based on just don't support this. No big surprise, really, considering they were invented some 20–25 years before anyone thought of computer screens that you could carry around in your pocket and rotate in any direction. There is a good reason that UI technologies like WPF came out around the time that touch screens and tablets did.
There are some possibilities that can be explored when it comes to flipping the entire screen, but that's not going to help when you want different controls going different directions. (And I guess it betrays my vantage point as a desktop app guy when I say this, but that just sounds like an incredibly confusing UI.)
If you absolutely have to have this, someone else is going to have to give you another route to hack it, perhaps along the lines of Dhawalk's comment: hosting the WinForms control inside of a WPF app that does provide built-in support for rotated controls. I don't know enough about this to make any concrete suggestions down that path. From a few minutes of searching, it appears that WindowsFormsHost does not actually support rotation transforms, so this may be a non-starter anyway.
I'm trying to make a new CAD program from scratch. The GUI is mostly easy to make in C#; it's just dragging-and-dropping things like command buttons and writing their associated code.
However I want the user of my CAD to be able to drag-and-drop icons from a toolbar onto a drawing pane. I also want them to be able to resize those icons, draw connections between them, etc. And I don't know how to do this part.
After doing a good bit of research, I'm still lost on what approach I should take for it. It's basically a 2D flowsheet, so do I need hardware acceleration? Do I make C# bitmaps and just print those after modifications on mouse events? Etc.
What should I study to learn how to do this?
Thank you!
You probably need to work with WPF. You might find these articles useful
A Beginners Guide to
WPF
A Guided Tour of WPF
Drag and Drop
Drag and Drop in WPF
WPF Drag and Drop Smorgasbord
Drag And Drop in WPF Explained (an end-to-end explanation)
WPF Diagram Designer
These were the ones that help me while I was going to do something similar. Hope they will be useful to you.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'd like to try to create a diagram making tool (something like entity-relation diagram you can create in SQL Server 2005, or class diagrams you can do in Microsoft Visual Studio)
Ie. I'd like to create boxes, put text in them, be able to edit this text and draw lines between boxes.
I never did this kind of programming before so I don't know where to start.
Do I use XAML or create a canvas and go into graphics programming?
I know there are some diagram tools out there but I'd really like to find out of these things by doing it myself.
WPF/XAML are a great place to start for something like this. You'll want to study WPF in general, with a focus on custom controls (for tables) and drawing lines (for the relationships.)
Well, here is the basis of one on CodeProject, with source and a tutorial. For WPF.
Also see this question.
The rendering engine you pick is somewhat arbitrary - you're going to have to do a lot of work no matter what framework you use.
Having implemented such a system in C# and WinForms, I can honestly say that's a bad route to go. Stick to WPF/Silverlight. Going with trends, write a Silverlight 4 app so you can deploy to desktops on multiple platforms.
I found that there are a lot of high-level decisions that you have to make that are even more important than which rendering engine you use. Some of these are:
How much do you need to zoom and pan around?
Do you want continuous zoom so that you can do neat animations to the data?
Do you need to be able to pan with just the mouse?
How will you distinguish pan movements from dragging around boxes and handles?
Will you change the layout of content in the boxes dependent upon the current zoom level? or will you rely on font scaling?
Do you need grouping? Once you get a few tables on the screen you will soon realize that being able to hide some detail is useful. Being able to group boxes and to show that group in iconic form as "meta" box allows the user to get rid of unwanted distractions.
Do you need search? Again trying to combat the "too much on the screen" problem, it's good to have a search box that hides everything that doesn't match the search (gray out, hide, etc.)
How will the user interact with the keyboard. Since your audience can include programmers, you're going to want to give a lot of thought to making all your diagrams editable with just the keyboard. This means things like handling focus intelligently along with which hot keys to use.
As Frank has pointed out - creating interactive graphics is big business. Many companies have already been there, spent £millions perfecting it. It would depend upon how much interactivity you want. I would advise you pick a graphing application that is extensible or has an API - that suits your budget. The better ones are (in my opinion) in the CAD domain, such as AutoCAD (£4k/seat), TurboCAD, VeCAD (£200/seat); and all have packages that allow you to resell their product within yours.
I can place a couple of buttons in Silverlight, but I'm not that experienced with the Silverlight tools and capabilities.
What do you think I should use to create something like this?
The control would have to pull and ID from the database and according to that place an image asociated with the record.
I need it to be animated with some crispy movement.
How can I achieve this?
It's all possible, but you need to break the task down into smaller steps.
Once you've done that you should find that you can solve some of these with your current knowledge, others will resolve themselves with a little more research, but there will be some you need to ask questions about here.
I'd suggest you start that break down and try to solve the little problems. Then if you get stuck come back and ask more specific questions.
Well, with Silverlight and c# you can make the animations needed and such, and you can set a Silverlight Image control with a data bound source, so it loads the images dynamically, but Silverlight can't talk with databases directly, you'll need to use a webservice to interact between Silverlight and the database. Don't know how much you know but to not leave anything out, with Expression Blend you can make the graphical part of you're app fast and easy, and with Visual Studio you'll add the code-behind and functionality.
In this link you can find a example of how to make an image slide show with Silverlight, it may not be exactly what you're looking for, but it should give you a heads start.
I'm using WINFORMS not WPF.
I just know basic c# .net gui programming. I donot want the traditional windows look. I want to have my own custom look (eg. gtalk, antivirus softwares, media players, google chrome).
Actually I'm inspired by google's PICASA software. Its awesome. I want to do something like that.How can I do that? If there is something I should learn please point me.
Also I may have to write my own custom controls (like modified tree view etc..) I guess. Please give some good learning resources.
This article describes how to draw custom windows. The author also shows how to draw non-rectangular windows.
If you could use WPF instead of Windows Forms, this is a good article about customizing window drawing:
http://www.codeguru.com/csharp/.net/net_wpf/article.php/c16379/
There is also a question with some good answers here on SO:
Creating custom forms in WPF?
Update:
I think that skinning and custom drawing is fun to do from a programmers perspective, but I also think that there is almost no benefit for the user.
The creators of the platform you are developing for might have put a lot of effort into the design of their windowing toolkits.
If you just want to change some visual aspects of your application you also should take into account that you might miss some important other aspects of UI design:
consistency
accessibility
aesthetics (if you are overdoing
effects, gradients, ...)
internationalization
...
As you are developing for Windows, you also lose the skinning ability of the OS itself. And I think that some of the skins that come with newer versions of Windows are pretty good.
You can try any of the following:
telerik
Syncfusion
(source: componentsource.co.jp)
Or other components.
They do make your UI pretty.
Edit: if you want to study how they do it, you can buy the source code-- along with documentation and understand from there.
There are some commercial control libraries available.
I can recommend the Krypton Suite. It consists of the free Krypton Toolkit (which contains a lot of skinnable controls) and other non-free controls (Navigator, Ribbon, Docking, Workspace). It has some built-in palettes and renderers that allow you to make your UI look like Office 2010, Office 2007, Office 2003, ...
You want to look for +winforms +skinning. I haven't tried these, but the first hits don't look bad. Most decent skinning tools will be paid for.
From what you said, you want to develop your own custom controls. You have some frameworks for this like Qt which can use Direct3D for hardware accelerated graphics. It also have a Visual Studio plugin. There is a free LGPL version and a commercial version of it.
I remembered about Qt because you mentioned Picasa and as far as I remember, I heard the Picasa UI has been written through Qt.
You can try using "SetWindowRgn(..)" to set an arbitrary region for your window. This may range from giving a rounded rectangle shape to giving a weird looking shape to the form!
Check this out: Link.
There is another option if you are working in Vista(aero enabled), ie you can check out DwmExtendFrameIntoClientArea(..) function here: link text
You can set the form's border style to 'none' and go on to create your custom form! You then might have to create custom buttons to carry out tasks like close, minimise, maximise etc. You might even need to write code for drag and drop events..
For the background, you might need to have a look at the gradient fills to give a great effect, otherwise you can use great looking pictures as Background..! But the latter option isnt good unless you have really good pic.