📄 treeviewoptions.cs
字号:
// TreeViewOptions.cs
// Copyright (C) 2001 Mike Krueger
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Xml;
using SharpDevelop.Gui.Dialogs.OptionPanels;
using SharpDevelop.Internal.Project;
using SharpDevelop.Internal.Text;
using SharpDevelop.Tool.Data;
namespace SharpDevelop.Gui.Dialogs {
/// <summary>
/// TreeView options are used, when more options will be edited (for something like
/// IDE Options + Plugin Options)
/// </summary>
public class TreeViewOptions : System.Windows.Forms.Form, ISdOptionDialog
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TreeView treeView1;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Panel panel3;
private TreeNode ideoptions = new TreeNode(Resource.GetString("Dialog.Options.TreeViewOptions.SharpDevelopOptionsText"));
ArrayList OptionPanels = new ArrayList();
public override void Dispose()
{
base.Dispose();
foreach (AbstractOptionPanel pane in OptionPanels)
pane.Dispose();
}
void AcceptEvent(object sender, EventArgs e)
{
foreach (AbstractOptionPanel pane in OptionPanels)
pane.Accept();
}
void SelectNode(object sender, TreeViewEventArgs e)
{
foreach (AbstractOptionPanel panel in OptionPanels) {
if (treeView1.SelectedNode.Text == panel.PanelName) {
panel3.Controls.Clear();
panel3.Controls.Add(panel);
panel.Dock = DockStyle.Fill;
label1.Text = panel.PanelName;
break;
}
}
}
public void AddOptionPanel(AbstractOptionPanel panel)
{
OptionPanels.Add(panel);
TreeNode node = new TreeNode(panel.PanelName);
node.ImageIndex = node.SelectedImageIndex = 2;
ideoptions.Nodes.Add(node);
if (treeView1.SelectedNode == null) // set the first inserted option node as selected.
treeView1.SelectedNode = node;
}
void InitImageList()
{
ImageList imglist = new ImageList();
imglist.Images.Add(Resource.GetBitmap("Icons.16x16.ClosedFolderBitmap"));
imglist.Images.Add(Resource.GetBitmap("Icons.16x16.OpenFolderBitmap"));
imglist.Images.Add(Resource.GetBitmap("Icons.16x16.Reference"));
treeView1.ImageList = imglist;
}
void ShowOpenFolderIcon(object sender, TreeViewCancelEventArgs e)
{
if (e.Node == ideoptions) {
e.Node.ImageIndex = e.Node.SelectedImageIndex = 1;
}
}
void ShowClosedFolderIcon(object sender, TreeViewCancelEventArgs e)
{
if (e.Node == ideoptions) {
e.Node.ImageIndex = e.Node.SelectedImageIndex = 0;
}
}
public TreeViewOptions(MainWindow window)
{
this.Text = Resource.GetString("Dialog.Options.TreeViewOptions.DialogName");
this.InitializeComponent();
button1.Click += new EventHandler(AcceptEvent);
this.FormBorderStyle = FormBorderStyle.Sizable;
MaximizeBox = MinimizeBox = false;
ShowInTaskbar = false;
StartPosition = FormStartPosition.CenterParent;
Owner = window;
Icon = Resource.GetIcon("Icons.16x16.Options");
InitImageList();
treeView1.Nodes.Add(ideoptions);
treeView1.BeforeExpand += new TreeViewCancelEventHandler(ShowOpenFolderIcon);
treeView1.BeforeCollapse += new TreeViewCancelEventHandler(ShowClosedFolderIcon);
}
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.splitter1 = new System.Windows.Forms.Splitter();
this.treeView1 = new System.Windows.Forms.TreeView();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.panel2 = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {this.panel2,
this.splitter1,
this.treeView1});
this.panel1.Size = new System.Drawing.Size(592, 456);
this.panel1.TabIndex = 0;
//
// splitter1
//
this.splitter1.Location = new System.Drawing.Point(121, 0);
this.splitter1.Size = new System.Drawing.Size(3, 456);
this.splitter1.TabIndex = 1;
this.splitter1.TabStop = false;
//
// treeView1
//
this.treeView1.Dock = System.Windows.Forms.DockStyle.Left;
this.treeView1.ImageIndex = -1;
this.treeView1.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(170, 456);
this.treeView1.TabIndex = 0;
this.treeView1.HideSelection = false;
this.treeView1.AfterSelect += new TreeViewEventHandler(SelectNode);
//
// button1
//
this.button1.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
this.button1.Location = new System.Drawing.Point(8, 464);
this.button1.Size = new System.Drawing.Size(74, 23);
this.button1.TabIndex = 1;
this.button1.DialogResult = DialogResult.OK;
this.button1.Text = Resource.GetString("Global.OKButtonText");
//
// button2
//
this.button2.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
this.button2.Location = new System.Drawing.Point(88, 464);
this.button2.Size = new System.Drawing.Size(74, 23);
this.button2.TabIndex = 2;
this.button2.DialogResult = DialogResult.Cancel;
this.button2.Text = Resource.GetString("Global.CancelButtonText");
//
// panel2
//
this.panel2.Controls.AddRange(new System.Windows.Forms.Control[] {this.panel3,
this.label1});
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(126, 0);
this.panel2.Size = new System.Drawing.Size(466, 456);
this.panel2.TabIndex = 2;
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(0, 8);
this.label1.Size = new System.Drawing.Size(456, 24);
this.label1.TabIndex = 2;
//
// panel3
//
this.panel3.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panel3.BackColor = System.Drawing.SystemColors.Control;
this.panel3.Location = new System.Drawing.Point(0, 32);
this.panel3.Size = new System.Drawing.Size(464, 424);
this.panel3.TabIndex = 4;
StartPosition = FormStartPosition.CenterScreen;
//
// Win32Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(622, 493);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.button2,
this.button1,
this.panel1});
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.ResumeLayout(false);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -