05-10-2010 06:56 AM
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.
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 🙂
Solved! Go to Solution.
05-10-2010 09:12 AM
Hello -
Your points are being constrained by the PointSize property. You could change your code to read:
or you could manually set the size of your points:
NickB
National Instruments
05-10-2010 09:32 AM - edited 05-10-2010 09:39 AM
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);