📄 wroxtoolbarbuttonsform.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace WroxDesign.Design
{
/// <summary>
/// Summary description for WroxToolBarButtons.
/// </summary>
public class WroxToolBarButtonsForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel btnResult;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.ListBox lstButtons;
private System.Windows.Forms.Button btnAccept;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnAdd;
private System.Windows.Forms.Button btnRemove;
private System.Windows.Forms.Button btnUp;
private System.Windows.Forms.Button btnDown;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.PropertyGrid propGrid;
private ArrayList _buttons;
public WroxToolBarButtonsForm(ArrayList Buttons)
{
InitializeComponent();
_buttons = Buttons;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnAdd = new System.Windows.Forms.Button();
this.btnRemove = new System.Windows.Forms.Button();
this.btnAccept = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.btnResult = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.btnDown = new System.Windows.Forms.Button();
this.btnUp = new System.Windows.Forms.Button();
this.lstButtons = new System.Windows.Forms.ListBox();
this.propGrid = new System.Windows.Forms.PropertyGrid();
this.btnResult.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// btnAdd
//
this.btnAdd.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
this.btnAdd.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnAdd.Location = new System.Drawing.Point(4, 276);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(56, 20);
this.btnAdd.TabIndex = 1;
this.btnAdd.Text = "Add";
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
//
// btnRemove
//
this.btnRemove.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
this.btnRemove.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnRemove.Location = new System.Drawing.Point(88, 276);
this.btnRemove.Name = "btnRemove";
this.btnRemove.Size = new System.Drawing.Size(56, 20);
this.btnRemove.TabIndex = 2;
this.btnRemove.Text = "Remove";
this.btnRemove.Click += new System.EventHandler(this.btnRemove_Click);
//
// btnAccept
//
this.btnAccept.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
this.btnAccept.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnAccept.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnAccept.Location = new System.Drawing.Point(308, 4);
this.btnAccept.Name = "btnAccept";
this.btnAccept.Size = new System.Drawing.Size(60, 20);
this.btnAccept.TabIndex = 0;
this.btnAccept.Text = "Accept";
//
// btnCancel
//
this.btnCancel.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCancel.Location = new System.Drawing.Point(376, 4);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(64, 20);
this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "Cancel";
//
// btnResult
//
this.btnResult.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btnCancel,
this.btnAccept});
this.btnResult.Dock = System.Windows.Forms.DockStyle.Bottom;
this.btnResult.Location = new System.Drawing.Point(0, 304);
this.btnResult.Name = "btnResult";
this.btnResult.Size = new System.Drawing.Size(444, 28);
this.btnResult.TabIndex = 1;
//
// panel1
//
this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btnDown,
this.btnUp,
this.btnRemove,
this.btnAdd,
this.lstButtons});
this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(200, 304);
this.panel1.TabIndex = 3;
//
// btnDown
//
this.btnDown.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnDown.Location = new System.Drawing.Point(152, 28);
this.btnDown.Name = "btnDown";
this.btnDown.Size = new System.Drawing.Size(44, 20);
this.btnDown.TabIndex = 4;
this.btnDown.Text = "Down";
this.btnDown.Click += new System.EventHandler(this.btnDown_Click);
//
// btnUp
//
this.btnUp.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnUp.Location = new System.Drawing.Point(152, 4);
this.btnUp.Name = "btnUp";
this.btnUp.Size = new System.Drawing.Size(44, 20);
this.btnUp.TabIndex = 3;
this.btnUp.Text = "Up";
this.btnUp.Click += new System.EventHandler(this.btnUp_Click);
//
// lstButtons
//
this.lstButtons.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left);
this.lstButtons.Name = "lstButtons";
this.lstButtons.Size = new System.Drawing.Size(148, 264);
this.lstButtons.TabIndex = 0;
this.lstButtons.SelectedIndexChanged += new System.EventHandler(this.lstButtons_SelectedIndexChanged);
//
// propGrid
//
this.propGrid.CommandsVisibleIfAvailable = true;
this.propGrid.Dock = System.Windows.Forms.DockStyle.Fill;
this.propGrid.LargeButtons = false;
this.propGrid.LineColor = System.Drawing.SystemColors.ScrollBar;
this.propGrid.Location = new System.Drawing.Point(200, 0);
this.propGrid.Name = "propGrid";
this.propGrid.Size = new System.Drawing.Size(244, 304);
this.propGrid.TabIndex = 2;
this.propGrid.Text = "WroxButton properties";
this.propGrid.ViewBackColor = System.Drawing.SystemColors.Window;
this.propGrid.ViewForeColor = System.Drawing.SystemColors.WindowText;
//
// WroxToolBarButtonsForm
//
this.AcceptButton = this.btnAccept;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(444, 332);
this.ControlBox = false;
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.propGrid,
this.panel1,
this.btnResult});
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.Name = "WroxToolBarButtonsForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "WroxToolBar Button Collection Editor";
this.Load += new System.EventHandler(this.WroxToolBarButtons_Load);
this.btnResult.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void lstButtons_SelectedIndexChanged(object sender, System.EventArgs e)
{
propGrid.SelectedObject = lstButtons.SelectedItem;
}
private void WroxToolBarButtons_Load(object sender, System.EventArgs e)
{
foreach (object obj in _buttons)
lstButtons.Items.Add(obj);
}
private void btnAdd_Click(object sender, System.EventArgs e)
{
int i = lstButtons.Items.Add(new WroxButton());
lstButtons.SelectedIndex = i;
}
private void btnRemove_Click(object sender, System.EventArgs e)
{
lstButtons.Items.Remove(lstButtons.SelectedItem);
propGrid.SelectedObject = null;
}
private void btnUp_Click(object sender, System.EventArgs e)
{
object selected = lstButtons.SelectedItem;
int idx = lstButtons.SelectedIndex;
if (selected != null)
{
lstButtons.Items.Remove(selected);
lstButtons.Items.Insert(idx - 1, selected);
}
}
private void btnDown_Click(object sender, System.EventArgs e)
{
object selected = lstButtons.SelectedItem;
int idx = lstButtons.SelectedIndex;
if (selected != null)
{
lstButtons.Items.Remove(selected);
lstButtons.Items.Insert(idx, selected);
}
}
public ArrayList Buttons
{
get { return new ArrayList(lstButtons.Items); }
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -