public ShellNavBar(IMauiContext context) : base(context?.GetPlatformParent()) { MauiContext = context; SetLayoutCallback(OnLayout); _menuButton = new TButton(PlatformParent); _menuButton.Clicked += OnMenuClicked; _menuIcon = new MaterialIcon(PlatformParent) { Color = _foregroundColor.ToCommon() }; UpdateMenuIcon(); _title = new TLabel(PlatformParent) { FontSize = this.GetDefaultTitleFontSize(), VerticalTextAlignment = (global::Tizen.UIExtensions.Common.TextAlignment)TextAlignment.Center, TextColor = _titleColor.ToCommon(), FontAttributes = Tizen.UIExtensions.Common.FontAttributes.Bold, }; _title.Show(); BackgroundColor = _backgroudColor; _menuButton.BackgroundColor = _backgroudColor; PackEnd(_menuButton); PackEnd(_title); }
private async void FillIcons() { List <DisplayableIcon> icons = new List <DisplayableIcon> { }; DataContext = this; await Task.Run(() => { foreach (string iconName in Enum.GetNames(typeof(UI.MaterialIcon))) { MaterialIcon icon = (MaterialIcon)Enum.Parse(typeof(MaterialIcon), iconName); //System.Diagnostics.Debug.WriteLine(icon); icons.Add(new DisplayableIcon { Name = iconName, Icon = icon, Code = ((int)MiconIcons.ToGlyph(icon)).ToString("X4") }); } App.Current.Dispatcher.Invoke(() => { iconsList.ItemsSource = icons; }); Thread.Sleep(1000); App.Current.Dispatcher.Invoke(() => { gridLoading.Visibility = Visibility.Hidden; }); }); }
public MenuItemViewModel(MenuItem item, object commandParameter) { Header = item.Header; MaterialIconKind icon; if (Enum.TryParse <MaterialIconKind>(item.Icon, out icon)) { Icon = new MaterialIcon { Kind = icon, Foreground = Avalonia.Media.Brushes.Gray } } ; if (item.Action != null) { Command = ReactiveCommand.Create(item.Action); } CommandParameter = commandParameter; if (item.Items != null) { Items = item.Items.Select(x => new MenuItemViewModel(x, commandParameter)).ToList(); } }
private void Start() { parent = transform.GetComponentInParent <MaterialIcon>(); if (parent != null) { myMaterial = transform.GetComponentInParent <MaterialIcon>().MyMaterial; } }
public MenuItemViewModel(Action action, string header, MaterialIconKind icon) { Command = ReactiveCommand.Create(action); Header = header; Icon = new MaterialIcon { Kind = icon, Foreground = Avalonia.Media.Brushes.Gray }; }
void SetIcon(int index) { Image _image = GetImage(index); MaterialIcon icon = _image.gameObject.GetOrAddComponent <MaterialIcon>(); icon.MyMaterial = GameManager.Game.SubMaterialList[index]; _image.sprite = icon.MyMaterial.image; }
/// <summary> /// Material图标 /// </summary> /// <typeparam name="TComponent">组件类型</typeparam> /// <param name="component">组件实例</param> /// <param name="icon">Material图标</param> public static TComponent Material <TComponent>(this TComponent component, MaterialIcon icon) where TComponent : IComponent, IIcon { var option = component as IOptionConfig; option?.Config <Config>(config => { config.SetAttribute(UiConst.MaterialIcon, icon.ToString()); }); return(component); }
public MenuItemViewModel(ICommand command, object commandParameter, string header, MaterialIconKind icon) { Command = command; CommandParameter = commandParameter; Header = header; Icon = new MaterialIcon { Kind = icon, Foreground = Avalonia.Media.Brushes.Gray }; }
protected override void OnElementChanged(ElementChangedEventArgs <Image> e) { base.OnElementChanged(e); if (e?.NewElement != null) { _materialIcon = this.Element as MaterialIcon; this.UpdateDrawable(); } }
/// <summary> /// 设置后缀 /// </summary> /// <typeparam name="TComponent">组件类型</typeparam> /// <param name="component">组件实例</param> /// <param name="icon">Material图标</param> /// <param name="onClick">图标单击事件处理函数,范例:click()</param> public static TComponent Suffix <TComponent>(this TComponent component, MaterialIcon icon, string onClick = null) where TComponent : IComponent, IPrefix { var option = component as IOptionConfig; option?.Config <Config>(config => { config.SetAttribute(MaterialConst.SuffixMaterialIcon, icon); config.SetAttribute(MaterialConst.OnSuffixIconClick, onClick); }); return(component); }
void SetIcon(int index) { Image _image = GetImage(index); MaterialIcon icon = _image.gameObject.GetOrAddComponent <MaterialIcon>(); icon.MyMaterial = GameManager.Game.BaseMaterialIndexData[index + 1]; _image.sprite = icon.MyMaterial.image; _image.SetNativeSize(); }
protected override void OnElementChanged(ElementChangedEventArgs <Image> e) { base.OnElementChanged(e); if (e?.NewElement != null) { _materialIcon = this.Element as MaterialIcon; _image = this.Control.Image?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); this.ChangeTintColor(); } }
protected override void OnElementChanged(ElementChangedEventArgs <Image> e) { base.OnElementChanged(e); if (e?.NewElement == null || Control == null) { return; } _materialIcon = Element as MaterialIcon; _image = Control.Image?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); ChangeTintColor(); }
public override void Run(ElmSharp.Box parent) { var page = new ElmSharp.Box(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; page.Show(); parent.PackEnd(page); foreach (var iconType in Enum.GetValues(typeof(MaterialIcons)).Cast <MaterialIcons>()) { var box = new ElmSharp.Box(parent) { IsHorizontal = true, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; box.Show(); var label = new Label(parent) { AlignmentX = 0.5, AlignmentY = -1, WeightY = 1, WeightX = 1, Text = iconType.ToString(), }; label.Show(); var icon = new MaterialIcon(parent) { AlignmentX = 0, AlignmentY = -1, WeightY = 1, WeightX = 1, IconType = iconType, }; icon.Show(); box.PackEnd(label); box.PackEnd(icon); page.PackEnd(box); } }
protected override void OnElementChanged(ElementChangedEventArgs <Image> e) { base.OnElementChanged(e); if (this.Control == null) { return; } if (e?.NewElement == null) { return; } _materialIcon = this.Element as MaterialIcon; this.UpdateDrawable(); }
public static T MaterialIcon <T>(this T button, MaterialIcon glyph, IconSize size, Color color = default) where T : Button { return(button.Icon(glyph.ToIconFontString(), Fonts.MI, (double)size, color)); }
public static T MaterialIcon <T>(this T image, MaterialIcon glyph, IconSize size, Color color = default) where T : Image { return(image.Icon(glyph.ToIconFontString(), Fonts.MI, (double)size, color)); }