1 Star 0 Fork 6

笑傲_紫月圣君/wnmp PHP集成环境

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
MainWindow.xaml.cs 33.33 KB
一键复制 编辑 原始数据 按行查看 历史
jianghong 提交于 2021-12-16 17:18 . 从任务栏恢复窗口时居中
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using wnmp.pages;
using wnmp.tools;
namespace wnmp
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private WebSite ws;
private download DownloadPage;
private List<SiteConf> SiteList;
private bool NginxStopping = false;
private bool MysqlStopping = false;
private bool PHPStopping = false;
private bool AppQuit = false;
private long LastClickTime;//防重复点击
private int CheckTime = 5*1000;//监控间隔时间
private bool UIisLoaded = false;//加载完成
private bool NginxUserRunning = false;//用户启动Nginx
private bool MysqlUserRunning = false;//用户启动mysql
private bool PhpUserRunning = false;//用户启动php
private System.Windows.Forms.NotifyIcon TrayIcon;
//主程序配置
private AppConf appConf;
private Tools tool;
public MainWindow()
{
InitializeComponent();
//初始化
InitApp();
}
private void InitApp()
{
//加载配置
appConf = new AppConf();
tool = new Tools(appConf);
//多开限制
if (tool.CheckAppIsRunning())
{
MessageBox.Show("程序已在运行中,可在任务栏查看!", "错误");
Environment.Exit(0);
return;
}
tool.getWnmpVersions();
//异步加载
new Thread(() => {
//配置检查
if (appConf.checkNewVersion(appConf.appNewVersion))
{
Dispatcher.Invoke(new Action(() => {
MessageBoxResult mbr = MessageBox.Show("有新版本可用,是否立即更新?", "更新提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (mbr == MessageBoxResult.Yes)
{
UpdateVersion();
}
}));
}
Dispatcher.Invoke(new Action(() => {
//设置UI
initUI();
//加载站点
loadList(false);
//加载完成
UIisLoaded = true;
//检测Mysql配置
tool.CheckMysqlINI();
//检测php配置
tool.CheckPhpINI();
}));
}).Start();
//nginx 监控
checkNginx();
//mysql 监控
checkMysql();
//PHP 监控
checkPHP();
//日志菜单
logBox.ContextMenu = new ContextMenu();
MenuItem logClean = new MenuItem();
logClean.Header = "清除日志";
logClean.Click += logClean_click;
logBox.ContextMenu.Items.Add(logClean);
}
/// <summary>
/// 初始化UI
/// </summary>
public void initUI(bool loadList=true)
{
Title = appConf.appName + "集成管理";
windowsTitle.Text = Title +" "+ appConf.appVersion;
phpVersionLabel.Content = "PHP " + appConf.phpVersion;
mysqlVersionLabel.Content = "Mysql " + appConf.mysqlVersion;
nginxVersionLabel.Content = "Nginx " + appConf.nginxVersion;
if (appConf.autoUpdate=="1")
{
autoUpdate.IsChecked = true;
}
else
{
autoUpdate.IsChecked = false;
}
if (appConf.quitType == "1")
{
quitType.IsChecked = true;
}
else
{
quitType.IsChecked = false;
}
if (!loadList)
{
return;
}
//获取可以软件版本
LoadApps();
//检测Mysql配置
tool.CheckMysqlINI();
//检测php配置
tool.CheckPhpINI();
}
/// <summary>
/// 加载可用版本
/// </summary>
public void LoadApps()
{
nginxVersionSelect.Items.Clear();
tool.getWnmpVersions();
for (int i = 0; i < tool.nginxVersions.Length; i++)
{
nginxVersionSelect.Items.Add(tool.nginxVersions[i]);
if (tool.nginxVersions[i] == appConf.nginxVersion)
{
nginxVersionSelect.SelectedIndex = i;
}
}
mysqlVersionSelect.Items.Clear();
for (int i = 0; i < tool.mysqlVersions.Length; i++)
{
mysqlVersionSelect.Items.Add(tool.mysqlVersions[i]);
if (tool.mysqlVersions[i] == appConf.mysqlVersion)
{
mysqlVersionSelect.SelectedIndex = i;
}
}
phpVersionSelect.Items.Clear();
for (int i = 0; i < tool.phpVersions.Length; i++)
{
phpVersionSelect.Items.Add(tool.phpVersions[i]);
if (tool.phpVersions[i] == appConf.phpVersion)
{
phpVersionSelect.SelectedIndex = i;
}
}
}
/// <summary>
/// 更新版本
/// </summary>
private void UpdateVersion()
{
try
{
//加载更新程序
string exe = Site.GetRootPath() + "/wnmpUpdate.exe";
Process.Start(exe);
}
catch
{
}
}
private void logClean_click(object sender, RoutedEventArgs e)
{
//清除日志
logBox.Text = "";
}
private void addWebSIteBtn_MouseDown(object sender, MouseButtonEventArgs e)
{
//添加新网站并打开站点管理窗口
//防重复点击
long time = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
if (LastClickTime > time - 1)
{
return;
}
else
{
LastClickTime = time;
}
SiteConf sc = new SiteConf();
sc.domainName = "www.test.xyz";
sc.staticRoot = "/";
sc.siteRoot = "C:\\Users";
sc.sitePort = "80";
sc.siteFile = "index.html index.php";
sc.IsNew = true;
openSiteWindow(sc);
}
/// <summary>
/// 加载站点
/// </summary>
private void loadList(bool force)
{
siteListBox.Items.Clear();
Log("正在加载网站列表...");
//加载站点列表
if (SiteList == null || force)
{
SiteList = null;
//加载loading
Label cc = new Label()
{
Width = 588,
Height = 250,
Padding = new Thickness(250,105,0,0)
};
siteListBox.Items.Add(cc);
SiteList = (new Site(appConf)).GetSiteList();
siteListBox.Items.Clear();
}
foreach (SiteConf item in SiteList)
{
Canvas c = new Canvas();
c.Width = 588;
c.Height = 35;
//域名
Label l1 = new Label
{
Content = item.domainName.Split(" ")[0],
Width = 135,
Height = 25,
Margin = new Thickness(10, 5, 0, 0),
ToolTip = "打开此网站"
};
l1.Cursor = Cursors.Hand;
l1.MouseDown += openUrl_MouseDown;
c.Children.Add(l1);
//端口
Label l2 = new Label
{
Content = item.sitePort,
Width = 50,
Height = 25,
Margin = new Thickness(175, 5, 0, 0)
};
c.Children.Add(l2);
//路径
Label l3 = new Label
{
Content = item.siteRoot,
Width = 200,
Height = 25,
Margin = new Thickness(255, 5, 0, 0),
ToolTip = item.siteRoot
};
c.Children.Add(l3);
//状态
Label l4 = new Label
{
Content = item.remake,
Width = 40,
Height = 25,
Margin = new Thickness(450, 5, 0, 0)
};
c.Children.Add(l4);
//按钮
Label l5= new Label
{
Content = "管 理",
Width = 40,
Height = 25,
Margin = new Thickness(520, 5, 0, 0),
Style = FindResource("defautBtnLable") as Style,
};
l5.DataContext = item.domainName;
l5.MouseDown += siteListBtn_mouseDown;
c.Children.Add(l5);
siteListBox.Items.Add(c);
}
}
/// <summary>
/// 修改管理站点
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void siteListBtn_mouseDown(object sender, MouseButtonEventArgs e)
{
//防重复点击
long time = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
if (LastClickTime > time - 1)
{
return;
}
else
{
LastClickTime = time;
}
Label l = (Label)sender;
foreach (var item in SiteList)
{
if(item.domainName== l.DataContext.ToString())
{
openSiteWindow(item);
}
}
}
private void openUrl_MouseDown(object sender, MouseButtonEventArgs e)
{
//打开默认浏览器
Label l = (Label)sender;
string domainName = l.Content.ToString().Trim().Split(" ")[0];
if (domainName != "")
{
foreach (var item in SiteList)
{
if (item.domainName.IndexOf(domainName)!=-1)
{
string url = "http://" + domainName + ":"+item.sitePort;
Process.Start("explorer", url);
break;
}
}
}
}
/// <summary>
/// 打开站点管理窗口
/// </summary>
/// <param name="sc"></param>
private void openSiteWindow(SiteConf sc)
{
//
if (ws == null)
{
ws = new WebSite(sc,this,appConf);
ws.Owner = this;
ws.Show();
}
else
{
try
{
ws.WindowState = WindowState.Normal;
ws.Activate();
ws.Show();
}
catch
{
ws = null;
ws = new WebSite(sc,this,appConf);
ws.Owner = this;
ws.Show();
}
}
}
private void refreshWebSIteBtn_MouseDown(object sender, MouseButtonEventArgs e)
{
//防重复点击
long time = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
if (LastClickTime > time - 1)
{
return;
}
else
{
LastClickTime = time;
}
LoadList();
}
public void LoadList()
{
//异步加载
new Thread(() => {
this.Dispatcher.Invoke(new Action(() => {
loadList(true);
}));
}).Start();
}
/// <summary>
/// 启动nginx
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void nginxRunBtn_MouseDown(object sender, MouseButtonEventArgs e)
{
//防重复点击
long time = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
if (LastClickTime > time - 1)
{
return;
}
else
{
LastClickTime = time;
}
//控制nginx
var btn = (TextBlock)sender;
var str = btn.Text;
if(str=="启 动")
{
NginxUserRunning = true;
Log("启动Nginx...");
tool.CmdNginx("start");
btn.Text = "停 止";
nginxStatusImg.Fill = new SolidColorBrush(Color.FromRgb(0,255,0));
}
else
{
NginxUserRunning = false;
if (NginxStopping)
{
return;
}
NginxStopping = true;
Log("正在停止Nginx...");
try
{
tool.CmdNginx("stop");
btn.Text = "启 动";
nginxStatusImg.Fill = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}
catch
{
Log("Nginx停止错误");
}
}
}
/// <summary>
/// 监控nginx主进程 每隔5秒
/// </summary>
private void checkNginx()
{
new Thread(()=> {
while (true)
{
if (AppQuit)
{
break;
}
if (tool.NginxIsRunning())
{
Dispatcher.Invoke(new Action(() => {
nginxRunBtn.Text = "停 止";
nginxStatusImg.Fill = new SolidColorBrush(Color.FromRgb(0, 255, 0));
if (NginxStopping)
{
NginxStopping = false;
Log("Nginx停止失败");
}
}));
}
else
{
if (NginxUserRunning)
{
//如果用户启动,则守护该进程
Log("Nginx意外停止,正在重启...");
tool.CmdNginx("start");
}
Dispatcher.Invoke(new Action(() => {
if (NginxStopping)
{
Log("已停止Nginx");
}
nginxRunBtn.Text = "启 动";
NginxStopping = false;
nginxStatusImg.Fill = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}));
}
Thread.Sleep(CheckTime);
}
}).Start();
}
private void nginxRestartBtn_MouseDown(object sender, MouseButtonEventArgs e)
{
//防重复点击
long time = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
if (LastClickTime > time - 1)
{
return;
}
else
{
LastClickTime = time;
}
//重启nginx
if (tool.NginxIsRunning())
{
Log("重启Nginx...");
tool.CmdNginx("restart");
nginxRunBtn.Text = "停 止";
nginxStatusImg.Fill = new SolidColorBrush(Color.FromRgb(0, 255, 0));
}
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
}
private void show_windows(object sender, EventArgs e)
{
//从任务栏重新显示界面
try
{
Show();
WindowState = WindowState.Normal;
_ = Activate();
Top = SystemParameters.WorkArea.Height / 2 - Height / 2;
Left = SystemParameters.WorkArea.Width / 2 - Width / 2;
}
catch
{
MessageBox.Show("窗口显示错误!");
}
}
private void close_windows(object sender, EventArgs e)
{
//退出程序
AppQuit = true;
if (tool.NginxIsRunning())
{
tool.CmdNginx("stop");
}
if (tool.MysqlIsRunning())
{
tool.CmdMysql("stop");
}
Environment.Exit(0);
}
/// <summary>
/// 监控Mysql主进程 每隔5秒
/// </summary>
private void checkMysql()
{
new Thread(() => {
while (true)
{
if (AppQuit)
{
break;
}
if (tool.MysqlIsRunning())
{
Dispatcher.Invoke(new Action(() => {
mysqlRunBtn.Text = "停 止";
mysqlStatusImg.Fill = new SolidColorBrush(Color.FromRgb(0, 255, 0));
if (MysqlStopping)
{
MysqlStopping = false;
Log("Msql停止失败");
}
}));
}
else
{
if (MysqlUserRunning)
{
//如果用户启动,则守护该进程
Log("Mysql意外停止,正在重启...");
tool.CmdMysql("start");
}
Dispatcher.Invoke(new Action(() => {
if (MysqlStopping)
{
Log("Mysql已停止");
}
mysqlRunBtn.Text = "启 动";
MysqlStopping = false;
mysqlStatusImg.Fill = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}));
}
Thread.Sleep(CheckTime);
}
}).Start();
}
/// <summary>
/// 启动MySQL
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void mysqlRunBtn_MouseDown(object sender, MouseButtonEventArgs e)
{
//防重复点击
long time = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
if (LastClickTime > time - 1)
{
return;
}
else
{
LastClickTime = time;
}
//控制mysql
var btn = (TextBlock)sender;
var str = btn.Text;
if (str == "启 动")
{
MysqlUserRunning = true;
Log("启动Mysql...");
tool.CmdMysql("start");
btn.Text = "停 止";
mysqlStatusImg.Fill = new SolidColorBrush(Color.FromRgb(0, 255, 0));
}
else
{
MysqlUserRunning = false;
if (MysqlStopping)
{
return;
}
MysqlStopping = true;
try
{
Log("正在停止Mysql...");
tool.CmdMysql("stop");
btn.Text = "启 动";
mysqlStatusImg.Fill = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}
catch
{
Log("Mysql停止失败,稍后重试");
}
}
}
private void mysqlRestartBtn_MouseDown(object sender, MouseButtonEventArgs e)
{
//防重复点击
long time = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
if (LastClickTime > time - 1)
{
return;
}
else
{
LastClickTime = time;
}
//重启mysql
if (tool.MysqlIsRunning())
{
try
{
Log("重启Mysql...");
tool.CmdMysql("restart");
mysqlRunBtn.Text = "停 止";
mysqlStatusImg.Fill = new SolidColorBrush(Color.FromRgb(0, 255, 0));
}
catch
{
Log("重启Mysql失败,稍后重试");
MessageBox.Show("重启Mysql失败,稍后重试");
}
}
}
/// <summary>
/// 日志输出
/// </summary>
/// <param name="txt"></param>
public void Log(string txt)
{
Dispatcher.Invoke(new Action(() => {
if (logBox.Text != "")
{
logBox.Text += "\r" + DateTime.Now.ToString() + " :" + txt;
logboxwarp.ScrollToEnd();
}
else
{
logBox.Text += DateTime.Now.ToString() + " :" + txt;
}
}));
}
/// <summary>
/// 启动php
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void phpRunBtn_MouseDown(object sender, MouseButtonEventArgs e)
{
//防重复点击
long time = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
if (LastClickTime > time - 1)
{
return;
}
else
{
LastClickTime = time;
}
//控制PHP
var btn = (TextBlock)sender;
var str = btn.Text;
if (str == "启 动")
{
PhpUserRunning = true;
Log("启动PHP...");
tool.CmdPHP("start");
btn.Text = "停 止";
phpStatusImg.Fill = new SolidColorBrush(Color.FromRgb(0, 255, 0));
Trace.WriteLine(0);
}
else
{
PhpUserRunning = false;
if (PHPStopping)
{
return;
}
try
{
Log("正在停止PHP...");
PHPStopping = true;
tool.CmdPHP("stop");
btn.Text = "启 动";
phpStatusImg.Fill = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}
catch
{
Log("PHP停止失败,稍后重试");
}
}
}
/// <summary>
/// 监控PHP主进程 每隔5秒
/// </summary>
private void checkPHP()
{
new Thread(() => {
while (true)
{
if (AppQuit)
{
break;
}
if (tool.PHPIsRunning())
{
Dispatcher.Invoke(new Action(() => {
phpRunBtn.Text = "停 止";
phpStatusImg.Fill = new SolidColorBrush(Color.FromRgb(0, 255, 0));
if (PHPStopping)
{
PHPStopping = false;
Log("PHP停止失败");
}
}));
}
else
{
if (PhpUserRunning)
{
//如果用户启动,则守护该进程
Log("PHP意外停止,正在重启...");
tool.CmdPHP("start");
}
Dispatcher.Invoke(new Action(() => {
if (PHPStopping)
{
Log("PHP已停止");
}
phpRunBtn.Text = "启 动";
PHPStopping = false;
phpStatusImg.Fill = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}));
}
Thread.Sleep(CheckTime);
}
}).Start();
}
private void phpRestartBtn_MouseDown(object sender, MouseButtonEventArgs e)
{
//防重复点击
long time = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
if (LastClickTime > time - 1)
{
return;
}
else
{
LastClickTime = time;
}
//重启php
if (tool.PHPIsRunning())
{
try
{
Log("重启PHP...");
tool.CmdPHP("restart");
phpRunBtn.Text = "停 止";
phpStatusImg.Fill = new SolidColorBrush(Color.FromRgb(0, 255, 0));
}
catch
{
Log("重启PHP失败,稍后重试");
}
}
}
private void Label_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
//查看nginx配置
tool.OpenConf("nginx");
}
private void Label_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//查看mysql配置
tool.OpenConf("mysql");
}
private void Label_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
{
//查看php配置
tool.OpenConf("php");
}
private void Label_MouseDown(object sender, MouseButtonEventArgs e)
{
//手动更新
UpdateVersion();
}
private void Label_MouseLeftButtonDown_2(object sender, MouseButtonEventArgs e)
{
if (e.ButtonState == MouseButtonState.Pressed)
{
this.DragMove();
}
}
private void close_windows(object sender, MouseButtonEventArgs e)
{
if (appConf.quitType == "0")
{
//退出程序
AppQuit = true;
if (tool.NginxIsRunning())
{
tool.CmdNginx("stop");
}
if (tool.MysqlIsRunning())
{
tool.CmdMysql("stop");
}
if (tool.PHPIsRunning())
{
tool.CmdPHP("stop");
}
Environment.Exit(0);
}
else
{
this.Hide();
//退出到任务栏
if (TrayIcon == null)
{
TrayIcon = new System.Windows.Forms.NotifyIcon();
TrayIcon.Icon = new System.Drawing.Icon("logo.ico");
TrayIcon.BalloonTipText = appConf.appName + appConf.appVersion + "正在运行";
TrayIcon.Text = appConf.appName + appConf.appVersion + "正在运行";
TrayIcon.MouseDoubleClick += show_windows;
TrayIcon.ShowBalloonTip(1000);
TrayIcon.ContextMenuStrip = new System.Windows.Forms.ContextMenuStrip();
TrayIcon.ContextMenuStrip.Items.Add("显示窗口");
TrayIcon.ContextMenuStrip.Items.Add("退出程序");
TrayIcon.ContextMenuStrip.Items[0].Click += show_windows;
TrayIcon.ContextMenuStrip.Items[1].Click += close_windows;
}
TrayIcon.Visible = true;
}
}
private void Label_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
this.WindowState = WindowState.Minimized;
}
private void quitType_Click(object sender, RoutedEventArgs e)
{
//防重复点击
long time = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
if (LastClickTime > time - 1)
{
return;
}
else
{
LastClickTime = time;
}
if ((bool)quitType.IsChecked)
{
appConf.quitType = "1";
}
else
{
appConf.quitType = "0";
}
appConf.Save();
}
private void autoUpdate_Click(object sender, RoutedEventArgs e)
{
//防重复点击
long time = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
if (LastClickTime > time - 1)
{
return;
}
else
{
LastClickTime = time;
}
if ((bool)autoUpdate.IsChecked)
{
appConf.autoUpdate = "1";
}
else
{
appConf.autoUpdate = "0";
}
appConf.Save();
}
/// <summary>
/// 切换PHP程序版本
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void phpVersionSelect_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int i = phpVersionSelect.SelectedIndex;
if (UIisLoaded)
{
if (!tool.PHPIsRunning())
{
appConf.phpVersion = tool.phpVersions[i];
appConf.Save();
initUI(false);
}
else
{
//phpVersionSelect.SelectedIndex = (new ArrayList(tool.phpVersions)).IndexOf(appConf.phpVersion);
MessageBox.Show("请先停止PHP", "错误");
}
}
}
private void nginxVersionSelect_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int i = nginxVersionSelect.SelectedIndex;
if (UIisLoaded)
{
if (!tool.NginxIsRunning())
{
appConf.nginxVersion = tool.nginxVersions[i];
appConf.Save();
initUI(false);
}
else
{
MessageBox.Show("请先停止Nginx", "错误");
}
}
}
private void mysqlVersionSelect_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int i = mysqlVersionSelect.SelectedIndex;
if (UIisLoaded)
{
if (!tool.MysqlIsRunning())
{
appConf.mysqlVersion = tool.mysqlVersions[i];
appConf.Save();
initUI(false);
}
else
{
MessageBox.Show("请先停止Mysql", "错误");
}
}
}
private void refreshWebSIteBtn_Copy_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
//打开软件下载界面
if (DownloadPage == null)
{
DownloadPage = new download(tool,appConf,this);
DownloadPage.Show();
}
else
{
try
{
DownloadPage.Activate();
DownloadPage.Show();
}
catch
{
DownloadPage = null;
DownloadPage = new download(tool,appConf,this);
DownloadPage.Show();
}
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/weilai1437/wnmp.git
git@gitee.com:weilai1437/wnmp.git
weilai1437
wnmp
wnmp PHP集成环境
master

搜索帮助