public TextBox(IPropertyEngine propertyEngine) : base(propertyEngine) { RegistrationGuard.RegisterFor <TextBox>(() => { TextWrappingProperty = PropertyEngine.RegisterProperty("TextWrapping", typeof(TextBox), typeof(TextWrapping), new PropertyMetadata { DefaultValue = TextWrapping.NoWrap }); ForegroundProperty = PropertyEngine.RegisterProperty("Foreground", typeof(TextBox), typeof(Brush), new PropertyMetadata { DefaultValue = new Brush(Colors.Black) }); TextProperty = PropertyEngine.RegisterProperty("Text", typeof(TextBox), typeof(string), new PropertyMetadata { DefaultValue = null }); FontFamilyProperty = PropertyEngine.RegisterProperty("FontFamily", typeof(TextBox), typeof(float), new PropertyMetadata { DefaultValue = "Arial" }); FontWeightProperty = PropertyEngine.RegisterProperty("FontWeight", typeof(TextBox), typeof(float), new PropertyMetadata { DefaultValue = FontWeights.Normal }); FontSizeProperty = PropertyEngine.RegisterProperty("FontSize", typeof(TextBox), typeof(float), new PropertyMetadata { DefaultValue = 16F }); }); NotifyRenderAffectedBy(TextProperty); GetChangedObservable(TextProperty).Subscribe(t => Text = (string)t); Children.OnChildAdded(AttachToTextBoxView); }
public TextBoxView(IPropertyEngine propertyEngine) : base(propertyEngine) { RegistrationGuard.RegisterFor <TextBoxView>(() => TextProperty = PropertyEngine.RegisterProperty("Text", typeof(TextBoxView), typeof(string), new PropertyMetadata { DefaultValue = null })); var changedObservable = GetChangedObservable(TextProperty); Pointer.Down.Subscribe(point => { Platform.Current.EventSource.ShowVirtualKeyboard(); Platform.Current.SetFocusedElement(this); }); Keyboard.KeyInput.Where(Filter).Subscribe(args => AddText(args.Text)); Keyboard.SpecialKeys.Subscribe(ProcessSpecialKey); NotifyRenderAffectedBy(TextProperty); Platform.Current.FocusedElement.Select(layout => layout == this) .Subscribe(isFocused => IsFocused = isFocused); changedSubscription = changedObservable .Subscribe(o => { FormattedText.Text = (string)o; EnforceCursorLimits(); Invalidate(); }); }
public Image(IPropertyEngine propertyEngine) : base(propertyEngine) { RegistrationGuard.RegisterFor <Image>(() => { StretchProperty = PropertyEngine.RegisterProperty("Stretch", typeof(Image), typeof(Stretch), new PropertyMetadata { DefaultValue = Stretch.Uniform }); SourceProperty = PropertyEngine.RegisterProperty("Source", typeof(Image), typeof(Bitmap), new PropertyMetadata() { DefaultValue = null }); }); }
public Button(IPropertyEngine propertyEngine) : base(propertyEngine) { RegistrationGuard.RegisterFor <Button>(() => { CommandProperty = PropertyEngine.RegisterProperty("Command", typeof(Button), typeof(ICommand), new PropertyMetadata()); }); Pointer.Down.Subscribe(p => { if (Command?.CanExecute(null) == true) { Command.Execute(null); } }); }
public TextBlock(IPropertyEngine propertyEngine) : base(propertyEngine) { RegistrationGuard.RegisterFor <TextBlock>(() => { TextProperty = PropertyEngine.RegisterProperty("Text", typeof(TextBlock), typeof(string), new PropertyMetadata { DefaultValue = null }); FontFamilyProperty = PropertyEngine.RegisterProperty("FontFamily", typeof(TextBlock), typeof(float), new PropertyMetadata { DefaultValue = "Arial" }); FontWeightProperty = PropertyEngine.RegisterProperty("FontWeight", typeof(TextBlock), typeof(float), new PropertyMetadata { DefaultValue = FontWeights.Normal }); FontSizeProperty = PropertyEngine.RegisterProperty("FontSize", typeof(TextBlock), typeof(float), new PropertyMetadata { DefaultValue = 14F }); }); Foreground = new Brush(Colors.Black); GetChangedObservable(TextProperty).Subscribe(t => Text = (string)t); NotifyRenderAffectedBy(TextProperty); }