/// <summary> /// When we change our deck, we also want to change the title of our presentation /// since the presentation title is the same /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void DeckStrip_SelectedIndexChanged(object sender, EventArgs e) { DeckTabPage page = (DeckTabPage)this.SelectedTab; ///for when we're closing if (page == null) { return; } using (this.m_Model.Workspace.Lock()) { PresentationModel current = ~this.m_Model.Workspace.CurrentPresentation; if (current != null) { using (Synchronizer.Lock(current.SyncRoot)) current.HumanName = page.Text; } } }
protected override void OnDrawItem(DrawItemEventArgs e) { Graphics g = e.Graphics; Brush textBrush, backBrush; // Get the item from the collection DeckTabPage tab = (DeckTabPage)this.TabPages[e.Index]; ///Draw the background by accesing the our tabpage's ///TabBackColor property backBrush = new SolidBrush(tab.TabBackColor); g.FillRectangle(backBrush, e.Bounds); backBrush.Dispose(); // Get the bounds for the tab rectangle Rectangle bounds = this.GetTabRect(e.Index); // Create a brush for drawing the text textBrush = new SolidBrush(SystemColors.MenuText); // Draw string, centering the text StringFormat flags = new StringFormat(); flags.Alignment = StringAlignment.Center; flags.LineAlignment = StringAlignment.Center; // Adjust the alignment so that the text is drawn vertically if (this.Alignment == TabAlignment.Left || this.Alignment == TabAlignment.Right) { g.RotateTransform(-90, System.Drawing.Drawing2D.MatrixOrder.Append); } // Center the text in the tab control g.TranslateTransform(bounds.X + (bounds.Width / 2.0f), bounds.Y + (bounds.Height / 2.0f), System.Drawing.Drawing2D.MatrixOrder.Append); // Draw the control string g.DrawString(tab.Text, e.Font, textBrush, new PointF(0, 0), new StringFormat(flags)); // Cleanup textBrush.Dispose(); }