public void TextWrappingTest() { EnglishTextWrapping englishWrapping = new EnglishTextWrapping(8); List <string> wrappedLines = englishWrapping.WrapSingleLineOnWidth("Layers or MM", 30); Assert.IsTrue(wrappedLines.Count == 3); Assert.IsTrue(wrappedLines[0] == "Layer"); Assert.IsTrue(wrappedLines[1] == "s or"); Assert.IsTrue(wrappedLines[2] == "MM"); }
public void AddTextField(string instructionsText, int pixelsFromLast) { GuiWidget spacer = new GuiWidget(10, pixelsFromLast); topToBottomControls.AddChild(spacer); EnglishTextWrapping wrapper = new EnglishTextWrapping(12); string wrappedInstructions = wrapper.InsertCRs(instructionsText, 400); string wrappedInstructionsTabsToSpaces = wrappedInstructions.Replace("\t", " "); TextWidget instructionsWidget = new TextWidget(wrappedInstructionsTabsToSpaces, textColor: ActiveTheme.Instance.PrimaryTextColor); instructionsWidget.HAnchor = Agg.UI.HAnchor.ParentLeft; topToBottomControls.AddChild(instructionsWidget); }
private void AdjustTextWrap() { if (textWidget != null) { if (Width > 0) { EnglishTextWrapping wrapper = new EnglishTextWrapping(textWidget.Printer.TypeFaceStyle.EmSizeInPoints); string wrappedMessage = wrapper.InsertCRs(unwrappedText, Width); textWidget.Text = wrappedMessage; } } }
private void AdjustTextWrap() { if (messageContainer != null) { double wrappingSize = middleRowContainer.Width - (middleRowContainer.Padding.Width + messageContainer.Margin.Width); if (wrappingSize > 0) { EnglishTextWrapping wrapper = new EnglishTextWrapping(12 * extraTextScaling * GuiWidget.DeviceScale); string wrappedMessage = wrapper.InsertCRs(unwrappedMessage, wrappingSize); messageContainer.Text = wrappedMessage; } } }
private void AdjustTextWrap() { if (messageContainer != null) { double wrappingSize = this.Width - this.Padding.Width; if (wrappingSize > 0) { EnglishTextWrapping wrapper = new EnglishTextWrapping(messageContainer.Printer.TypeFaceStyle.EmSizeInPoints); string wrappedMessage = wrapper.InsertCRs(unwrappedMessage, wrappingSize); messageContainer.Text = wrappedMessage; } } }
private FlowLayoutWidget GetHelpTextWidget() { FlowLayoutWidget allText = new FlowLayoutWidget(FlowDirection.TopToBottom); double textRegionWidth = 260 * TextWidget.GlobalPointSizeScaleRatio; allText.Margin = new BorderDouble(3) * TextWidget.GlobalPointSizeScaleRatio; allText.Padding = new BorderDouble(3) * TextWidget.GlobalPointSizeScaleRatio; allText.HAnchor = HAnchor.ParentLeftRight; allText.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay; double helpPointSize = 10; EnglishTextWrapping wrapper = new EnglishTextWrapping(helpPointSize); string[] wrappedText = wrapper.WrapText(HelpText, textRegionWidth - allText.Padding.Width); foreach (string line in wrappedText) { GuiWidget helpWidget = new TextWidget(line, pointSize: helpPointSize, textColor: RGBA_Bytes.White); allText.AddChild(helpWidget); } allText.MinimumSize = new Vector2(textRegionWidth, allText.MinimumSize.y); allText.Visible = false; return allText; }
private void AddInHelpText(FlowLayoutWidget topToBottomSettings, OrganizerSettingsData settingInfo) { FlowLayoutWidget allText = new FlowLayoutWidget(FlowDirection.TopToBottom); double textRegionWidth = 380; allText.Margin = new BorderDouble(3); allText.Padding = new BorderDouble(5); allText.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay; double helpPointSize = 10; EnglishTextWrapping wrapper = new EnglishTextWrapping(helpPointSize); string[] wrappedText = wrapper.WrapText(settingInfo.HelpText, textRegionWidth - allText.Padding.Width); foreach (string line in wrappedText) { GuiWidget helpWidget = new TextWidget(line, pointSize: helpPointSize, textColor: RGBA_Bytes.White); helpWidget.Margin = new BorderDouble(5, 0, 0, 0); helpWidget.HAnchor = HAnchor.ParentLeft; allText.AddChild(helpWidget); } allText.MinimumSize = new Vector2(textRegionWidth, allText.MinimumSize.y); if (wrappedText.Length > 0) { topToBottomSettings.AddChild(allText); } }