| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525 | using PaintDotNet.Base.CommTool;using PaintDotNet.Instrument.CustomInterface;using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace PaintDotNet.Instrument{    /// <summary>    /// 自定义界面    /// </summary>    internal class CustomInterfaceDialog : PdnBaseForm    {        /// <summary>        /// 工作空间        /// </summary>        private AppWorkspace appWorkspace;        /// <summary>        /// 当前选中 1工具栏 2快捷键 3快捷栏        /// </summary>        private int currentInedx = 0;        /// <summary>        /// 工具栏自定义组件        /// </summary>        private TopTools topTools;        /// <summary>        /// 快捷键自定义组件        /// </summary>        private ShortKeys shortKeys;        /// <summary>        /// 快捷栏自定义组件        /// </summary>        private FastTools fastTools;        /// <summary>        /// 新增、重命名的弹窗        /// </summary>        private CreateNameDialog createNameDialog;        /// <summary>        /// 是否新建弹窗        /// </summary>        private bool istoCreate = true;        #region 控件        private CustomControl.SelectButton buttonTopTools;        private CustomControl.SelectButton buttonShortKeys;        private CustomControl.SelectButton buttonFastTools;        private GroupBox groupBoxTypes;        private Button buttonSave;        private Button buttonExport;        private Button buttonImport;        private Button buttonCreateName;        private Button buttonDeleteName;        private Button buttonEditName;        private GroupBox groupBoxButtons;        //private Label label1;        //private Label label2;        #endregion        public CustomInterfaceDialog(AppWorkspace AppWorkspace)        {            this.appWorkspace = AppWorkspace;            InitializeComponent();            InitializeLanguageText();            this.StartPosition = FormStartPosition.CenterScreen;                        this.topTools = new TopTools(this.appWorkspace);            this.topTools.CustomInterfaceDialog = this;            this.shortKeys = new ShortKeys(this.appWorkspace);            this.fastTools = new FastTools(this.appWorkspace);            this.buttonTopToolsClick(null, null);        }        private void InitializeLanguageText()        {            this.Text = PdnResources.GetString("Menu.Tools.CustomInterface.Text");            this.groupBoxTypes.Text = PdnResources.GetString("Menu.Type.text");            this.buttonFastTools.BtnText = PdnResources.GetString("Menu.tool.Generateshortcut.Shortcutbar.text");            this.buttonShortKeys.BtnText = PdnResources.GetString("Menu.hotkey.text");            this.buttonTopTools.BtnText = PdnResources.GetString("Menu.tool.Generateshortcut.toolbar.text");            this.groupBoxButtons.Text = PdnResources.GetString("Menu.operation.text");            this.buttonDeleteName.Text = PdnResources.GetString("Menu.Edit.Delete.Text");            this.buttonEditName.Text = PdnResources.GetString("Menu.Rename.text");            this.buttonCreateName.Text = PdnResources.GetString("Menu.New.text");            this.buttonExport.Text = PdnResources.GetString("Menu.tool.Generateshortcut.Exportconfiguration.text");            this.buttonImport.Text = PdnResources.GetString("Menu.tool.Generateshortcut.Importconfiguration.text");            this.buttonSave.Text = PdnResources.GetString("Menu.File.Save.Text");        }        private void InitializeComponent()        {            this.groupBoxTypes = new System.Windows.Forms.GroupBox();            this.buttonFastTools = new PaintDotNet.CustomControl.SelectButton();            this.buttonShortKeys = new PaintDotNet.CustomControl.SelectButton();            this.buttonTopTools = new PaintDotNet.CustomControl.SelectButton();            this.groupBoxButtons = new System.Windows.Forms.GroupBox();            this.buttonDeleteName = new System.Windows.Forms.Button();            this.buttonEditName = new System.Windows.Forms.Button();            this.buttonCreateName = new System.Windows.Forms.Button();            this.buttonExport = new System.Windows.Forms.Button();            this.buttonImport = new System.Windows.Forms.Button();            this.buttonSave = new System.Windows.Forms.Button();            this.groupBoxTypes.SuspendLayout();            this.groupBoxButtons.SuspendLayout();            this.SuspendLayout();            //             // groupBoxTypes            //             this.groupBoxTypes.Controls.Add(this.buttonFastTools);            this.groupBoxTypes.Controls.Add(this.buttonShortKeys);            this.groupBoxTypes.Controls.Add(this.buttonTopTools);            this.groupBoxTypes.Location = new System.Drawing.Point(13, 13);            this.groupBoxTypes.Name = "groupBoxTypes";            this.groupBoxTypes.Size = new System.Drawing.Size(87, 463);            this.groupBoxTypes.TabIndex = 1;            this.groupBoxTypes.TabStop = false;            this.groupBoxTypes.Text = "类型";            //             // buttonFastTools            //             this.buttonFastTools.BackColor = System.Drawing.SystemColors.ControlDark;            this.buttonFastTools.BtnSelect = false;            this.buttonFastTools.BtnText = "按钮";            this.buttonFastTools.Location = new System.Drawing.Point(6, 83);            this.buttonFastTools.Name = "buttonFastTools";            this.buttonFastTools.Size = new System.Drawing.Size(75, 23);            this.buttonFastTools.TabIndex = 2;            this.buttonFastTools.Click += new System.EventHandler(this.buttonFastToolsClick);            //             // buttonShortKeys            //             this.buttonShortKeys.BackColor = System.Drawing.SystemColors.ControlDark;            this.buttonShortKeys.BtnSelect = false;            this.buttonShortKeys.BtnText = "按钮";            this.buttonShortKeys.Location = new System.Drawing.Point(6, 53);            this.buttonShortKeys.Name = "buttonShortKeys";            this.buttonShortKeys.Size = new System.Drawing.Size(75, 23);            this.buttonShortKeys.TabIndex = 1;            this.buttonShortKeys.Click += new System.EventHandler(this.buttonShortKeysClick);            //             // buttonTopTools            //             this.buttonTopTools.BackColor = System.Drawing.SystemColors.ControlDark;            this.buttonTopTools.BtnSelect = false;            this.buttonTopTools.BtnText = "按钮";            this.buttonTopTools.Location = new System.Drawing.Point(6, 23);            this.buttonTopTools.Name = "buttonTopTools";            this.buttonTopTools.Size = new System.Drawing.Size(75, 23);            this.buttonTopTools.TabIndex = 0;            this.buttonTopTools.Click += new System.EventHandler(this.buttonTopToolsClick);            //             // groupBoxButtons            //             this.groupBoxButtons.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)             | System.Windows.Forms.AnchorStyles.Right)));            this.groupBoxButtons.Controls.Add(this.buttonDeleteName);            this.groupBoxButtons.Controls.Add(this.buttonEditName);            this.groupBoxButtons.Controls.Add(this.buttonCreateName);            this.groupBoxButtons.Controls.Add(this.buttonExport);            this.groupBoxButtons.Controls.Add(this.buttonImport);            this.groupBoxButtons.Controls.Add(this.buttonSave);            this.groupBoxButtons.Location = new System.Drawing.Point(107, 13);            this.groupBoxButtons.Name = "groupBoxButtons";            this.groupBoxButtons.Size = new System.Drawing.Size(623, 58);            this.groupBoxButtons.TabIndex = 2;            this.groupBoxButtons.TabStop = false;            this.groupBoxButtons.Text = "操作";            //             // buttonDeleteName            //             this.buttonDeleteName.Location = new System.Drawing.Point(461, 23);            this.buttonDeleteName.Name = "buttonDeleteName";            this.buttonDeleteName.Size = new System.Drawing.Size(75, 23);            this.buttonDeleteName.TabIndex = 5;            this.buttonDeleteName.Text = "删除";            this.buttonDeleteName.UseVisualStyleBackColor = true;            this.buttonDeleteName.Click += new System.EventHandler(this.buttonDeleteNameClick);            //             // buttonEditName            //             this.buttonEditName.Location = new System.Drawing.Point(379, 23);            this.buttonEditName.Name = "buttonEditName";            this.buttonEditName.Size = new System.Drawing.Size(75, 23);            this.buttonEditName.TabIndex = 4;            this.buttonEditName.Text = "重命名";            this.buttonEditName.UseVisualStyleBackColor = true;            this.buttonEditName.Click += new System.EventHandler(this.buttonEditNameClick);            //             // buttonCreateName            //             this.buttonCreateName.Location = new System.Drawing.Point(297, 23);            this.buttonCreateName.Name = "buttonCreateName";            this.buttonCreateName.Size = new System.Drawing.Size(75, 23);            this.buttonCreateName.TabIndex = 3;            this.buttonCreateName.Text = "新建";            this.buttonCreateName.UseVisualStyleBackColor = true;            this.buttonCreateName.Click += new System.EventHandler(this.buttonCreateNameClick);            //             // buttonExport            //             this.buttonExport.Location = new System.Drawing.Point(135, 23);            this.buttonExport.Name = "buttonExport";            this.buttonExport.Size = new System.Drawing.Size(75, 23);            this.buttonExport.TabIndex = 2;            this.buttonExport.Text = "导出配置";            this.buttonExport.UseVisualStyleBackColor = true;            this.buttonExport.Click += new System.EventHandler(this.buttonExportClick);            //             // buttonImport            //             this.buttonImport.Location = new System.Drawing.Point(216, 23);            this.buttonImport.Name = "buttonImport";            this.buttonImport.Size = new System.Drawing.Size(75, 23);            this.buttonImport.TabIndex = 1;            this.buttonImport.Text = "导入配置";            this.buttonImport.UseVisualStyleBackColor = true;            this.buttonImport.Click += new System.EventHandler(this.buttonImportClick);            //             // buttonSave            //             this.buttonSave.Location = new System.Drawing.Point(542, 23);            this.buttonSave.Name = "buttonSave";            this.buttonSave.Size = new System.Drawing.Size(75, 23);            this.buttonSave.TabIndex = 0;            this.buttonSave.Text = "保存";            this.buttonSave.UseVisualStyleBackColor = true;            this.buttonSave.Click += new System.EventHandler(this.buttonSaveClick);            //             // CustomInterfaceDialog            //             this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);            this.ClientSize = new System.Drawing.Size(742, 488);            this.Controls.Add(this.groupBoxButtons);            this.Controls.Add(this.groupBoxTypes);            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;            this.MaximizeBox = false;            this.MinimizeBox = false;            this.Name = "CustomInterfaceDialog";            this.Text = "自定义界面";            this.Controls.SetChildIndex(this.groupBoxTypes, 0);            this.Controls.SetChildIndex(this.groupBoxButtons, 0);            this.groupBoxTypes.ResumeLayout(false);            this.groupBoxButtons.ResumeLayout(false);            this.ResumeLayout(false);        }        /// <summary>        /// 工具栏        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void buttonTopToolsClick(object sender, EventArgs e)        {            if (currentInedx != 1)            {                //设置按钮的选中/非选择的状态                buttonTopTools.BtnSelect = true;                buttonShortKeys.BtnSelect = false;                buttonFastTools.BtnSelect = false;                this.Controls.Remove(this.shortKeys);                this.Controls.Remove(this.fastTools);                this.topTools.Location = new System.Drawing.Point(107, 78);                this.Controls.Add(this.topTools);                currentInedx = 1;                this.buttonSave.Text = PdnResources.GetString("Menu.File.Save.Text");            }            ChangeButtonByIndex();        }        /// <summary>        /// 快捷键        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void buttonShortKeysClick(object sender, EventArgs e)        {            if (currentInedx != 2)            {                //设置按钮的选中/非选择的状态                buttonShortKeys.BtnSelect = true;                buttonFastTools.BtnSelect = false;                buttonTopTools.BtnSelect = false;                this.Controls.Remove(this.topTools);                this.Controls.Remove(this.fastTools);                this.shortKeys.Location = new System.Drawing.Point(107, 78);                this.Controls.Add(this.shortKeys);                currentInedx = 2;                this.buttonSave.Text = PdnResources.GetString("Menu.File.Close.Text");//#17140            }            ChangeButtonByIndex();        }        /// <summary>        /// 快捷栏        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void buttonFastToolsClick(object sender, EventArgs e)        {            if (currentInedx != 3)            {                //设置按钮的选中/非选择的状态                buttonFastTools.BtnSelect = true;                buttonTopTools.BtnSelect = false;                buttonShortKeys.BtnSelect = false;                this.Controls.Remove(this.topTools);                this.Controls.Remove(this.shortKeys);                this.fastTools.Location = new System.Drawing.Point(107, 78);                this.Controls.Add(this.fastTools);                currentInedx = 3;                this.buttonSave.Text = PdnResources.GetString("Menu.File.Save.Text");            }            ChangeButtonByIndex();        }        private void ChangeButtonByIndex()         {            //6 135, 23            //5 216, 23            //7 297, 23 隐藏显示            //8 379, 23 隐藏显示            //9 461, 23 隐藏显示            //4 542, 23            switch (currentInedx)             {                case 1:                    this.buttonCreateName.Visible = true;                    this.buttonEditName.Visible = true;                    this.buttonDeleteName.Visible = true;                    this.buttonSave.Visible = false;//自定义菜单实时保存 导入配置重启生效 (这里可以去掉保存按钮了,因为实时保存,以及导入配置还差实时保存更新,或者提示“软件重启后生效”)                    this.buttonExport.Location = new System.Drawing.Point(135 + 81, 23);                    this.buttonImport.Location = new System.Drawing.Point(216 + 81, 23);                    this.buttonCreateName.Location = new System.Drawing.Point(297 + 81, 23);                    this.buttonEditName.Location = new System.Drawing.Point(379 + 81, 23);                    this.buttonDeleteName.Location = new System.Drawing.Point(461 + 81, 23);                    //this.buttonSave.Location = new System.Drawing.Point(542, 23);                    break;                case 2:                    this.buttonCreateName.Visible = false;                    this.buttonEditName.Visible = false;                    this.buttonDeleteName.Visible = false;                    this.buttonSave.Visible = true;                    this.buttonExport.Location = new System.Drawing.Point(379, 23);                    this.buttonImport.Location = new System.Drawing.Point(461, 23);                    this.buttonSave.Location = new System.Drawing.Point(542, 23);                    break;                case 3:                    this.buttonCreateName.Visible = false;                    this.buttonEditName.Visible = false;                    this.buttonDeleteName.Visible = false;                    this.buttonSave.Visible = true;                    this.buttonExport.Location = new System.Drawing.Point(379, 23);                    this.buttonImport.Location = new System.Drawing.Point(461, 23);                    this.buttonSave.Location = new System.Drawing.Point(542, 23);                    break;            }        }        /// <summary>        /// 保存        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void buttonSaveClick(object sender, EventArgs e)        {            switch (currentInedx)            {                case 1: //1工具栏                    this.topTools.SaveToolbar();                    break;                case 2: //2快捷键                    this.Close();                    //SaveShortcutKeys()???                    break;                case 3: //3快捷栏                    this.fastTools.SaveToolbar();                    break;            }            //this.Close();        }        /// <summary>        /// 删除        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void buttonDeleteNameClick(object sender, EventArgs e)        {            if(currentInedx==1) //1工具栏            {                if (MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodelete.Text")+"?", PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.OK)                {                    this.topTools.TreeView2Delete();                }            }        }        /// <summary>        /// 重命名        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void buttonEditNameClick(object sender, EventArgs e)        {            if(this.topTools.treeViewLeft.SelectedNode!=null)            {                istoCreate = false;                createNameDialog = new CreateNameDialog(this);                createNameDialog.SetThisText(PdnResources.GetString("Menu.tool.Generateshortcut.Edittoolbar.text"));                createNameDialog.SetTextBoxValue(this.topTools.GetSelectedNodeText());                createNameDialog.StartPosition = FormStartPosition.CenterParent;                createNameDialog.ShowDialog();            }            else            {                MessageBox.Show(PdnResources.GetString("Menu.leaseselectthetoolbarnode.Text"));            }        }        /// <summary>        /// 新建        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void buttonCreateNameClick(object sender, EventArgs e)        {            istoCreate = true;            createNameDialog = new CreateNameDialog(this);            createNameDialog.SetThisText(PdnResources.GetString("Menu.tool.Generateshortcut.Newtoolbar.text"));            createNameDialog.StartPosition = FormStartPosition.CenterParent;            createNameDialog.ShowDialog();        }        /// <summary>        /// 导入配置        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void buttonImportClick(object sender, EventArgs e)        {            switch (currentInedx)            {                case 1: //1工具栏                    this.topTools.ImportToolbarXml();                    break;                case 2: //2快捷键                    this.shortKeys.ImportToolbarXml();                    break;                case 3: //3快捷栏                    this.fastTools.ImportToolbarXml();                    break;            }        }        /// <summary>        /// 导出配置        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void buttonExportClick(object sender, EventArgs e)        {            switch (currentInedx)            {                case 1: //1工具栏                    this.topTools.ExportToolbarXml();                    break;                case 2: //2快捷键                    this.shortKeys.ExportToolbarXml();                    break;                case 3: //3快捷栏                    this.fastTools.ExportToolbarXml();                    break;            }        }        /// <summary>        /// 获取新建窗口里面输入的名称        /// </summary>        /// <param name="name"></param>        public override void GetCreateName(string name)        {            if (!name.Equals(""))            {                if (istoCreate)  //新增                {                    this.topTools.CreateTreeView2Node(name);                }                else        //重命名                {                    this.topTools.ReNameTreeView2Node(name);                }                createNameDialog.Close();            }            else            {                MessageBox.Show(PdnResources.GetString("Menu.leaseenterworkflowname.Text"));            }        }        /// <summary>        /// 重命名按钮的可用状态        /// </summary>        /// <param name="canuse"></param>        public void RenameButtonStatus(bool canuse)        {            this.buttonEditName.Enabled = canuse;        }        /// <summary>        /// 删除按钮的可用状态        /// </summary>        /// <param name="canuse"></param>        public void DeleteButtonStatus(bool canuse)        {            this.buttonDeleteName.Enabled = canuse;        }    }}
 |