usingcAlgo.API;namespacecAlgo{// This sample shows how to use shapes stretch property[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]publicclassStretchSample:Indicator{[Parameter("Stretch", DefaultValue = Stretch.Uniform)]publicStretchStretch{get;set;}protectedoverridevoidInitialize(){varrectangle=newRectangle{Stretch=Stretch,HorizontalAlignment=HorizontalAlignment.Center,VerticalAlignment=VerticalAlignment.Center,Height=100,Width=200,FillColor=Color.Blue,StrokeColor=Color.Red,Opacity=0.7,};Chart.AddControl(rectangle);}publicoverridevoidCalculate(intindex){}}}
1 2 3 4 5 6 7 8 91011121314151617
importclrclr.AddReference("cAlgo.API")fromcAlgo.APIimport*classTest():definitialize(self):rectangle=Rectangle()# Stretch is a parameter of type Stretch defined in# indicator C# filerectangle.Stretch=api.Stretchrectangle.HorizontalAlignment=HorizontalAlignment.Centerrectangle.VerticalAlignment=VerticalAlignment.Centerrectangle.Height=100rectangle.Width=200rectangle.FillColor=Color.Bluerectangle.StrokeColor=Color.Redrectangle.Opacity=0.7api.Chart.AddControl(rectangle)
Fields
None
Summary
The content preserves its original size.
Signature
1
Stretch.None;
Return Value
Stretch
Fill
Summary
The content is resized to fill the destination dimensions. The aspect ratio is not preserved.
Signature
1
Stretch.Fill;
Return Value
Stretch
Uniform
Summary
The content is resized to fit in the destination dimensions while it preserves its native aspect ratio.
Signature
1
Stretch.Uniform;
Return Value
Stretch
UniformToFill
Summary
The content is resized to fill the destination dimensions while it preserves its native aspect ratio. If the aspect ratio of the destination rectangle differs from the source, the source content is clipped to fit in the destination dimensions.