轉(zhuǎn)帖|其它|編輯:郝浩|2010-12-20 14:05:57.000|閱讀 2842 次
概述:在很多軟件界面中,一個好的界面、方便的導(dǎo)航除了為軟件增色不少外,也提高了用戶體驗,促進(jìn)軟件的良性發(fā)展,因為我們的軟件一般需要有菜單、工具條、狀態(tài)條等這些基本的東西,但是工具條本身應(yīng)該是一些常用的快捷鍵,內(nèi)容不能放置太多,否則會容易給客戶凌亂的感覺。菜單條則可以分類,但是好像每次去點擊,一步步深入,則顯得比較麻煩。本篇我介紹一下一個很好的導(dǎo)航條OutlookBar控件。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
在很多軟件界面中,一個好的界面、方便的導(dǎo)航除了為軟件增色不少外,也提高了用戶體驗,促進(jìn)軟件的良性發(fā)展,因為我們的軟件一般需要有菜單、工具條、狀態(tài)條等這些基本的東西,但是工具條本身應(yīng)該是一些常用的快捷鍵,內(nèi)容不能放置太多,否則會容易給客戶凌亂的感覺。菜單條則可以分類,但是好像每次去點擊,一步步深入,則顯得比較麻煩。本篇我介紹一下一個很好的導(dǎo)航條OutlookBar控件。
在我的2個版本的送水軟件中,都用到了OutLookBar的工具條,使用的界面效果如下所示。
左邊的工具條它們都是同一個控件來的,控件提供了一種類似Outlook方式的工具條,用來切換各種業(yè)務(wù)窗口,用上這個控件,肯定為您的程序增色不少。這個控件結(jié)合上面介紹的布局控件"WeifenLuo.WinFormsUI.Docking"(具體見文章WinForm界面開發(fā)之布局控件"WeifenLuo.WinFormsUI.Docking"的使用),那么效果會更好。下面介紹下如何在代碼中使用這個Outlookbar工具控件。
1、首先創(chuàng)建一個窗體,用來放置該控件,由于該控件不是一個可視化的控件,因此需要做一些特別的處理,如添加一個ImageList控件,并把OutlookBar控件中用到的圖標(biāo)加載進(jìn)來,記得選擇一些好看的圖片哦。
2、在MainToolWindow窗體的構(gòu)造函數(shù)或者Load事件中添加OutlookBar的初始化代碼和設(shè)置代碼,如下所示。
private OutlookBar outlookBar1 = null;
public MainToolWindow()
{
InitializeComponent();
InitializeOutlookbar();
}
private void InitializeOutlookbar()
{
outlookBar1 = new OutlookBar();
#region 銷售管理
OutlookBarBand outlookShortcutsBand = new OutlookBarBand("銷售管理");
outlookShortcutsBand.SmallImageList = this.imageList;
outlookShortcutsBand.LargeImageList = this.imageList;
outlookShortcutsBand.Items.Add(new OutlookBarItem("訂單管理", 0));
outlookShortcutsBand.Items.Add(new OutlookBarItem("客戶管理", 1));
outlookShortcutsBand.Items.Add(new OutlookBarItem("水票管理", 2));
outlookShortcutsBand.Items.Add(new OutlookBarItem("套餐管理", 3));
outlookShortcutsBand.Items.Add(new OutlookBarItem("今日盤點", 5));
outlookShortcutsBand.Items.Add(new OutlookBarItem("來電記錄", 6));
outlookShortcutsBand.Items.Add(new OutlookBarItem("送貨記錄", 7));
outlookShortcutsBand.Background = SystemColors.AppWorkspace;
outlookShortcutsBand.TextColor = Color.White;
outlookBar1.Bands.Add(outlookShortcutsBand);
#endregion
#region 產(chǎn)品庫存管理
OutlookBarBand mystorageBand = new OutlookBarBand("產(chǎn)品庫存管理");
mystorageBand.SmallImageList = this.imageList;
mystorageBand.LargeImageList = this.imageList;
mystorageBand.Items.Add(new OutlookBarItem("產(chǎn)品管理", 2));
mystorageBand.Items.Add(new OutlookBarItem("庫存管理", 3));
mystorageBand.Background = SystemColors.AppWorkspace;
mystorageBand.TextColor = Color.White;
outlookBar1.Bands.Add(mystorageBand);
#endregion
outlookBar1.Dock = DockStyle.Fill;
outlookBar1.SetCurrentBand(0);
outlookBar1.ItemClicked += new OutlookBarItemClickedHandler(OnOutlookBarItemClicked);
outlookBar1.ItemDropped += new OutlookBarItemDroppedHandler(OnOutlookBarItemDropped);
//outlookBar1.FlatArrowButtons = true;
this.panel1.Controls.AddRange(new Control[] { outlookBar1 });
}
private void OnOutlookBarItemClicked(OutlookBarBand band, OutlookBarItem item)
{
switch (item.Text)
{
#region 銷售管理
case "訂單管理":
Portal.gc.MainDialog.ShowContent("訂單管理", typeof(FrmOrder));
break;
case "客戶管理":
Portal.gc.MainDialog.ShowContent("客戶管理", typeof(FrmCustomer));
break;
case "水票管理":
Portal.gc.MainDialog.ShowContent("水票管理", typeof(FrmTicketHistory));
break;
case "套餐管理":
FrmYouhui dlg = new FrmYouhui();
dlg.ShowDialog();
break;
case "來電記錄":
Portal.gc.MainDialog.ShowContent("來電記錄", typeof(FrmComingCall));
break;
case "送貨記錄":
Portal.gc.MainDialog.ShowContent("送貨記錄", typeof(FrmDeliving));
break;
#endregion
#region 產(chǎn)品庫存管理
case "產(chǎn)品管理":
Portal.gc.MainDialog.ShowContent("產(chǎn)品管理", typeof(FrmProduct));
break;
case "庫存管理":
Portal.gc.MainDialog.ShowContent("庫存管理", typeof(FrmStock));
break;
#endregion
..
default:
break;
}
}
private void OnOutlookBarItemDropped(OutlookBarBand band, OutlookBarItem item)
{
// string message = "Item : " + item.Text + " was dropped";
// MessageBox.Show(message);
}
在代碼中注意綁定相關(guān)項目的圖標(biāo)序號,否則如果序號不正確,可能會出錯的,其實整個控件就是提供展示一些圖標(biāo),并用同一的事件對鼠標(biāo)的事件進(jìn)行處理,用戶根據(jù)OutlookBarItem的文本內(nèi)容來判斷處理,雖然模式有點落后,不過個人感覺控件還是非常好用,方便。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:網(wǎng)絡(luò)轉(zhuǎn)載