📄 program.cs
字号:
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Deployment.Application;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace Wahoo {
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args) {
Application.EnableVisualStyles();
int columns = 10;
int rows = 20;
// Query string or command line args??
if( ApplicationDeployment.IsNetworkDeployed ) {
string activationUri = ApplicationDeployment.CurrentDeployment.ActivationUri.AbsoluteUri;
if( !string.IsNullOrEmpty(activationUri) ) {
Uri uri = new Uri(activationUri);
if( !string.IsNullOrEmpty(uri.Query) ) {
// Parse (expecting format: "?columns=Xxx&rows=Xxx")
string query = uri.Query.ToLower();
GetQueryArg(query, "columns", ref columns);
GetQueryArg(query, "rows", ref rows);
}
}
}
else {
// Process command line args as per normal
if( args != null && args.Length == 2 ) {
columns = int.Parse(args[0]);
rows = int.Parse(args[1]);
}
}
Application.Run(new MainForm(columns, rows));
}
// A query string extraction helper
static bool GetQueryArg<T>(string query, string arg, ref T value) {
Regex regex = new Regex(arg + "=(?<value>[^&]*)");
Match match = regex.Match(query);
if( match == null ) { return false; }
string s = match.Groups["value"].Value;
if( string.IsNullOrEmpty(s) ) { return false; }
TypeConverter converter = TypeDescriptor.GetConverter(typeof(T));
if( !converter.CanConvertFrom(typeof(string)) ) { return false; }
value = (T)converter.ConvertFrom(s);
return true;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -