Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with custom pointstyle

Solved!
Go to solution

Hello, I want to create a custom pointstyle for my scattergraph plots. I want to create an rectangel with an black border.

I have readed the following article http://zone.ni.com/devzone/cda/tut/p/id/10526 and this one helps a lot.

 

But there is a tiny problem with the black border. The following picture shows this problem, the border is only on 2 sides of my rectangel.

 

Unbenannt.JPG

 

This is my code of my tiny class. 

 

ref class BorderPointStyle : NationalInstruments::UI::PointStyle { public: BorderPointStyle(void) {} public: virtual void Draw(Object^ context, PointStyleDrawArgs^ args)override { Graphics^ g = args->Graphics; Rectangle rect_b = Rectangle(0,0,7,7); Rectangle rect_i = Rectangle(0,0,6,6); System::Drawing::Pen^ pen = gcnew System::Drawing::Pen(Color::Black); g->FillRectangle(gcnew SolidBrush(args->Color),rect_i);//Draw the innerarea

g->DrawRectangle(pen, rect_b);// Draw the border

} };

 

 Maybe has someone a resolution for my problem 🙂

 

 

0 Kudos
Message 1 of 3
(3,701 Views)
Solution
Accepted by topic author jeschki

Hello - 

 

Your points are being constrained by the PointSize property.  You could change your code to read:

 

Size s = args.Size;
Rectangle rect_b = new Rectangle(0, 0, s.Width - 1, s.Height - 1);
Rectangle rect_i = new Rectangle(0, 0, s.Width, s.Height);

 

or you could manually set the size of your points:

 

waveformGraph1.Plots[0].PointSize = new Size(7, 7);

 

NickB

National Instruments 

0 Kudos
Message 2 of 3
(3,689 Views)

Hello, your first answer solved my problem!

 

If I use the following code so I will get only a point without any border.

waveformGraph1.Plots[0].PointSize = new Size(7, 7);


I used the size of the args object so i can use every plot size 🙂

Rectangle rect_b = Rectangle(0,0,args->Size.Width,args->Size.Height);//Border

Rectangle rect_i = Rectangle(0,0,args->Size.Width-1,args->Size.Height-1);//Inner area
System::Drawing::Pen^ pen = gcnew System::Drawing::Pen(Color::Black,3);
g->FillRectangle(gcnew SolidBrush(args->Color),rect_i);
g->DrawRectangle(pen, rect_b);

 

 

 

 

 

 

Message Edited by jeschki on 05-10-2010 09:39 AM
0 Kudos
Message 3 of 3
(3,685 Views)