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; }
void UpdateProcessVisibility() { if (Application.Current.Platform == null) { return; } if (_isProgressRunning) { _box = new ElmSharp.Box(TForms.NativeParent); _box.Show(); _progress = new ElmSharp.ProgressBar(TForms.NativeParent) { Style = "process/popup/small", }; _progress.Show(); _progress.PlayPulse(); _box.PackEnd(_progress); if (!string.IsNullOrEmpty(_text)) { var progressLabel = new ElmSharp.Label(TForms.NativeParent) { TextStyle = "DEFAULT = 'align=center'", }; progressLabel.Text = _text; progressLabel.Show(); _box.PackEnd(progressLabel); } _layout.SetPartContent("elm.swallow.content", _box, true); UpdateTitle(); UpdateText(); } else { _layout.SetPartContent("elm.swallow.content", null, 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 override void Run(ElmSharp.Box parent) { var scrollView = new ScrollView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, VerticalScrollBarVisibility = ScrollBarVisibility.Always, }; scrollView.Show(); var content = new ElmSharp.Box(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, }; scrollView.SetScrollCanvas(content); parent.PackEnd(scrollView); var lineText1 = new ElmSharp.Label(parent) { WeightX = 1, WeightY = 1, Text = "LineView with SolidBrush" }; lineText1.Show(); var line1 = new LineView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, Stroke = new SolidColorBrush(Color.Maroon), StrokeThickness = 5, Aspect = Stretch.Uniform, X1 = 100, Y1 = 0, X2 = 500, Y2 = 300 }; line1.Show(); content.PackEnd(lineText1); content.PackEnd(line1); var lineText2 = new ElmSharp.Label(parent) { WeightX = 1, WeightY = 1, Text = "LineView with GradientBrush" }; lineText2.Show(); var line2 = new LineView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, Stroke = new LinearGradientBrush(new System.Collections.Generic.List <GradientStop>() { new GradientStop(Color.Lavender, 0.2f), new GradientStop(Color.LightSkyBlue, 0.4f), new GradientStop(Color.LightCyan, 0.6f), new GradientStop(Color.LightPink, 0.8f), new GradientStop(Color.YellowGreen, 1.0f), }), StrokeThickness = 15, Aspect = Stretch.Uniform, X1 = 100, Y1 = 300, X2 = 500, Y2 = 100 }; line2.Show(); content.PackEnd(lineText2); content.PackEnd(line2); var lineText3 = new ElmSharp.Label(parent) { WeightX = 1, WeightY = 1, Text = "LineView StrokeDashArray" }; lineText3.Show(); var line3 = new LineView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, Stroke = new SolidColorBrush(Color.PaleGoldenrod), StrokeThickness = 5, Aspect = Stretch.Uniform, X1 = 100, Y1 = 300, X2 = 500, Y2 = 100, StrokeDashArray = new float[] { 9, 3, 5, 3 }, StrokeDashOffset = 5 }; line3.Show(); content.PackEnd(lineText3); content.PackEnd(line3); var lineText4 = new ElmSharp.Label(parent) { WeightX = 1, WeightY = 1, Text = "LineView PenLineCap Test" }; lineText4.Show(); var line4 = new LineView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, Stroke = new SolidColorBrush(Color.Red), StrokeThickness = 15, Aspect = Stretch.Uniform, X1 = 100, Y1 = 300, X2 = 500, Y2 = 100 }; line4.Show(); content.PackEnd(lineText4); content.PackEnd(line4); var lineCapButton = new Button(parent) { Text = "Change PenLineCap", WeightX = 0.5, WeightY = 0.3, AlignmentY = -1, AlignmentX = -1, }; lineCapButton.Show(); lineCapButton.Clicked += (s, e) => { switch (line4.StrokeLineCap) { case (PenLineCap.Flat): line4.StrokeLineCap = PenLineCap.Round; break; case (PenLineCap.Round): line4.StrokeLineCap = PenLineCap.Square; break; case (PenLineCap.Square): line4.StrokeLineCap = PenLineCap.Flat; break; } }; content.PackEnd(lineCapButton); }
public override void Run(ElmSharp.Box parent) { var scrollView = new ScrollView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, VerticalScrollBarVisibility = ScrollBarVisibility.Always, }; scrollView.Show(); var content = new ElmSharp.Box(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, }; scrollView.SetScrollCanvas(content); parent.PackEnd(scrollView); var rectText1 = new ElmSharp.Label(parent) { WeightX = 1, WeightY = 1, Text = "RectView with SolidBrush" }; rectText1.Show(); var rect1 = new RectView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, Stroke = new SolidColorBrush(Color.Maroon), StrokeThickness = 5, Fill = new SolidColorBrush(Color.Lavender), Aspect = Stretch.Uniform, }; rect1.Show(); content.PackEnd(rectText1); content.PackEnd(rect1); var rectText2 = new ElmSharp.Label(parent) { WeightX = 1, WeightY = 1, Text = "RectView with GradientBrush" }; rectText2.Show(); var rect2 = new RectView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, Stroke = new LinearGradientBrush(new System.Collections.Generic.List <GradientStop>() { new GradientStop(Color.Lavender, 0.2f), new GradientStop(Color.LightSkyBlue, 0.4f), new GradientStop(Color.LightCyan, 0.6f), new GradientStop(Color.LightPink, 0.8f), new GradientStop(Color.YellowGreen, 1.0f), }), Fill = new RadialGradientBrush(new System.Collections.Generic.List <GradientStop>() { new GradientStop(Color.YellowGreen, 0.2f), new GradientStop(Color.LightPink, 0.4f), new GradientStop(Color.LightCyan, 0.6f), new GradientStop(Color.LightSkyBlue, 0.8f), new GradientStop(Color.Lavender, 1.0f), }), StrokeThickness = 15, Aspect = Stretch.Fill, }; rect2.Show(); content.PackEnd(rectText2); content.PackEnd(rect2); var rectText3 = new ElmSharp.Label(parent) { WeightX = 1, WeightY = 1, Text = "RectView Aspect Test" }; rectText3.Show(); var rect3 = new RectView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, Stroke = new SolidColorBrush(Color.PaleGoldenrod), StrokeThickness = 5, Fill = new SolidColorBrush(Color.MediumPurple), Aspect = Stretch.Fill, RadiusX = 120, RadiusY = 120 }; rect3.Show(); content.PackEnd(rectText3); content.PackEnd(rect3); }
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 }
protected override ElmSharp.EvasObject OnGetContent(Cell cell, string part) { if (part != MainContentPart) { return(null); } NativeCell viewCell = (NativeCell)cell; var minimumHeight = PageHeight > 800 ? 96 : 76; ElmSharp.Box mainBox = new ElmSharp.Box(Forms.NativeParent); mainBox.BackgroundColor = Color.LightYellow.ToNative(); mainBox.MinimumHeight = minimumHeight; mainBox.IsHorizontal = false; mainBox.SetAlignment(-1, -1); mainBox.Show(); ElmSharp.Box contentBox = new ElmSharp.Box(Forms.NativeParent); contentBox.MinimumHeight = minimumHeight; contentBox.IsHorizontal = true; contentBox.SetAlignment(-1, -1); contentBox.Show(); ElmSharp.Box left = new ElmSharp.Box(Forms.NativeParent); left.IsHorizontal = false; left.Show(); left.SetWeight(4.0, 1); left.SetAlignment(-1, -1); contentBox.PackEnd(left); ElmSharp.Label titleName = new ElmSharp.Label(Forms.NativeParent); left.PackEnd(titleName); titleName.Show(); titleName.Text = $"<span font_size=34 font_style=italic color=#7F3300> {viewCell.Name}</span>"; titleName.MinimumWidth = 250; titleName.SetAlignment(-1, -1); ElmSharp.Label titleCategory = new ElmSharp.Label(Forms.NativeParent); left.PackEnd(titleCategory); titleCategory.Show(); titleCategory.Text = $"<span align=center font_size=24 color=#008000>{viewCell.Category}</span>"; titleCategory.SetAlignment(-1, -1); ElmSharp.Box right = new ElmSharp.Box(Forms.NativeParent); right.Show(); right.MinimumWidth = 96; right.MinimumHeight = minimumHeight; right.SetWeight(1, 1); right.SetAlignment(-1, 0); ElmSharp.Image image; if (viewCell.ImageFilename != "") { image = new ElmSharp.Image(right); image.Load(global::Tizen.Applications.Application.Current.DirectoryInfo.Resource + viewCell.ImageFilename + ".jpg"); image.SetAlignment(0.5, 0.5); image.MinimumHeight = minimumHeight; image.MinimumWidth = minimumHeight; image.Show(); right.PackEnd(image); } ElmSharp.Rectangle rec = new ElmSharp.Rectangle(left); rec.MinimumHeight = 1; rec.MinimumWidth = 400; rec.AlignmentX = -1; rec.Color = ElmSharp.Color.Gray; rec.Show(); contentBox.PackEnd(right); mainBox.PackEnd(contentBox); mainBox.PackEnd(rec); return(mainBox); }
public override void Run(ElmSharp.Box parent) { var scrollView = new ScrollView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, VerticalScrollBarVisibility = ScrollBarVisibility.Always, }; scrollView.Show(); var content = new ElmSharp.Box(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, }; scrollView.SetScrollCanvas(content); parent.PackEnd(scrollView); var ellipseText1 = new ElmSharp.Label(parent) { WeightX = 1, WeightY = 1, Text = "EllipseView with SolidBrush" }; ellipseText1.Show(); var ellipse1 = new EllipseView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, Stroke = new SolidColorBrush(Color.Maroon), StrokeThickness = 5, Fill = new SolidColorBrush(Color.Lavender), Aspect = Stretch.Uniform, }; ellipse1.Show(); content.PackEnd(ellipseText1); content.PackEnd(ellipse1); var ellipseText2 = new ElmSharp.Label(parent) { WeightX = 1, WeightY = 1, Text = "EllipseView with GradientBrush" }; ellipseText2.Show(); var ellipse2 = new EllipseView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, Stroke = new LinearGradientBrush(new System.Collections.Generic.List <GradientStop>() { new GradientStop(Color.Lavender, 0.2f), new GradientStop(Color.LightSkyBlue, 0.4f), new GradientStop(Color.LightCyan, 0.6f), new GradientStop(Color.LightPink, 0.8f), new GradientStop(Color.YellowGreen, 1.0f), }), Fill = new RadialGradientBrush(new System.Collections.Generic.List <GradientStop>() { new GradientStop(Color.YellowGreen, 0.2f), new GradientStop(Color.LightPink, 0.4f), new GradientStop(Color.LightCyan, 0.6f), new GradientStop(Color.LightSkyBlue, 0.8f), new GradientStop(Color.Lavender, 1.0f), }), StrokeThickness = 15, Aspect = Stretch.Fill, }; ellipse2.Show(); content.PackEnd(ellipseText2); content.PackEnd(ellipse2); var ellipseText3 = new ElmSharp.Label(parent) { WeightX = 1, WeightY = 1, Text = "EllipseView Aspect Test" }; ellipseText3.Show(); var ellipse3 = new EllipseView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, Stroke = new SolidColorBrush(Color.PaleGoldenrod), StrokeThickness = 5, Fill = new SolidColorBrush(Color.MediumPurple), Aspect = Stretch.Fill }; ellipse3.Show(); var aspectButton = new Button(parent) { Text = "Change Aspect", WeightX = 0.5, WeightY = 0.5, AlignmentY = -1, AlignmentX = -1, }; aspectButton.Show(); aspectButton.Clicked += (s, e) => { switch (ellipse3.Aspect) { case (Stretch.Fill): ellipse3.Aspect = Stretch.Uniform; break; case (Stretch.Uniform): ellipse3.Aspect = Stretch.UniformToFill; break; case (Stretch.UniformToFill): ellipse3.Aspect = Stretch.Fill; break; } }; content.PackEnd(ellipseText3); content.PackEnd(ellipse3); content.PackEnd(aspectButton); }