public override void Run(Window window) { Conformant conformant = new Conformant(window); conformant.Show(); GenList list = new GenList(window) { Homogeneous = true }; GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (obj, part) => { return(string.Format("{0} - {1}", (string)obj, part)); } }; for (int i = 0; i < 100; i++) { list.Append(defaultClass, string.Format("{0} Item", i)); } list.Show(); list.ItemSelected += List_ItemSelected;; list.ItemActivated += List_ItemActivated; list.ItemUnselected += List_ItemUnselected; list.ItemPressed += List_ItemPressed; list.ItemRealized += List_ItemRealized; list.ItemReleased += List_ItemReleased; list.ItemUnrealized += List_ItemUnrealized; list.ItemLongPressed += List_ItemLongPressed; list.ItemDoubleClicked += List_ItemDoubleClicked; list.Geometry = window.GetInnerSquare(); }
/// <summary> /// Gets the item class used for header and footer cells. /// </summary> /// <returns>The header and footer item class.</returns> GenItemClass GetHeaderFooterItemClass() { if (_headerFooterItemClass == null) { _headerFooterItemClass = new GenItemClass("full") { GetContentHandler = (data, part) => { VisualElement element = data as VisualElement; var renderer = Platform.GetOrCreateRenderer(element); if (element.MinimumHeightRequest == -1) { SizeRequest request = element.Measure(double.PositiveInfinity, double.PositiveInfinity); renderer.NativeView.MinimumHeight = Forms.ConvertToScaledPixel(request.Request.Height); } else { renderer.NativeView.MinimumHeight = Forms.ConvertToScaledPixel(element.MinimumHeightRequest); } (renderer as LayoutRenderer)?.RegisterOnLayoutUpdated(); return(renderer.NativeView); } }; } return(_headerFooterItemClass); }
private void CreateFirstPage(IEnumerable <TestCaseBase> testCases) { _firstPageWindow = CreateWindow(); Console.WriteLine("Screen DPI : {0}", _firstPageWindow.ScreenDpi.X); Conformant conformant = new Conformant(_firstPageWindow); conformant.Show(); Box box = new Box(_firstPageWindow) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; box.Show(); var bg = new Background(_firstPageWindow); bg.Color = Color.White; bg.SetContent(box); conformant.SetContent(bg); GenList list = new GenList(_firstPageWindow) { Homogeneous = true, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1 }; GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (data, part) => { TestCaseBase tc = data as TestCaseBase; return(tc == null ? "" : tc.TestName); } }; foreach (var tc in testCases.Where <TestCaseBase>((tc) => tc.TargetProfile.HasFlag(GetTargetProfile()))) { list.Append(defaultClass, tc); } if (Profile == "wearable") { list.Prepend(defaultClass, null); list.Append(defaultClass, null); } list.ItemSelected += (s, e) => { TestCaseBase tc = e.Item.Data as TestCaseBase; StartTCFromList(tc); }; list.Show(); box.PackEnd(list); }
public override void Run(Window window) { var surface = new CircleSurface(); var list = new CircleGenList(window, surface) { Homogeneous = true, VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible, }; list.Show(); ((IRotaryActionWidget)list).Activate(); list.Move(0, 0); list.Resize(360, 360); GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (obj, part) => { return(string.Format("{0} - {1}", (string)obj, part)); } }; for (int i = 0; i < 100; i++) { list.Append(defaultClass, string.Format("{0} Item", i)); } list.ItemSelected += List_ItemSelected;; }
public override void Run(Window window) { Conformant conformant = new Conformant(window); conformant.Show(); GenList list = new GenList(window) { Homogeneous = true, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1 }; GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (obj, part) => { return(string.Format("{0} - {1}", (string)obj, part)); } }; for (int i = 0; i < 100; i++) { list.Append(defaultClass, string.Format("{0} Item", i)); } list.Show(); list.ItemSelected += List_ItemSelected;; list.Geometry = window.GetInnerSquare(); }
public NativeContent() { Class = new GenItemClass("full") { GetContentHandler = GetContent, }; }
GenItemClass GetCancelEffectTemplete() { if (_cancelEffectTemplete != null) { return(_cancelEffectTemplete); } _cancelEffectTemplete = new GenItemClass("full_off") { GetContentHandler = (data, part) => { VisualElement element = data as VisualElement; var renderer = Platform.GetOrCreateRenderer(element); if (element.MinimumHeightRequest == -1) { SizeRequest request = element.Measure(double.PositiveInfinity, double.PositiveInfinity); renderer.NativeView.MinimumHeight = XForms.ConvertToScaledPixel(request.Request.Height); } else { renderer.NativeView.MinimumHeight = XForms.ConvertToScaledPixel(element.MinimumHeightRequest); } (renderer as LayoutRenderer)?.RegisterOnLayoutUpdated(); return(renderer.NativeView); } }; return(_cancelEffectTemplete); }
public override void Run(Window window) { Conformant conformant = new Conformant(window); conformant.Show(); var surface = new CircleSurface(conformant); var list = new CircleGenList(conformant, surface) { Homogeneous = true, VerticalScrollBarColor = Color.Red, VerticalScrollBackgroundColor = Color.Pink, VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Visible, }; ((IRotaryActionWidget)list).Activate(); conformant.SetContent(list); GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (obj, part) => { return(string.Format("{0} - {1}", (string)obj, part)); } }; for (int i = 0; i < 100; i++) { list.Append(defaultClass, string.Format("{0} Item", i)); } list.ItemSelected += List_ItemSelected;; }
/// <summary> /// Gets the item class used for header and footer cells. /// </summary> /// <returns>The header and footer item class.</returns> protected GenItemClass GetHeaderFooterItemClass() { if (_headerFooterItemClass == null) { _headerFooterItemClass = new GenItemClass(ThemeConstants.GenItemClass.Styles.Full) { GetContentHandler = (data, part) => { var context = data as HeaderFooterItemContext; if (context == null || context.Element == null) { return(null); } var renderer = Platform.GetOrCreateRenderer(context.Element); if (context.Element.MinimumHeightRequest == -1) { SizeRequest request = context.Element.Measure(double.PositiveInfinity, double.PositiveInfinity); renderer.NativeView.MinimumHeight = Forms.ConvertToScaledPixel(request.Request.Height); } else { renderer.NativeView.MinimumHeight = Forms.ConvertToScaledPixel(context.Element.MinimumHeightRequest); } (renderer as ILayoutRenderer)?.RegisterOnLayoutUpdated(); return(renderer.NativeView); } }; } return(_headerFooterItemClass); }
public override void Run(Window window) { Conformant conformant = new Conformant(window); conformant.Show(); Box box = new Box(window); conformant.SetContent(box); box.Show(); GenList list = new GenList(window) { Homogeneous = true, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1 }; Button button = new Button(window) { Text = "Remove", AlignmentX = -1, AlignmentY = -1, }; GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (obj, part) => { return(string.Format("{0} - {1}", (string)obj, part)); } }; GenListItem[] itemArr = new GenListItem[9]; for (int i = 0; i < 9; i++) { itemArr[i] = list.Append(defaultClass, string.Format("{0} Item", i)); } int idx = 0; button.Clicked += (s, e) => { if (idx < 9) { Console.WriteLine("GenListItem deleted"); itemArr[idx++].Delete(); } }; button.Show(); list.Show(); list.ItemSelected += List_ItemSelected; list.ItemRealized += List_ItemRealized; list.ItemUnrealized += List_ItemUnrealized; box.PackEnd(list); box.PackEnd(button); }
/// <summary> /// Sets the header. /// </summary> /// <param name="header">Header of the list.</param> public void SetHeader(VisualElement header) { if (header == null) { if (HasHeader()) { RemoveHeader(); } return; } GenItemClass headerTemplate = GetHeaderFooterItemClass(); _headerElement = header; if (HasHeader()) { FirstItem.UpdateItemClass(headerTemplate, header); } else { _headerContext = new ItemContext(); _headerContext.Item = _itemContextList.Count > 0 ? InsertBefore(headerTemplate, header, FirstItem) : Append(headerTemplate, header); _headerContext.Item.SelectionMode = GenItemSelectionMode.None; _headerContext.Item.Deleted += HeaderDeletedHandler; _itemContextList.Insert(0, _headerContext); } }
public override void Run(Window window) { Conformant conformant = new Conformant(window); conformant.Show(); GenGrid grid = new GenGrid(window) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, ItemAlignmentX = -1, ItemAlignmentY = -1, ItemWidth = window.ScreenSize.Width / 3, ItemHeight = window.ScreenSize.Width / 3, HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible, VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible }; GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (obj, part) => { Color item = (Color)obj; return(String.Format("#{0:X}{1:X}{2:X}", item.R, item.G, item.B)); }, GetContentHandler = (obj, part) => { Color item = (Color)obj; Console.WriteLine("{0} part create requested", part); if (part == "elm.swallow.icon") { var colorbox = new Rectangle(window) { Color = item }; return(colorbox); } return(null); } }; var rnd = new Random(); for (int i = 0; i < 10; i++) { int r = rnd.Next(255); int g = rnd.Next(255); int b = rnd.Next(255); Color color = Color.FromRgb(r, g, b); var griditem = grid.Append(defaultClass, color); griditem.SetTooltipText("AAAAAA"); //griditem.TooltipStyle = "transparent"; griditem.TooltipContentDelegate = () => { return(new Button(window)); }; } grid.Show(); grid.Geometry = window.GetInnerSquare(); }
/// <summary> /// Sets the footer. /// </summary> /// <param name="footer">Footer of the list.</param> public void SetFooter(VisualElement footer) { if (footer == null) { if (HasFooter()) { RemoveFooter(); } return; } GenItemClass footerTemplate = GetHeaderFooterItemClass(); _footerElement = footer; if (HasFooter()) { (_footerContext.Item as GenListItem).UpdateItemClass(footerTemplate, footer); } else { _footerContext = new ItemContext(); _footerContext.Item = Append(footerTemplate, footer); _footerContext.Item.SelectionMode = GenItemSelectionMode.None; _footerContext.Item.Deleted += FooterDeletedHandler; _itemContextList.Add(_footerContext); } }
public override void Run(Window window) { Conformant conformant = new Conformant(window); conformant.Show(); GenList list = new GenList(window) { Homogeneous = true, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1 }; Button button = new Button(window) { Text = "Remove", AlignmentX = -1, AlignmentY = -1, }; GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (obj, part) => { return(string.Format("{0} - {1}", (string)obj, part)); } }; GenListItem[] itemArr = new GenListItem[9]; for (int i = 0; i < 9; i++) { itemArr[i] = list.Append(defaultClass, string.Format("{0} Item", i)); } int idx = 0; button.Clicked += (s, e) => { if (idx < 9) { Console.WriteLine("GenListItem deleted"); itemArr[idx++].Delete(); } }; button.Show(); list.Show(); list.ItemSelected += List_ItemSelected; list.ItemRealized += List_ItemRealized; list.ItemUnrealized += List_ItemUnrealized; var square = window.GetInnerSquare(); list.Geometry = new Rect(square.X, square.Y, square.Width, square.Height * 3 / 4); button.Geometry = new Rect(square.X, square.Y + square.Height * 3 / 4, square.Width, square.Height / 4); }
void Initialize(EvasObject parent) { _menu = new GenList(parent) { BackgroundColor = EColor.Transparent, Style = "solid/default", }; _menu.ItemSelected += (s, e) => { _flyoutMenu.TryGetValue(e.Item.Data as Item, out Element element); SelectedItemChanged?.Invoke(this, new SelectedItemChangedEventArgs(element, -1)); }; _menu.Show(); PackEnd(_menu); _defaultClass = new GenItemClass("double_label") { GetTextHandler = (obj, part) => { if (part == "elm.text") { return(((Item)obj).Title); } else { return(null); } }, GetContentHandler = (obj, part) => { if (part == "elm.swallow.icon") { var icon = ((Item)obj).Icon; if (icon != null) { var image = new Native.Image(parent) { MinimumWidth = Forms.ConvertToScaledPixel(24), MinimumHeight = Forms.ConvertToScaledPixel(24) }; var result = image.LoadFromImageSourceAsync(icon); return(image); } else { return(null); } } else { return(null); } } }; }
public override void Run(Window window) { Background bg = new Background(window) { Color = Color.Gray, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1 }; bg.Show(); bg.Lower(); window.AddResizeObject(bg); Conformant conformant = new Conformant(window); conformant.Show(); GenList list = new GenList(window) { Homogeneous = false, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1 }; GenItemClass fullyCustomizeClass = new GenItemClass("full") { GetContentHandler = (obj, part) => { Log.Debug(string.Format("{0} part create requested", part)); var btn = new Button(window) { AlignmentX = -1, WeightX = 1, Text = (string)(obj as ItemContext).Data }; btn.MinimumHeight = 100; (obj as ItemContext).Realized = btn; (obj as ItemContext).Item?.UpdateField("elm.swallow.content", GenListItemFieldType.None); return(btn); }, }; for (int i = 0; i < 100; i++) { var context = new ItemContext(); context.Data = string.Format("{0} Item", i); context.Item = list.Append(fullyCustomizeClass, context, GenListItemType.Normal); } list.Show(); list.ItemSelected += List_ItemSelected; list.Geometry = window.GetInnerSquare(); }
void Initialize(EvasObject parent) { _menu = new GenList(parent) { BackgroundColor = EColor.Transparent, Style = "solid/default", }; _menu.ItemSelected += (s, e) => { MenuItemSelected?.Invoke(this, e); }; _menu.Show(); PackEnd(_menu); _defaultClass = new GenItemClass("double_label") { GetTextHandler = (obj, part) => { if (part == "elm.text") { return(((Item)obj).Title); } else { return(null); } }, GetContentHandler = (obj, part) => { if (part == "elm.swallow.icon") { var icon = ((Item)obj).Icon; if (icon != null) { var image = new ElmSharp.Image(parent) { MinimumWidth = Forms.ConvertToScaledPixel(24), MinimumHeight = Forms.ConvertToScaledPixel(24) }; var result = image.Load(ResourcePath.GetPath(icon)); return(image); } else { return(null); } } else { return(null); } } }; }
protected void InitializeFooterItemContext(GenItemClass footerTemplate) { var context = new HeaderFooterItemContext(); context.Element = GetFooter(); context.Item = Append(footerTemplate, context); context.Item.SelectionMode = GenItemSelectionMode.None; context.Item.Deleted += OnFooterItemDeleted; FooterItemContext = context; }
protected CellRenderer(string style) { Class = new GenItemClass(style) { GetTextHandler = GetText, GetContentHandler = GetContent, DeleteHandler = ItemDeleted, ReusableContentHandler = ReusableContent, }; }
public ShellMoreToolbar(EvasObject parent) : base(parent) { SetAlignment(-1, -1); SetWeight(1, 1); Homogeneous = true; SelectionMode = GenItemSelectionMode.Always; BackgroundColor = ShellRenderer.DefaultBackgroundColor.ToNative(); _defaultClass = new GenItemClass(ThemeConstants.GenItemClass.Styles.Full) { GetContentHandler = GetContent, }; }
public SearchResultList() : base(Forms.NativeParent) { SetAlignment(-1, -1); SetWeight(1, 1); Homogeneous = true; AllowFocus(true); SelectionMode = GenItemSelectionMode.Always; BackgroundColor = EColor.White; _defaultClass = new GenItemClass(ThemeConstants.GenItemClass.Styles.Full) { GetContentHandler = GetContent, }; }
public ShellMoreTabs(EvasObject parent) : base(parent) { SetAlignment(-1, -1); SetWeight(1, 1); NativeParent = parent; Homogeneous = true; SelectionMode = GenItemSelectionMode.Always; BackgroundColor = TThemeConstants.Shell.ColorClass.DefaultBackgroundColor; _defaultClass = new GenItemClass(TThemeConstants.GenItemClass.Styles.Full) { GetContentHandler = GetContent, }; }
public ShellMoreToolbar(ShellItemRenderer renderer) : base(System.Maui.Maui.NativeParent) { _shellItemRenderer = renderer; Homogeneous = true; AlignmentX = -1; AlignmentY = -1; WeightX = 1; WeightY = 1; BackgroundColor = ShellRenderer.DefaultBackgroundColor.ToNative(); ItemSelected += OnItemSelected; _defaultClass = new GenItemClass("full") { GetContentHandler = GetContent, }; }
public ShellSearchResultList(IMauiContext context) : base(context?.GetPlatformParent()) { MauiContext = context; SetAlignment(-1, -1); SetWeight(1, 1); AllowFocus(true); Homogeneous = true; SelectionMode = GenItemSelectionMode.Always; BackgroundColor = EColor.White; _defaultClass = new GenItemClass(TThemeConstants.GenItemClass.Styles.Full) { GetContentHandler = GetContent, }; }
protected void InitializeHeaderItemContext(GenItemClass headerTemplate) { var context = new HeaderFooterItemContext(); context.Element = GetHeader(); if (FirstItem != null) { context.Item = InsertBefore(headerTemplate, context, FirstItem); } else { context.Item = Append(headerTemplate, context); } context.Item.SelectionMode = GenItemSelectionMode.None; context.Item.Deleted += OnHeaderItemDeleted; HeaderItemContext = context; }
public MSimpleDialog(EvasObject parent) : base(parent) { Style = Styles.Popup.Simple; _layout = new Box(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; _layout.Show(); _genList = new GenList(parent) { WeightX = 1, WeightY = 1, AlignmentY = -1, AlignmentX = -1, SelectionMode = GenItemSelectionMode.Always }; _itemClass = new GenItemClass(Styles.GenListItem.Default) { GetContentHandler = GetContent, GetTextHandler = GetText }; _genList.ItemSelected += (s, e) => { Dismiss(); (e.Item.Data as MSimpleDialogItem)?.SendSelected(); }; OutsideClicked += (s, e) => { Dismiss(); }; _genList.Show(); _layout.PackEnd(_genList); SetContent(_layout); }
public override void Run(Window window) { Conformant conformant = new Conformant(window); conformant.Show(); GenList list = new GenList(window) { Homogeneous = true, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1 }; GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (obj, part) => { return(string.Format("{0} - {1}", (string)obj, part)); } }; GenListItem[] items = new GenListItem[100]; for (int i = 0; i < 100; i++) { if (i < 30) { items[i] = list.Append(defaultClass, string.Format("{0} Item", i)); } else if (i < 60) { items[i] = list.Prepend(defaultClass, string.Format("{0} Item", i)); } else { items[i] = list.InsertBefore(defaultClass, string.Format("{0} Item", i), items[50]); } } list.Show(); list.ItemSelected += List_ItemSelected;; conformant.SetContent(list); }
public void ItemList(GenGrid view, JArray imgArray) { Log.Info(ReactConstants.Tag, "=== Enter ItemList ==="); foreach (var item in imgArray) { Log.Info(ReactConstants.Tag, "[GenGrid] title: " + item["title"].ToString() + " content:" + item["content"].ToString()); GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (obj, part) => { Log.Info(ReactConstants.Tag, "[GenGrid] img title: " + item["title"].ToString()); return(item["title"].ToString()); }, GetContentHandler = (obj, part) => { if (part == "elm.swallow.icon") { Log.Info(ReactConstants.Tag, "[GenGrid] img path: " + item["content"].ToString()); Image img = new Image(ReactProgram.RctWindow); img.Load(item["content"].ToString()); img.MinimumWidth = view.ItemWidth; img.MinimumHeight = view.ItemHeight; return(img); } return(null); } }; Log.Info(ReactConstants.Tag, "grid.Append -> image class"); view.Append(defaultClass, null); Log.Info(ReactConstants.Tag, "ItemStyle: " + defaultClass.ItemStyle.ToString()); } Log.Info(ReactConstants.Tag, "=== Exit ItemList ==="); }
public override void Run(Window window) { var layout = new Layout(window); layout.Show(); layout.Move(0, 0); layout.Resize(360, 360); var surface = new CircleSurface(layout); var list = new CircleGenList(layout, surface) { Homogeneous = true, VerticalScrollBackgroundRadius = 165, VerticalScrollBarRadius = 165, VerticalScrollBackgroundLineWidth = 30, VerticalScrollBarLineWidth = 30, }; list.Show(); ((IRotaryActionWidget)list).Activate(); list.Move(0, 0); list.Resize(360, 360); list.Lower(); GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (obj, part) => { return(string.Format("{0} - {1}", (string)obj, part)); } }; for (int i = 0; i < 100; i++) { list.Append(defaultClass, string.Format("{0} Item", i)); } list.ItemSelected += List_ItemSelected;; }
private void InitializeListItem() { GenItemClass defaultClass = new GenItemClass("default") { GetTextHandler = (obj, part) => { return((string)obj); } }; for (int i = 0; i < TestItemMax; ++i) { if (i == 999) { ItemTarget = list.Append(defaultClass, new string(arrLabel[i % 10].ToCharArray())); } else { list.Append(defaultClass, new string(arrLabel[i % 10].ToCharArray())); } } }