diff --git a/CTZServerControl.sln b/CTZServerControl.sln new file mode 100644 index 0000000..feb2b37 --- /dev/null +++ b/CTZServerControl.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CTZServerControl", "CTZServerControl\CTZServerControl.csproj", "{B598E5F8-DD73-4457-A90B-D3AE1760F618}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B598E5F8-DD73-4457-A90B-D3AE1760F618}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B598E5F8-DD73-4457-A90B-D3AE1760F618}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B598E5F8-DD73-4457-A90B-D3AE1760F618}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B598E5F8-DD73-4457-A90B-D3AE1760F618}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/CTZServerControl/App.config b/CTZServerControl/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/CTZServerControl/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CTZServerControl/CTZServerControl.csproj b/CTZServerControl/CTZServerControl.csproj new file mode 100644 index 0000000..ffd8c91 --- /dev/null +++ b/CTZServerControl/CTZServerControl.csproj @@ -0,0 +1,91 @@ + + + + + Debug + AnyCPU + {B598E5F8-DD73-4457-A90B-D3AE1760F618} + WinExe + Properties + CTZServerControl + CTZServerControl + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Frm_Main.cs + + + + + + Frm_Main.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + \ No newline at end of file diff --git a/CTZServerControl/Frm_Main.Designer.cs b/CTZServerControl/Frm_Main.Designer.cs new file mode 100644 index 0000000..ccdb7a5 --- /dev/null +++ b/CTZServerControl/Frm_Main.Designer.cs @@ -0,0 +1,121 @@ +namespace CTZServerControl +{ + partial class Frm_Main + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.outdata = new System.Windows.Forms.ListBox(); + this.start = new System.Windows.Forms.Button(); + this.serverpath = new System.Windows.Forms.TextBox(); + this.process1 = new System.Diagnostics.Process(); + this.send = new System.Windows.Forms.Button(); + this.cmd = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // outdata + // + this.outdata.FormattingEnabled = true; + this.outdata.ItemHeight = 12; + this.outdata.Location = new System.Drawing.Point(13, 38); + this.outdata.Name = "outdata"; + this.outdata.Size = new System.Drawing.Size(768, 496); + this.outdata.TabIndex = 0; + // + // start + // + this.start.Location = new System.Drawing.Point(705, 8); + this.start.Name = "start"; + this.start.Size = new System.Drawing.Size(75, 23); + this.start.TabIndex = 1; + this.start.Text = "启动服务器"; + this.start.UseVisualStyleBackColor = true; + this.start.Click += new System.EventHandler(this.start_Click); + // + // serverpath + // + this.serverpath.Location = new System.Drawing.Point(13, 10); + this.serverpath.Name = "serverpath"; + this.serverpath.Size = new System.Drawing.Size(686, 21); + this.serverpath.TabIndex = 2; + // + // process1 + // + this.process1.StartInfo.Domain = ""; + this.process1.StartInfo.LoadUserProfile = false; + this.process1.StartInfo.Password = null; + this.process1.StartInfo.StandardErrorEncoding = null; + this.process1.StartInfo.StandardOutputEncoding = null; + this.process1.StartInfo.UserName = ""; + this.process1.SynchronizingObject = this; + // + // send + // + this.send.Location = new System.Drawing.Point(705, 539); + this.send.Name = "send"; + this.send.Size = new System.Drawing.Size(75, 23); + this.send.TabIndex = 3; + this.send.Text = "发送命令"; + this.send.UseVisualStyleBackColor = true; + this.send.Click += new System.EventHandler(this.send_Click); + // + // cmd + // + this.cmd.FormattingEnabled = true; + this.cmd.Location = new System.Drawing.Point(13, 541); + this.cmd.Name = "cmd"; + this.cmd.Size = new System.Drawing.Size(686, 20); + this.cmd.TabIndex = 4; + // + // Frm_Main + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(792, 573); + this.Controls.Add(this.cmd); + this.Controls.Add(this.send); + this.Controls.Add(this.serverpath); + this.Controls.Add(this.start); + this.Controls.Add(this.outdata); + this.Name = "Frm_Main"; + this.Text = "CTZServer"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Frm_Main_FormClosed); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ListBox outdata; + private System.Windows.Forms.Button start; + private System.Windows.Forms.TextBox serverpath; + private System.Diagnostics.Process process1; + private System.Windows.Forms.Button send; + private System.Windows.Forms.ComboBox cmd; + } +} + diff --git a/CTZServerControl/Frm_Main.cs b/CTZServerControl/Frm_Main.cs new file mode 100644 index 0000000..b617a39 --- /dev/null +++ b/CTZServerControl/Frm_Main.cs @@ -0,0 +1,96 @@ +using System; +using System.Diagnostics; +using System.Windows.Forms; + +namespace CTZServerControl +{ + public partial class Frm_Main : Form + { + Process process = null; + public Frm_Main() + { + InitializeComponent(); + } + + private void start_Click(object sender, EventArgs e) + { + start.Enabled = false; + ProcessStartInfo startinfo = new ProcessStartInfo(@"C:\Program Files\Java\jre7\bin\java.exe"); + startinfo.Arguments = "-Xmx2048M -jar spigot.jar"; + startinfo.UseShellExecute = false; + startinfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory + "Spigot"; + startinfo.RedirectStandardInput = true; + startinfo.RedirectStandardError = true; + startinfo.RedirectStandardOutput = true; + startinfo.CreateNoWindow = true; + process = Process.Start(startinfo); + process.BeginErrorReadLine(); + process.ErrorDataReceived += Process_OutputDataReceived; + process.BeginOutputReadLine(); + process.OutputDataReceived += Process_OutputDataReceived; + process.Exited += Process_Exited; + } + + private void Process_Exited(object sender, EventArgs e) + { + outdata.Items.Add("服务端已退出!"); + start.Enabled = true; + } + + //新建委托 + private delegate void OutputDataDelegate(string number); + //委托调用的方法 + private void OutputData(string data) + { + bool scroll = this.outdata.TopIndex == getListEndIndex(outdata); + outdata.Items.Add(data); + if (scroll) this.outdata.TopIndex = getListEndIndex(outdata); + } + + private int getListEndIndex(ListBox listbox) + { + return listbox.Items.Count - (int)(listbox.Height / listbox.ItemHeight); + } + + private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e) + { + if (e.Data == null) + { + process.OutputDataReceived -= Process_OutputDataReceived; + } + else + { + Invoke(new OutputDataDelegate(OutputData), new object[] { e.Data }); + } + } + + private void send_Click(object sender, EventArgs e) + { + sendcmd(); + } + + private void Frm_Main_FormClosed(object sender, FormClosedEventArgs e) + { + process.Kill(); + } + + private void cmd_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + sendcmd(); + } + } + + private void sendcmd() + { + runcmd(cmd.Text); + cmd.Text = ""; + } + + private void runcmd(string cmd) + { + process.StandardInput.WriteLine(cmd); + } + } +} diff --git a/CTZServerControl/Frm_Main.resx b/CTZServerControl/Frm_Main.resx new file mode 100644 index 0000000..170cc55 --- /dev/null +++ b/CTZServerControl/Frm_Main.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/CTZServerControl/ProcessControl.cs b/CTZServerControl/ProcessControl.cs new file mode 100644 index 0000000..526b53f --- /dev/null +++ b/CTZServerControl/ProcessControl.cs @@ -0,0 +1,7 @@ +namespace CTZServerControl +{ + class ProcessControl + { + + } +} diff --git a/CTZServerControl/Program.cs b/CTZServerControl/Program.cs new file mode 100644 index 0000000..d3e5585 --- /dev/null +++ b/CTZServerControl/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace CTZServerControl +{ + static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Frm_Main()); + } + } +} diff --git a/CTZServerControl/Properties/AssemblyInfo.cs b/CTZServerControl/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..da69f09 --- /dev/null +++ b/CTZServerControl/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("CTZServerControl")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("CTZServerControl")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +//将 ComVisible 设置为 false 将使此程序集中的类型 +//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("b598e5f8-dd73-4457-a90b-d3ae1760f618")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/CTZServerControl/Properties/Resources.Designer.cs b/CTZServerControl/Properties/Resources.Designer.cs new file mode 100644 index 0000000..c0ba5ed --- /dev/null +++ b/CTZServerControl/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本: 4.0.30319.42000 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace CTZServerControl.Properties +{ + + + /// + /// 强类型资源类,用于查找本地化字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CTZServerControl.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 覆盖当前线程的 CurrentUICulture 属性 + /// 使用此强类型的资源类的资源查找。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/CTZServerControl/Properties/Resources.resx b/CTZServerControl/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/CTZServerControl/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/CTZServerControl/Properties/Settings.Designer.cs b/CTZServerControl/Properties/Settings.Designer.cs new file mode 100644 index 0000000..9b26bb9 --- /dev/null +++ b/CTZServerControl/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CTZServerControl.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/CTZServerControl/Properties/Settings.settings b/CTZServerControl/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/CTZServerControl/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + +