filecommands.cs
来自「SharpDevelop2.0.0 c#开发免费工具」· CS 代码 · 共 75 行
CS
75 行
// Copyright (c) 2005 Daniel Grunwald
// Licensed under the terms of the "BSD License", see doc/license.txt
using System;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace Base
{
public class NewFileCommand : AbstractMenuCommand
{
public override void Run()
{
Workbench workbench = (Workbench)this.Owner;
if (workbench.CloseCurrentContent()) {
workbench.ShowContent(new TextViewContent());
}
}
}
public class OpenFileCommand : AbstractMenuCommand
{
public override void Run()
{
Workbench workbench = (Workbench)this.Owner;
if (workbench.CloseCurrentContent()) {
using (OpenFileDialog dlg = new OpenFileDialog()) {
dlg.CheckFileExists = true;
dlg.DefaultExt = ".txt";
dlg.Filter = FileViewContent.GetFileFilter("/Workspace/FileFilter");
if (dlg.ShowDialog() == DialogResult.OK) {
IViewContent content = DisplayBindingManager.CreateViewContent(dlg.FileName);
if (content != null) {
workbench.ShowContent(content);
}
}
}
}
}
}
public class SaveFileCommand : AbstractMenuCommand
{
public override void Run()
{
Workbench workbench = (Workbench)this.Owner;
if (workbench.ActiveViewContent != null) {
workbench.ActiveViewContent.Save();
}
}
}
public class SaveFileAsCommand : AbstractMenuCommand
{
public override void Run()
{
Workbench workbench = (Workbench)this.Owner;
if (workbench.ActiveViewContent != null) {
workbench.ActiveViewContent.SaveAs();
}
}
}
public class ExitCommand : AbstractMenuCommand
{
public override void Run()
{
Workbench workbench = (Workbench)this.Owner;
if (workbench.CloseCurrentContent()) {
workbench.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?