测试问题

master
gekoukate 1 year ago
parent 745d663c4a
commit 1e05cacd3a

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

@ -10,8 +10,14 @@ using StartServerWPF.Modules.Main.Model;
namespace StartServerWPF.Modules.Main namespace StartServerWPF.Modules.Main
{ {
public static class JsonParser public class JsonParser
{ {
// public static string zyProPath = @"\serverprogram";
public static string systemConfigPath = "SystemConfig.json";
public static string systemLogFileName;
public static string serverVision = "20230517";
public static SystemConfig ReadSystemJsonFile(string jsonFile) public static SystemConfig ReadSystemJsonFile(string jsonFile)
{ {
//try //try
@ -93,15 +99,6 @@ namespace StartServerWPF.Modules.Main
{ {
string str = JsonConvert.SerializeObject(sc, Formatting.Indented); string str = JsonConvert.SerializeObject(sc, Formatting.Indented);
File.WriteAllText(jsonFile, str); File.WriteAllText(jsonFile, str);
//using (StreamWriter sw = new StreamWriter(jsonFile))
//{
// JsonSerializer js = new JsonSerializer();
// JsonWriter jw = new JsonTextWriter(sw);
// js.Serialize(jw, sc);
// jw.Close();
// sw.Close();
//}
} }
public static void UpdateApmsJson(string apmsJsonPath, string savePath) public static void UpdateApmsJson(string apmsJsonPath, string savePath)

@ -4,6 +4,9 @@
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
<UseWindowsForms>True</UseWindowsForms> <UseWindowsForms>True</UseWindowsForms>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Remove="Images\calendar.png" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" /> <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="MySql.Data" Version="8.0.33" /> <PackageReference Include="MySql.Data" Version="8.0.33" />
@ -15,4 +18,7 @@
<HintPath>..\StartServerWPF\DotRas.dll</HintPath> <HintPath>..\StartServerWPF\DotRas.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Images\calendar.png" />
</ItemGroup>
</Project> </Project>

@ -23,8 +23,8 @@ namespace StartServerWPF.Modules.Main.ViewModels
public MainViewModel(IDialogService dialogService) public MainViewModel(IDialogService dialogService)
{ {
Message = "View A from your Prism Module"; Message = "View A from your Prism Module";
Console.WriteLine(System.Environment.CurrentDirectory + "\\" + systemConfigPath); Console.WriteLine(System.Environment.CurrentDirectory + "\\" + JsonParser.systemConfigPath);
sc = JsonParser.ReadSystemJsonFile(systemConfigPath); sc = JsonParser.ReadSystemJsonFile(JsonParser.systemConfigPath);
int moniTimeInd = sc.proMonitor.ProParams.IndexOf("-btime"); int moniTimeInd = sc.proMonitor.ProParams.IndexOf("-btime");
string moniTimeStr = sc.proMonitor.ProParams.Substring(moniTimeInd + 7); string moniTimeStr = sc.proMonitor.ProParams.Substring(moniTimeInd + 7);
int moniTimeIndEnd = moniTimeStr.IndexOf(">"); int moniTimeIndEnd = moniTimeStr.IndexOf(">");
@ -54,30 +54,47 @@ namespace StartServerWPF.Modules.Main.ViewModels
} }
private DateTime startTime; private DateTime startTime;
private DateTime moniStartTime; private DateTime moniStartTime;
public DateTime StartTime { get => startTime; set => startTime = value; } public DateTime StartTime { get => startTime; set => SetProperty(ref startTime, value); }
public DateTime MoniStartTime { get => moniStartTime; set => moniStartTime = value; } public DateTime MoniStartTime { get => moniStartTime; set => SetProperty(ref moniStartTime, value); }
private string runTime; private string runTime;
public string RunTime public string RunTime
{ {
get { return runTime; } get { return runTime; }
set { runTime = value; } set { SetProperty(ref runTime, value); }
} }
private string vPNStatus; private string vPNStatus;
public string VPNStatus public string VPNStatus
{ {
get { return vPNStatus; } get { return vPNStatus; }
set { vPNStatus = value; } set { SetProperty(ref vPNStatus, value);
}
} }
private string vpnIP; private string vpnIP;
public string VpnIP public string VpnIP
{ {
get { return vpnIP; } get { return vpnIP; }
set { vpnIP = value; } set { SetProperty(ref vpnIP, value); }
}
private string vPNStatusForeColor;
public string VPNStatusForeColor
{
get { return vPNStatusForeColor; }
set { SetProperty(ref vPNStatusForeColor, value); }
} }
private bool vPNIsConnect;
public bool VPNIsConnect
{
get { return vPNIsConnect; }
set { SetProperty(ref vPNIsConnect, value); }
}
private ObservableCollection<string> reciveDataSource=new ObservableCollection<string>(); private ObservableCollection<string> reciveDataSource=new ObservableCollection<string>();
@ -99,7 +116,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
public int SelectedIndex public int SelectedIndex
{ {
get { return selectedIndex; } get { return selectedIndex; }
set { selectedIndex = value; } set { SetProperty(ref selectedIndex, value); }
} }
private bool isEnabledStart; private bool isEnabledStart;
@ -107,12 +124,12 @@ namespace StartServerWPF.Modules.Main.ViewModels
public bool IsEnabledStart public bool IsEnabledStart
{ {
get { return isEnabledStart; } get { return isEnabledStart; }
set { isEnabledStart = value; } set { SetProperty(ref isEnabledStart, value); }
} }
private int proMonInterval = 10; private int proMonInterval = 10;
public int ProMonInterval { get => proMonInterval; public int ProMonInterval { get => proMonInterval;
set => proMonInterval = value; set => SetProperty(ref proMonInterval, value);
} }
#endregion #endregion
@ -144,7 +161,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
KillProcess(sc.proApms); KillProcess(sc.proApms);
KillProcess(sc.proMonitor); KillProcess(sc.proMonitor);
string logStr = DateTime.Now.ToString("s") + "\t程序关闭"; string logStr = DateTime.Now.ToString("s") + "\t程序关闭";
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr); WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
//switch (kserindex) //switch (kserindex)
//{ //{
// case -1: // case -1:
@ -179,7 +196,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
vpn.ConnectVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw); vpn.ConnectVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw);
Thread.Sleep(1000); Thread.Sleep(1000);
string logStr = DateTime.Now.ToString("s") + "\tVPN手动连接"; string logStr = DateTime.Now.ToString("s") + "\tVPN手动连接";
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr); WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
SetControlstatus(); SetControlstatus();
} }
@ -192,7 +209,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
SetControlstatus(); SetControlstatus();
Thread.Sleep(100); Thread.Sleep(100);
string logStr = DateTime.Now.ToString("s") + "\tVPN手动断开"; string logStr = DateTime.Now.ToString("s") + "\tVPN手动断开";
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr); WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
} }
} }
@ -268,7 +285,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
// labelStartTime.Text = "启动时间:" + StartTime.ToString(); // labelStartTime.Text = "启动时间:" + StartTime.ToString();
RunTime = "运行时间:" + DateDiff(DateTime.Now, StartTime); RunTime = "运行时间:" + DateDiff(DateTime.Now, StartTime);
string logStr = StartTime.ToString("s") + "\t服务器程序启动"; string logStr = StartTime.ToString("s") + "\t服务器程序启动";
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr); WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
// progressBar1.Style = ProgressBarStyle.Marquee; // progressBar1.Style = ProgressBarStyle.Marquee;
IsEnabledStart = false; IsEnabledStart = false;
@ -320,7 +337,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
timer1.Stop(); timer1.Stop();
// progressBar1.Style = ProgressBarStyle.Continuous; // progressBar1.Style = ProgressBarStyle.Continuous;
string logStr = DateTime.Now.ToString("s") + "\t服务器程序关闭"; string logStr = DateTime.Now.ToString("s") + "\t服务器程序关闭";
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr); WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
// labelStartTime.Text = "启动时间:"; // labelStartTime.Text = "启动时间:";
StartTime = new DateTime(); StartTime = new DateTime();
@ -427,14 +444,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
[DllImport("shell32.dll")] [DllImport("shell32.dll")]
public static extern int ShellExecute(IntPtr hwnd, StringBuilder lpszOp, StringBuilder lpszFile, StringBuilder lpszParams, StringBuilder lpszDir, int FsShowCmd); public static extern int ShellExecute(IntPtr hwnd, StringBuilder lpszOp, StringBuilder lpszFile, StringBuilder lpszParams, StringBuilder lpszDir, int FsShowCmd);
public string proPath;
public string zyProPath = @"\serverprogram";
public string systemConfigPath = "SystemConfig.json";
public string systemLogFileName;
public int showState = 0;
public string serverVision = "20210629";
public VPNHelper vpn; public VPNHelper vpn;
@ -449,7 +458,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
public void InitializeParams() public void InitializeParams()
{ {
timer1.Interval = ProMonInterval * 1000; timer1.Interval = ProMonInterval * 1000;
this.Message = "服务器版本:" + serverVision; this.Message = "服务器版本:" + JsonParser.serverVision;
IntervalTimesSource.Add(5); IntervalTimesSource.Add(5);
IntervalTimesSource.Add(10); IntervalTimesSource.Add(10);
IntervalTimesSource.Add(15); IntervalTimesSource.Add(15);
@ -457,9 +466,9 @@ namespace StartServerWPF.Modules.Main.ViewModels
IntervalTimesSource.Add(30); IntervalTimesSource.Add(30);
IntervalTimesSource.Add(60); IntervalTimesSource.Add(60);
SelectedIndex = 1; SelectedIndex = 1;
systemLogFileName = "SerLog_" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; JsonParser.systemLogFileName = "SerLog_" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
string logStr = DateTime.Now.ToString("s") + "\t程序启动"; string logStr = DateTime.Now.ToString("s") + "\t程序启动";
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr); WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
//CheckIp(); //CheckIp();
} }
#region 方法 #region 方法
@ -582,7 +591,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
Thread.Sleep(20); Thread.Sleep(20);
ReciveDataSource.Add("服务器程序重启成功"); ReciveDataSource.Add("服务器程序重启成功");
string logStr = DateTime.Now.ToString("s") + "\t服务器程序" + sc.proServer.ProName + "重启"; string logStr = DateTime.Now.ToString("s") + "\t服务器程序" + sc.proServer.ProName + "重启";
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr); WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
} }
sfp = FindProcess(sc.proRecv); sfp = FindProcess(sc.proRecv);
if (sfp == 0) if (sfp == 0)
@ -597,7 +606,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
Thread.Sleep(20); Thread.Sleep(20);
ReciveDataSource.Add("接收数据程序重启成功"); ReciveDataSource.Add("接收数据程序重启成功");
string logStr = DateTime.Now.ToString("s") + "\t接收数据程序" + sc.proRecv.ProName + "重启"; string logStr = DateTime.Now.ToString("s") + "\t接收数据程序" + sc.proRecv.ProName + "重启";
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr); WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
} }
sfp = FindProcess(sc.proApms); sfp = FindProcess(sc.proApms);
if (sfp == 0) if (sfp == 0)
@ -612,7 +621,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
Thread.Sleep(20); Thread.Sleep(20);
ReciveDataSource.Add("自动识别程序重启成功"); ReciveDataSource.Add("自动识别程序重启成功");
string logStr = DateTime.Now.ToString("s") + "\t自动识别程序" + sc.proApms.ProName + "重启"; string logStr = DateTime.Now.ToString("s") + "\t自动识别程序" + sc.proApms.ProName + "重启";
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr); WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
} }
sfp = FindProcess(sc.proMonitor); sfp = FindProcess(sc.proMonitor);
if (sfp == 0) if (sfp == 0)
@ -627,7 +636,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
Thread.Sleep(20); Thread.Sleep(20);
ReciveDataSource.Add("网页服务程序重启成功"); ReciveDataSource.Add("网页服务程序重启成功");
string logStr = DateTime.Now.ToString("s") + "\t网页服务程序" + sc.proMonitor.ProName + "重启"; string logStr = DateTime.Now.ToString("s") + "\t网页服务程序" + sc.proMonitor.ProName + "重启";
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr); WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
} }
RunTime = "运行时间:" + DateDiff(DateTime.Now, StartTime); RunTime = "运行时间:" + DateDiff(DateTime.Now, StartTime);
vpnStatus = vpn.CheckVpnStatus(sc.vpnInfo.VpnName); vpnStatus = vpn.CheckVpnStatus(sc.vpnInfo.VpnName);
@ -636,7 +645,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
vpn.ConnectVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw); vpn.ConnectVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw);
Thread.Sleep(1000); Thread.Sleep(1000);
string logStr = DateTime.Now.ToString("s") + "\tVPN断开重连"; string logStr = DateTime.Now.ToString("s") + "\tVPN断开重连";
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr); WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
} }
} }
public void GetLocalIp() public void GetLocalIp()
@ -668,8 +677,10 @@ namespace StartServerWPF.Modules.Main.ViewModels
// buttonDisconnectVPN.Enabled = true; // buttonDisconnectVPN.Enabled = true;
// labelVPNstatus.ForeColor = Color.Blue; // labelVPNstatus.ForeColor = Color.Blue;
VPNIsConnect = true;
VPNStatusForeColor = "#FF0000FF";
VPNStatus = "VPN已连接"; VPNStatus = "VPN已连接";
VpnIP = "本机IP" + vpn.GetLocalIp(); VpnIP = vpn.GetLocalIp();
} }
else else
{ {
@ -678,6 +689,8 @@ namespace StartServerWPF.Modules.Main.ViewModels
// buttonDisconnectVPN.Enabled = false; // buttonDisconnectVPN.Enabled = false;
// labelVPNstatus.ForeColor = Color.Red; // labelVPNstatus.ForeColor = Color.Red;
VPNIsConnect = false;
VPNStatusForeColor = "#FFFF0000";
VPNStatus = "VPN未连接"; VPNStatus = "VPN未连接";
} }
} }

