- demo.zip
- diagram.png
- Example.exe
- TabStripControlLibrary.dll
- 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
|
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms.Design;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Design;
namespace RibbonStyle {
/// <summary>
/// Tab is a specialized ToolStripButton with extra padding
/// </summary>
[System.ComponentModel.DesignerCategory("code")]
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.None)] // turn off the ability to add this in the DT, the TabPageSwitcher designer will provide this.
public class Tab : ToolStripButton {
private TabStripPage tabStripPage;
public bool b_on = false;
public bool b_selected = false;
public bool b_active = false;
public bool b_fading = true;
public int o_opacity = 180;
public int e_opacity = 40;
public int i_opacity;
private Timer timer = new Timer();
/// <summary>
/// Constructor for tab - support all overloads.
/// </summary>
public Tab() {
Initialize();
}
public Tab(string text):base(text,null,null) {
Initialize();
}
public Tab(Image image):base(null,image,null) {
Initialize();
}
public Tab(string text, Image image):base(text,image,null) {
Initialize();
}
public Tab(string text, Image image, EventHandler onClick):base(text,image,onClick) {
Initialize();
}
public Tab(string text, Image image, EventHandler onClick, string name):base(text,image,onClick,name) {
Initialize();
}
/// <summary>
/// Common initialization code between all CTORs.
/// </summary>
private void Initialize() {
this.AutoSize = false;
this.Width = 60;
CheckOnClick = true; // Tab will use the "checked" property in order to represent the "selected tab".
this.ForeColor = Color.FromArgb(44, 90, 154);
this.Font = new Font("Segoe UI", 9);
this.Margin = new Padding(6, this.Margin.Top, this.Margin.Right, this.Margin.Bottom);
i_opacity = o_opacity;
timer.Interval = 1;
timer.Tick += new EventHandler(timer_Tick);
}
/// <summary>
/// Hide the CheckOnClick from the Property Grid so that we can use it for our own purposes.
/// </summary>
[DefaultValue(true)]
public new bool CheckOnClick {
get { return base.CheckOnClick; }
set { base.CheckOnClick = value; }
}
/// <summary>
/// Specify the default display style to be ImageAndText
/// </summary>
protected override ToolStripItemDisplayStyle DefaultDisplayStyle {
get {
return ToolStripItemDisplayStyle.ImageAndText;
}
}
/// <summary>
/// Add extra internal spacing so we have enough room for our curve.
/// </summary>
protected override Padding DefaultPadding {
get {
return new Padding(35, 0, 6, 0);
}
}
/// <summary>
/// The associated TabStripPage - when Tab is clicked, this TabPage will be selected.
/// </summary>
[DefaultValue("null")]
public TabStripPage TabStripPage {
get {
return tabStripPage;
}
set {
tabStripPage = value;
}
}
protected override void OnMouseEnter(EventArgs e)
{
b_on = true; b_fading = true; b_selected = true;
timer.Start();
base.OnMouseEnter(e);
}
protected override void OnMouseLeave(EventArgs e)
{
b_on = false; b_fading = true;
timer.Start();
base.OnMouseLeave(e);
}
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
Bitmap bmpdummy = new Bitmap(100,100);
Graphics g = Graphics.FromImage(bmpdummy);
float textwidth = g.MeasureString(this.Text, this.Font).Width;
this.Width = Convert.ToInt16(textwidth) + 26;
}
}
private void timer_Tick(object sender, EventArgs e)
{
if (b_on)
{
if (i_opacity > e_opacity)
{
i_opacity -= 20;
this.Invalidate();
}
else
{
i_opacity = e_opacity;
this.Invalidate();
timer.Stop();
}
}
if (!b_on)
{
if (i_opacity < o_opacity)
{
i_opacity += 8;
this.Invalidate();
}
else
{
i_opacity = o_opacity;
b_fading = false;
this.Invalidate();
b_selected = false;
timer.Stop();
}
}
}
}
}
|
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