usingcAlgo.API;usingSystem.Text;namespacecAlgo{// This sample indicator shows how to use different Line Stacking Strategies on a TextBlock[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]publicclassLineStackingStrategySample:Indicator{protectedoverridevoidInitialize(){varstackPanel=newStackPanel{Orientation=Orientation.Vertical,BackgroundColor=Color.Gold,Opacity=0.6,HorizontalAlignment=HorizontalAlignment.Center,VerticalAlignment=VerticalAlignment.Center};varstringBuilder=newStringBuilder();stringBuilder.AppendLine("First line of text");stringBuilder.AppendLine("Second line of text");stringBuilder.AppendLine("Third line of text");stringBuilder.AppendLine("Fourth line of text");stringBuilder.AppendLine("Fifth line of text");stackPanel.AddChild(newTextBlock{Margin=5,Text="LineStackingStrategy = BlockLineHeight:\n"+stringBuilder.ToString(),LineStackingStrategy=LineStackingStrategy.BlockLineHeight,FontWeight=FontWeight.Bold,ForegroundColor=Color.Black});stackPanel.AddChild(newTextBlock{Margin=5,Text="LineStackingStrategy = MaxHeight:\n"+stringBuilder.ToString(),LineStackingStrategy=LineStackingStrategy.MaxHeight,FontWeight=FontWeight.Bold,ForegroundColor=Color.Black});Chart.AddControl(stackPanel);}publicoverridevoidCalculate(intindex){}}}
importclrclr.AddReference("cAlgo.API")fromcAlgo.APIimport*classTest():defget_text_block(self,text,lineStackingStrategy):textBlock=TextBlock()textBlock.Text=texttextBlock.FontWeight=FontWeight.BoldtextBlock.ForegroundColor=Color.BlacktextBlock.Margin=Thickness(5)textBlock.LineStackingStrategy=lineStackingStrategyreturntextBlockdefinitialize(self):stackPanel=StackPanel()stackPanel.Orientation=Orientation.VerticalstackPanel.BackgroundColor=Color.GoldstackPanel.Opacity=0.6stackPanel.HorizontalAlignment=HorizontalAlignment.CenterstackPanel.VerticalAlignment=VerticalAlignment.Centerlines=""" First line of text Second line of text Third line of text Fourth line of text Fifth line of text"""stackPanel.AddChild(self.get_text_block(f"LineStackingStrategy = BlockLineHeight:\n{lines}",LineStackingStrategy.BlockLineHeight))stackPanel.AddChild(self.get_text_block(f"LineStackingStrategy = MaxHeight:\n{lines}",LineStackingStrategy.MaxHeight))api.Chart.AddControl(stackPanel)
Fields
BlockLineHeight
Summary
The stack height is determined by the block element line-height property value.
Signature
1
LineStackingStrategy.BlockLineHeight;
Return Value
LineStackingStrategy
MaxHeight
Summary
The stack height is the smallest value that containing all the inline elements on that line when those elements are properly aligned.