コード例 #1
0
        public static void UpdateBrightnessControlDimensions(Toolbar toolbar, ActionMenuItemView menuItem)
        {
            // Get the position of the menu item
            int[] itemLocation = new int[2];
            menuItem?.GetLocationInWindow(itemLocation);
            // Get the position of the toolbar
            int[] toolbarLocation = new int[2];
            toolbar.GetLocationInWindow(toolbarLocation);
            // Calculate the horizontal center position of the menu item
            var itemCenterX = itemLocation[0] - toolbarLocation[0] + menuItem.Width / 2;

            // Get or calculate the distance between the bottom of the menu item icon and the bottom of the toolbar
            // NOTE: TotalPaddingBottom is actually slightly less than toolbar height - icon height / 2, however it automatically handles if the icon gravity has been modified
            BrightnessToolbarItemIconBottomPadding = menuItem.TotalPaddingBottom;
            // int itemBottomPadding = (_toolbar.Height - menuItem.ItemData.Icon.Bounds.Height())/2;
            // Calculate the width of the brightness control container required top center under the menu item
            BrightnessContainerWidth = 2 * (toolbar.Width - itemCenterX);
        }