protected virtual void Dispose(bool disposing) { if (_isDisposed) { return; } if (disposing) { if (_nativePositive != null) { _nativePositive.Unrealize(); _nativePositive = null; } if (_nativeNeutral != null) { _nativeNeutral.Unrealize(); _nativeNeutral = null; } if (_nativeNegative != null) { _nativeNegative.Unrealize(); _nativeNegative = null; } if (_nativeContent != null) { _nativeContent.Unrealize(); _nativeContent = null; } if (_control != null) { _control.ShowAnimationFinished -= ShowAnimationFinishedHandler; _control.Dismissed -= DismissedHandler; _control.OutsideClicked -= OutsideClickedHandler; _control.BackButtonPressed -= BackButtonPressedHandler; _control.Unrealize(); _control = null; } } _isDisposed = true; }
void UpdateButton() { _bottomButton?.Hide(); if (BottomButton != null) { _bottomButton = new ElmSharp.Button(_popUp) { WeightX = 1.0, WeightY = 1.0, Style = "bottom" }; if (!string.IsNullOrEmpty(BottomButton.Text)) { _bottomButton.Text = BottomButton.Text; } if (!BottomButton.IconImageSource.IsNullOrEmpty()) { var iconSource = BottomButton.IconImageSource as FileImageSource; var buttonImage = new ElmSharp.Image(_bottomButton); buttonImage.LoadAsync(ResourcePath.GetPath(iconSource)); buttonImage.Show(); _bottomButton.SetPartContent("elm.swallow.content", buttonImage); } _bottomButton.Clicked += (s, e) => { ((IMenuItemController)BottomButton).Activate(); }; if (_buttonBgColor != Color.Default) { Log.Debug(FormsCircularUI.Tag, $"InformationPopup set button background color:{_buttonBgColor.ToNative()}"); _bottomButton.BackgroundColor = _buttonBgColor.ToNative(); } } else { _bottomButton.Unrealize(); _bottomButton = null; } _popUp.SetPartContent("button1", _bottomButton); }
void Initialize() { if (_button == null) { _button = new EButton(XForms.NativeParent); _button.BackgroundColor = EColor.Transparent; _button.SetPartColor("effect", EColor.Transparent); _button.SetPartColor("effect_pressed", EColor.Transparent); _button.Show(); _button.Pressed += OnPressed; _button.Released += OnReleased; _button.Clicked += OnClicked; Control.PackEnd(_button); } }
void Initialize() { if (_button == null) { _button = new EButton(XForms.NativeParent); _button.SetTransparentStyle(); _button.Opacity = 0; _button.Show(); _button.Pressed += OnPressed; _button.Released += OnReleased; _button.Clicked += OnClicked; _button.Focused += OnButtonFocused; _button.Unfocused += OnButtonFocused; Control.PackEnd(_button); } }
protected virtual void Dispose(bool disposing) { if (_isDisposed) { return; } if (disposing) { if (_bottomButton != null) { _bottomButton.Unrealize(); _bottomButton = null; } if (_box != null) { _box.Unrealize(); _box = null; } if (_progress != null) { _progress.Unrealize(); _progress = null; } if (_progressLabel != null) { _progressLabel.Unrealize(); _progressLabel = null; } if (_popUp != null) { _layout.Unrealize(); _layout = null; _popUp.BackButtonPressed -= BackButtonPressedHandler; _popUp.Unrealize(); _popUp = null; } } _isDisposed = true; }
internal void Show(Forms.Page sender, SnackBarOptions arguments) { var snackBarDialog = Forms.Platform.Tizen.Native.Dialog.CreateDialog(Forms.Forms.NativeParent, arguments.Actions.Any()); snackBarDialog.Timeout = arguments.Duration.TotalSeconds; var message = arguments.MessageOptions.Message.Replace("&", "&").Replace("<", "<").Replace(">", ">") .Replace(Environment.NewLine, "<br>"); snackBarDialog.Message = message; foreach (var action in arguments.Actions) { var ok = new EButton(snackBarDialog) { Text = action.Text }; snackBarDialog.NeutralButton = ok; ok.Clicked += async(s, evt) => { snackBarDialog.Dismiss(); if (action.Action != null) { await action.Action(); } arguments.SetResult(true); }; } snackBarDialog.TimedOut += (s, evt) => DismissSnackBar(); snackBarDialog.BackButtonPressed += (s, evt) => DismissSnackBar(); snackBarDialog.Show(); void DismissSnackBar() { snackBarDialog.Dismiss(); arguments.SetResult(false); } }
void UpdateFirstButton() { _firstButton?.Hide(); if (FirstButton != null) { _firstButton = new ElmSharp.Button(_popUp) { WeightX = 1.0, WeightY = 1.0, Style = "popup/circle/left" }; if (!string.IsNullOrEmpty(FirstButton.Text)) { _firstButton.Text = FirstButton.Text; } if (FirstButton.Icon != null) { var iconPath = FirstButton.Icon.File; if (!string.IsNullOrEmpty(iconPath)) { var buttonImage = new ElmSharp.Image(_firstButton); buttonImage.LoadAsync(ResourcePath.GetPath(iconPath)); buttonImage.Show(); _firstButton.SetPartContent("elm.swallow.content", buttonImage); } } _firstButton.Clicked += (s, e) => { FirstButton.Activate(); }; } else { _firstButton = null; } _popUp.SetPartContent("button1", _firstButton); }
public void Show(Forms.Page sender, SnackbarArguments arguments) { var snackbarDialog = Forms.Platform.Tizen.Native.Dialog.CreateDialog(Forms.Forms.NativeParent, (arguments.ActionButtonText != null)); snackbarDialog.Timeout = TimeSpan.FromMilliseconds(arguments.Duration).TotalSeconds; var message = arguments.Message.Replace("&", "&").Replace("<", "<").Replace(">", ">") .Replace(Environment.NewLine, "<br>"); snackbarDialog.Message = message; if (!string.IsNullOrEmpty(arguments.ActionButtonText) && arguments.Action != null) { var ok = new EButton(snackbarDialog) { Text = arguments.ActionButtonText }; snackbarDialog.NeutralButton = ok; ok.Clicked += async(s, evt) => { snackbarDialog.Dismiss(); await arguments.Action(); arguments.SetResult(true); }; } snackbarDialog.TimedOut += (s, evt) => { DismissSnackbar(); }; snackbarDialog.BackButtonPressed += (s, evt) => { DismissSnackbar(); }; snackbarDialog.Show(); void DismissSnackbar() { snackbarDialog.Dismiss(); arguments.SetResult(false); } }
protected virtual void Dispose(bool disposing) { if (_isDisposed) { return; } if (disposing) { if (_firstButton != null) { _firstButton.Unrealize(); _firstButton = null; } if (_secondButton != null) { _secondButton.Unrealize(); _secondButton = null; } if (_nativeContent != null) { _nativeContent.Unrealize(); _nativeContent = null; } if (_popUp != null) { _layout.Unrealize(); _layout = null; _popUp.Unrealize(); _popUp = null; } } _isDisposed = true; }
public void Dismiss() { _popUp.Hide(); if (_bottomButton != null) { _bottomButton.Unrealize(); _bottomButton = null; _popUp.SetPartContent("button1", null); } if (_box != null) { _box.Unrealize(); _box = null; } if (_progress != null) { _progress.Unrealize(); _progress = null; } if (_progressLabel != null) { _progressLabel.Unrealize(); _progressLabel = null; } if (_popUp != null) { _layout.Unrealize(); _layout = null; _popUp.BackButtonPressed -= BackButtonPressedHandler; _popUp.Unrealize(); _popUp = null; } }
public static void UpdateContentLayout(this EButton platformButton, Button button) { //TODO : Need to impl }
public HomePage() { InitializeComponent(); #if __IOS__ const string originalText = "Native UILabel."; const string longerText = "Native UILabel. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue."; var uiLabel = new UILabel { MinimumFontSize = 14f, Lines = 0, LineBreakMode = UILineBreakMode.WordWrap, Text = originalText, }; stackLayout.Children.Add(uiLabel); var uiButton = new UIButton(UIButtonType.RoundedRect); uiButton.SetTitle("Change Text", UIControlState.Normal); uiButton.Font = UIFont.FromName("Helvetica", 14f); uiButton.TouchUpInside += (sender, args) => { uiLabel.Text = uiLabel.Text == originalText ? longerText : originalText; uiLabel.SizeToFit(); }; stackLayout.Children.Add(uiButton); var explanation1 = new UILabel { MinimumFontSize = 14f, Lines = 0, LineBreakMode = UILineBreakMode.WordWrap, Text = "The next control is a CustomControl (a customized UILabel with a bad SizeThatFits implementation).", }; stackLayout.Children.Add(explanation1); var brokenControl = new CustomControl { MinimumFontSize = 14, Lines = 0, LineBreakMode = UILineBreakMode.WordWrap, Text = "This control has incorrect sizing - there's empty space above and below it." }; stackLayout.Children.Add(brokenControl); var explanation2 = new UILabel { MinimumFontSize = 14f, Lines = 0, LineBreakMode = UILineBreakMode.WordWrap, Text = "The next control is a CustomControl, but an override to the GetDesiredSize method is passed in when adding the control to the layout.", }; stackLayout.Children.Add(explanation2); var fixedControl = new CustomControl { MinimumFontSize = 14, Lines = 0, LineBreakMode = UILineBreakMode.WordWrap, Text = "This control has correct sizing - there's no empty space above and below it." }; stackLayout.Children.Add(fixedControl, FixSize); #endif #if __ANDROID__ const string originalText = "Native TextView."; const string longerText = "Native TextView. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue."; var textView = new TextView(Forms.Context) { Text = originalText, TextSize = 14 }; textView.SetSingleLine(false); textView.SetLines(3); stackLayout.Children.Add(textView); var button = new Android.Widget.Button(Forms.Context) { Text = "Change Text" }; button.Click += (sender, args) => { textView.Text = textView.Text == originalText ? longerText : originalText; }; stackLayout.Children.Add(button); var explanation1 = new TextView(Forms.Context) { Text = "The next control is a CustomControl (a customized TextView with a bad OnMeasure implementation).", TextSize = 14 }; stackLayout.Children.Add(explanation1); var brokenControl = new CustomControl(Forms.Context) { Text = "This control has incorrect sizing - it doesn't occupy the available width of the device.", TextSize = 14 }; stackLayout.Children.Add(brokenControl); var explanation2 = new TextView(Forms.Context) { Text = "The next control is a CustomControl, but with a custom GetDesiredSize delegate to accomodate it's sizing problem.", TextSize = 14 }; stackLayout.Children.Add(explanation2); var goodControl = new CustomControl(Forms.Context) { Text = "This control has correct sizing - it occupies the available width of the device.", TextSize = 14 }; stackLayout.Children.Add(goodControl, FixSize); #endif #if WINDOWS_PHONE_APP const string originalText = "Native TextBlock."; const string longerText = "Native TextBlock. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue."; var textBlock = new TextBlock { Text = originalText, FontSize = 14, FontFamily = new FontFamily("HelveticaNeue"), TextWrapping = TextWrapping.Wrap }; stackLayout.Children.Add(textBlock); var button = new Windows.UI.Xaml.Controls.Button { Content = "Change Text" }; button.Click += (sender, args) => { textBlock.Text = textBlock.Text == originalText ? longerText : originalText; }; stackLayout.Children.Add(button); var explanation1 = new TextBlock { Text = "The next control is a CustomControl (a customized TextBlock with a bad ArrangeOverride implementation).", FontSize = 14, FontFamily = new FontFamily("HelveticaNeue"), TextWrapping = TextWrapping.Wrap }; stackLayout.Children.Add(explanation1); var brokenControl = new CustomControl { Text = "This control has incorrect sizing - it doesn't occupy the available width of the device." }; stackLayout.Children.Add(brokenControl); var explanation2 = new TextBlock { Text = "The next control is a CustomControl, but an ArrangeOverride delegate is passed in when adding the control to the layout.", FontSize = 14, FontFamily = new FontFamily("HelveticaNeue"), TextWrapping = TextWrapping.Wrap }; stackLayout.Children.Add(explanation2); var fixedControl = new CustomControl { Text = "This control has correct sizing - it occupies the available width of the device." }; stackLayout.Children.Add(fixedControl, arrangeOverrideDelegate: (renderer, finalSize) => { if (finalSize.Width <= 0 || double.IsInfinity(finalSize.Width)) { return(null); } var frameworkElement = renderer.Control; frameworkElement.Arrange(new Rect(0, 0, finalSize.Width * 2, finalSize.Height)); return(finalSize); }); #endif #if WINDOWS_UWP const string originalText = "Native TextBlock."; const string longerText = "Native TextBlock. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue."; var textBlock = new TextBlock { Text = originalText, FontSize = 14, FontFamily = new FontFamily("HelveticaNeue"), TextWrapping = TextWrapping.Wrap }; stackLayout.Children.Add(textBlock); var button = new Windows.UI.Xaml.Controls.Button { Content = "Change Text" }; button.Click += (sender, args) => { textBlock.Text = textBlock.Text == originalText ? longerText : originalText; }; stackLayout.Children.Add(button); var explanation1 = new TextBlock { Text = "The next control is a CustomControl (a customized TextBlock with a bad ArrangeOverride implementation).", FontSize = 14, FontFamily = new FontFamily("HelveticaNeue"), TextWrapping = TextWrapping.Wrap }; stackLayout.Children.Add(explanation1); var brokenControl = new CustomControl { Text = "This control has incorrect sizing - it doesn't occupy the available width of the device." }; stackLayout.Children.Add(brokenControl); var explanation2 = new TextBlock { Text = "The next control is a CustomControl, but an ArrangeOverride delegate is passed in when adding the control to the layout.", FontSize = 14, FontFamily = new FontFamily("HelveticaNeue"), TextWrapping = TextWrapping.Wrap }; stackLayout.Children.Add(explanation2); var fixedControl = new CustomControl { Text = "This control has correct sizing - it occupies the available width of the device." }; stackLayout.Children.Add(fixedControl, arrangeOverrideDelegate: (renderer, finalSize) => { if (finalSize.Width <= 0 || double.IsInfinity(finalSize.Width)) { return(null); } var frameworkElement = renderer.Control; frameworkElement.Arrange(new Rect(0, 0, finalSize.Width * 2, finalSize.Height)); return(finalSize); }); #endif #if __TIZEN__ const string originalText = "Native ElmSharp.Label."; const string longerText = "Native ElmSharp.Label. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue."; var label = new ElmSharp.Label(Tizen.Program.ElmWindow) { Text = originalText, // Line Wrap does not applied to longerText as expected because ElmSharp.Label does not measure itself. LineWrapType = ElmSharp.WrapType.Char }; stackLayout.Children.Add(label); var button = new ElmSharp.Button(Tizen.Program.ElmWindow) { Text = "Change Text" }; button.Clicked += (sender, args) => { label.Text = label.Text == originalText ? longerText : originalText; }; stackLayout.Children.Add(button); var explanation1 = new ElmSharp.Label(Tizen.Program.ElmWindow) { Text = "The next control is a CustomControl (a customized ElmSharp.Label without any measurement method).", LineWrapType = ElmSharp.WrapType.Char, }; // measureDelegate is required to show the line wrap option properly. stackLayout.Children.Add(explanation1, FixSize); var brokenControl = new CustomControl(Tizen.Program.ElmWindow) { Text = "This control has incorrect sizing - there's empty space above and below it.", FontSize = 28 }; stackLayout.Children.Add(brokenControl); var explanation2 = new ElmSharp.Label(Tizen.Program.ElmWindow) { Text = "The next control is a CustomControl, but with a custom GetDesiredSize delegate to accomodate it's sizing problem.", LineWrapType = ElmSharp.WrapType.Word, }; stackLayout.Children.Add(explanation2, FixSize); var goodControl = new CustomControl(Tizen.Program.ElmWindow) { Text = "This control has correct sizing - it occupies the available size of the device - (one two three four five six).", FontSize = 28 }; stackLayout.Children.Add(goodControl, FixSize); #endif }