/* * Purely invalidating the layout as text is added to the TextBox will not cause it to expand. * If the TextBox is set to WordWrap and it is part of the layout it will refuse to Measure itself beyond its established width. * Even giving it infinite constraints will cause it to always set its DesiredSize to the same width but with a vertical growth. * The only way I was able to grow it was by setting layout renderers width explicitly to some value but then it just set its own Width to that Width which is not helpful. * Even vertically it would measure oddly in cases of rapid text changes. * Holding down the backspace key or enter key would cause the final result to be not quite right. * Both of these issues were fixed by just creating a static TextBox that is not part of the layout which let me just measure * the size of the text as it would fit into the TextBox unconstrained and then just return that Size from the GetDesiredSize call. * */ Size GetCopyOfSize(FormsTextBox control, global::Windows.Foundation.Size constraint) { if (_copyOfTextBox == null) { _copyOfTextBox = CreateTextBox(); // This causes the copy to be initially setup correctly. // I found that if the first measure of this copy occurs with Text then it will just keep defaulting to a measure with no text. _copyOfTextBox.Measure(_zeroSize); } _copyOfTextBox.Text = control.Text; _copyOfTextBox.FontSize = control.FontSize; _copyOfTextBox.FontFamily = control.FontFamily; _copyOfTextBox.FontStretch = control.FontStretch; _copyOfTextBox.FontStyle = control.FontStyle; _copyOfTextBox.FontWeight = control.FontWeight; _copyOfTextBox.Margin = control.Margin; _copyOfTextBox.Padding = control.Padding; // have to reset the measure to zero before it will re-measure itself _copyOfTextBox.Measure(_zeroSize); _copyOfTextBox.Measure(constraint); Size result = new Size ( Math.Ceiling(_copyOfTextBox.DesiredSize.Width), Math.Ceiling(_copyOfTextBox.DesiredSize.Height) ); return(result); }
private decimal GetSliderValue(int avatorIdx, EnumVoiceEffect effect) { decimal value = 0.00m; FormsTextBox TargetTextBox = null; AvatorParam_VREX avator = AvatorParams[avatorIdx] as AvatorParam_VREX; switch (effect) { case EnumVoiceEffect.volume: TargetTextBox = avator.AvatorUI.VolumeText; break; case EnumVoiceEffect.speed: TargetTextBox = avator.AvatorUI.SpeedText; break; case EnumVoiceEffect.pitch: TargetTextBox = avator.AvatorUI.PitchText; break; case EnumVoiceEffect.intonation: TargetTextBox = avator.AvatorUI.IntonationText; break; } if (TargetTextBox != null) { value = Convert.ToDecimal(TargetTextBox.Text); } return(value); }
public static void TestKeyboardFlags(this FormsTextBox Control, KeyboardFlags?flags) { if (flags == null) { return; } if (flags.Value.HasFlag(KeyboardFlags.CapitalizeSentence)) { if (!Control.IsSpellCheckEnabled) { throw new global::System.Exception("IsSpellCheckEnabled not enabled"); } } else if (flags.Value.HasFlag(KeyboardFlags.CapitalizeWord)) { if (!Control.InputScope.Names.Select(x => x.NameValue).Contains(InputScopeNameValue.NameOrPhoneNumber)) { throw new global::System.Exception("Input Scope Not Set to NameOrPhoneNumber"); } if (!Control.IsSpellCheckEnabled) { throw new global::System.Exception("IsSpellCheckEnabled not enabled"); } } else { return; } }
public static void SetKeyboardFlags(this FormsTextBox Control, KeyboardFlags?flags) { if (flags == null) { return; } var result = new InputScope(); var value = InputScopeNameValue.Default; if (flags.Value.HasFlag(KeyboardFlags.CapitalizeSentence)) { Control.IsSpellCheckEnabled = true; } else if (flags.Value.HasFlag(KeyboardFlags.CapitalizeWord)) { value = InputScopeNameValue.NameOrPhoneNumber; Control.IsSpellCheckEnabled = true; } else { return; } InputScopeName nameValue = new InputScopeName(); nameValue.NameValue = value; result.Names.Add(nameValue); Control.InputScope = result; }
public SearchFormDriver(WindowControl window, Async async) { Async = async; Window = window; ButtonExecute = new FormsButton(Window.Dynamic()._buttonExecute); TextBoxSearch = new FormsTextBox(Window.Dynamic()._textBoxSearch); ListBoxEmployee = new FormsListBox(Window.Dynamic()._listBoxEmployee); }
public AddFormDriver(WindowControl window, Async async) { Window = window; Async = async; ButtonEntry = new FormsButton(Window.Dynamic()._buttonEntry); TextBoxName = new FormsTextBox(Window.Dynamic()._textBoxName); TextBoxAddress = new FormsTextBox(Window.Dynamic()._textBoxAddress); RadioButtonWoman = new FormsRadioButton(Window.Dynamic()._radioButtonWoman); RadioButtonMan = new FormsRadioButton(Window.Dynamic()._radioButtonMan); }
public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint) { FormsTextBox child = Control; if (Children.Count == 0 || child == null) { return(new SizeRequest()); } return(CalculateDesiredSizes(child, new global::Windows.Foundation.Size(widthConstraint, heightConstraint), Element.AutoSize)); }
public void Test() { var textBox = new FormsTextBox(_form._textBox); var button = new FormsButton(_form._button); textBox.EmulateChangeText("abc"); button.SetFocus(); string err = _form._errorProvider.GetError(_form._textBox); Assert.AreEqual("数字じゃないよ。", err); }
internal static void SetKeyboardEnterButton(FormsTextBox control, ReturnType returnType) { var scopeName = new InputScopeName() { NameValue = GetKeyboardButtonType(returnType) }; var inputScope = new InputScope { Names = { scopeName } }; control.InputScope = inputScope; }
public SearchFormDriver(WindowControl window) { Window = window; SearchButton = new FormsButton(Window.Dynamic().SearchButton); ClearButton = new FormsButton(Window.Dynamic().ClearButton); KeywordText = new FormsTextBox(Window.Dynamic().KeywordText); ExtensionText = new FormsTextBox(Window.Dynamic().ExtensionText); UpdateDate1 = new FwC1DateEdit(Window.Dynamic().UpdateDate1); UpdateDate2 = new FwC1DateEdit(Window.Dynamic().UpdateDate2); ShowPreviewButton = new FormsButton(Window.Dynamic().ShowPreviewButton); TargetIndexGrid = new FwFlexGridEx(Window.Dynamic().TargetIndexGrid); ReslutGrid = new FwFlexGridEx(Window.Dynamic().ReslutGrid); }
protected override void OnAttached() { _control = Control as FormsTextBox; if (_control != null) { _previousBrush = _control.Background; _previousFocusBrush = _control.BackgroundFocusBrush; _previousBorderBrush = _control.BorderBrush; _control.Background = new SolidColorBrush(Colors.Red); _control.BackgroundFocusBrush = new SolidColorBrush(Colors.Red); _control.BorderBrush = new SolidColorBrush(Colors.Red); } }
public IndexBuildFormDriver(WindowControl window, Async async) { Window = window; Async = async; TargetDirText = new FormsTextBox(Window.Dynamic().TargetDirText); ReferenceButton = new FormsButton(Window.Dynamic().ReferenceButton); UpdateIndexButton = new FormsButton(Window.Dynamic().UpdateIndexButton); AddOuterIndexButton = new FormsButton(Window.Dynamic().AddOuterIndexButton); StopButton = new FormsButton(Window.Dynamic().StopButton); ProgressBar = new FormsProgressBar(Window.Dynamic().ProgressBar); ActiveIndexGrid = new FwFlexGridEx(Window.Dynamic().ActiveIndexGrid); IndexHistoryGrid = new FwFlexGridEx(Window.Dynamic().IndexHistoryGrid); }
SizeRequest CalculateDesiredSizes(FormsTextBox control, global::Windows.Foundation.Size constraint, EditorAutoSizeOption sizeOption) { if (sizeOption == EditorAutoSizeOption.TextChanges) { Size result = GetCopyOfSize(control, constraint); control.Measure(constraint); return(new SizeRequest(result)); } else { control.Measure(constraint); Size result = new Size(Math.Ceiling(control.DesiredSize.Width), Math.Ceiling(control.DesiredSize.Height)); return(new SizeRequest(result)); } }
public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint) { if (Children.Count == 0 || Control == null) { return(new SizeRequest()); } var constraint = new global::Windows.Foundation.Size(widthConstraint, heightConstraint); FormsTextBox child = Control; child.Measure(constraint); var result = new Size(Math.Ceiling(child.DesiredSize.Width), Math.Ceiling(child.DesiredSize.Height)); return(new SizeRequest(result)); }
public OuterIndexFormDriver(WindowControl window, Async async) { Window = window; Async = async; OuterStorePathText = new FormsTextBox(Window.Dynamic().OuterStorePathText); OuterTargetPathText = new FormsTextBox(Window.Dynamic().OuterTargetPathText); LocalPathText = new FormsTextBox(Window.Dynamic().LocalPathText); ReferenceButton = new FormsButton(Window.Dynamic().ReferenceButton); OKButton = new FormsButton(Window.Dynamic().OKButton); CancelButton = new FormsButton(Window.Dynamic().CancelButton1); ActiveIndexGrid = new FwFlexGridEx(Window.Dynamic().ActiveIndexGrid); }
public void TestEmulateChangeText() { FormsTextBox textBox = new FormsTextBox(testDlg["textBox"]()); textBox.EmulateChangeText("textBox"); string textBoxText = textBox.Text; Assert.AreEqual("textBox", textBoxText); // 非同期 app[GetType(), "ChangeTextEvent"](textBox.AppVar); textBox.EmulateChangeText("textBox1", new Async()); new NativeMessageBox(testDlg.WaitForNextModal()).EmulateButtonClick("OK"); textBoxText = textBox.Text; Assert.AreEqual("textBox1", textBoxText); }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (Control != null) { if (Element is CustomEntry customEntry) { Control.InputScope = new InputScope() { Names = { new InputScopeName(InputScopeNameValue.Number) } }; } FormsTextBox nativeTextBox = Control; nativeTextBox.PreventKeyboardDisplayOnProgrammaticFocus = false; } }
private void ResetParameters(Val_Talker val_, Dictionary <string, WPFSlider> _interface) { TalkerPrimitive defaultParam = talkerDefaultParamList[val_.talkerRealName]; AvatorParam_VREX avator = AvatorParams[ConvertNametoIndex(val_)] as AvatorParam_VREX; foreach (KeyValuePair <string, EffectValueInfo> val__ in defaultParam.VoiceEffects) { FormsTextBox TargetTextBox = null; double value = 0.00; if (val__.Key == "音量") { TargetTextBox = avator.AvatorUI.VolumeText; value = (double)val__.Value.val; } else if (val__.Key == "話速") { TargetTextBox = avator.AvatorUI.SpeedText; value = (double)val__.Value.val; } else if (val__.Key == "高さ") { TargetTextBox = avator.AvatorUI.PitchText; value = (double)val__.Value.val; } else if (val__.Key == "抑揚") { TargetTextBox = avator.AvatorUI.IntonationText; value = (double)val__.Value.val; } else { break; } if (TargetTextBox != null) { TargetTextBox.EmulateChangeText(string.Format("{0:0.00}", value)); } } }
private void ApplyEffectParameters(Val_Talker val_, Dictionary <string, WPFSlider> _interface) { FormsTextBox TargetTextBox = null; double value = 0.00; AvatorParam_VREX avator = AvatorParams[ConvertNametoIndex(val_)] as AvatorParam_VREX; foreach (var effect in avator.VoiceEffects) { switch (effect.Key) { case EnumVoiceEffect.volume: TargetTextBox = avator.AvatorUI.VolumeText; value = (double)val_.parametor["音量"].val_decimal; break; case EnumVoiceEffect.speed: TargetTextBox = avator.AvatorUI.SpeedText; value = (double)val_.parametor["話速"].val_decimal; break; case EnumVoiceEffect.pitch: TargetTextBox = avator.AvatorUI.PitchText; value = (double)val_.parametor["高さ"].val_decimal; break; case EnumVoiceEffect.intonation: TargetTextBox = avator.AvatorUI.IntonationText; value = (double)val_.parametor["抑揚"].val_decimal; break; } if (TargetTextBox != null) { TargetTextBox.EmulateChangeText(string.Format("{0:0.00}", value)); } } }
static void Assert(string accessPath, FormsTextBox textBox) => CaptureAdaptor.AddCode($"{accessPath}.Text.Is({ToLiteral(textBox.Text)});");