Changing StrokeStyle of a Path


Author
Message
Volvick Derose
Volvick Derose
Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)
Group: Forum Members
Posts: 71, Visits: 1
I try to create a composite shape; the following code works fine for NRectangle shape, but not NRectangle path

NStrokeStyle strokeStyle = new NStrokeStyle();
strokeStyle.Factor = 3;
strokeStyle.Width = new NLength(3, NGraphicsUnit.Point);
outsideShape.Style.StrokeStyle = strokeStyle;
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Volvick,

You should always use one of NStyle.SetStyle static methods for setting the style of any element! These methods automatically check if the Style of the given element is null and create it if it is. In this way you will never have a null reference exception when setting one of the styles of an element but you forget to check if its Style property is null. The following is a simple example:

 

NRectanglePath rectPath = new NRectanglePath(300, 300, 100, 100);

 

// Always use one of the NStyle.SetStyle methods for setting the style of any element!

NStyle.SetFillStyle(rectPath, new NColorFillStyle(KnownArgbColorValue.Red));

 

NCompositeShape shape = new NCompositeShape();

shape.Primitives.AddChild(rectPath);

document.ActiveLayer.AddChild(shape);



Best Regards,
Nevron Support Team


Volvick Derose
Volvick Derose
Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)Forum Guru (71 reputation)
Group: Forum Members
Posts: 71, Visits: 1
Hopefully this one works

NStrokeStyle strokeStyle = new NStrokeStyle();
strokeStyle.Factor = 3;
strokeStyle.Width = new NLength(3, NGraphicsUnit.Point);
NStyle.SetStrokeStyle(outsideShape, strokeStyle);
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search