コード例 #1
0
ファイル: Platform.cs プロジェクト: solyn/Xamarin.Forms
        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);
                }
            }
        }
コード例 #2
0
 public ExtendedToolbarItem(string text, string icon, ToolbarItemOrder itemOrder, Action doCommand)
 {
     Text    = text;
     Icon    = icon;
     Order   = itemOrder;
     Command = new Command(doCommand);
 }
コード例 #3
0
        public ToolbarItem(string name, string icon, Action activated, ToolbarItemOrder order = ToolbarItemOrder.Default, int priority = 0)
        {
            if (activated == null)
            {
                throw new ArgumentNullException("activated");
            }

            Text = name;
コード例 #4
0
        public TFluent Order(ToolbarItemOrder order)
        {
            this.BuilderActions.Add(menuItem => {
                menuItem.Order = order;
            });

            return(this as TFluent);
        }
コード例 #5
0
 private static ToolbarItem createButton(string text, string icon, ToolbarItemOrder order)
 {
     return(new ToolbarItem
     {
         Text = text,
         Icon = icon,
         Order = order
     });
 }
コード例 #6
0
ファイル: Toolbar.Windows.cs プロジェクト: sung-su/maui
        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);
                }
            }
        }
コード例 #7
0
ファイル: ToolbarItem.cs プロジェクト: Costo/Xamarin.Forms
		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;
		}
コード例 #8
0
        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;
        }
コード例 #9
0
ファイル: PlatformUWP.cs プロジェクト: yone64/Xamarin.Forms
        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();
            }
        }
コード例 #10
0
        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);
                }
            }
        }
コード例 #11
0
        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();
            }
        }
コード例 #12
0
 public BindableToolbarItem(string name, string icon, Action activated, ToolbarItemOrder order = ToolbarItemOrder.Default, int priority = 0)
     : base(name, icon, activated, order, priority)
 {
 }
コード例 #13
0
 protected ToolbarItemViewModel(ToolbarItemOrder position = ToolbarItemOrder.Default)
 {
     Position = position;
 }
コード例 #14
0
 protected ToolbarItemViewModel(ICommand command, ToolbarItemOrder position = ToolbarItemOrder.Default) : this(position)
 {
     Command = command;
 }
コード例 #15
0
 public static T Order <T>(this T menuitem, ToolbarItemOrder order) where T : IRxToolbarItem
 {
     menuitem.Order = order;
     return(menuitem);
 }
コード例 #16
0
ファイル: BasePage.cs プロジェクト: pratik8490/TextShield
 public ExtendedToolbarItem(string text, string icon, ToolbarItemOrder itemOrder, Action doCommand)
 {
     Text = text;
     Icon = icon;
     Order = itemOrder;
     Command = new Command(doCommand);
 }
コード例 #17
0
 public TextToolbarItemViewModel(string text, ICommand command, ToolbarItemOrder position = ToolbarItemOrder.Default) : base(command, position)
 {
     Text = text;
 }
コード例 #18
0
 public static ToolbarItem Order(this ToolbarItem item, ToolbarItemOrder order)
 {
     item.Order = order;
     return(item);
 }