@ -34,10 +34,12 @@ namespace StartServerWPF.Modules.Main.ViewModels
// _title = "编辑" + _title; // _title = "编辑" + _title;
var _type = parameters.GetValue<int>("type"); var _type = parameters.GetValue<int>("type");
// _title = (_type == 0 ? "新增" : "修改") + _title; // _title = (_type == 0 ? "新增" : "修改") + _title;
MainModel = parameters.GetValue<VpnInfo>("model"); _systemConfig = parameters.GetValue<SystemConfig>("model");
MainModel= _systemConfig.vpnInfo;
MoniTime= parameters.GetValue<DateTime>("moniTime"); MoniTime= parameters.GetValue<DateTime>("moniTime");
} }
private SystemConfig _systemConfig;
private VpnInfo _mainModel = new VpnInfo(); private VpnInfo _mainModel = new VpnInfo();
public VpnInfo MainModel public VpnInfo MainModel
{ {
@ -53,12 +55,17 @@ namespace StartServerWPF.Modules.Main.ViewModels
public DelegateCommand FilePathSaveCommand=> new(()=> public DelegateCommand FilePathSaveCommand=> new(()=>
{ {
updateJson = false;
System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
fbd.SelectedPath = MainModel.DataSavePath; fbd.SelectedPath = MainModel.DataSavePath;
fbd.ShowNewFolderButton = true; fbd.ShowNewFolderButton = true;
if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{ {
MainModel.DataSavePath = fbd.SelectedPath; MainModel.DataSavePath = fbd.SelectedPath;
if (MainModel.DataSavePath != _systemConfig.vpnInfo.DataSavePath)
{
updateJson = true;
}
} }
}); });
public DelegateCommand LogPathSaveCommand=> new(() => public DelegateCommand LogPathSaveCommand=> new(() =>
@ -75,6 +82,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
MainModel.SystemLogPath = fbd.SelectedPath; MainModel.SystemLogPath = fbd.SelectedPath;
} }
}); });
bool updateJson = false;
public ICommand ConfirmCommand public ICommand ConfirmCommand
{ {
get => new DelegateCommand(() => get => new DelegateCommand(() =>
@ -83,29 +91,20 @@ namespace StartServerWPF.Modules.Main.ViewModels
// 数据校验关键字段不能为空、年龄做数字区间的校验、做UserName的唯一检查自定义特性检查 // 数据校验关键字段不能为空、年龄做数字区间的校验、做UserName的唯一检查自定义特性检查
if (string.IsNullOrEmpty(MainModel.VpnName) || string.IsNullOrEmpty(MainModel.VpnIP)) if (string.IsNullOrEmpty(MainModel.VpnName) || string.IsNullOrEmpty(MainModel.VpnIP))
{ {
MessageBox.Show("内容不能为空", "提示", System.Windows.MessageBoxButton.OK); MessageBox.Show("内容不能为空", "提示", MessageBoxButton.OK);
return; return;
} }
if (MessageBox.Show("确认修改?", "参数设置", MessageBoxButton.OKCancel, if (MessageBox.Show("确认修改?", "参数设置", MessageBoxButton.OKCancel,
MessageBoxImage.Exclamation) == MessageBoxResult.OK) MessageBoxImage.Exclamation) == MessageBoxResult.OK)
{ {
//if (updateSysConfig)
//{
// JsonParser.WriteSystemConfigFile(fm.systemConfigPath, fsc);
//}
//if (updateJson)
//{
// JsonParser.UpdateRecvJson(fm.sc.proRecv.ProPath + fm.sc.proRecv.JsonPath, fm.sc.DataSavePath);
// JsonParser.UpdateApmsJson(fm.sc.proApms.ProPath + fm.sc.proApms.JsonPath, fm.sc.DataSavePath);
//}
//var device = _deviceInfoModel.deviceInfoModelList.Where(device => device.Index == MainModel.Index).FirstOrDefault();
//if (device != null)
//{
// _deviceInfoModel.deviceInfoModelList.Remove(device);
// _deviceInfoModel.deviceInfoModelList.Add(MainModel);
// _deviceInfoModel.Save();
//} JsonParser.WriteSystemConfigFile(JsonParser.systemConfigPath, _systemConfig);
if (updateJson)
{
JsonParser.UpdateRecvJson(_systemConfig.proRecv.ProPath + _systemConfig.proRecv.JsonPath, _systemConfig.vpnInfo.DataSavePath);
JsonParser.UpdateApmsJson(_systemConfig.proApms.ProPath + _systemConfig.proApms.JsonPath, _systemConfig.vpnInfo.DataSavePath);
}
RequestClose?.Invoke(new DialogResult(ButtonResult.OK)); RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
} }
}); });

@ -39,15 +39,15 @@
<ColumnDefinition Width="1*"/> <ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/> <ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<RadioButton GroupName="con" x:Name="rtnConnect" Content="连接" Command="{Binding ConnectVPNCommand}" Grid.Row="0" VerticalAlignment="Center"/> <RadioButton GroupName="con" IsChecked="{Binding VPNIsConnect}" x:Name="rtnConnect" Content="连接" Command="{Binding ConnectVPNCommand}" CommandParameter="{Binding RelativeSource={ RelativeSource Mode=Self},Path=IsChecked}" Grid.Row="0" VerticalAlignment="Center"/>
<RadioButton GroupName="con" Content="断开连接" Grid.Column="1" Command="{Binding DisConnectVPNCommand}" VerticalAlignment="Center" IsChecked="True"/> <RadioButton GroupName="con" Content="断开连接" Grid.Column="1" Command="{Binding DisConnectVPNCommand}" VerticalAlignment="Center" IsChecked="True"/>
<StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" > <StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" >
<Button Content="检查状态" Command="{Binding GetVPNStatusCommand}"/> <Button Content="检查状态" Command="{Binding GetVPNStatusCommand}" Margin="5,0,5,0"/>
<TextBlock Text="{Binding VPNStatus}"/> <TextBlock Text="{Binding VPNStatus}" Foreground="{Binding VPNStatusForeColor}"/>
</StackPanel> </StackPanel>
<Button Content="参数设置" Grid.Row="1" Command="{Binding SetVPNParaCommand}" VerticalAlignment="Center"/> <Button Content="参数设置" Grid.Row="1" Command="{Binding SetVPNParaCommand}" VerticalAlignment="Center"/>
<Button Content="运行日志" Grid.Row="1" Grid.Column="1" Command="{Binding DisplayLogCommand}" VerticalAlignment="Center"/> <Button Content="运行日志" Grid.Row="1" Grid.Column="1" Command="{Binding DisplayLogCommand}" VerticalAlignment="Center"/>
<TextBlock Grid.Row="1" Grid.Column="2" VerticalAlignment="Center"> <TextBlock Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" Margin="5,0,5,0">
<Run Text="本机IP:"/> <Run Text="本机IP:"/>
<Run Text="{Binding VpnIP}"/> <Run Text="{Binding VpnIP}"/>
</TextBlock> </TextBlock>

