Zoom Pen and Brush

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
jjs2002
Newbie
Newbie
Posts: 4
Joined: Tue Jul 08, 2003 4:00 am

Zoom Pen and Brush

Post by jjs2002 » Wed Apr 07, 2004 7:16 pm

I just downloaded the new version and the problem with the pen and brush of the zoom that was posted here earlier is still a problem. Is there a workaround for this????? Also is there a fix coming for this anytime soon? I have a deadline that is very soon.

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Wed Apr 07, 2004 9:20 pm

Hi --

Please find a copy of the whole thread below (posted to the Steema private Pro Support newsgroups):
Hi,

I just downloaded the TeeChart 1.1.1544.23908. The first thing I tried is
the Zoom Pen and Brush, but besides some minor changes. The main Colour and
Transparency issues are still present.
To reproduce my problems you just need to do some changes in the Feature
Demo, Misceallanous, Zoom and Scroll.

Is the bug fix you told me some time ago was not included in this release
for some reason?


Hi,

> Is the bug fix you told me some time ago was not included in this release
> for some reason?

The fix is in this release.

Using a simple transparent brush to fill the zoom rectangle area did not
give us the required painting performance, so we opted for the .NET
Frameworks XOR draw methods. These gave us the performance we were looking
for but unfortunately do not give us the capability to alter the default
transparency used in these methods or to alter the width of the pen.

An example of zoom use would therefore be:

private void Form1_Load(object sender, System.EventArgs e) {
commander1.Chart = tChart1;
line1.FillSampleValues();

tChart1.Zoom.Brush.Color = Color.DarkBlue;
//The following trick has already been incorporated into the source
//in the next version you will be able to do:
//tChart1.Zoom.Pen.Color = Color.Red;
int penXOR = -1 ^ Color.Red.ToArgb();
tChart1.Zoom.Pen.Color = Color.FromArgb(penXOR);
tChart1.Zoom.Pen.Style = System.Drawing.Drawing2D.DashStyle.Dash;
}


Thank you Christopher for your quick answer.

> An example of zoom use would therefore be:
>
> private void Form1_Load(object sender, System.EventArgs e) {
> commander1.Chart = tChart1;
> line1.FillSampleValues();
>
> tChart1.Zoom.Brush.Color = Color.DarkBlue;
> //The following trick has already been incorporated into the source
> //in the next version you will be able to do:
> //tChart1.Zoom.Pen.Color = Color.Red;
> int penXOR = -1 ^ Color.Red.ToArgb();
> tChart1.Zoom.Pen.Color = Color.FromArgb(penXOR);
> tChart1.Zoom.Pen.Style = System.Drawing.Drawing2D.DashStyle.Dash;
> }

Does the same thing works even for the Brush Color?


Hi,

> Thank you Christopher for your quick answer.

You're welcome :-)!

> Does the same thing works even for the Brush Color?

Yes, the XOR trick is already incorporated into the source code for
Brush.Color.


Hi Christopher,

> Yes, the XOR trick is already incorporated into the source code for
> Brush.Color.

There is still something I don't understand. I'll try to explain myself in
detail:
I XORed the Pen Color with the background color of my chart and I got
exactely the color I expected.
But I can't understand what happens to the Brush Color.
My desired Color is 182 189 210.
Using this color I get on the screen 126 117 210 which is exactely the
desired color XORed with the background color (200 200 200).
So I XORed the desired color with the background color and I got on screen:
73 66 45 which is the desired color XORed with White (255 255 255) or the
second color (126 117 210) XORed with the background color.

Well, I won't bother you with other color combination I tried without useful
result, anyway,
I am not absolutely understanding what's happening.

Can you help me getting 182 189 210 in the zoom rectangle?

Hi,

> Well, I won't bother you with other color combination I tried without
useful
> result, anyway,
> I am not absolutely understanding what's happening.
>
> Can you help me getting 182 189 210 in the zoom rectangle?

Or maybe you could help me <gg>!

Let me explain the situation. In the .NET Framework there is only one draw
method I am aware of for drawing XOR brushes which is the
FillReversibleRectangle() method. Try the following code to see the
situation:

private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs
e) {
Rectangle r1 = new Rectangle(this.Left + 20, this.Top + 50, 200, 200);
//Color custom = Color.Red;
Color custom = Color.FromArgb(182,189,210);
int xorColor = -1 ^ custom.ToArgb();
int color = custom.ToArgb();
System.Windows.Forms.ControlPaint.FillReversibleRectangle(r1,
Color.FromArgb(xorColor));

Rectangle r2 = new Rectangle(220, 50, 200, 200);
e.Graphics.FillRectangle(new SolidBrush(custom), r2);
}

As you can see, when the Color custom is set to Color.Red the XOR trick
works perfectly, however, this trick does not seem to work for "custom" ARGB
colours. This is exactly the situation we are in with the Zoom.Brush.

Please let me know if you find a way to make your custom colour appear in a
rectangle painted using FillReversibleRectangle().


Hi Christopher,

> As you can see, when the Color custom is set to Color.Red the XOR trick
> works perfectly, however, this trick does not seem to work for "custom"
ARGB
> colours. This is exactly the situation we are in with the Zoom.Brush.
>
> Please let me know if you find a way to make your custom colour appear in
a
> rectangle painted using FillReversibleRectangle().

Ok, I understood the problem, and made some research.
At first I thought the FillReversibleRectangle() function should xor my
color with the background color, but the color you can pass at the
FillReversibleRectangle() is the background color you wish to draw onto.
Given that "bakcground color" the function arbitrarily decides which color
is more visible on that back color.
I mada a last try, using a bitwise not on my desired color getting nowhere.

I give up.

Thank you.
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Post Reply