public IEnumerator TextPresenter_ShouldReturnSameTextAsInputedPlusPreviousText_WhenSkipIsActivatedAndIsAdditiveText() { // ARRANGE string previousText = "Hello!"; string speechText = " My <bold> text </bold> have <s> 9 </s> segments"; string expectedOutput = previousText + speechText; IEnumerable <ILineSegment> lineSegments = DialogueTestHelpers.GetListSegments( new[] { " My ", "<bold>", " text ", "</bold>", " have ", "<s>", " 9 ", "</s>", " segments" }); ITextPresenter textPresenter = new TextPresenter( coroutineAccessor: DialogueTestHelpers.GetMockCoroutineAccessor(), lineProcessor: DialogueTestHelpers.GetMockLineProcessor(lineSegments)); textPresenter.Initialize( speech: DialogueTestHelpers.GetMockSpeech(speechText, DialogueTestHelpers.GetMockSpeechSettings()), preppendText: previousText); // ACT textPresenter.Present(); textPresenter.Skip(); while (textPresenter.IsPresenting) { yield return(new WaitForFixedUpdate()); } // ASSERT Assert.AreEqual(expectedOutput, textPresenter.CurrentText); }
protected override void OnTemplateApplied(TemplateAppliedEventArgs e) { base.OnTemplateApplied(e); _presenter = e.NameScope.Get <TextPresenter>("PART_TextPresenter"); ContextMenu = new ContextMenu { DataContext = this, Items = new Avalonia.Controls.Controls() }; var menuItems = (ContextMenu.Items as Avalonia.Controls.Controls); if (IsCopyEnabled) { menuItems.Add(new MenuItem { Header = "Copy", Foreground = ColorTheme.CurrentTheme.Foreground, Command = CopyCommand, Icon = GetCopyPresenter() }); } if (!IsReadOnly) { CreatePasteItem(); menuItems.Add(_pasteItem); } }
public IEnumerator TextPresenter_ShouldReturnSameTextAsInputed_WhenAfterPresenting() { // ARRANGE string speechText = "My <bold> text </bold> have <s> 9 </s> segments"; IEnumerable <ILineSegment> lineSegments = DialogueTestHelpers.GetListSegments( new [] { "My ", "<bold>", " text ", "</bold>", " have ", "<s>", " 9 ", "</s>", " segments" }); ITextPresenter textPresenter = new TextPresenter( coroutineAccessor: DialogueTestHelpers.GetMockCoroutineAccessor(), lineProcessor: DialogueTestHelpers.GetMockLineProcessor(lineSegments)); textPresenter.Initialize( speech: DialogueTestHelpers.GetMockSpeech(speechText, DialogueTestHelpers.GetMockSpeechSettings()), preppendText: string.Empty); // ACT textPresenter.Present(); while (textPresenter.IsPresenting) { yield return(new WaitForFixedUpdate()); } // ASSERT Assert.AreEqual(speechText, textPresenter.CurrentText); }
/// <summary> /// コンストラクタ。 /// </summary> public TextEditorControl() { AutoScaleMode = AutoScaleMode.Font; DoubleBuffered = true; MinimumSize = new Size(300, 100); _presenter = new TextPresenter(new CanvasContext(this), @" { ""ui_colors"": { ""background"": ""#E8E8EC"", ""scrollThumb"": ""#C2C3C9"", ""scrollThumb_active"": ""#222222"", ""scrollArrow"": ""#868999"", ""scrollArrow_active"": ""#222222"", ""scrollArrow_disable"": ""#C2C3C9"", }, ""fonts"": { ""asciiFont"": { ""name"": ""Consolas"", ""height"": 14.0 }, ""jpFont"": { ""name"": ""メイリオ"", ""height"": 12.0 }, }, ""tabWidth"": 4, ""scrollSpeed_vertical"": 3, ""scrollSpeed_horizontal"": 4, ""lineHeightAdjust"": 0, }"); _keyBindings = BindKeys(); Disposed += (s, e) => Disposer.Dispose(_presenter); }
public void TextPresenter_Can_Contain_Null_With_Password_Char_Set() { var target = new TextPresenter { PasswordChar = '*' }; Assert.NotNull(target.FormattedText); }
public void TextPresenter_Can_Contain_Null_WithOut_Password_Char_Set() { using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface)) { var target = new TextPresenter(); Assert.NotNull(target.TextLayout); } }
protected override void OnTemplateApplied(TemplateAppliedEventArgs e) { _presenter = e.NameScope.Get <TextPresenter>("PART_TextPresenter"); _presenter.Cursor = new Cursor(StandardCursorType.Ibeam); if (IsFocused) { _presenter.ShowCaret(); } }
public void Text_Presenter_Replaces_Formatted_Text_With_Password_Char() { var target = new TextPresenter { PasswordChar = '*', Text = "Test" }; Assert.NotNull(target.FormattedText); Assert.Equal("****", target.FormattedText.Text); }
public void TextPresenter_Can_Contain_Null_With_Password_Char_Set() { using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface)) { var target = new TextPresenter { PasswordChar = '*' }; Assert.NotNull(target.FormattedText); } }
public void Text_Presenter_Replaces_Formatted_Text_With_Password_Char() { using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface)) { var target = new TextPresenter { PasswordChar = '*', Text = "Test" }; Assert.NotNull(target.FormattedText); Assert.Equal("****", target.FormattedText.Text); } }
public void SetPresenter(TextPresenter presenter) { _subscription?.Dispose(); _subscription = null; _presenter = presenter; if (_presenter != null) { _subscription = _presenter.GetObservable(TextPresenter.CaretIndexProperty) .Subscribe(OnCaretIndexChanged); } TextViewVisualChanged?.Invoke(this, EventArgs.Empty); CursorRectangleChanged?.Invoke(this, EventArgs.Empty); }
public void Text_Presenter_Replaces_Formatted_Text_With_Password_Char() { using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface)) { var target = new TextPresenter { PasswordChar = '*', Text = "Test" }; target.Measure(Size.Infinity); Assert.NotNull(target.TextLayout); var actual = string.Join(null, target.TextLayout.TextLines.SelectMany(x => x.TextRuns).Select(x => x.Text.Span.ToString())); Assert.Equal("****", actual); } }