using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace Insiders.Windows.Forms
{
///
/// FunctionBar の概要の説明です。
///
[ToolboxBitmap(typeof(ToolBar))]
public class FunctionBar : System.Windows.Forms.ToolBar
{
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.ToolBarButton toolBarButtonEscape;
private System.Windows.Forms.ToolBarButton toolBarSeparator1;
private System.Windows.Forms.ToolBarButton toolBarButtonF1;
private System.Windows.Forms.ToolBarButton toolBarButtonF2;
private System.Windows.Forms.ToolBarButton toolBarButtonF3;
private System.Windows.Forms.ToolBarButton toolBarButtonF4;
private System.Windows.Forms.ToolBarButton toolBarSeparator2;
private System.Windows.Forms.ToolBarButton toolBarButtonF5;
private System.Windows.Forms.ToolBarButton toolBarButtonF6;
private System.Windows.Forms.ToolBarButton toolBarButtonF7;
private System.Windows.Forms.ToolBarButton toolBarButtonF8;
private System.Windows.Forms.ToolBarButton toolBarSeparator3;
private System.Windows.Forms.ToolBarButton toolBarButtonF9;
private System.Windows.Forms.ToolBarButton toolBarButtonF10;
private System.Windows.Forms.ToolBarButton toolBarButtonF11;
private System.Windows.Forms.ToolBarButton toolBarButtonF12;
private System.ComponentModel.IContainer components;
public FunctionBar()
{
// この呼び出しは、Windows.Forms フォーム デザイナで必要です。
InitializeComponent();
// TODO: InitComponent 呼び出しの後に初期化処理を追加してください。
}
///
/// 使用されているリソースに後処理を実行します。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region コンポーネント デザイナで生成されたコード
///
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
/// コード]エディタで変更しないでください。
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FunctionBar));
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.toolBarButtonEscape = new System.Windows.Forms.ToolBarButton();
this.toolBarSeparator1 = new System.Windows.Forms.ToolBarButton();
this.toolBarButtonF1 = new System.Windows.Forms.ToolBarButton();
this.toolBarButtonF2 = new System.Windows.Forms.ToolBarButton();
this.toolBarButtonF3 = new System.Windows.Forms.ToolBarButton();
this.toolBarButtonF4 = new System.Windows.Forms.ToolBarButton();
this.toolBarSeparator2 = new System.Windows.Forms.ToolBarButton();
this.toolBarButtonF5 = new System.Windows.Forms.ToolBarButton();
this.toolBarButtonF6 = new System.Windows.Forms.ToolBarButton();
this.toolBarButtonF7 = new System.Windows.Forms.ToolBarButton();
this.toolBarButtonF8 = new System.Windows.Forms.ToolBarButton();
this.toolBarSeparator3 = new System.Windows.Forms.ToolBarButton();
this.toolBarButtonF9 = new System.Windows.Forms.ToolBarButton();
this.toolBarButtonF10 = new System.Windows.Forms.ToolBarButton();
this.toolBarButtonF11 = new System.Windows.Forms.ToolBarButton();
this.toolBarButtonF12 = new System.Windows.Forms.ToolBarButton();
//
// imageList1
//
this.imageList1.ImageSize = new System.Drawing.Size(24, 24);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// toolBarButtonEscape
//
this.toolBarButtonEscape.Text = "閉じる";
this.toolBarButtonEscape.ImageIndex = 12;
this.toolBarButtonEscape.Tag = "Escape";
//
// toolBarSeparator1
//
this.toolBarSeparator1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
this.toolBarSeparator1.Tag = "";
//
// toolBarButtonF1
//
this.toolBarButtonF1.ImageIndex = 0;
this.toolBarButtonF1.Tag = "F1";
//
// toolBarButtonF2
//
this.toolBarButtonF2.ImageIndex = 1;
this.toolBarButtonF2.Tag = "F2";
//
// toolBarButtonF3
//
this.toolBarButtonF3.ImageIndex = 2;
this.toolBarButtonF3.Tag = "F3";
//
// toolBarButtonF4
//
this.toolBarButtonF4.ImageIndex = 3;
this.toolBarButtonF4.Tag = "F4";
//
// toolBarSeparator2
//
this.toolBarSeparator2.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
this.toolBarSeparator2.Tag = "";
//
// toolBarButtonF5
//
this.toolBarButtonF5.ImageIndex = 4;
this.toolBarButtonF5.Tag = "F5";
//
// toolBarButtonF6
//
this.toolBarButtonF6.ImageIndex = 5;
this.toolBarButtonF6.Tag = "F6";
//
// toolBarButtonF7
//
this.toolBarButtonF7.ImageIndex = 6;
this.toolBarButtonF7.Tag = "F7";
//
// toolBarButtonF8
//
this.toolBarButtonF8.ImageIndex = 7;
this.toolBarButtonF8.Tag = "F8";
//
// toolBarSeparator3
//
this.toolBarSeparator3.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButtonF9
//
this.toolBarButtonF9.ImageIndex = 8;
this.toolBarButtonF9.Tag = "F9";
//
// toolBarButtonF10
//
this.toolBarButtonF10.ImageIndex = 9;
this.toolBarButtonF10.Tag = "F10";
//
// toolBarButtonF11
//
this.toolBarButtonF11.ImageIndex = 10;
this.toolBarButtonF11.Tag = "F11";
//
// toolBarButtonF12
//
this.toolBarButtonF12.ImageIndex = 11;
this.toolBarButtonF12.Tag = "F12";
//
// FunctionBar
//
this.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
this.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButtonEscape,
this.toolBarSeparator1,
this.toolBarButtonF1,
this.toolBarButtonF2,
this.toolBarButtonF3,
this.toolBarButtonF4,
this.toolBarSeparator2,
this.toolBarButtonF5,
this.toolBarButtonF6,
this.toolBarButtonF7,
this.toolBarButtonF8,
this.toolBarSeparator3,
this.toolBarButtonF9,
this.toolBarButtonF10,
this.toolBarButtonF11,
this.toolBarButtonF12});
this.ButtonSize = new System.Drawing.Size(24, 24);
this.ImageList = this.imageList1;
this.Size = new System.Drawing.Size(100, 30);
this.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
}
#endregion
#region ファンクションの設定メソッド
///
/// 指定されたファンクション・ボタンの設定を変更し、有効にする。
///
public void SetFunction(FunctionKey key, string setText, string setToolTipText)
{
int index = (int)TranlateKeyToButtonID(key);
this.Buttons[index].Text = setText;
this.Buttons[index].ToolTipText = setToolTipText;
this.Buttons[index].Enabled = true;
}
///
/// 指定されたファンクション・ボタンを無効にする。
///
///
public void DisableFunction(params FunctionKey[] keys)
{
if (keys == null)
{
throw new ArgumentNullException("keys");
}
int index;
for (int i = 0; i < keys.Length; i++)
{
index = (int)TranlateKeyToButtonID(keys[i]);
this.Buttons[index].Text = "";
this.Buttons[index].ToolTipText = "";
this.Buttons[index].Enabled = false;
}
}
#endregion
#region ファンクション・ボタンの内部処理コード
///
/// FunctionKeyをMenuItemIDに変換します。
///
///
///
private FunctionButton TranlateKeyToButtonID(FunctionKey key)
{
switch (key)
{
case FunctionKey.F1: return FunctionButton.F1;
case FunctionKey.F2: return FunctionButton.F2;
case FunctionKey.F3: return FunctionButton.F3;
case FunctionKey.F4: return FunctionButton.F4;
case FunctionKey.F5: return FunctionButton.F5;
case FunctionKey.F6: return FunctionButton.F6;
case FunctionKey.F7: return FunctionButton.F7;
case FunctionKey.F8: return FunctionButton.F8;
case FunctionKey.F9: return FunctionButton.F9;
case FunctionKey.F10: return FunctionButton.F10;
case FunctionKey.F11: return FunctionButton.F11;
case FunctionKey.F12: return FunctionButton.F12;
case FunctionKey.Escape: return FunctionButton.Escape;
}
throw new ArgumentException("key");
}
///
/// ファンクション・ボタンのインデック番号
///
private enum FunctionButton
{
Escape = 0,
F1 = 2,
F2 = 3,
F3 = 4,
F4 = 5,
F5 = 7,
F6 = 8,
F7 = 9,
F8 = 10,
F9 = 12,
F10 = 13,
F11 = 14,
F12 = 15
}
#endregion
}
}