MonoMobile.Views.DialogViewController.ConfigureToolbarItems C# (CSharp) Method

ConfigureToolbarItems() private method

private ConfigureToolbarItems ( ) : void
return void
		private void ConfigureToolbarItems()
		{
			var standardButtonSize = 31;

			if (ToolbarButtons != null)
			{
				var buttonList = ToolbarButtons.Where((button)=>button.Command == null || !(button as ICommandButton).Hidden).ToList();

				var leftCount = buttonList.Where((button)=>button.Location == BarButtonLocation.Left).Count();
				var rightCount = buttonList.Where((button)=>button.Location == BarButtonLocation.Right).Count();
				
				if (rightCount > leftCount)
				{
					var buttonWidth = buttonList.Last((button)=>button.Location == BarButtonLocation.Right).Width;
					_LeftFixedSpace.Width = buttonWidth == 0 ? standardButtonSize : buttonWidth;

					buttonList.Add(_LeftFixedSpace);
				}

				if (leftCount > rightCount)
				{
					var buttonWidth = buttonList.First((button)=>button.Location == BarButtonLocation.Left).Width;
					_RightFixedSpace.Width = buttonWidth == 0 ? standardButtonSize : buttonWidth;

					buttonList.Add(_RightFixedSpace);
				}

				CommandBarButtonItem[] buttons = buttonList.ToArray();	
				SetToolbarItems(buttons, false);
 
				var nav = ParentViewController as UINavigationController;
				if (nav != null)
				{
					nav.NavigationBar.Opaque = false;
 
					var themeable = RootView as IThemeable;
					if (themeable != null && themeable.Theme != null)
					{
						nav.Toolbar.TintColor = themeable.Theme.BarTintColor;
					}
				}
			}
		}