@ -67,8 +67,16 @@
<Button Content="设置路径" Command="{Binding LogPathSaveCommand}" Grid.Row="1" Grid.Column="2"/> <Button Content="设置路径" Command="{Binding LogPathSaveCommand}" Grid.Row="1" Grid.Column="2"/>
</Grid> </Grid>
<StackPanel Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="监控日期:"/> <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
<TextBlock Text="{Binding MoniTime,StringFormat=yyyy-MM-dd HH:mm:ss}" /> <TextBlock>
<Run Text="监控日期:"/>
<Run Text="{Binding MoniTime,StringFormat=yyyy-MM-dd HH:mm:ss}"/>
</TextBlock>
<Image Name="tb_calendar_img" Source="/Images/calendar.png" Grid.Column="1" Width="18" Height="18" Margin="0,0,0,0" PreviewMouseLeftButtonUp="tb_calendar_img_MouseLeftButtonUp"/>
</StackPanel>
<Popup x:Name="Pop" PopupAnimation="None" Width="200" Height="210" PlacementTarget="{Binding ElementName=tb_calendar}" Placement="Bottom" AllowsTransparency="True" StaysOpen="False" VerticalAlignment="Top" Margin="-200,0,0,0">
<Calendar Name="calendar" SelectedDate="{Binding MoniTime}" HorizontalAlignment="Left" Margin="0,44,0,0" VerticalAlignment="Top" />
</Popup>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="4" > <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="4" >
<Button Content="确认" Width="100" Height="30" Margin="5,0" <Button Content="确认" Width="100" Height="30" Margin="5,0"

@ -24,5 +24,41 @@ namespace StartServerWPF.Modules.Main.Views
{ {
InitializeComponent(); InitializeComponent();
} }
private void calendar_DisplayModeChanged(object sender, CalendarModeChangedEventArgs e)
{
if (calendar.DisplayMode == CalendarMode.Month || calendar.DisplayMode == CalendarMode.Decade)
{
calendar.DisplayMode = CalendarMode.Year;
}
}
/// <summary>
/// 点击日历图标显示Calendar控件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tb_calendar_img_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (Pop.IsOpen)
{
Pop.IsOpen = false;
}
else
{
Pop.IsOpen = true;
}
}
///// <summary>
///// 监听日期变化隐藏Calendar控件
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//private void calendar_DisplayDateChanged(object sender, CalendarDateChangedEventArgs e)
//{
// var year = calendar.DisplayDate.Date.Year;
// var month = calendar.DisplayDate.Date.Month;
// tb_calendar.Text = year + "年" + month + "月";
// Pop.IsOpen = false;
//}
} }
} }

@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://prismlibrary.com/" xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True" prism:ViewModelLocator.AutoWireViewModel="True"
Title="{Binding Title}" Height="350" Width="525" > Title="{Binding Title}" Height="500" Width="800" >
<Grid> <Grid>
<ContentControl prism:RegionManager.RegionName="MainContentRegion" /> <ContentControl prism:RegionManager.RegionName="MainContentRegion" />
</Grid> </Grid>

Loading…
Cancel
Save