private void FillPizzaPage() { var table = new TableLayoutPanel { Location = new Point((int)(ClientSize.Width * 0.6), ClientSize.Height / 4), AutoSize = true }; var row = 0; foreach (Ingredients ingredient in Enum.GetValues(typeof(Ingredients))) { MakeLabeledCheckbox(table, ingredient, row++); } var size = new NumericUpDown { Maximum = Constraints.MaxPizzaSize, Minimum = Constraints.MinPizzaSize, Anchor = AnchorStyles.Left }; size.ValueChanged += (sender, args) => { order.Pizza.Size = (int)(sender as NumericUpDown).Value; pizzaPage.Invalidate(); }; table.Controls.Add(size, 1, row); table.Controls.Add(new Label { Text = @"Размер пиццы: ", AutoSize = true, Anchor = AnchorStyles.Right }, 0, row); pizzaPage.Controls.Add(table); tabsControl.Controls.Add(pizzaPage); pizzaPage.Paint += PizzaPaint; }
/// @brief Determine availability of close plugin button when tab is changed. /// @details Enable close plugin button based on if active tab is subclass of /// Gear.PluginSupport.PluginBase and if that class permit close the window. Typically /// the user plugins enabled it; but the cog window, main memory, logic probe, etc, /// don't allow to close. /// @param[in] sender Reference to object where event was raised. /// @param[in] e Event data arguments. /// @since V14.07.03 - Added. private void documentsTab_Click(object sender, EventArgs e) { TabPage tp = documentsTab.SelectedTab; if (tp.Controls[0] is PluginBase) { PluginBase b = (tp.Controls[0]) as PluginBase; if (b.IsClosable) { closeButton.Enabled = true; } else { closeButton.Enabled = false; } b.Repaint(false); } else { closeButton.Enabled = false; } tp.Invalidate(); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); e.Graphics.Clear(BackColor); Rectangle r = this.ClientRectangle; if (TabCount <= 0) { return; } //Draw a custom background for Transparent TabPages r = SelectedTab.Bounds; StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; Font DrawFont = new Font(Font.FontFamily, 24, FontStyle.Regular, GraphicsUnit.Pixel); ControlPaint.DrawStringDisabled(e.Graphics, "", DrawFont, BackColor, r, sf); DrawFont.Dispose(); //Draw a border around TabPage r.Inflate(3, 3); TabPage tp = TabPages[SelectedIndex]; SolidBrush PaintBrush = new SolidBrush(tp.BackColor); e.Graphics.FillRectangle(PaintBrush, r); ControlPaint.DrawBorder(e.Graphics, r, PaintBrush.Color, ButtonBorderStyle.Outset); //Draw the Tabs for (int index = 0; index <= TabCount - 1; index++) { tp = TabPages[index]; tp.Invalidate(); tp.ForeColor = Color.FromArgb(0, 168, 198); tp.BackColor = Color.FromArgb(41, 41, 41); r = GetTabRect(index); ButtonBorderStyle bs = ButtonBorderStyle.Outset; if (index == SelectedIndex) { bs = ButtonBorderStyle.Inset; } PaintBrush.Color = tp.BackColor; e.Graphics.FillRectangle(PaintBrush, r); ControlPaint.DrawBorder(e.Graphics, r, PaintBrush.Color, bs); PaintBrush.Color = tp.ForeColor; //Set up rotation for left and right aligned tabs if (Alignment == TabAlignment.Left | Alignment == TabAlignment.Right) { float RotateAngle = 90; if (Alignment == TabAlignment.Left) { RotateAngle = 270; } PointF cp = new PointF(r.Left + (r.Width / 2), r.Top + (r.Height / 2)); e.Graphics.TranslateTransform(cp.X, cp.Y); e.Graphics.RotateTransform(RotateAngle); r = new Rectangle(-(r.Height / 2), -(r.Width / 2), r.Height, r.Width); } //Draw the Tab Text if (tp.Enabled) { e.Graphics.DrawString(tp.Text, Font, PaintBrush, r, sf); } else { ControlPaint.DrawStringDisabled(e.Graphics, tp.Text, Font, tp.BackColor, r, sf); } e.Graphics.ResetTransform(); } PaintBrush.Dispose(); }
private void RaccoonButton_Click(object sender, EventArgs e) { IsChoosedSpecies = true; ChoosedSpecies = AnimalSpecies.Raccoon; CageTPage.Invalidate(); }