实现:
利用OutlookBar命名空间
OutlookBar.cs:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace OutlookBar
{
internal class BandTagInfo
{
public OutlookBar outlookBar;
public int index;
public BandTagInfo(OutlookBar ob, int index)
{
outlookBar=ob;
this.index=index;
}
}
public class OutlookBar : Panel
{
private int buttonHeight;
private int selectedBand;
private int selectedBandHeight;
public int ButtonHeight
{
get
{
return buttonHeight;
}
set
{
buttonHeight=value;
// do recalc layout for entire bar
}
}
public int SelectedBand
{
get
{
return selectedBand;
}
set
{
SelectBand(value);
}
}
public OutlookBar()
{
buttonHeight=25;
selectedBand=0;
selectedBandHeight=0;
}
public void Initialize()
{
// parent must exist!
Parent.SizeChanged+=new EventHandler(SizeChangedEvent);
}
public void AddBand(string caption, ContentPanel content)
{
content.outlookBar=this;
int index=Controls.Count;
BandTagInfo bti=new BandTagInfo(this, index);
BandPanel bandPanel=new BandPanel(caption, content, bti);
Controls.Add(bandPanel);
UpdateBarInfo();
RecalcLayout(bandPanel, index);
}
public void SelectBand(int index)
{
selectedBand=index;
RedrawBands();
}
private void RedrawBands()
{
for (int i=0; i<Controls.Count; i++)
C#实现OutlookBar
最新推荐文章于 2025-06-12 14:02:27 发布