📄 singlemdiapplication.cs
字号:
#region Using directives
using System;
using System.Collections.ObjectModel;
using System.Windows.Forms;
using Microsoft.VisualBasic.ApplicationServices;
#endregion
namespace DocApp {
public class SingleMDIApplication : WindowsFormsApplicationBase {
internal static SingleMDIApplication Application = new SingleMDIApplication();
// Must call base constructor to ensure correct initial
// WindowsFormsApplicationBase configuration
public SingleMDIApplication() : base() {
// This ensures the underlying single-SDI framework is employed,
// and OnStartupNextInstance is fired
this.IsSingleInstance = true;
}
// Load MDI parent form and first MDI child form
protected override void OnCreateMainForm() {
this.MainForm = new MDIParentForm();
this.OpenDocument(this.CommandLineArgs);
}
// Load subsequent MDI child form
protected override void OnStartupNextInstance(StartupNextInstanceEventArgs e) {
this.OpenDocument(e.CommandLine);
}
private void OpenDocument(ReadOnlyCollection<string> args) {
// Get file name, if provided
string fileName = (args.Count > 0 ? args[0] : null);
if( string.IsNullOrEmpty(fileName) ) return;
// Ask MDI parent to create a new MDI child and open
// file, if one was passed
((MDIParentForm)this.MainForm).OpenDocument(fileName);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -