private void _optionToolStripMenuItem_Click(object sender, EventArgs e) { var form = new DetailSettingsForm(); try { form.Text = "オプション"; form.Size = new Size(500, 400); form.Theme = _theme; var basic = new BasicSettingsDetailPage( _app.Settings, _app.WindowSettings, _app.MainForm.ToolRegistry ); form.RegisterPage("基本", basic); var background = new BackgroundSettingsDetailPage(_app.Settings, _app.WindowSettings); form.RegisterPage("背景", background); var confirm = new ConfirmSettingsDetailPage(_app.Settings); form.RegisterPage("確認", confirm); var folder = new FolderSettingsDetailPage(_app.BootstrapSettings, _app.WindowSettings); form.RegisterPage("フォルダ", folder); var hotkey = new HotKeySettingsDetailPage(_app.HotKey, _app.WindowSettings); form.RegisterPage("ホットキー", hotkey); var abbrev = new AbbrevSettingDetailPage(_app._AbbrevWordPersister); form.RegisterPage("単語補完", abbrev); var misc = new MiscSettingsDetailPage(_app.Settings, _app.WindowSettings); form.RegisterPage("その他", misc); if (form.ShowDialog(this) == DialogResult.OK) { var cmd = form.GetUpdateCommand(); if (cmd != null) { cmd.Execute(); MessageBox.Show(this, "一部の設定はアプリケーションを再起動するまで反映されません。", "設定の変更"); } } } finally { form.Dispose(); } }
private void InitItems() { _remove = new ToolStripMenuItem(); _remove.Text = "削除(&R)"; _remove.Click += (sender, e) => { using (_owner.CommandExecutor.BeginChain()) { var req = new RemoveRequest(); var cmds = new CompositeCommand(); var parent = default(IEditor); foreach (var editor in _owner.SelectionManager.SelectedEditors) { if (parent == null) { parent = editor.Parent; } if (editor.CanUnderstand(req)) { cmds.Children.Add(editor.GetCommand(req)); } } _owner.CommandExecutor.Execute(cmds); if (parent != null) { parent.RequestSelect(SelectKind.True, true); } } }; _clone = new ToolStripMenuItem(); _clone.Text = "複製(&C)"; _clone.Click += (sender, e) => { var cloning = new List <IEditor>(_owner.SelectionManager.SelectedEditors); var req = new CloneRequest(cloning); req.MoveDelta = CloneMoveDelta; if (cloning.Any()) { var target = cloning.First().Parent; var cmd = target.PerformRequest(req) as CloneCommand; if (cmd != null && cmd.ClonedEditors != null) { _owner.SelectionManager.DeselectAll(); foreach (var cloned in cmd.ClonedEditors) { cloned.RequestSelect(SelectKind.True, false); } } } }; _cut = new ToolStripMenuItem(); _cut.Text = "切り取り(&X)"; _cut.Click += (sender, e) => { var cmd = GetCutCommand(); _owner.CommandExecutor.Execute(cmd); }; _copy = new ToolStripMenuItem(); _copy.Text = "コピー(&C)"; _copy.Click += (sender, e) => { var targets = _owner.SelectionManager.SelectedEditors; var req = new CopyRequest(targets); var list = new EditorBundle(targets); list.PerformGroupRequest(req, _owner.CommandExecutor); }; _copyAsImage = new ToolStripMenuItem(); _copyAsImage.Text = "画像としてコピー(&I)"; _copyAsImage.Click += (sender, e) => { _owner.CopySelectedAsImage(); }; _paste = new ToolStripMenuItem(); _paste.Text = "貼り付け(&P)"; _paste.Click += (sender, e) => { var found = _owner.RootEditor.FindEnabledEditor( _currentEvent.Location ); if (found != null) { var cmd = found.RequestPaste(_currentEvent.Location, null) as PasteCommand; if (cmd != null && cmd.PastedEditors != null) { _owner.SelectionManager.DeselectAll(); foreach (var editor in cmd.PastedEditors) { editor.RequestSelect(SelectKind.True, false); } } } }; _pasteInBlock = new ToolStripMenuItem(); _pasteInBlock.Text = "段落内に貼り付け(&P)"; _pasteInBlock.Click += (sender, e) => { var found = _owner.RootEditor.FindEnabledEditor( _currentEvent.Location ); if (found != null) { var cmd = found.RequestPaste( _currentEvent.Location, EditorConsts.InBlockPasteDescription ) as PasteCommand; if (cmd != null && cmd.PastedEditors != null) { _owner.SelectionManager.DeselectAll(); foreach (var editor in cmd.PastedEditors) { editor.RequestSelect(SelectKind.True, false); } } } }; _front = new ToolStripMenuItem(); _front.Text = "前面に移動(&F)"; _front.Click += (sender, e) => { var found = _owner.RootEditor.FindEnabledEditor( _currentEvent.Location ); if (found != null) { found.RequestReorder(ReorderKind.Front); } }; _frontMost = new ToolStripMenuItem(); _frontMost.Text = "最前面に移動(&F)"; _frontMost.Click += (sender, e) => { var found = _owner.RootEditor.FindEnabledEditor( _currentEvent.Location ); if (found != null) { found.RequestReorder(ReorderKind.FrontMost); } }; _back = new ToolStripMenuItem(); _back.Text = "背面に移動(&B)"; _back.Click += (sender, e) => { var found = _owner.RootEditor.FindEnabledEditor( _currentEvent.Location ); if (found != null) { found.RequestReorder(ReorderKind.Back); } }; _backMost = new ToolStripMenuItem(); _backMost.Text = "最背面に移動(&B)"; _backMost.Click += (sender, e) => { var found = _owner.RootEditor.FindEnabledEditor( _currentEvent.Location ); if (found != null) { found.RequestReorder(ReorderKind.BackMost); } }; _arrangeHLeft = new ToolStripMenuItem("左揃え(&L)"); _arrangeHLeft.Click += (sender, e) => { var editors = _owner.SelectionManager.SelectedEditors; var rect = editors.Select(ed => ed.Figure.Bounds).Aggregate((r1, r2) => Rectangle.Union(r1, r2)); using (_owner.CommandExecutor.BeginChain()) { foreach (var edi in editors) { var left = rect.Left; edi.RequestMove(new Size(left - edi.Figure.Left, 0)); } } }; _arrangeHCenter = new ToolStripMenuItem("左右中央揃え(&C)"); _arrangeHCenter.Click += (sender, e) => { var editors = _owner.SelectionManager.SelectedEditors; var rect = editors.Select(ed => ed.Figure.Bounds).Aggregate((r1, r2) => Rectangle.Union(r1, r2)); var center = RectUtil.GetCenter(rect); using (_owner.CommandExecutor.BeginChain()) { foreach (var edi in editors) { var left = center.X - edi.Figure.Width / 2; edi.RequestMove(new Size(left - edi.Figure.Left, 0)); } } }; _arrangeHRight = new ToolStripMenuItem("右揃え(&R)"); _arrangeHRight.Click += (sender, e) => { var editors = _owner.SelectionManager.SelectedEditors; var rect = editors.Select(ed => ed.Figure.Bounds).Aggregate((r1, r2) => Rectangle.Union(r1, r2)); using (_owner.CommandExecutor.BeginChain()) { foreach (var edi in editors) { var left = rect.Right - edi.Figure.Width; edi.RequestMove(new Size(left - edi.Figure.Left, 0)); } } }; _arrangeVTop = new ToolStripMenuItem("上揃え(&T)"); _arrangeVTop.Click += (sender, e) => { var editors = _owner.SelectionManager.SelectedEditors; var rect = editors.Select(ed => ed.Figure.Bounds).Aggregate((r1, r2) => Rectangle.Union(r1, r2)); using (_owner.CommandExecutor.BeginChain()) { foreach (var edi in editors) { var top = rect.Top; edi.RequestMove(new Size(0, top - edi.Figure.Top)); } } }; _arrangeVMiddle = new ToolStripMenuItem("上下中央揃え(&M)"); _arrangeVMiddle.Click += (sender, e) => { var editors = _owner.SelectionManager.SelectedEditors; var rect = editors.Select(ed => ed.Figure.Bounds).Aggregate((r1, r2) => Rectangle.Union(r1, r2)); var center = RectUtil.GetCenter(rect); using (_owner.CommandExecutor.BeginChain()) { foreach (var edi in editors) { var top = center.Y - edi.Figure.Height / 2; edi.RequestMove(new Size(0, top - edi.Figure.Top)); } } }; _arrangeVBottom = new ToolStripMenuItem("下揃え(&B)"); _arrangeVBottom.Click += (sender, e) => { var editors = _owner.SelectionManager.SelectedEditors; var rect = editors.Select(ed => ed.Figure.Bounds).Aggregate((r1, r2) => Rectangle.Union(r1, r2)); using (_owner.CommandExecutor.BeginChain()) { foreach (var edi in editors) { var top = rect.Bottom - edi.Figure.Height; edi.RequestMove(new Size(0, top - edi.Figure.Top)); } } }; _detailForm = new ToolStripMenuItem(); _detailForm.Text = "設定(&S)"; _detailForm.Click += (sender, e) => { var found = _owner.RootEditor.FindEnabledEditor( _currentEvent.Location ); if (found != null) { if (found.Controller != null && found.Controller.UIProvider != null) { var ui = found.Controller.UIProvider; var form = new DetailSettingsForm(); try { form.Size = _detailFormSize; form.Theme = _owner.Theme; ui.ConfigureDetailForm(form); if (form.ShowDialog() == DialogResult.OK) { var cmd = form.GetUpdateCommand(); if (cmd != null) { _owner.CommandExecutor.Execute(cmd); } } } finally { form.Dispose(); } } } }; }