protected override void Dispose(bool disposing) { if (_isDisposed) { return; } _isDisposed = true; if (disposing) { if (Control != null) { Control.SetOnClickListener(null); Control.SetOnTouchListener(null); Control.RemoveOnAttachStateChangeListener(this); _textColorSwitcher = null; } _backgroundTracker?.Dispose(); _backgroundTracker = null; _buttonLayoutManager?.Dispose(); _buttonLayoutManager = null; } base.Dispose(disposing); }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { if (e.OldElement != null) { ((ObservableList <string>)e.OldElement.Items).CollectionChanged -= RowsCollectionChanged; } if (e.NewElement != null) { ((ObservableList <string>)e.NewElement.Items).CollectionChanged += RowsCollectionChanged; if (Control == null) { EditText textField = CreateNativeControl(); textField.Focusable = false; textField.Clickable = true; textField.Tag = this; textField.InputType = InputTypes.Null; textField.SetOnClickListener(PickerListener.Instance); _textColorSwitcher = new TextColorSwitcher(textField.TextColors); SetNativeControl(textField); } UpdatePicker(); UpdateTextColor(); } base.OnElementChanged(e); }
protected override void OnElementChanged(ElementChangedEventArgs <Button> e) { base.OnElementChanged(e); if (e.OldElement != null) { } if (e.NewElement != null) { if (Control == null) { AppCompatButton button = CreateNativeControl(); button.SetOnClickListener(ButtonClickListener.Instance.Value); button.SetOnTouchListener(ButtonTouchListener.Instance.Value); button.Tag = this; _textColorSwitcher = new TextColorSwitcher(button.TextColors); SetNativeControl(button); button.AddOnAttachStateChangeListener(this); } UpdateAll(); UpdateBackgroundColor(); } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { if (e.OldElement != null) { ((INotifyCollectionChanged)e.OldElement.Items).CollectionChanged -= RowsCollectionChanged; } if (e.NewElement != null) { ((INotifyCollectionChanged)e.NewElement.Items).CollectionChanged += RowsCollectionChanged; if (Control == null) { var textField = CreateNativeControl(); var useLegacyColorManagement = e.NewElement.UseLegacyColorManagement(); _textColorSwitcher = new TextColorSwitcher(textField.TextColors, useLegacyColorManagement); SetNativeControl(textField); } UpdateFont(); UpdatePicker(); UpdateTextColor(); } base.OnElementChanged(e); }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { if (e.OldElement != null) { ((INotifyCollectionChanged)e.OldElement.Items).CollectionChanged -= RowsCollectionChanged; } if (e.NewElement != null) { ((INotifyCollectionChanged)e.NewElement.Items).CollectionChanged += RowsCollectionChanged; if (Control == null) { EditText textField = CreateNativeControl(); textField.Focusable = true; textField.Clickable = true; textField.Tag = this; textField.InputType = InputTypes.Null; textField.KeyPress += TextFieldKeyPress; textField.SetOnClickListener(PickerListener.Instance); var useLegacyColorManagement = e.NewElement.UseLegacyColorManagement(); _textColorSwitcher = new TextColorSwitcher(textField.TextColors, useLegacyColorManagement); SetNativeControl(textField); } UpdateFont(); UpdatePicker(); UpdateTextColor(); } base.OnElementChanged(e); }
protected override void OnElementChanged(ElementChangedEventArgs <Button> e) { base.OnElementChanged(e); if (e.NewElement != null) { if (Control == null) { AppCompatButton button = CreateNativeControl(); button.SetOnClickListener(ButtonClickListener.Instance.Value); button.SetOnTouchListener(ButtonTouchListener.Instance.Value); button.Tag = this; var useLegacyColorManagement = e.NewElement.UseLegacyColorManagement(); _textColorSwitcher = new TextColorSwitcher(button.TextColors, useLegacyColorManagement); SetNativeControl(button); button.AddOnAttachStateChangeListener(this); } _defaultFontSize = 0f; _defaultPadding = null; UpdateAll(); } }
public static Color GetRandomObstacleColor() { if (!isInitialized) { Init(); } Color[] randColorBlock = colorsDB[Random.Range(0, colorsDB.Count)]; Color backgroundColor = randColorBlock[3]; Color obstacleColor = randColorBlock[2]; Color playerColor = randColorBlock[1]; Color textColor = randColorBlock[0]; TextColorSwitcher.ChangeColor(textColor); PlayerController.ChangeColor(playerColor); CameraController.SetNewBackgroundColor(backgroundColor); return(obstacleColor); }
protected override void Dispose(bool disposing) { if (_isDisposed) { return; } _isDisposed = true; if (disposing) { if (Control != null) { Control.SetOnClickListener(null); Control.RemoveOnAttachStateChangeListener(this); Control.Tag = null; _textColorSwitcher = null; } } base.Dispose(disposing); }
protected override void OnElementChanged(ElementChangedEventArgs <Button> e) { base.OnElementChanged(e); if (e.OldElement != null) { } if (e.NewElement != null) { if (Control == null) { AppCompatButton button = CreateNativeControl(); button.SetOnClickListener(ButtonClickListener.Instance.Value); button.SetOnTouchListener(ButtonTouchListener.Instance.Value); button.Tag = this; var useLegacyColorManagement = e.NewElement.UseLegacyColorManagement(); _textColorSwitcher = new TextColorSwitcher(button.TextColors, useLegacyColorManagement); SetNativeControl(button); button.AddOnAttachStateChangeListener(this); } if (_backgroundTracker == null) { _backgroundTracker = new ButtonBackgroundTracker(Element, Control); } else { _backgroundTracker.Button = e.NewElement; } UpdateAll(); } }
protected override void OnElementChanged(ElementChangedEventArgs <Button> e) { base.OnElementChanged(e); if (e.NewElement != null) { if (Control == null) { AppCompatButton button = CreateNativeControl(); button.SetOnClickListener(this); button.SetOnTouchListener(this); button.AddOnAttachStateChangeListener(this); _textColorSwitcher = new TextColorSwitcher(button.TextColors, e.NewElement.UseLegacyColorManagement()); SetNativeControl(button); } _defaultFontSize = 0f; _buttonLayoutManager?.Update(); UpdateAll(); } }
void IVisualElementRenderer.SetElement(VisualElement element) { if (element == null) { throw new ArgumentNullException(nameof(element)); } if (!(element is Entry)) { throw new ArgumentException($"{nameof(element)} must be of type {nameof(Entry)}"); } VisualElement oldElement = Entry; Entry = (Entry)element; Performance.Start(out string reference); if (oldElement != null) { oldElement.PropertyChanged -= OnElementPropertyChanged; oldElement.FocusChangeRequested -= OnFocusChangeRequested; } if (oldElement == null) { _textInputEditText = new MaterialFormsEditText(Context); AddView(_textInputEditText); _textInputEditText.FocusChange += _textInputEditText_FocusChange; Hint = Entry.Placeholder; _textInputEditText.AddTextChangedListener(this); _textInputEditText.SetOnEditorActionListener(this); _textInputEditText.OnKeyboardBackPressed += OnKeyboardBackPressed; _textInputEditText.SelectionChanged += SelectionChanged; var useLegacyColorManagement = Entry.UseLegacyColorManagement(); _textColorSwitcher = new TextColorSwitcher(_textInputEditText.TextColors, useLegacyColorManagement); _hintColorSwitcher = new TextColorSwitcher(_textInputEditText.HintTextColors, useLegacyColorManagement); } // When we set the control text, it triggers the SelectionChanged event, which updates CursorPosition and SelectionLength; // These one-time-use variables will let us initialize a CursorPosition and SelectionLength via ctor/xaml/etc. _cursorPositionChangePending = Element.IsSet(Entry.CursorPositionProperty); _selectionLengthChangePending = Element.IsSet(Entry.SelectionLengthProperty); Hint = Entry.Placeholder; _textInputEditText.Text = Entry.Text; UpdateInputType(); UpdateColor(); UpdateAlignment(); UpdateFont(); UpdatePlaceholderColor(true); UpdateMaxLength(); UpdateImeOptions(); UpdateReturnType(); UpdateBackgroundColor(); if (_cursorPositionChangePending || _selectionLengthChangePending) { UpdateCursorSelection(); } element.PropertyChanged += OnElementPropertyChanged; if (_tracker == null) { _tracker = new VisualElementTracker(this); } element.SendViewInitialized(this); EffectUtilities.RegisterEffectControlProvider(this, oldElement, element); Performance.Stop(reference); ElementChanged?.Invoke(this, new VisualElementChangedEventArgs(oldElement, element)); element.FocusChangeRequested += OnFocusChangeRequested; }
protected override void UpdateTextColor() { _textColorSwitcher = _textColorSwitcher ?? new TextColorSwitcher(EditText.TextColors, Element.UseLegacyColorManagement()); _textColorSwitcher.UpdateTextColor(EditText, Element.TextColor); }
protected override void UpdateTitleColor() { _hintColorSwitcher = _hintColorSwitcher ?? new TextColorSwitcher(EditText.HintTextColors, Element.UseLegacyColorManagement()); _hintColorSwitcher.UpdateTextColor(EditText, Element.TitleColor, EditText.SetHintTextColor); }
//------------------------ public static void SetNewTextColor(Color color) { TextColorSwitcher.ChangeColor(color); }
private void UpdateTextColor() { _textColorSwitcher = _textColorSwitcher ?? new TextColorSwitcher(Control.TextColors, false); _textColorSwitcher.UpdateTextColor(Control, Element.TextColor); }