using Metis.Setting;
using PaintDotNet.Base;
using PaintDotNet.Data.Param;
using PaintDotNet.Setting;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
namespace PaintDotNet.Menus
{
///
/// 设置菜单
///
internal sealed class SettingMenu : PdnMenuItem
{
private PdnMenuItem menuGeneralSetting;
private PdnMenuItem menuGridSetting;
private PdnMenuItem menuWatermarkSetting;
private PdnMenuItem menuWorkTypeSetting;
private PdnMenuItem menuRuleSetting;
private PdnMenuItem menuLabelSetting;
private PdnMenuItem menuMeasureSetting;
private PdnMenuItem menuWorkFlowSetting;
private ToolStripSeparator menuToolsSeperator1;
private PdnMenuItem menuFocusSetting;
private ToolStripSeparator menuToolsSeperator2;
private PdnMenuItem menuModuleSetting;
private PdnMenuItem menuImportExportSetting;
private ToolStripSeparator menuToolsSeperator3;
public SettingMenu(int menuId)
{
InitializeComponent();
this.MenuId = menuId;
//在脚本中不显示
this.CanUseInScript = false;
this.AutomaticScript = false;
}
protected override void OnAppWorkspaceChanged()
{
base.OnAppWorkspaceChanged();
}
private void InitializeComponent()
{
this.menuGeneralSetting = new PdnMenuItem(ActionType.GeneralSetting);
this.menuGridSetting = new PdnMenuItem(ActionType.GridSetting);
this.menuWatermarkSetting = new PdnMenuItem(ActionType.WatermarkSetting);
this.menuWorkTypeSetting = new PdnMenuItem(ActionType.WorkTypeSetting);
this.menuRuleSetting = new PdnMenuItem(ActionType.RuleSetting);
this.menuLabelSetting = new PdnMenuItem(ActionType.LabelSetting);
this.menuMeasureSetting = new PdnMenuItem(ActionType.MeasureSetting);
this.menuWorkFlowSetting = new PdnMenuItem(ActionType.WorkFlowSetting);
this.menuToolsSeperator1 = new ToolStripSeparator();
this.menuFocusSetting = new PdnMenuItem(ActionType.FocusSetting);
this.menuToolsSeperator2 = new ToolStripSeparator();
this.menuModuleSetting = new PdnMenuItem(ActionType.ModuleSetting);
this.menuImportExportSetting = new PdnMenuItem(ActionType.ImportExportSetting);
this.menuToolsSeperator3 = new ToolStripSeparator();
//
// 主菜单
//
this.DropDownItems.AddRange(new ToolStripItem[] {
this.menuGeneralSetting,
this.menuGridSetting,
this.menuWatermarkSetting,
this.menuWorkTypeSetting,
this.menuRuleSetting,
this.menuLabelSetting,
this.menuMeasureSetting,
this.menuWorkFlowSetting,
this.menuToolsSeperator1,
this.menuFocusSetting,
this.menuToolsSeperator2,
this.menuModuleSetting,
this.menuToolsSeperator3,
this.menuImportExportSetting
});
this.Name = "Menu.Setting";
this.Text = PdnResources.GetString("Menu.Setting.Text");
//
// 常规设置
//
this.menuGeneralSetting.Click += new EventHandler(MenuGeneralSetting_Click);
//
// 网格设置
//
this.menuGridSetting.Click += new EventHandler(MenuGridSetting_Click);
//
// 水印设置
//
this.menuWatermarkSetting.Click += new EventHandler(WatermarkSettingsDialog_Click);
//
// 工型设置
//
this.menuWorkTypeSetting.Click += new EventHandler(MenuWorkTypeSetting_Click);
//
// 标尺设置
//
this.menuRuleSetting.Click += new EventHandler(MenuRulerSetting_Click); ;
//
// 标注设置
//
this.menuLabelSetting.Click += new EventHandler(MenuLabelSetting_Click);
//
// 测量设置
//
this.menuMeasureSetting.Click += new EventHandler(MenuMeasureSetting_Click);
//
// 工作流程
//
this.menuWorkFlowSetting.Click += new EventHandler(MenuWorkFlowSetting_Click);
//
// 聚焦参数
//
this.menuFocusSetting.Click += new EventHandler(menuFocusSetting_Click);
//
// 模块管理
//
this.menuModuleSetting.Click += new EventHandler(MenuModuleSetting_Click);
//
// 导入导出管理
//
this.menuImportExportSetting.Click += new EventHandler(MenuImportExportSetting_Click);
this.menuImportExportSetting.Text = PdnResources.GetString("ImportAndExportSet");
//
// 加载菜单的文字和icon
//
this.LoadNames(this.Name);
this.LoadIcons();
}
///
/// 常规设置
///
///
///
private void MenuGeneralSetting_Click(object sender, EventArgs e)
{
if (AppWorkspace.startScriptRecording)
{
AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List());
}
using (GeneralSettingDialog af = new GeneralSettingDialog(AppWorkspace))
{
af.StartPosition = FormStartPosition.CenterScreen;
af.ShowDialog(AppWorkspace);
}
}
///
/// 网格设置
///
///
///
private void MenuGridSetting_Click(object sender, EventArgs e)
{
if (AppWorkspace.startScriptRecording)
{
AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List());
}
//using (GridSettingDialog af = new GridSettingDialog(AppWorkspace))
//{
// af.StartPosition = FormStartPosition.CenterScreen;
// af.ShowDialog(AppWorkspace);
//}
using (GridSettingForm af = new GridSettingForm(AppWorkspace))
{
af.StartPosition = FormStartPosition.CenterScreen;
af.ShowDialog(AppWorkspace);
}
}
///
/// 聚焦参数
///
///
///
private void menuFocusSetting_Click(object sender, EventArgs e)
{
if (AppWorkspace.startScriptRecording)
{
AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List());
}
using (FocusingParameter fp = new FocusingParameter())
{
fp.StartPosition = FormStartPosition.CenterScreen;
fp.ShowDialog(AppWorkspace);
}
}
private void MenuModuleSetting_Click(object sender, EventArgs e)
{
if (AppWorkspace.startScriptRecording)
{
AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List());
}
using (ModuleManageDialog af = new ModuleManageDialog(AppWorkspace))
{
af.StartPosition = FormStartPosition.CenterScreen;
af.ShowDialog(AppWorkspace);
}
}
///
/// 标尺设置
///
///
///
private void MenuRulerSetting_Click(object sender, EventArgs e)
{
if (AppWorkspace.startScriptRecording)
{
AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List());
}
using (RulerSettingDialog af = new RulerSettingDialog(AppWorkspace))
{
af.StartPosition = FormStartPosition.CenterScreen;
af.ShowDialog(AppWorkspace);
}
}
///
/// 测量设置
///
///
///
private void MenuMeasureSetting_Click(object sender, EventArgs e)
{
if (AppWorkspace.startScriptRecording)
{
AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List());
}
using (MeasureSettingDialog af = new MeasureSettingDialog(AppWorkspace))
{
af.StartPosition = FormStartPosition.CenterScreen;
af.ShowDialog(AppWorkspace);
}
}
///
/// 标注设置
///
///
///
private void MenuLabelSetting_Click(object sender, EventArgs e)
{
if (AppWorkspace.startScriptRecording)
{
AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List());
}
using (LabelSettingDialog af = new LabelSettingDialog(AppWorkspace))
{
af.StartPosition = FormStartPosition.CenterScreen;
af.ShowDialog();
}
}
///
/// 工作流程
///
///
///
private void MenuWorkFlowSetting_Click(object sender, EventArgs e)
{
if (AppWorkspace.startScriptRecording)
{
AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List());
}
using (WorkFlowSettingDialog af = new WorkFlowSettingDialog(AppWorkspace))
{
af.StartPosition = FormStartPosition.CenterScreen;
af.ShowDialog();
}
}
private string GetCultureInfoName(CultureInfo ci)
{
CultureInfo en_US = new CultureInfo("en-US");
if (ci.Equals(en_US))
{
return GetCultureInfoName(ci.Parent);
}
else
{
return ci.NativeName;
}
}
///
/// 工型设置
///
///
///
private void MenuWorkTypeSetting_Click(object sender, EventArgs e)
{
if (AppWorkspace.startScriptRecording)
{
AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List());
}
using (WorkTypeSettingDialog af = new WorkTypeSettingDialog())
{
af.StartPosition = FormStartPosition.CenterScreen;
af.ShowDialog(AppWorkspace);
}
}
///
/// 水印设置
///
///
///
private void WatermarkSettingsDialog_Click(object sender, EventArgs e)
{
if (AppWorkspace.startScriptRecording)
{
AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List());
}
using (WatermarkSettingsDialog af = new WatermarkSettingsDialog())
{
af.StartPosition = FormStartPosition.CenterScreen;
af.ShowDialog(AppWorkspace);
}
}
///
/// 导入导出设置
///
///
///
private void MenuImportExportSetting_Click(object sender, EventArgs e)
{
if (AppWorkspace.startScriptRecording)
{
AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List());
}
using (ImportExportSettingDialog af = new ImportExportSettingDialog())
{
af.StartPosition = FormStartPosition.CenterScreen;
af.ShowDialog(AppWorkspace);
}
}
}
}