Exemple #1
0
        public PopupMenuButton CreateSplitButton(SplitButtonParams buttonParams, OperationGroup operationGroup = null)
        {
            PopupMenuButton menuButton = null;

            var innerButton = new IconButton(buttonParams.Icon, this)
            {
                Name        = buttonParams.ButtonName + " Inner SplitButton",
                ToolTipText = buttonParams.DefaultActionTooltip,
            };

            innerButton.Click += (s, e) =>
            {
                buttonParams.DefaultAction.Invoke(menuButton);
            };

            // Remove right Padding for drop style
            innerButton.Padding = innerButton.Padding.Clone(right: 0);

            if (operationGroup == null)
            {
                menuButton = new PopupMenuButton(innerButton, this);
            }
            else
            {
                menuButton = new OperationGroupButton(operationGroup, innerButton, this);
            }

            menuButton.DynamicPopupContent = () =>
            {
                var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme);
                buttonParams.ExtendPopupMenu?.Invoke(popupMenu);

                return(popupMenu);
            };

            menuButton.Name                = buttonParams.ButtonName + " Menu SplitButton";
            menuButton.BackgroundColor     = this.ToolbarButtonBackground;
            menuButton.HoverColor          = this.ToolbarButtonHover;
            menuButton.MouseDownColor      = this.ToolbarButtonDown;
            menuButton.DrawArrow           = true;
            menuButton.Margin              = this.ButtonSpacing;
            menuButton.DistinctPopupButton = true;

            innerButton.Selectable = true;
            return(menuButton);
        }
        public PopupMenuButton CreateSplitButton(SplitButtonParams buttonParams, OperationGroup operationGroup = null)
        {
            PopupMenuButton menuButton = null;

            GuiWidget innerButton;

            if (buttonParams.ButtonText == null)
            {
                innerButton = new IconButton(buttonParams.Icon, this)
                {
                    Name        = buttonParams.ButtonName + " Inner SplitButton",
                    Enabled     = buttonParams.ButtonEnabled,
                    ToolTipText = buttonParams.ButtonTooltip,
                };

                // Remove right Padding for drop style
                innerButton.Padding = innerButton.Padding.Clone(right: 0);
            }
            else
            {
                if (buttonParams.Icon == null)
                {
                    innerButton = new TextButton(buttonParams.ButtonText, this)
                    {
                        Name        = buttonParams.ButtonName,
                        Enabled     = buttonParams.ButtonEnabled,
                        ToolTipText = buttonParams.ButtonTooltip,
                    };
                }
                else
                {
                    innerButton = new TextIconButton(buttonParams.ButtonText, buttonParams.Icon, this)
                    {
                        Name        = buttonParams.ButtonName,
                        Enabled     = buttonParams.ButtonEnabled,
                        ToolTipText = buttonParams.ButtonTooltip,
                    };
                }
            }

            innerButton.Click += (s, e) =>
            {
                buttonParams.ButtonAction.Invoke(menuButton);
            };


            if (operationGroup == null)
            {
                menuButton = new PopupMenuButton(innerButton, this);
            }
            else
            {
                menuButton = new OperationGroupButton(operationGroup, innerButton, this);
            }

            var theme = ApplicationController.Instance.MenuTheme;

            menuButton.DynamicPopupContent = () =>
            {
                var popupMenu = new PopupMenu(theme);
                buttonParams.ExtendPopupMenu?.Invoke(popupMenu);

                return(popupMenu);
            };

            menuButton.Name = buttonParams.ButtonName + " Menu SplitButton";
            if (buttonParams.ButtonText == null)
            {
                menuButton.BackgroundColor = this.ToolbarButtonBackground;
            }
            else
            {
                menuButton.BackgroundColor = this.MinimalShade;
            }

            menuButton.HoverColor          = this.ToolbarButtonHover;
            menuButton.MouseDownColor      = this.ToolbarButtonDown;
            menuButton.DrawArrow           = true;
            menuButton.Margin              = this.ButtonSpacing;
            menuButton.DistinctPopupButton = true;
            menuButton.BackgroundRadius    = new RadiusCorners(theme.ButtonRadius, theme.ButtonRadius, 0, 0);

            innerButton.Selectable = true;
            return(menuButton);
        }