How can you draw a geometric figure (line, square, triangle), then convert it into a control or object so that events, tooltips and so on can be applied to it.

I thought at first to take the panels, draw on them, but the panels overlap and overlap each other.

Thank.

Adding: Take for example CorelDraw or PhotoShop. They can create geometric shapes. After creation, we can move them, resize and perform other actions. How can you do something like this in c #?

Appendix 2: Used by Windows Forms. Yes, it is required to create arbitrary controls, but so that their background does not overlap each other. I tried at the loaf to make OpacityMask, but the resharper swears that there is no such thing. how to make (let’s use the button as an example) so that the control has a transparent background, but there is a picture on it.

and button1.BackColor = null - does not roll.

  • @ Emil Sabitov, please formulate your question correctly - it is very difficult to understand what you want here - DreamChild
  • @DreamChild, yes, I myself can not properly formulate. Here is an example added. Read it. If it's still not clear, I'll try in other words to write. Thank. - Emil Sabitov
  • @ Emil: Can't you create a control with a background = null (not Transparent)? They should, in theory, skip mouse events. - VladD
  • I understand that you want to create arbitrary controls? - DreamChild
  • one
    and what is generally used? winform, wpf? or a clean console, and we’ll draw on the canvas? - Carma

1 answer 1

If you want controls with intricate forms, then on WinForms it is not as easy as you would like. It may make sense to dig into WinApi, whose functions will have to be accessed from managed code (this is said a little here ). Is there such an entity as a region, which allows you to determine the shape of the window component (including buttons and all other controls). A few words about it here. How it will work, to be honest, I don’t know, you will probably have to dance with a tambourine and call the spirits of long-dead ancestors, and also care about the correct interaction of managed and not very controlled code. (In a nutshell, all of the above is nothing more than my guess, which, quite possibly, will work .. and it is quite possible that there is not)

But in WPF with triangular buttons, everything is somewhat simpler - XAML allows such things without any special distortions, as far as I know (well, plus support for hardware acceleration again). Moreover, a long time ago (about three years ago) I got into the hands of a tool called Expression Blend - Microsoft's XAML'a WYSIWYG editor for creating application interfaces, in which all these round buttons with all kinds of gradients are created without problems. 3 years have passed since then, and I think it has become even more convenient to create all these whistles and fakes there.

  • Thanks for the detailed answer! I think it’s not for nothing that the tambourine hangs on the wall. That is his time. How nice that I have not started doing this project. So I'll start right away in WPF. The editor will definitely look. Probably he will come in handy. It turns out with the help of your advice, you can create about the same shapes as in photoshop? I need to make the interface something like AutoCAD’s plans. That is, any lines that can be changed, approximate, and so on. Thanks again! - Emil Sabitov
  • I will not accept your answer yet. Suddenly, even people will drop in and practical advice will be given;) - Emil Sabitov