Profile Picture

Changing StrokeStyle of a Path

Posted By Volvick Derose 13 Years Ago
Author
Message
Volvick Derose
Posted 13 Years Ago
View Quick Profile
Forum Guru

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
Last Active: 12 Years Ago
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
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 2 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009

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
Posted 13 Years Ago
View Quick Profile
Forum Guru

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
Last Active: 12 Years Ago
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);



Similar Topics


Reading This Topic