public TVShellSectionRenderer(ShellSection section) { ShellSection = section; ShellSection.PropertyChanged += OnSectionPropertyChanged; (ShellSection.Items as INotifyCollectionChanged).CollectionChanged += OnShellSectionCollectionChanged; _mainLayout = new EBox(Forms.NativeParent); _mainLayout.SetLayoutCallback(OnLayout); _contentArea = new EBox(Forms.NativeParent); _contentArea.Show(); _mainLayout.PackEnd(_contentArea); UpdateSectionItems(); UpdateCurrentItem(ShellSection.CurrentItem); }
public CollectionView(EvasObject parent) : base(parent) { AllowFocus(true); SetLayoutCallback(OnLayout); Scroller = CreateScroller(parent); Scroller.Show(); PackEnd(Scroller); Scroller.Scrolled += OnScrolled; _scrollAnimationStop = new SmartEvent(Scroller, ThemeConstants.Scroller.Signals.StopScrollAnimation); _scrollAnimationStop.On += OnScrollStopped; _innerLayout = new EBox(parent); _innerLayout.SetLayoutCallback(OnInnerLayout); _innerLayout.Show(); Scroller.SetContent(_innerLayout); }
protected override void Dispose(bool disposing) { if (disposing) { if (Element != null) { Element.CurrentPageChanged -= OnCurrentPageChanged; Element.PagesChanged -= OnPagesChanged; _scroller.PageScrolled -= OnPageScrolled; _index.Changed -= OnIndexChanged; } _innerContainer = null; _scroller = null; _index = null; } base.Dispose(disposing); }
public ShellSectionRenderer(ShellSection section) { ShellSection = section; ShellSection.PropertyChanged += OnSectionPropertyChanged; (ShellSection.Items as INotifyCollectionChanged).CollectionChanged += OnShellSectionCollectionChanged; _mainLayout = new EBox(Forms.NativeParent); _mainLayout.SetLayoutCallback(OnLayout); _contentArea = new EBox(Forms.NativeParent); _contentArea.Show(); _mainLayout.PackEnd(_contentArea); UpdateTabsItem(); UpdateCurrentItem(ShellSection.CurrentItem); ((IShellController)Shell.Current).AddAppearanceObserver(this, ShellSection); (ShellSection as IShellSectionController).AddDisplayedPageObserver(this, UpdateDisplayedPage); }
private void Initialize() { _outterLayout = new ElmSharp.Layout(TForms.NativeParent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; _outterLayout.Show(); _outterLayout.SetTheme("layout", "application", "default"); _index = new Index(_outterLayout) { IsHorizontal = true, AutoHide = false, }; _index.Show(); _outterLayout.SetPartContent("elm.swallow.content", _index); _scroller = new Scroller(_outterLayout); _scroller.PageScrolled += OnPageScrolled; // Disables the visibility of the scrollbar in both directions: _scroller.HorizontalScrollBarVisiblePolicy = ElmSharp.ScrollBarVisiblePolicy.Invisible; _scroller.VerticalScrollBarVisiblePolicy = ElmSharp.ScrollBarVisiblePolicy.Invisible; // Sets the limit of scroll to one page maximum: _scroller.HorizontalPageScrollLimit = 1; _scroller.SetPageSize(1.0, 1.0); _scroller.SetAlignment(-1, -1); _scroller.SetWeight(1.0, 1.0); _scroller.Show(); _innerContainer = new Box(_outterLayout); _innerContainer.SetLayoutCallback(OnInnerLayoutUpdate); _innerContainer.SetAlignment(-1, -1); _innerContainer.SetWeight(1.0, 1.0); _innerContainer.Show(); _scroller.SetContent(_innerContainer); _outterLayout.SetPartContent("elm.swallow.bg", _scroller); }
public TVShellSectionHandler(ShellSection section, IMauiContext context) { ShellSection = section; MauiContext = context; ShellSection.PropertyChanged += OnSectionPropertyChanged; if (ShellSection.Items is INotifyCollectionChanged collection) { collection.CollectionChanged += OnShellSectionCollectionChanged; } _mainLayout = new EBox(PlatformParent); _mainLayout.SetLayoutCallback(OnLayout); _contentArea = new EBox(PlatformParent); _contentArea.Show(); _mainLayout.PackEnd(_contentArea); UpdateSectionItems(); UpdateCurrentItem(ShellSection.CurrentItem); }
public ShellItemView(ShellItem item, IMauiContext context) { ShellItem = item; MauiContext = context; //Initialize(); _mainLayout = new EBox(NativeParent); _mainLayout.SetLayoutCallback(OnLayout); _mainLayout.Show(); _contentHolder = new EBox(NativeParent); _contentHolder.Show(); _mainLayout.PackEnd(_contentHolder); ShellItem.PropertyChanged += OnShellItemPropertyChanged; if (ShellItem.Items is INotifyCollectionChanged notifyCollectionChanged) { notifyCollectionChanged.CollectionChanged += OnShellItemsCollectionChanged; } ShellController.AddAppearanceObserver(this, ShellItem); UpdateTabsItems(); UpdateCurrentItem(ShellItem.CurrentItem); }
public ShellSectionHandler(ShellSection section, IMauiContext context) { ShellSection = section; MauiContext = context; ShellSection.PropertyChanged += OnSectionPropertyChanged; if (ShellSection.Items is INotifyCollectionChanged collection) { collection.CollectionChanged += OnShellSectionCollectionChanged; } _mainLayout = new EBox(PlatformParent); _mainLayout.SetLayoutCallback(OnLayout); _contentArea = new EBox(PlatformParent); _contentArea.Show(); _mainLayout.PackEnd(_contentArea); UpdateTabsItem(); UpdateCurrentItem(ShellSection.CurrentItem); ((IShellController)Shell.Current).AddAppearanceObserver(this, ShellSection); (ShellSection as IShellSectionController).AddDisplayedPageObserver(this, UpdateDisplayedPage); }
/// <summary> /// Initializes a new instance of the CarouselView class. /// </summary> #pragma warning disable CS8618 public CollectionView(EvasObject parent) : base(parent) #pragma warning restore CS8618 { AllowFocus(true); SetLayoutCallback(OnLayout); Scroller = new EScroller(parent); Scroller.Show(); PackEnd(Scroller); Scroller.Scrolled += OnScrolled; _scrollAnimationStart = new SmartEvent(Scroller, ThemeConstants.Scroller.Signals.StartScrollAnimation); _scrollAnimationStart.On += OnScrollStarted; _scrollAnimationStop = new SmartEvent(Scroller, ThemeConstants.Scroller.Signals.StopScrollAnimation); _scrollAnimationStop.On += OnScrollStopped; Scroller.DragStart += OnDragStart; Scroller.KeyDown += OnKeyDown; _innerLayout = new EBox(parent); _innerLayout.SetLayoutCallback(OnInnerLayout); _innerLayout.Show(); Scroller.SetContent(_innerLayout); }
public override void Run(ElmSharp.Box parent) { var scrollBox = new ElmSharp.Box(parent) { IsHorizontal = true, WeightX = 1, AlignmentX = -1, MinimumHeight = 100, }; scrollBox.Show(); var menuScroll = new ScrollView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, HorizontalScrollBarVisibility = ScrollBarVisibility.Default, }; menuScroll.Show(); scrollBox.PackEnd(menuScroll); var menu = new ElmSharp.Box(parent) { IsHorizontal = true, WeightX = 1, AlignmentX = -1, MinimumHeight = 100, }; menu.Show(); menuScroll.SetScrollCanvas(menu); menuScroll.SetContentSize(200 * 5, 100); parent.PackEnd(scrollBox); var scrollview = new ScrollView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, }; scrollview.Show(); scrollview.ScrollOrientation = ScrollOrientation.Both; scrollview.VerticalScrollBarVisibility = ScrollBarVisibility.Always; scrollview.HorizontalScrollBarVisibility = ScrollBarVisibility.Always; var scrollCanvas = new ElmSharp.Box(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; scrollCanvas.Show(); scrollview.SetScrollCanvas(scrollCanvas); int itemWidth = 500; int itemHeight = 500; int itemCols = 5; int itemRows = 5; scrollview.SetContentSize(itemWidth * itemCols, itemHeight * itemRows); for (int i = 0; i < itemRows; i++) { var innerContainer = new ElmSharp.Box(parent) { IsHorizontal = true, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; innerContainer.Show(); for (int j = 0; j < itemCols; j++) { var rnd = new Random(); var item = new Rectangle(parent) { MinimumHeight = itemHeight, MinimumWidth = itemWidth, Color = ElmSharp.Color.FromRgb(rnd.Next(10, 255), rnd.Next(10, 255), rnd.Next(10, 255)) }; item.Show(); innerContainer.PackEnd(item); } scrollCanvas.PackEnd(innerContainer); } parent.PackEnd(scrollview); // menu button var scrollToBtn = new Button(parent) { AlignmentY = -1, WeightX = 1, FontSize = 30, Text = "Scroll(rnd)", MinimumWidth = 200, }; scrollToBtn.Show(); scrollToBtn.Clicked += (s, e) => { var rnd = new Random(); scrollview.ScrollToAsync(new Rect(rnd.Next(0, itemCols * itemWidth), rnd.Next(0, itemRows * itemHeight), itemWidth, itemHeight), true); }; menu.PackEnd(scrollToBtn); var vBar = new Button(parent) { AlignmentY = -1, WeightX = 1, FontSize = 30, Text = "V-bar(O)", MinimumWidth = 200, }; vBar.Show(); vBar.Clicked += (s, e) => { if (scrollview.VerticalScrollBarVisibility == ScrollBarVisibility.Always) { vBar.Text = "V-bar(X)"; scrollview.VerticalScrollBarVisibility = ScrollBarVisibility.Never; } else { vBar.Text = "V-bar(O)"; scrollview.VerticalScrollBarVisibility = ScrollBarVisibility.Always; } }; menu.PackEnd(vBar); var hBar = new Button(parent) { AlignmentY = -1, WeightX = 1, FontSize = 30, Text = "H-bar(O)", MinimumWidth = 200, }; hBar.Show(); hBar.Clicked += (s, e) => { if (scrollview.HorizontalScrollBarVisibility == ScrollBarVisibility.Always) { hBar.Text = "H-bar(X)"; scrollview.HorizontalScrollBarVisibility = ScrollBarVisibility.Never; } else { hBar.Text = "H-bar(O)"; scrollview.HorizontalScrollBarVisibility = ScrollBarVisibility.Always; } }; menu.PackEnd(hBar); var vScroll = new Button(parent) { AlignmentY = -1, WeightX = 1, FontSize = 30, Text = "V-Scroll(O)", MinimumWidth = 200, }; vScroll.Show(); vScroll.Clicked += (s, e) => { if (scrollview.ScrollOrientation == ScrollOrientation.Horizontal || scrollview.ScrollOrientation == ScrollOrientation.Neither) { vScroll.Text = "V-Scroll(O)"; scrollview.ScrollOrientation = scrollview.ScrollOrientation == ScrollOrientation.Horizontal ? ScrollOrientation.Both : ScrollOrientation.Vertical; } else { vScroll.Text = "V-Scroll(X)"; scrollview.ScrollOrientation = scrollview.ScrollOrientation == ScrollOrientation.Both ? ScrollOrientation.Horizontal : ScrollOrientation.Neither; } }; menu.PackEnd(vScroll); var hScroll = new Button(parent) { AlignmentY = -1, WeightX = 1, FontSize = 30, Text = "H-Scroll(O)", MinimumWidth = 200, }; hScroll.Show(); hScroll.Clicked += (s, e) => { if (scrollview.ScrollOrientation == ScrollOrientation.Vertical || scrollview.ScrollOrientation == ScrollOrientation.Neither) { hScroll.Text = "H-Scroll(O)"; scrollview.ScrollOrientation = scrollview.ScrollOrientation == ScrollOrientation.Vertical ? ScrollOrientation.Both : ScrollOrientation.Horizontal; } else { hScroll.Text = "H-Scroll(X)"; scrollview.ScrollOrientation = scrollview.ScrollOrientation == ScrollOrientation.Both ? ScrollOrientation.Vertical : ScrollOrientation.Neither; } }; menu.PackEnd(hScroll); }
public override void Run(ElmSharp.Box parent) { var flyoutBox = new ElmSharp.Box(parent); var detailBox = new ElmSharp.Box(parent); var flyoutPage = new FlyoutPage(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, IsPresented = false, Flyout = flyoutBox, Detail = detailBox, }; flyoutPage.DimArea.BackgroundColor = EColor.Blue; flyoutPage.DimArea.Opacity = 100; var list = new GenList(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1 }; GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (data, part) => { return(data as string); } }; for (int i = 0; i < 10; i++) { list.Append(defaultClass, $"Flyout List Item {i}"); } list.Show(); flyoutBox.PackEnd(list); var openLabel = new ElmSharp.Label(parent) { AlignmentX = 0.5, WeightX = 1, Text = $"IsPresented: {flyoutPage.IsPresented}" }; var gestureLabel = new ElmSharp.Label(parent) { AlignmentX = 0.5, WeightX = 1, Text = $"IsGestureEnabled: {flyoutPage.IsGestureEnabled}" }; var behaviorLabel = new ElmSharp.Label(parent) { AlignmentX = 0.5, WeightX = 1, Text = $"FlyoutLayoutBehavior: {flyoutPage.FlyoutLayoutBehavior}" }; var openButton = new ElmSharp.Button(parent) { AlignmentX = -1, WeightX = 1, Text = "Open Flyout" }; var gestureButton = new ElmSharp.Button(parent) { AlignmentX = -1, WeightX = 1, Text = "Enable/Disable Gesture" }; var behaviorButton = new ElmSharp.Button(parent) { AlignmentX = -1, WeightX = 1, Text = "Default/Split Behavior" }; var sRatioButton = new ElmSharp.Button(parent) { AlignmentX = -1, WeightX = 1, Text = "Split ratio + 10" }; var dRatioButton = new ElmSharp.Button(parent) { AlignmentX = -1, WeightX = 1, Text = "popover ratio + 10" }; var sRatioButton2 = new ElmSharp.Button(parent) { AlignmentX = -1, WeightX = 1, Text = "Split ratio - 10" }; var dRatioButton2 = new ElmSharp.Button(parent) { AlignmentX = -1, WeightX = 1, Text = "popover ratio - 10" }; list.ItemSelected += (s, e) => { flyoutPage.IsPresented = false; }; flyoutPage.IsPresentedChanged += (s, e) => { openLabel.Text = $"IsPresented: {flyoutPage.IsPresented}"; }; openButton.Clicked += (s, e) => { flyoutPage.IsPresented = !flyoutPage.IsPresented; }; gestureButton.Clicked += (s, e) => { flyoutPage.IsGestureEnabled = !flyoutPage.IsGestureEnabled; gestureLabel.Text = $"IsGestureEnabled: {flyoutPage.IsGestureEnabled}"; }; sRatioButton.Clicked += (s, e) => { flyoutPage.SplitRatio += 0.1; }; sRatioButton2.Clicked += (s, e) => { flyoutPage.SplitRatio -= 0.1; }; dRatioButton.Clicked += (s, e) => { flyoutPage.PopoverRatio += 0.1; }; dRatioButton2.Clicked += (s, e) => { flyoutPage.PopoverRatio -= 0.1; }; behaviorButton.Clicked += (s, e) => { if (flyoutPage.FlyoutLayoutBehavior == FlyoutLayoutBehavior.Default) { flyoutPage.FlyoutLayoutBehavior = FlyoutLayoutBehavior.Split; } else { flyoutPage.FlyoutLayoutBehavior = FlyoutLayoutBehavior.Default; } behaviorLabel.Text = $"FlyoutLayoutBehavior: {flyoutPage.FlyoutLayoutBehavior}"; openLabel.Text = $"IsPresented: {flyoutPage.IsPresented}"; }; openLabel.Show(); gestureLabel.Show(); behaviorLabel.Show(); openButton.Show(); gestureButton.Show(); behaviorButton.Show(); sRatioButton.Show(); sRatioButton2.Show(); dRatioButton.Show(); dRatioButton2.Show(); detailBox.PackEnd(openLabel); detailBox.PackEnd(gestureLabel); detailBox.PackEnd(behaviorLabel); detailBox.PackEnd(openButton); detailBox.PackEnd(gestureButton); detailBox.PackEnd(behaviorButton); detailBox.PackEnd(sRatioButton); detailBox.PackEnd(sRatioButton2); detailBox.PackEnd(dRatioButton); detailBox.PackEnd(dRatioButton2); flyoutBox.Show(); detailBox.Show(); flyoutPage.Show(); parent.PackEnd(flyoutPage); }
protected override void OnElementChanged(ElementChangedEventArgs <CarouselPage> e) { if (NativeView == null) { _outterLayout = new Box(Forms.NativeParent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; _outterLayout.Show(); _scroller = new Scroller(Forms.NativeParent) { HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible, VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible, HorizontalPageScrollLimit = 1, HorizontalRelativePageSize = 1.0, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; _scroller.PageScrolled += OnPageScrolled; _scroller.Show(); _innerContainer = new Box(Forms.NativeParent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; _innerContainer.SetLayoutCallback(OnInnerLayoutUpdate); _innerContainer.Show(); _scroller.SetContent(_innerContainer); _index = new Index(Forms.NativeParent) { IsHorizontal = true, AutoHide = false, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; _index.Changed += OnIndexChanged; _index.Show(); _outterLayout.SetLayoutCallback(OnOutterLayoutUpdate); _outterLayout.PackEnd(_scroller); _outterLayout.PackEnd(_index); SetNativeView(_outterLayout); } if (e.OldElement != null) { e.OldElement.CurrentPageChanged -= OnCurrentPageChanged; e.OldElement.PagesChanged -= OnPagesChanged; _isInitalized = false; } if (e.NewElement != null) { Element.CurrentPageChanged += OnCurrentPageChanged; Element.PagesChanged += OnPagesChanged; } base.OnElementChanged(e); }
public override void Run(ElmSharp.Box parent) { Console.WriteLine($" run !!!"); var data = new List <string>(); for (int i = 0; i < 50; i++) { data.Add($"item {i}"); } var drawer = new Ext.TVNavigationDrawer(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; var naviView = new Ext.TVNavigationView(parent); var content = new Box(parent) { BackgroundColor = Color.White }; var label = new Label(parent) { AlignmentX = 0.5, WeightX = 1, Text = "selected item index: / data: ", }; label.Show(); content.PackEnd(label); var bLabel = new Label(parent) { AlignmentX = 0.5, WeightX = 1, Text = "behavior: ", }; bLabel.Show(); content.PackEnd(bLabel); var openButton = new Button(parent) { MinimumWidth = 500, Text = "open / close" }; openButton.Show(); content.PackEnd(openButton); var headerButton = new Button(parent) { MinimumWidth = 500, Text = "add / remove header" }; headerButton.Show(); content.PackEnd(headerButton); var footerButton = new Button(parent) { MinimumWidth = 500, Text = "add / remove footer" }; footerButton.Show(); content.PackEnd(footerButton); var contentButton = new Button(parent) { MinimumWidth = 500, Text = "add / remove content" }; contentButton.Show(); content.PackEnd(contentButton); var headerButton2 = new Button(parent) { MinimumHeight = 100, MinimumWidth = 300, Text = "header" }; headerButton2.Show(); content.PackEnd(headerButton2); headerButton2.Clicked += (s, e) => { if (_header.MinimumHeight < 200) { _header.MinimumHeight = 300; } else { _header.MinimumHeight = 150; } }; openButton.Clicked += (s, e) => { drawer.IsOpen = !drawer.IsOpen; }; headerButton.Clicked += (s, e) => { if (naviView.Header != null) { naviView.Header = null; } else { naviView.Header = CreateHeader(parent); } }; footerButton.Clicked += (s, e) => { if (naviView.Footer != null) { naviView.Footer = null; } else { naviView.Footer = CreateFooter(parent); } }; contentButton.Clicked += (s, e) => { if (naviView.Content != null) { naviView.Content = null; } else { naviView.Content = CreateContent(parent); } }; naviView.Header = CreateHeader(parent); naviView.Footer = CreateFooter(parent); naviView.Content = CreateContent(parent); naviView.BackgroundImage = CreateBackgroundImage(parent); //naviView.BackgroundColor = Color.Yellow; drawer.Main = content; drawer.NavigationView = naviView; drawer.Show(); parent.PackEnd(drawer); }
public ElmSharp.EvasObject GetContent(object data, string part) { var minimumHeight = PageHeight > 800 ? 96 : 76; if (part == "elm.swallow.content") { DataSource2 itemSource = (DataSource2)data; ElmSharp.Box mainBox = new ElmSharp.Box(Forms.NativeParent); mainBox.BackgroundColor = Xamarin.Forms.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> {itemSource.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>{itemSource.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 (itemSource.ImageFilename != "") { image = new ElmSharp.Image(right); image.Load(global::Tizen.Applications.Application.Current.DirectoryInfo.Resource + itemSource.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); } return(null); }
public override void Run(ElmSharp.Box parent) { var scrollview = new ScrollView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, }; scrollview.Show(); scrollview.ScrollOrientation = ScrollOrientation.Vertical; parent.PackEnd(scrollview); var scrollCanvas = new ElmSharp.Box(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; scrollCanvas.Show(); scrollview.SetScrollCanvas(scrollCanvas); var img1 = new Image(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, MinimumHeight = 300, }; img1.Show(); img1.LoadAsync(Application.Current.DirectoryInfo.Resource + "image.png"); scrollCanvas.PackEnd(img1); { var label = new Label(parent) { Text = "AspectFill" }; label.Show(); scrollCanvas.PackEnd(label); var img2 = new Image(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, MinimumHeight = 300, }; img2.Show(); img2.Aspect = Aspect.AspectFill; img2.LoadAsync("http://i.imgur.com/9f974SC.jpg"); img2.LoadingCompleted += (s, e) => Console.WriteLine($"Loading completed"); scrollCanvas.PackEnd(img2); } { var label = new Label(parent) { Text = "AppectFit" }; label.Show(); scrollCanvas.PackEnd(label); var img2 = new Image(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, MinimumHeight = 300, }; img2.Show(); img2.Aspect = Aspect.AspectFit; img2.LoadAsync("http://i.imgur.com/9f974SC.jpg"); img2.LoadingCompleted += (s, e) => Console.WriteLine($"Loading completed"); scrollCanvas.PackEnd(img2); } { var label = new Label(parent) { Text = "Fill" }; label.Show(); scrollCanvas.PackEnd(label); var img2 = new Image(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, MinimumHeight = 300, }; img2.Show(); img2.Aspect = Aspect.Fill; img2.LoadAsync("http://i.imgur.com/9f974SC.jpg"); img2.LoadingCompleted += (s, e) => Console.WriteLine($"Loading completed"); scrollCanvas.PackEnd(img2); } { var label = new Label(parent) { Text = "Animated" }; label.Show(); scrollCanvas.PackEnd(label); var animated = new Image(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, MinimumHeight = 300, }; animated.Show(); animated.Aspect = Aspect.AspectFit; animated.LoadAsync(Application.Current.DirectoryInfo.Resource + "animated.gif"); animated.LoadingCompleted += (s, e) => { Console.WriteLine($"Loading completed"); animated.SetIsAnimationPlaying(true); }; scrollCanvas.PackEnd(animated); } { var label = new Label(parent) { Text = "IsAnimationPlaying = false" }; label.Show(); scrollCanvas.PackEnd(label); var img2 = new Image(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, MinimumHeight = 300, }; img2.Show(); img2.Aspect = Aspect.AspectFit; img2.LoadAsync(Application.Current.DirectoryInfo.Resource + "animated2.gif"); img2.LoadingCompleted += (s, e) => { Console.WriteLine($"Loading completed"); (s as Image).SetIsAnimationPlaying(false); }; scrollCanvas.PackEnd(img2); } scrollview.SetContentSize(720, 3000); }
/// <summary> /// Initialize ThumbnailIndex View /// </summary> private void Initialize() { Console.WriteLine("Initialize"); _isFirstItem = true; _pbox = new PaddingBox(Forms.NativeParent) { Padding = new Thickness { Left = 0, Right = 0, Top = 22, Bottom = 0 }, HeaderSize = new ElmSharp.Size(200, 19), HeaderGap = 38 }; _pbox.Show(); _index = new ElmSharp.Index(_pbox) { Style = "thumbnail", AutoHide = false, IsHorizontal = true, AlignmentX = 0.5, AlignmentY = 0.5, }; _index.Show(); _pbox.Header = _index; //index.Geometry = new Rect(0, 22, 200, 19); _scroller = new ElmSharp.Scroller(_pbox) { HorizontalLoop = false, VerticalLoop = false, HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible, VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible, HorizontalPageScrollLimit = 1, VerticalPageScrollLimit = 0, }; _scroller.PageScrolled += (s, e) => { Console.WriteLine($" _scroller PageScrolled"); var pageIndex = _scroller.HorizontalPageIndex; _items[pageIndex].Select(true); }; _scroller.Show(); _pbox.Content = _scroller; //_scroller.Geometry = new Rect(0, 79, 360, 281); var box = new ElmSharp.Box(_scroller) { IsHorizontal = true, AlignmentX = 0.5, AlignmentY = 0.5, }; _scroller.SetContent(box); box.Show(); // Create Rectangle for layout center align in Box var padder = new ElmSharp.Rectangle(box); box.PackEnd(padder); _items.Clear(); // Initialize ThumbnailItems foreach (var item in Element.ThumbnailItems) { // create layout var page = new ElmSharp.Layout(box) { WeightX = 1.0, WeightY = 1.0, AlignmentX = -1.0, AlignmentY = 0.5 }; page.SetTheme("layout", "body_thumbnail", "default"); page.Show(); // set icon var img = new ElmSharp.Image(page); var icon = item.Image; Console.WriteLine($"item.Image File:{icon.File}"); img.LoadAsync(ResourcePath.GetPath(icon.File)); page.SetPartContent("elm.icon", img); var indexItem = _index.Append(null); _items.Add(indexItem); // first item case if (_isFirstItem) { Console.WriteLine($"_isFirstItem is true"); page.Resized += (s, e) => { var g = _scroller.Geometry; var pg = page.Geometry; padder.MinimumWidth = (g.Width - pg.Width) / 2; padder.MinimumHeight = g.Height / 2; _scroller.SetPageSize(pg.Width, pg.Height); }; indexItem.Select(true); } _isFirstItem = false; box.PackEnd(page); } box.PackEnd(padder); _index.Update(0); }
/// <summary> /// Initializes a new instance of the <see cref="Tizen.UIExtensions.ElmSharp.TVNavigationDrawer"/> class. /// </summary> /// <param name="parent"></param> public TVNavigationDrawer(EvasObject parent) : base(parent) { SetLayoutCallback(OnLayout); _drawerBox = new EBox(parent); _drawerBox.Show(); PackEnd(_drawerBox); _mainBox = new EBox(parent); _mainBox.SetLayoutCallback(OnMainBoxLayout); _mainBox.Show(); PackEnd(_mainBox); _focusControlArea = new Button(parent) { Color = EColor.Transparent, BackgroundColor = EColor.Transparent }; _focusControlArea.SetEffectColor(EColor.Transparent); _focusControlArea.Show(); _mainBox.PackEnd(_focusControlArea); _behavior = Common.DrawerBehavior.Drawer; _drawerBox.KeyUp += (s, e) => { if (e.KeyName == "Return" || e.KeyName == "Right") { IsOpen = false; } }; _mainBox.KeyUp += (s, e) => { if (e.KeyName == "Left") { if (_focusControlArea.IsFocused) { IsOpen = true; } } else { // Workaround to prevent unexpected movement of the focus to drawer during page pushing. if (_behavior == DrawerBehavior.Locked) { _drawerBox.AllowTreeFocus = true; } } }; _mainBox.KeyDown += (s, e) => { if (e.KeyName != "Left") { // Workaround to prevent unexpected movement of the focus to drawer during page pushing. if (_behavior == DrawerBehavior.Locked) { _drawerBox.AllowTreeFocus = false; } } }; UpdateFocusPolicy(); }
/// <summary> /// Create EvasObject handler /// </summary> /// <param name="parent">EvasObject</param> /// <returns>Returns box.Handle pointer</returns> protected override IntPtr CreateHandle(EvasObject parent) { _box = new Box(parent); return(_box.Handle); }
void OnActionSheetRequest(Page sender, ActionSheetArguments arguments) { // Verify that the page making the request is child of this platform if (!PageIsInThisContext(sender)) { return; } var alert = Dialog.CreateDialog(MauiContext.GetPlatformParent()); alert.Title = arguments.Title; var box = new EBox(alert); if (null != arguments.Destruction) { var destruction = new TButton(alert) { Text = arguments.Destruction, AlignmentX = -1 }; //TextColor should be set after applying style destruction.TextColor = TColor.Red; destruction.Clicked += (s, evt) => { arguments.SetResult(arguments.Destruction); alert.Dismiss(); }; destruction.Show(); box.PackEnd(destruction); } foreach (string buttonName in arguments.Buttons) { var button = new TButton(alert) { Text = buttonName, AlignmentX = -1 }; button.Clicked += (s, evt) => { arguments.SetResult(buttonName); alert.Dismiss(); }; button.Show(); box.PackEnd(button); } box.Show(); alert.Content = box; if (null != arguments.Cancel) { var cancel = new TButton(alert) { Text = arguments.Cancel }; alert.NegativeButton = cancel; cancel.Clicked += (s, evt) => { alert.Dismiss(); }; } alert.BackButtonPressed += (s, evt) => { alert.Dismiss(); }; alert.Show(); _alerts.Add(alert); alert.Dismissed += (s, e) => _alerts.Remove(alert); }
public override void Run(ElmSharp.Box parent) { var scrollview = new ScrollView(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, }; scrollview.Show(); scrollview.ScrollOrientation = ScrollOrientation.Vertical; parent.PackEnd(scrollview); var scrollCanvas = new ElmSharp.Box(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; scrollCanvas.Show(); scrollview.SetScrollCanvas(scrollCanvas); RadioButton rd1 = new RadioButton(parent) { StateValue = 1, Text = "Value #1", TextColor = Color.Violet, TextBackgroundColor = Color.Yellow, AlignmentX = -1, AlignmentY = 0, WeightX = 1, WeightY = 1 }; rd1.Show(); Radio rd2 = new Radio(parent) { StateValue = 2, Text = "Value #2", AlignmentX = -1, AlignmentY = 0, WeightX = 1, WeightY = 1 }; rd2.Show(); Radio rd3 = new Radio(parent) { StateValue = 3, Text = "Value #3", AlignmentX = -1, AlignmentY = 0, WeightX = 1, WeightY = 1 }; rd3.Show(); rd2.SetGroup(rd1); rd3.SetGroup(rd2); var label = new Label(parent) { AlignmentX = -1, AlignmentY = 0, WeightX = 1, WeightY = 1 }; label.Show(); rd1.ValueChanged += OnRadioValueChanged; rd2.ValueChanged += OnRadioValueChanged; rd3.ValueChanged += OnRadioValueChanged; void OnRadioValueChanged(object sender, EventArgs e) { label.Text = string.Format("Value Changed: {0}", ((Radio)sender).GroupValue); } scrollCanvas.PackEnd(label); scrollCanvas.PackEnd(rd1); scrollCanvas.PackEnd(rd2); scrollCanvas.PackEnd(rd3); scrollview.SetContentSize(720, 3000); }