After years of avoiding this, i finally want to tackle some graphic output. Searching, i found a lamentable loss of docs for anything a bit more complicated than "DrawLine"...
Attached a sample of a booking plan, what should in the end be viewable and printable.
* Textblock, horizontally centered, pegged to the upper border
* Blocks of rows of rectangles, number of rectangles might differ for every row
* Each rectangle has a number inside
* Each row has "outside" a row number, ideally "not rotated"
* Each block has a naming letter, not rotated
* in the end all of them should be placed together and scaled to fit onto a given page format.
Basically my question is, how to dynamically handle multiple placings of somewhat rotated "Building blocks". Naturally, i might accept restrictions, calculating everything "by hand", but there has to be a better way.
I think i meanwhile grasped the concept of transformations more or less, but i struggle how to proceed. Would it get easier using panels?
(Chris, i remember you presented some GDI samples back in VN days, but can't find them anymore, is there a place to get them?)
Winforms, GDI+ and basic conceptual fightings
Winforms, GDI+ and basic conceptual fightings
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Re: Winforms, GDI+ and basic conceptual fightings
Hi Karl,
if you like to do that in Windows forms, I would build my own helper class that is built over DrawLine.
After all, what you need is a collection of lines.
Basically your objects are all rectangles with some caracteristics:
- width and length
- rotation
- origin
- available or not (X)
- text
So I would start with this...
Wolfgang
if you like to do that in Windows forms, I would build my own helper class that is built over DrawLine.
After all, what you need is a collection of lines.
Basically your objects are all rectangles with some caracteristics:
- width and length
- rotation
- origin
- available or not (X)
- text
So I would start with this...
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Re: Winforms, GDI+ and basic conceptual fightings
Wolfgang,
that's the easy part...
What puzzles me, is the "assembly" of the parts. For placement, i need bounding boxes, for rotation a useful origin for each part, and i still seem to misunderstand the effects of ResetTransform.
that's the easy part...
What puzzles me, is the "assembly" of the parts. For placement, i need bounding boxes, for rotation a useful origin for each part, and i still seem to misunderstand the effects of ResetTransform.
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Re: Winforms, GDI+ and basic conceptual fightings
Hi Karl,
My old session (for vulcan) was included in 2023's session material, in the folder "Old sessions", but I'm attaching it also here:
Regarding rotation, have a look in the GDI+ demo code, in the method DrawWave(). Basically you need to
- Save current state with Graphics:BeginContainer()
- Move the painting coordinates to the center of the object (collection of lines etc) that you want to draw rotated with TranslateTransform()
- Rotate the painting axis with RotateTransform()
- Do the drawing
- Restore the default drawing state with EndContainer()
This will draw everything rotated, but if you need to do some parts not rotated, then I'm afraid you will need to do some math calculation on where you should draw normally those parts.
My old session (for vulcan) was included in 2023's session material, in the folder "Old sessions", but I'm attaching it also here:
Regarding rotation, have a look in the GDI+ demo code, in the method DrawWave(). Basically you need to
- Save current state with Graphics:BeginContainer()
- Move the painting coordinates to the center of the object (collection of lines etc) that you want to draw rotated with TranslateTransform()
- Rotate the painting axis with RotateTransform()
- Do the drawing
- Restore the default drawing state with EndContainer()
This will draw everything rotated, but if you need to do some parts not rotated, then I'm afraid you will need to do some math calculation on where you should draw normally those parts.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Re: Winforms, GDI+ and basic conceptual fightings
Thx Chris for the files, will study.
While on it, i get an
on this line
METHOD OnPaint(e AS PaintEventArgs) AS VOID CLASS DemoPictureBox
This i also saw recently in another application - i have no clue, what is wrong here.
While on it, i get an
Code: Select all
error XS0507: 'DemoPictureBox.OnPaint(System.Windows.Forms.PaintEventArgs)': cannot change access modifiers when overriding 'protected' inherited member 'System.Windows.Forms.PictureBox.OnPaint(System.Windows.Forms.PaintEventArgs)' 135,1 GDI_plus_demo.prg DemoPictureBox:OnPaint
METHOD OnPaint(e AS PaintEventArgs) AS VOID CLASS DemoPictureBox
This i also saw recently in another application - i have no clue, what is wrong here.
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Re: Winforms, GDI+ and basic conceptual fightings
Hi Karl,
The parent OnPaint() method of the PictureBox class is PROTECTED, message says that when you override this method in a subclass, it can't have different visibility, so you need to make it PROTECTED as well. Vulcan was doing this automatically.
The parent OnPaint() method of the PictureBox class is PROTECTED, message says that when you override this method in a subclass, it can't have different visibility, so you need to make it PROTECTED as well. Vulcan was doing this automatically.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu