Can you allocate space at the bottom of a .NET Chart Control - c#

I'm using the .net chart control. I'd like to allocate some space at the bottom of the chart to add some additional information (date, associated file name, note, etc.) - about 0 to 4 lines in total. To do this I'd like to allocate some reserved space below the X axis title (the 0 to 4 lines worth) and use an annotation anchored to the bottom to contain the additional information. Or, if there's some other way to accomplish the same thing, that would be great.
I've been working for a couple of days trying to accomplish this but have not found a "professional" way to do it. I am able to do it by adding several blank lines to the X axis label, but I'd like something a little better than that.
I am using a dock style of fill and allowing auto sizing. I've tried margins and padding with no success. Annotations appear to simply overlay existing area on the chart but do not allocate any additional space.
I'm looking to allocate a fixed size block at the bottom since the text block will be a fixed size height, rather than a percentage (relative coordinates).
Does anyone have any suggestions that I might try? Thanks!

I found a way to accomplish what I was looking to do. I simply used a chart Title and docked it to the bottom of the chart. It allows me to add in the extra data that I wanted to add and space is properly allocated for it. I'm new to using MSCharts and hadn't noticed that I could use multiple titles docked to different places on the chart.

Related

C# string.Format alignment issue

I have a problem with the alignment of a few names (changed for this question).
with this code I display the names in a richtextbox where it should be in one row with the "Spalte:" after the Names...but it doesn't. Can anybody help me please?
(only the first for-loop is necessary for my question, the next one does another job)
I added a pic what it looks like and how it should be looking. I know I can do it like its in the commented area (doesn't work in every case), but I need to change the code for a few other things so this needs to work....
Here is what I have:
And here is what I want:
Thanks for helping me :D
You have four options:
Change the code for the RichTextBox to use a fixed-width font. Most fonts have variable widths for each character, meaning you can't line things up neatly based on spacing alone.
Use tabs instead of spaces for the layout (and make sure the tab size is large enough to account for variances in your text).
Use a grid control of some type (DataGrid, GridView, etc)
Use a custom control for each row with labels at specific places (and either calculate positions yourself to place them on the form or use something like a FlowLayoutPanel).

Crystal Report Layout issue

I am designing a Crystal Report in Visual Studio 2012 and can't seem to manage the position of a vertical line. I need the line to stick the right edge of the page, but it resists. Even if I managed to align it on the right, it displays at a different position after deploying the software on another machine, even when just previewing.
Setting the page size to A4 doesn't help. How can I make this easier on me?
Designer View:
In Report preview the right hand side line is not shown properly:
If I move the line a bit to the left, like this...
...the row background goes beyond the line in preview.
You might have better luck using a Box object for the outer layers and only using lines for the inside columns. Just like the lines, the Box can span multiple sections and will resize vertically if the report has extra lines added in. At the very least this will make sure the outside borders always connect perfectly.
If you're still having problems with precision, try setting the Size and Position. Set the Left and Top to zero, and calculate the appropriate Width value based on the Width of your report.
In the end Crystal reports are a little finicky when it comes to layout, and different viewers/printers might jostle stuff around a little. But unless the report has a dynamic width, you should be able to get it pretty close with a Box and very specific Size/Position values.

C# draw a string pixel perfect

I'm trying to draw a string using either textrenderer.drawtext, graphics.drawstring or graphicspath.addstring - the main purpose is to extract all fonts to bitmaps to edit them and use them as bitmaps with shaders in a game.
With textrenderer.drawtext and graphics.drawstring, I get a padding on top of varying degrees - so I try graphicspath.addstring. I extract the font family's ascent height and descent height, but they are wildly unusable with emheight. (using ascent and descent with emheight is how microsoft suggest you do what I am trying to do - via http://msdn.microsoft.com/en-us/library/xwf9s90b%28v=vs.110%29.aspx. Has anyone successfully ever draw pixel perfect fonts using C#? Every time I ever try or look it up, textrenderer and graphics always' padding always screwed up drawing and this new graphicspath method seems to have an issue with using a specific scale.
The usual methods using TextRenderer or MeasureString will give you a SizeF, containing the bounds of the string you measure. Most formats include a little slack so you can compose text by adding strings together.
The aim of theses methods is to help create blocks of text by letting you measure when a line will be full or how many pixels to advance for the next line.
They are not really meant for maesuring single characters.
For this there is a special stringformat GenericTypographic as described here which leaves out the white space.
To get an even more precise measurement one can use GraphicsPath.AddString and then GetBounds, maybe after switching antialias off..
Now, if you wanted to draw a single character precisely, say centered on a Button this would do the job.
But you know all that and your aim is different - if I understand you correctl,y you want to create Bitmaps from each character in order to later join them to form text. This means you need them to line up correctly vertically, ie sit on the same baseline.
The sizes of the characters don't help you here; now, normally you'd need the baseline of each charcater, which you don't get, at least not for anything descending like 'f' or even just ',' etc..
But it wouldn't help you either because in GDI you don't print/draw to the baseline anyway..
What you should do, imo is either draw one long string with all characters, so that they're all lined up right and then cut out the characters one by one. Or you could draw each character on its own, but suffix all or some characters you know to have ascenders and descenders and then only pick the first columns from the result.
So the only way I figured out how to do this is is to first draw the string to a graphicpath, then measure all the empty spots in the graphic path, and get it's height only after I've measure every spot, then redraw the string (I have an attempt counter to limit attempts but increase em to pixel accuracy) taking the old size and new size into account by a modifier and then extract the final size and store it.
Only I got to get around the BS of every font having a weird top padding that isn't associated with it's ascent and internal overflow (ex: Ñ), as well as descent, in refrence to a 0,0 point, this way.

Top-docking controls more than 32768 pixels

I have a WinForms application that allows you to edit documents. Each document is made of chapters and each chapter holds a collection of RTF blocks. The RTF blocks are loaded in a PanelControl using Dock = DockStyle.Top.
The problem is that when the total height of a chapter gets too large (estimating > 32768 pixels) the lower blocks are not properly docked: they appear behind one another. When trying to isolate the problem I noticed that this also happens with simpler controls like a LabelControl.
Things I tried are methods like Refresh(), Invalidate() and PerformLayout: they will not resolve the issue.
What does help is resizing the form. After that all controls are laid out correctly.
Can anyone help on how to solve this without resizing the form?
Attached a simple demo-project that illustrates the problem.
From my comment above (seems really to be the problem here):
WinForms (and the GDI in general) is often behaving unpredictably if one tries to use coordinates outside a 16 bit range. Try to avoid that. In the range of possible problems are things just not getting drawn at all, OverflowExceptions at unexpected code positions etc.
If it's possible to you take decision to change this layout, I suggest you to take another approach on showing/editing the documents chapters with some kind of pagination or collapsing RTF blocks into a menu and showing only current.
You see.. it makes a sense the height value be a integer 16-bit value.
A screen is way more tiny than this.
As panel height increases to such a high size. You see that using scroll bar will become very very sensible.. and it's not a good thing.
Content with size 2x, 3x, 5x being scrolled is usable to user. But scrolling a content with height (~32768) of at least (using good resolution monitor w/ window maximized) in optimal case 32x the size of window is very uncomfortable.
Plus, I believe that the productivity of user will decrease due to brain difficulty in locate "things" in a increasing collection of "things".

ZedGraph - How to fill the area between two curves?

I've two curves. One of them is above the another. I've also set the IsSmooth to true (the lines are bent at the corners).
I want to fill the area between the top and bottom curve…
What's the best method to do so?
I think using PolyObj is not a good idea because I have to store the points separately, and the final filled area is not smooth like the lines.
Here is a sample:

Categories

Resources