void Form_FormClosed(object sender, FormClosedEventArgs e) { if (sender is BaseForm) { var form = (BaseForm)sender; if (TaskBar != null) { TabItem ti = TaskBar.GetItemByTag(form); if (ti != null) { TaskBar.Items.Remove(ti); } } if (form == SelectedForm) { SelectedForm = null; } if (Forms.Contains(form)) { Forms.Remove(form); } } }
protected override void DrawItemBackground(TabItemPaintEventArgs e) { //base.DrawItemBackground(e); TaskBar taskBar = e.GetBar <TaskBar>(); Color backColor = e.Bar.ItemBackColor; switch (e.Status) { case UIControlStatus.Selected: case UIControlStatus.Focused: if (taskBar.IsActive) { backColor = taskBar.SelectedItemBackColor; } else { backColor = taskBar.InactiveSelectedItemBackColor; } break; case UIControlStatus.Hover: backColor = taskBar.HoverItemBackColor; break; } if (!backColor.IsEmpty) { GraphicsPath path = PaintHelper.GetRoundRectangle(e.Bounds, taskBar.TabRounded, taskBar.TabRounded, 0, 0); //if (e.Status == UIControlStatus.Hover) //{ // LinearGradientBrush backBrush = new LinearGradientBrush(e.Bounds, backColor, backColor, 90.0f); // ColorBlend cb = new ColorBlend(3); // cb.Colors = new Color[] { PaintHelper.GetLightColor(backColor), backColor, backColor }; // cb.Positions = new float[] { 0.0f, 0.5f, 1.0f }; // backBrush.InterpolationColors = cb; // e.Graphics.FillPath(backBrush, path); //} //else //{ SolidBrush backBrush = new SolidBrush(backColor); e.Graphics.FillPath(backBrush, path); //} // if ((e.Status == UIControlStatus.Normal || e.Status == UIControlStatus.Hover) && e.Bounds.Height > 10) { Rectangle rectShadow = e.Bounds; rectShadow.Y = rectShadow.Bottom - 6; rectShadow.Height = 5; var brush = new LinearGradientBrush(rectShadow, Color.Transparent, PaintHelper.AdjustColorSLess(PaintHelper.GetDarkColor(backColor), 20), 90.0f); rectShadow.Y++;//规避一个Gdi+错误, 会导致第一行有一个很深的线 //e.Graphics.FillRectangle(Brushes.Red, rectShadow); e.Graphics.FillRectangle(brush, rectShadow); } } }
void Form_Activated(object sender, EventArgs e) { if (sender is Form && TaskBar != null) { Form form = (Form)sender; TaskBar.SelectByTag(form); } }
void Form_TextChanged(object sender, EventArgs e) { if (sender is Form && TaskBar != null) { Form form = (Form)sender; TabItem item = TaskBar.GetItemByTag(form); if (item != null) { item.Text = form.Text; } } }