Skip to content

Commit

Permalink
add terminal emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion committed Mar 26, 2014
1 parent 3bd8177 commit bddb0e9
Show file tree
Hide file tree
Showing 9 changed files with 992 additions and 98 deletions.
9 changes: 9 additions & 0 deletions MAClientGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@
<Compile Include="frmConfig.Designer.cs">
<DependentUpon>frmConfig.cs</DependentUpon>
</Compile>
<Compile Include="frmNiceTerm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmNiceTerm.Designer.cs">
<DependentUpon>frmNiceTerm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TextBoxEx.cs">
Expand All @@ -120,6 +126,9 @@
<EmbeddedResource Include="frmConfig.resx">
<DependentUpon>frmConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmNiceTerm.resx">
<DependentUpon>frmNiceTerm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
Expand Down
1 change: 1 addition & 0 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public struct WndInfo
public int procid;
public int threadid;
}

public static void hideWnd(WndInfo[] wnds)
{
foreach (WndInfo w in wnds)
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MAClientGUI包括一个MAClient的配置工具和一个简单的终端模拟器

frmConfig
![frmConfig](http://ww1.sinaimg.cn/large/436919cbjw1eet6z0leiyj20n30ku78u.jpg)

frmNiceTerm
![frmNiceTerm](http://ww3.sinaimg.cn/large/436919cbjw1eet72g7sp2j20mj0fkwi3.jpg)
183 changes: 99 additions & 84 deletions frmConfig.Designer.cs

Large diffs are not rendered by default.

62 changes: 48 additions & 14 deletions frmConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ public partial class frmConfig : Form
{
configParser cf;
string server;
string maclient_path = System.Environment.CurrentDirectory + "\\maclient_cli.exe";
string maclient_path;
List<frmNiceTerm> niceterms = new List<frmNiceTerm>();
public frmConfig()
{
InitializeComponent();
maclient_path = System.Environment.CurrentDirectory + "\\maclient_cli.exe";

}

private void btnChooseCfg_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -293,6 +296,10 @@ private void cboServer_SelectedIndexChanged(object sender, EventArgs e)
string[] slist = { "cn", "cn2", "cn3", "tw", "kr", "jp" };
server = slist[cboServer.SelectedIndex];
refreshAccount();
if (cboServer.SelectedIndex >= 4)
chkUseNiceTerm.Checked = true;
else
chkUseNiceTerm.Checked = false;
}

private void cboCfgFile_SelectedIndexChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -990,11 +997,10 @@ private void button45_Click(object sender, EventArgs e)
{
txtCondSell.Text = "";
}
string mcpath = System.Environment.CurrentDirectory + "\\maclient_cli.exe";
private void start_mac(string arg = "")
{
string cfgpath = cboCfgFile.Text;
if (!File.Exists(mcpath))
if (!File.Exists(maclient_path))
{
if (MessageBox.Show("当前目录下木有maclient_cli.exe或maclient_cli.py,是否手动寻找?", "呵呵", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
{
Expand All @@ -1004,7 +1010,7 @@ private void start_mac(string arg = "")
fileDialog1.RestoreDirectory = true;
if (fileDialog1.ShowDialog() == DialogResult.OK)
{
mcpath = fileDialog1.FileName;
maclient_path = fileDialog1.FileName;
}
else
{
Expand Down Expand Up @@ -1052,17 +1058,29 @@ private void start_mac(string arg = "")
}

}


//cboCfgFile.SelectedIndex = 0;
Process proc = new Process();
proc.StartInfo.FileName = mcpath;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.Arguments = "\"" + cfgpath + "\" " + arg;
proc.EnableRaisingEvents = true;
proc.Start();

if (chkUseNiceTerm.Checked)
{
frmNiceTerm f = new frmNiceTerm();
f.Show();
niceterms.Add(f);
int _cur = niceterms.Count;
f.kill_callback = () => niceterms.RemoveAt(_cur - 1);
if(maclient_path.EndsWith("py"))
f.StartProcess("python.exe", maclient_path+" \"" + cfgpath + "\" " + arg);
else
f.StartProcess(maclient_path, "\"" + cfgpath + "\" " + arg);
}
else
{
Process proc = new Process();
proc.StartInfo.FileName = maclient_path;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.Arguments = "\"" + cfgpath + "\" " + arg;
proc.EnableRaisingEvents = true;
proc.Start();
}

}
private void button3_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -1395,6 +1413,22 @@ private void button60_Click_1(object sender, EventArgs e)

private void frmConfig_FormClosing(object sender, FormClosingEventArgs e)
{
if (niceterms.Count > 0){
if (MessageBox.Show("在终端模拟器中还运行着" + niceterms.Count + "个MAClient,退出后将终止他们的运行\n红豆泥要继续嘛?","咦",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation)==DialogResult.Yes)
{
foreach (frmNiceTerm nt in niceterms)
{
if (nt.process != null && !nt.process.HasExited)
{
nt.process.Kill();
nt.outputWorker.CancelAsync();
}
}
}else{
e.Cancel=true;
return;
}
}
WndHdl.WndInfo[] res = WndHdl.findHwndbyTitleReg(@"\[[^\]]+\] AP\:");
WndHdl.showWndIfHided(res);
Process.GetCurrentProcess().Kill();
Expand Down
148 changes: 148 additions & 0 deletions frmNiceTerm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bddb0e9

Please sign in to comment.