internal async Task UpdateToolbarItems() { var toolbarProvider = GetToolbarProvider(); if (toolbarProvider == null) { return; } CommandBar commandBar = await toolbarProvider.GetCommandBarAsync(); if (commandBar == null) { return; } commandBar.PrimaryCommands.Clear(); commandBar.SecondaryCommands.Clear(); var toolBarForegroundBinder = GetToolbarProvider() as IToolBarForegroundBinder; foreach (ToolbarItem item in _toolbarTracker.ToolbarItems) { toolBarForegroundBinder?.BindForegroundColor(commandBar); var button = new AppBarButton(); button.SetBinding(AppBarButton.LabelProperty, "Text"); if (commandBar.IsDynamicOverflowEnabled && item.Order == ToolbarItemOrder.Secondary) { button.SetBinding(AppBarButton.IconProperty, "IconImageSource", _imageSourceIconElementConverter); } else { var img = new WImage(); img.SetBinding(WImage.SourceProperty, "Value"); img.SetBinding(WImage.DataContextProperty, "IconImageSource", _imageConverter); button.Content = img; } button.Command = new MenuItemCommand(item); button.DataContext = item; button.SetValue(NativeAutomationProperties.AutomationIdProperty, item.AutomationId); button.SetAutomationPropertiesName(item); button.SetAutomationPropertiesAccessibilityView(item); button.SetAutomationPropertiesHelpText(item); button.SetAutomationPropertiesLabeledBy(item); ToolbarItemOrder order = item.Order == ToolbarItemOrder.Default ? ToolbarItemOrder.Primary : item.Order; if (order == ToolbarItemOrder.Primary) { toolBarForegroundBinder?.BindForegroundColor(button); commandBar.PrimaryCommands.Add(button); } else { commandBar.SecondaryCommands.Add(button); } } }
public ExtendedToolbarItem(string text, string icon, ToolbarItemOrder itemOrder, Action doCommand) { Text = text; Icon = icon; Order = itemOrder; Command = new Command(doCommand); }
public ToolbarItem(string name, string icon, Action activated, ToolbarItemOrder order = ToolbarItemOrder.Default, int priority = 0) { if (activated == null) { throw new ArgumentNullException("activated"); } Text = name;
public TFluent Order(ToolbarItemOrder order) { this.BuilderActions.Add(menuItem => { menuItem.Order = order; }); return(this as TFluent); }
private static ToolbarItem createButton(string text, string icon, ToolbarItemOrder order) { return(new ToolbarItem { Text = text, Icon = icon, Order = order }); }
internal void UpdateMenu() { if (Handler.PlatformView is not MauiToolbar wh) { return; } var commandBar = wh.CommandBar; if (commandBar == null) { return; } commandBar.PrimaryCommands.Clear(); commandBar.SecondaryCommands.Clear(); List <ToolbarItem> toolbarItems = new List <ToolbarItem>(ToolbarItems ?? Array.Empty <ToolbarItem>()); foreach (ToolbarItem item in toolbarItems) { var button = new AppBarButton(); button.SetBinding(AppBarButton.LabelProperty, "Text"); if (commandBar.IsDynamicOverflowEnabled && item.Order == ToolbarItemOrder.Secondary) { button.SetBinding(AppBarButton.IconProperty, "IconImageSource", _imageSourceIconElementConverter); } else if (!item.IconImageSource.IsNullOrEmpty()) { var img = new WImage(); img.SetBinding(WImage.SourceProperty, "Value"); img.SetBinding(WImage.DataContextProperty, "IconImageSource", _imageConverter); button.Content = img; } button.Command = new MenuItemCommand(item); button.DataContext = item; button.SetValue(NativeAutomationProperties.AutomationIdProperty, item.AutomationId); button.SetAutomationPropertiesName(item); button.SetAutomationPropertiesAccessibilityView(item); button.SetAutomationPropertiesHelpText(item); button.UpdateTextColor(BarTextColor); button.SetAutomationPropertiesLabeledBy(item, null); ToolbarItemOrder order = item.Order == ToolbarItemOrder.Default ? ToolbarItemOrder.Primary : item.Order; if (order == ToolbarItemOrder.Primary) { commandBar.PrimaryCommands.Add(button); } else { commandBar.SecondaryCommands.Add(button); } } }
public ToolbarItem(string name, string icon, Action activated, ToolbarItemOrder order = ToolbarItemOrder.Default, int priority = 0) { if (activated == null) throw new ArgumentNullException("activated"); Text = name; Icon = icon; Clicked += (s, e) => activated(); Order = order; Priority = priority; }
public ToolbarItem(string name, string icon, Action activated, ToolbarItemOrder order = ToolbarItemOrder.Default, int priority = 0) { if (activated == null) { throw new ArgumentNullException("activated"); } Text = name; IconImageSource = icon; Clicked += (s, e) => activated(); Order = order; Priority = priority; }
internal async Task UpdateToolbarItems() { CommandBar commandBar = await GetCommandBarAsync(); if (commandBar != null) { commandBar.PrimaryCommands.Clear(); commandBar.SecondaryCommands.Clear(); if (_page.BottomAppBar != null || _page.TopAppBar != null) { _page.BottomAppBar = null; _page.TopAppBar = null; _page.InvalidateMeasure(); } } var toolBarProvider = GetToolbarProvider() as IToolBarForegroundBinder; foreach (ToolbarItem item in _toolbarTracker.ToolbarItems.OrderBy(ti => ti.Priority)) { if (commandBar == null) { commandBar = CreateCommandBar(); } toolBarProvider?.BindForegroundColor(commandBar); var button = new AppBarButton(); button.SetBinding(AppBarButton.LabelProperty, "Text"); button.SetBinding(AppBarButton.IconProperty, "Icon", _fileImageSourcePathConverter); button.Command = new MenuItemCommand(item); button.DataContext = item; ToolbarItemOrder order = item.Order == ToolbarItemOrder.Default ? ToolbarItemOrder.Primary : item.Order; if (order == ToolbarItemOrder.Primary) { toolBarProvider?.BindForegroundColor(button); commandBar.PrimaryCommands.Add(button); } else { commandBar.SecondaryCommands.Add(button); } } if (commandBar?.PrimaryCommands.Count + commandBar?.SecondaryCommands.Count == 0) { ClearCommandBar(); } }
internal async Task UpdateToolbarItems() { var toolbarProvider = GetToolbarProvider(); if (toolbarProvider == null) { return; } CommandBar commandBar = await toolbarProvider.GetCommandBarAsync(); if (commandBar == null) { return; } commandBar.PrimaryCommands.Clear(); commandBar.SecondaryCommands.Clear(); var toolBarForegroundBinder = GetToolbarProvider() as IToolBarForegroundBinder; foreach (ToolbarItem item in _toolbarTracker.ToolbarItems.OrderBy(ti => ti.Priority)) { toolBarForegroundBinder?.BindForegroundColor(commandBar); var button = new AppBarButton(); button.SetBinding(AppBarButton.LabelProperty, "Text"); button.SetBinding(AppBarButton.IconProperty, "Icon", _fileImageSourcePathConverter); button.Command = new MenuItemCommand(item); button.DataContext = item; button.SetValue(NativeAutomationProperties.AutomationIdProperty, item.AutomationId); button.SetAutomationPropertiesName(item); button.SetAutomationPropertiesAccessibilityView(item); button.SetAutomationPropertiesHelpText(item); button.SetAutomationPropertiesLabeledBy(item); ToolbarItemOrder order = item.Order == ToolbarItemOrder.Default ? ToolbarItemOrder.Primary : item.Order; if (order == ToolbarItemOrder.Primary) { toolBarForegroundBinder?.BindForegroundColor(button); commandBar.PrimaryCommands.Add(button); } else { commandBar.SecondaryCommands.Add(button); } } }
internal async Task UpdateToolbarItems() { CommandBar commandBar = await GetCommandBarAsync(); if (commandBar != null) { commandBar.PrimaryCommands.Clear(); commandBar.SecondaryCommands.Clear(); } commandBar = AddOpenMasterButton(commandBar); foreach (ToolbarItem item in _toolbarTracker.ToolbarItems.OrderBy(ti => ti.Priority)) { if (commandBar == null) { commandBar = CreateCommandBar(); } var button = new AppBarButton(); button.SetBinding(AppBarButton.LabelProperty, "Text"); button.SetBinding(AppBarButton.IconProperty, "Icon", _fileImageSourcePathConverter); button.Command = new MenuItemCommand(item); button.DataContext = item; ToolbarItemOrder order = item.Order == ToolbarItemOrder.Default ? ToolbarItemOrder.Primary : item.Order; if (order == ToolbarItemOrder.Primary) { commandBar.PrimaryCommands.Add(button); } else { commandBar.SecondaryCommands.Add(button); } } if (commandBar?.PrimaryCommands.Count + commandBar?.SecondaryCommands.Count == 0) { ClearCommandBar(); } }
public BindableToolbarItem(string name, string icon, Action activated, ToolbarItemOrder order = ToolbarItemOrder.Default, int priority = 0) : base(name, icon, activated, order, priority) { }
protected ToolbarItemViewModel(ToolbarItemOrder position = ToolbarItemOrder.Default) { Position = position; }
protected ToolbarItemViewModel(ICommand command, ToolbarItemOrder position = ToolbarItemOrder.Default) : this(position) { Command = command; }
public static T Order <T>(this T menuitem, ToolbarItemOrder order) where T : IRxToolbarItem { menuitem.Order = order; return(menuitem); }
public TextToolbarItemViewModel(string text, ICommand command, ToolbarItemOrder position = ToolbarItemOrder.Default) : base(command, position) { Text = text; }
public static ToolbarItem Order(this ToolbarItem item, ToolbarItemOrder order) { item.Order = order; return(item); }