Exemple #1
0
		private void AddButtonGroupToFlow(ButtonGroup buttonGroup)
		{
			FlowLayoutPanel buttonFlow = new FlowLayoutPanel();
			buttonFlow.AutoSize = true;
			buttonFlow.FlowDirection = FlowDirection.LeftToRight;
			buttonFlow.Margin = new Padding(30, 0, 0, 15);
			buttonFlow.AutoSizeMode = AutoSizeMode.GrowAndShrink;
			buttonFlow.WrapContents = true;
			bool foundAtLeastOne = false;
			foreach (IThingOnDashboard item in ThingsToMakeButtonsFor)
			{
				if (item == this)
				{
					continue;
				}
				if (item.Group == buttonGroup.Group)
				{
					buttonFlow.Controls.Add(MakeButton(item, buttonGroup));
					foundAtLeastOne = true;
				}
			}
			if (foundAtLeastOne)
			{
				Label header = new Label();
				header.AutoSize = true;
				header.Text = StringCatalog.Get(buttonGroup.Group.ToString());
				header.Font = new Font("Arial", 12);
				_flow.Controls.Add(header);
				_flow.Controls.Add(buttonFlow);
			}
		}
Exemple #2
0
		private Control MakeButton(IThingOnDashboard item, ButtonGroup group)
		{
			DashboardButton button = MakeButton(item);
			button.BackColor = Color.Transparent;
			button.Font = Font;
			button.AutoSize = false;
			button.BorderColor = group.BorderColor;
			button.DoneColor = group.DoneColor;

			button.Dock = DockStyle.None;
			button.Anchor = AnchorStyles.None;
			button.Size = _bestButtonSize;
			button.SizeChanged += ButtonSizeChanged;
			button.Text = item.LocalizedLabel;
			button.Click += OnButtonClick;
			// if fonts or text are localized, we will need to re-measure stuff
			button.TextChanged += delegate { _smallestPossibleButtonSizes = null; };
			button.FontChanged += delegate { _smallestPossibleButtonSizes = null; };
			_toolTip.SetToolTip(button, item.LocalizedLabel + GetToolTipDescription(item));
			return button;
		}