- source.zip
- Source
- TabStripApp
- archive
- bin
- Release
- diagram.png
- Example.exe
- TabStripApp.pdb
- TabStripApp.vshost.exe
- TabStripControlLibrary.dll
- TabStripControlLibrary.pdb
- Form1.cs
- Form1.Designer.cs
- Form1.resx
- InfoForm.cs
- Program.cs
- Properties
- Resources
- advanced-directory.png
- B_click.png
- B_click1.png
- B_click11.png
- B_on.png
- B_on1.png
- B_on11.png
- config-users.png
- gnome-dev-harddisk-1394.png
- gnome-dev-removable-usb.png
- gnome-finance.png
- gnome-netstatus-rx.png
- gnome-searchtool-animation.png
- gnome-starthere.png
- logviewer.png
- mozilla-thunderbird.png
- pan.png
- stock_contact.png
- stock_mail-compose.png
- stock_mail-druid.png
- stock_mail-flag-for-followup-done.png
- stock_mail-receive.png
- stock_mail-receive1.png
- stock_mail-send.png
- stock_new-spreadsheet.png
- stock_outbox.png
- stock_weather-storm.png
- Thumbs.db
- xsane.png
- RibbonButton.cs
- TabPanel.cs
- TabStripApp.csproj
- TabStripApp.sln
- TabStripControlLibrary
- demo.zip
- diagram.png
- Example.exe
- TabStripControlLibrary.dll
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Layout;
namespace RibbonStyle
{
[ToolboxItem(typeof(TabStripToolboxItem))]
public partial class TabStrip : ToolStrip
{
Font boldFont = new Font(SystemFonts.MenuFont, FontStyle.Bold);
private const int EXTRA_PADDING = 0;
public TabStrip()
{
Renderer = new TabStripProfessionalRenderer();
this.Padding = new Padding(60, 3, 30, 0);
this.AutoSize = false;
this.Size = new Size(this.Width, 26);
this.BackColor = Color.FromArgb(191, 219, 255);
this.GripStyle = ToolStripGripStyle.Hidden;
this.ShowItemToolTips = false;
}
protected override ToolStripItem CreateDefaultItem(string text, Image image, EventHandler onClick)
{
return new Tab(text, image, onClick);
}
protected override Padding DefaultPadding
{
get
{
Padding padding = base.DefaultPadding;
padding.Top += EXTRA_PADDING;
padding.Bottom += EXTRA_PADDING;
return padding;
}
}
private Tab currentSelection;
public Tab SelectedTab
{
get { return currentSelection; }
set
{
if (currentSelection != value)
{
currentSelection = value;
if (currentSelection != null)
{
PerformLayout();
if (currentSelection.TabStripPage != null)
{
currentSelection.TabStripPage.Activate();
}
}
}
}
}
protected override void OnItemClicked(ToolStripItemClickedEventArgs e)
{
for (int i = 0; i < Items.Count; i++)
{
Tab currentTab = Items[i] as Tab;
SuspendLayout();
if (currentTab != null)
{
if (currentTab != e.ClickedItem)
{
currentTab.Checked = false;
currentTab.Font = this.Font;
currentTab.b_active = false;
}
else
{
// currentTab.Font = boldFont;
currentTab.b_active = true;
}
}
ResumeLayout();
}
SelectedTab = e.ClickedItem as Tab;
base.OnItemClicked(e);
}
protected override void SetDisplayedItems()
{
base.SetDisplayedItems();
for (int i = 0; i < DisplayedItems.Count; i++)
{
if (DisplayedItems[i] == SelectedTab)
{
DisplayedItems.Add(SelectedTab);
break;
}
}
}
protected override Size DefaultSize
{
get
{
Size size = base.DefaultSize;
// size.Height += EXTRA_PADDING*2;
return size;
}
}
public override Size GetPreferredSize(Size proposedSize)
{
Size preferredSize = Size.Empty;
proposedSize -= this.Padding.Size;
foreach (ToolStripItem item in this.Items)
{
preferredSize = LayoutUtils.UnionSizes(preferredSize, item.GetPreferredSize(proposedSize) + item.Padding.Size);
}
return preferredSize + this.Padding.Size;
}
private int tabOverlap = 0;
[DefaultValue(10)]
public int TabOverlap
{
get { return tabOverlap; }
set
{
if (tabOverlap != value)
{
tabOverlap = value;
// call perform layout so we
PerformLayout();
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm Electronic Engineer, I did my end degree project at Astrophysical Institute and Tech Institute. I'm HP Procurve AIS and ASE ,Microsoft 3.5 MCTS
I live in Canary Islands ,developing customized solutions
Deeply involved in Xamarin Forms LOB (including Azure Cloud with offline support, custom controls, dependencies) projects, WP8.1 & W10 projects, WPF modern styled projects. Portable libraries like portablePDF, portableOneDrive, portableReports and portablePrinting (using Google Printing API).
Web and apps showcase at:
Expediteapps
Take a look to my blog
Blog