60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
using Api.Framework;
|
|
using Api.Framework.Tools;
|
|
using System;
|
|
using UI.Framework.Forms;
|
|
|
|
namespace FLSystem.Forms
|
|
{
|
|
public partial class web_api_form : BaseForm
|
|
{
|
|
public web_api_form()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 刷新按钮状态
|
|
/// </summary>
|
|
private void RefStatus()
|
|
{
|
|
this.simpleButton1.Text = WebClient.IsStart ? "关闭服务器" : "启动服务器";
|
|
|
|
ApiClient.Setting.ServerConfig.IsOpen = WebClient.IsStart;
|
|
this.numericUpDown1.Enabled = this.textBox1.Enabled = !WebClient.IsStart;
|
|
}
|
|
private void web_api_form_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var config = ApiClient.Setting.ServerConfig;
|
|
this.textBox1.Text = config.Host;
|
|
this.textBox2.Text = config.Domain;
|
|
this.numericUpDown1.Value = config.Port;
|
|
RefStatus();
|
|
Util.Save(ApiClient.Setting.ServerConfig);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (!this.IsDisposed) ShowError(ex);
|
|
}
|
|
}
|
|
|
|
private void simpleButton1_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
ApiClient.Setting.ServerConfig.Domain = this.textBox2.Text;
|
|
if (WebClient.IsStart) WebClient.Close();
|
|
else WebClient.Start(this.textBox1.Text, (int)this.numericUpDown1.Value);
|
|
RefStatus();
|
|
Util.Save(ApiClient.Setting.ServerConfig);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (!this.IsDisposed) ShowError(ex);
|
|
}
|
|
}
|
|
|
|
}
|
|
} |