diff --git a/Common/CommonSTA.cs b/Common/CommonSTA.cs index 74c20e1..21914c3 100644 --- a/Common/CommonSTA.cs +++ b/Common/CommonSTA.cs @@ -4,7 +4,7 @@ namespace Mj.Common { - public static class CommonSTA // static 不是必须 + public static class CommonSTA { public static double dpi = 1; public static byte Doping = 1; @@ -27,6 +27,7 @@ public static class CommonSTA // static 不是必须 public static string PSPName = @""; public static System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping(); public static System.Net.NetworkInformation.Ping ping2 = new System.Net.NetworkInformation.Ping(); + public static System.Net.NetworkInformation.Ping ping3 = new System.Net.NetworkInformation.Ping(); } } diff --git a/View/IndexView.xaml b/View/IndexView.xaml index a9297f7..92e16d9 100644 --- a/View/IndexView.xaml +++ b/View/IndexView.xaml @@ -773,7 +773,8 @@ - + + diff --git a/View/IndexView.xaml.cs b/View/IndexView.xaml.cs index 97a3ff8..b39fec8 100644 --- a/View/IndexView.xaml.cs +++ b/View/IndexView.xaml.cs @@ -11,8 +11,19 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; -using System.Drawing; - +//默认值 +//"window", "Runed", "0"""[1] +//"UE5Beta", "activation", ""[] +//"window", "ManySame", ""[1] +//"window", "Yuanjiao", ""[1] +//"window", "主题", "幻影白"""[] +//"window", "DPI", ""[1] +//"window", "禁用托盘",""[1] +//"setgame", "IP" +//"xfc", "自定义位置" +//"xfc", "自定义大小" +//"xfc", "top" +//"xfc", "left" namespace Mj.View { @@ -25,24 +36,7 @@ public partial class IndexView : Window #region SynchronizationContext public static System.Threading.SynchronizationContext mainThreadSynContext; #endregion - #region DPI所需接口 - [System.Runtime.InteropServices.DllImport("gdi32.dll", EntryPoint = "GetDeviceCaps", SetLastError = true)] - public static extern int GetDeviceCaps(IntPtr hdc, int nIndex); - enum DeviceCap - { - VERTRES = 10, - PHYSICALWIDTH = 110, - SCALINGFACTORX = 114, - DESKTOPVERTRES = 117, - } - public static double GetScreenScalingFactor() - { - var g = Graphics.FromHwnd(IntPtr.Zero); - IntPtr desktop = g.GetHdc(); - var physicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES); - return physicalScreenHeight; - } - #endregion + #region DataContext(其他事件要用 public IndexViewModel IndexViewModel = new IndexViewModel(); #endregion @@ -74,13 +68,6 @@ public IndexView() else { IndexViewModel.ini.IniWriteValue("window", "Runed", "0"); - IndexViewModel.ini5.IniWriteValue("UE5Beta", "activation", "0"); - IndexViewModel.ini.IniWriteValue("window", "ManySame", "0"); - IndexViewModel.ini.IniWriteValue("window", "Yuanjiao", "0"); - IndexViewModel.ini.IniWriteValue("window", "主题", "幻影白"); - IndexViewModel.ini.IniWriteValue("window", "DPI", "0"); - IndexViewModel.ini.IniWriteValue("window", "禁用托盘", "0"); - IndexViewModel.ini.IniWriteValue("xfc", "big", "0.2"); IndexViewModel.ini.IniWriteValue("setgame", "FCN路径", Environment.CurrentDirectory + @"\FCN.exe"); IndexViewModel.ini.IniWriteValue("setgame", "PPSSPP路径", Environment.CurrentDirectory + @"\"); IndexViewModel.ini.IniWriteValue("setgame", "ISO路径", Environment.CurrentDirectory + @"\memstick\PSP\GAME\"); @@ -126,13 +113,10 @@ public IndexView() { window.Show(); #region 是否DPI禁用(主窗口大小调整 - window.MaxHeight = 10000 * Common.CommonSTA.dpi; - window.Width = (SystemParameters.PrimaryScreenWidth * 0.6 * Common.CommonSTA.dpi * Common.CommonSTA.dpi) + 5; - window.Height = (SystemParameters.PrimaryScreenHeight * 0.64 * Common.CommonSTA.dpi * Common.CommonSTA.dpi) + 10; - window.Top = (SystemParameters.PrimaryScreenHeight * (0.5 - 0.32 * Common.CommonSTA.dpi) - 20) * Common.CommonSTA.dpi - 5; - window.Left = SystemParameters.PrimaryScreenWidth * Common.CommonSTA.dpi * (0.5 - 0.3 * Common.CommonSTA.dpi) - 2.5; - window.MinHeight = 390 * Common.CommonSTA.dpi; - window.MinWidth = 281 * Common.CommonSTA.dpi; + + window.Top = (SystemParameters.PrimaryScreenHeight * (0.5 - 0.32 * Common.CommonSTA.dpi) - 20) - 5; + window.Left = SystemParameters.PrimaryScreenWidth * (0.5 - 0.3 * Common.CommonSTA.dpi) - 2.5; + #endregion } ), null); @@ -141,7 +125,7 @@ public IndexView() { View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => loading.Close()), null); - MessageBox.Show("操作被禁止\n资源:" + Environment.CurrentDirectory + @"\" + "\n请检查杀软自动拦截d3dcompiler_47.dll" + "如有疑问请咨询群内管理员"); + MessageBox.Show("操作被禁止\n资源:" + Environment.CurrentDirectory + @"\" + "\n请检查杀软自动拦截d3dcompiler_47.dll\n是游戏模拟器解压的一部分" + "如有疑问请咨询群内管理员"); View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => Application.Current.Shutdown()), null); } @@ -156,15 +140,15 @@ public IndexView() #region SynchronizationContext mainThreadSynContext = System.Threading.SynchronizationContext.Current; #endregion + #region DataContext this.DataContext = IndexViewModel; #endregion - #region 获取DPI(其他窗口也用到 - Common.CommonSTA.dpi = double.Parse(GetScreenScalingFactor().ToString(), 0) / double.Parse(SystemParameters.PrimaryScreenHeight.ToString(), 0); - #endregion + #region 是否DPI禁用(主窗口大小调整 window.Top = (SystemParameters.PrimaryScreenHeight * (0.5 - 0.32 * Common.CommonSTA.dpi) - 20) - 5; window.Left = SystemParameters.PrimaryScreenWidth * (0.5 - 0.3 * Common.CommonSTA.dpi) - 2.5; + //if (IndexViewModel.ini.IniReadValue("window", "DPI") != "1" && NomalExe) //{ // //window.MaxHeight = 10000 * Common.CommonSTA.dpi; @@ -183,7 +167,7 @@ public IndexView() } #endregion #region 小概率启动 - if (IndexViewModel.ini.IniReadValue("setgame", "菜菜子") == "1" || (new Random().Next(0, 1000) == 521 && NomalExe)) + if (IndexViewModel.ini.IniReadValue("setgame", "菜菜子") == "1" || ((new Random().Next(0, 1000) == 521 && NomalExe))) { View.BloodView blood = new BloodView(); View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => @@ -199,770 +183,14 @@ public IndexView() #region 自启动 if (IndexViewModel.ini.IniReadValue("setgame", "自启") == "1") { - if (IndexViewModel.ini.IniReadValue("setgame", "游戏名") == "") - { - IndexViewModel.IndexModel.MainContent = (FrameworkElement)Type.GetType("Mj.View.Page4View").GetConstructor(System.Type.EmptyTypes).Invoke(null); - IndexViewModel.IndexModel.Select1 = 1; IndexViewModel.IndexModel.Select2 = 0; IndexViewModel.IndexModel.Select3 = 0; - MessageBox.Show("请修改您的游戏昵称"); - return; - } - if (!System.IO.File.Exists(Common.CommonSTA.LujingISO + "UJS00329.iso")) - { - IndexViewModel.IndexModel.MainContent = (FrameworkElement)Type.GetType("Mj.View.Page4View").GetConstructor(System.Type.EmptyTypes).Invoke(null); - IndexViewModel.IndexModel.Select1 = 1; IndexViewModel.IndexModel.Select2 = 0; IndexViewModel.IndexModel.Select3 = 0; - MessageBox.Show("未找到游戏文件目录,请重新初始化\n\r\n\r或请前往设置中指定您自己[UJS00329.iso]的位置"); - return; - } - if (IndexViewModel.IndexModel.PlayContent == "等待选服/取消") - { - Common.CommonSTA.Stop = true; - } - else + System.Threading.Tasks.Task.Run(() => { - IndexViewModel.IndexModel.PlayContent = "启动中"; - Common.CommonSTA.IsPlayStart = true; - Common.CommonSTA.Stop = false; - IndexViewModel.IndexModel.ICO = "../Assets/ico.ico"; - #region 隐藏启动器 - if (IndexViewModel.ini.IniReadValue("window", "禁用托盘") != "1") - { - Application.Current.Dispatcher.Invoke(new Action(() => - { - if (this != null) - { - this.Hide(); - } - })); - } - #endregion - if (!System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\isppsspp")) - { - #region PPSSPP初始化 - if (System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ppsspp.ini")) - { - System.IO.File.Delete(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ppsspp.ini"); - } - try - { - System.Diagnostics.Process.Start(Common.CommonSTA.LujingPSP + @"PPSSPPWindows64.exe"); - } - catch (Exception) - { - IndexViewModel.IndexModel.MainContent = (FrameworkElement)Type.GetType("Mj.View.Page5View").GetConstructor(System.Type.EmptyTypes).Invoke(null); - IndexViewModel.IndexModel.Select1 = 1; IndexViewModel.IndexModel.Select2 = 0; IndexViewModel.IndexModel.Select3 = 0; - MessageBox.Show("模拟器损坏,请重新初始化\n\r\n\r或请前往设置中指定您自己[PPSSPP]的位置"); - Common.CommonSTA.IsPlayStart = false; - IndexViewModel.IndexModel.ICO = "../Assets/logo128.ico"; - IndexViewModel.IndexModel.PlayContent = "立即开始"; - return; - } - System.Threading.Tasks.Task.Run(() => - { - System.Diagnostics.Process[] pProcess; - pProcess = System.Diagnostics.Process.GetProcesses(); - while (true) - { - if (System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ppsspp.ini")) - { - System.Threading.Thread.Sleep(500); - for (int i = 1; i <= pProcess.Length - 1; i++) - { - if (pProcess[i].ProcessName == "PPSSPPWindows64") - { - pProcess[i].Kill(); - break; - } - } - break; - } - System.Threading.Thread.Sleep(500); - } - #endregion - //设置改变 - #region 默认 - IndexViewModel.psp.IniWriteValue("General", "CheckForNewVersion ", " False"); - IndexViewModel.psp.IniWriteValue("General", "ForceLagSync2 ", " True"); - IndexViewModel.psp.IniWriteValue("Graphics", "AnisotropyLevel ", " 0"); - IndexViewModel.psp.IniWriteValue("Graphics", "ReplaceTextures ", " True"); - IndexViewModel.psp.IniWriteValue("Graphics", "TextureBackoffCache ", " True"); - IndexViewModel.psp.IniWriteValue("Graphics", "FullScreen ", " True"); - IndexViewModel.psp.IniWriteValue("Graphics", "SplineBezierQuality ", " 0"); - IndexViewModel.psp.IniWriteValue("Graphics", "DisableSlowFramebufEffects ", " True"); - IndexViewModel.psp.IniWriteValue("Network", "ForcedFirstConnect ", " True"); - IndexViewModel.psp.IniWriteValue("Network", "EnableNetworkChat ", " True"); - IndexViewModel.psp.IniWriteValue("Network", "ChatButtonPosition ", " 3"); - IndexViewModel.psp.IniWriteValue("Network", "ChatScreenPosition ", " 3"); - #endregion - + View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => { - if (!System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\isppsspp")) - { - try - { - System.IO.File.Create(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\isppsspp").WriteByte(1); - } - catch (Exception) - { - MessageBox.Show("操作被禁止"); - } - } - - #region 正常启动 - if (IndexViewModel.ini.IniReadValue("setgame", "联机") != "0") - { - #region 悬浮窗总执行 - if (IndexViewModel.IndexModel.IPtupian == "../Assets/ping-close.png")//AAA窗口开启的话 - { - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.XfcView.Hide()), null); - Common.CommonSTA.Noping3 = 1; - Common.CommonSTA.XDS = 0; - //AAA窗口关闭 - } - else - { - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.XfcView.Owner = this), null); - try - { - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.XfcView.Show()), null); - Common.CommonSTA.XDS = 1; - Common.CommonSTA.Noping3 = 0; - } - catch (Exception) - { - MessageBox.Show("要复活小电视嘛 = = "); - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.XfcView = new View.XfcView()), null); - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.XfcView.Show()), null); - Common.CommonSTA.XDS = 1; - Common.CommonSTA.Noping3 = 0; - } - } - #endregion - #region 有网模式 - try - { - System.Diagnostics.Process.Start(Common.CommonSTA.LujingFCN);//FCN - } - catch (Exception) - { - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.MainContent = (FrameworkElement)Type.GetType("Mj.View.Page5View").GetConstructor(System.Type.EmptyTypes).Invoke(null)), null); - IndexViewModel.IndexModel.Select1 = 1; IndexViewModel.IndexModel.Select2 = 0; IndexViewModel.IndexModel.Select3 = 0; - MessageBox.Show("联机模块损坏,请重新初始化\n\r\n\r或请前往设置中指定您自己[联机模块]的位置"); - IndexViewModel.IndexModel.ICO = "../Assets/logo128.ico"; - IndexViewModel.IndexModel.PlayContent = "立即开始"; - Common.CommonSTA.IsPlayStart = false; - return; - } - Common.CommonSTA.Danji = false; - Common.CommonSTA.IsOK = false; - if (IndexViewModel.ini.IniReadValue("setgame", "不提示") != "1") - { - #region 显示弹窗 - try - { - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.Tishi.Show()), null); - } - catch (Exception) - { - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.Tishi = new View.UMessageBox()), null); - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.Tishi.Show()), null); - } - #endregion - #region 倒计时 - System.Threading.Tasks.Task.Run(() => - { - for (int i = 5; i > 0; i--) - { - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.Tishi.ZDL = "知道了(" + i + ")"), null); - System.Threading.Thread.Sleep(1000); - } - #region 自动关闭弹窗 - try - { - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.Tishi.Hide()), null); - } - catch (Exception) - { - ; - } - #endregion - Common.CommonSTA.IsOK = true; - }).ContinueWith((t) => - { - - return 1; - }); - #endregion - } - System.Threading.Tasks.Task.Run(() => - { - IndexViewModel.IndexModel.PlayContent = "等待选服/取消"; - while (true) - { - if (Common.CommonSTA.Stop == true) - { - Common.CommonSTA.Noping2 = 1; - break; - } - if (Common.CommonSTA.Danji == true) - { - #region 悬浮窗关闭 - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.XfcView.Hide()), null); - Common.CommonSTA.Noping3 = 1; - Common.CommonSTA.XDS = 0; - #endregion - #region 关闭网络 - IndexViewModel.psp.IniWriteValue("Network", "EnableWlan", "False"); - #endregion - #region 保险 - IndexViewModel.psp.IniWriteValue("SystemParam", "PSPModel", "1"); - if (IndexViewModel.ini.IniReadValue("setgame", "游戏名") != "") - { - IndexViewModel.psp.IniWriteValue("SystemParam", "NickName", Common.CommonSTA.PSPName); - } - if (IndexViewModel.ini.IniReadValue("setgame", "金手指") != "1") - { - IndexViewModel.psp.IniWriteValue("General", "EnableCheats", "False"); - if (System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini")) - { - System.IO.File.Delete(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini"); - } - } - else - { - IndexViewModel.psp.IniWriteValue("General", "EnableCheats", "True"); - try - { - if (!System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini")) - { - System.IO.File.WriteAllBytes(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini", Properties.Resources.ULJS00329); - } - } - catch (Exception) - { - MessageBox.Show("操作被禁止"); - } - } - if (System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ULJS00329_ppsspp.ini")) - { - System.IO.File.Delete(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ULJS00329_ppsspp.ini"); - } - IndexViewModel.psp.IniWriteValue("Graphics", "FullScreen ", " True"); - IndexViewModel.psp.IniWriteValue("CPU", "IOTimingMethod ", " 0"); - IndexViewModel.psp.IniWriteValue("Network", "PortOffset ", " 5000"); - IndexViewModel.psp.IniWriteValue("Network", "proAdhocServer ", " " + Common.CommonSTA._ip); - int[] mac = new int[] { new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16) }; - IndexViewModel.psp.IniWriteValue("SystemParam", "MacAddress ", " " + mac[0] + mac[1] + ":" + mac[2] + mac[3] + ":" + mac[4] + mac[5] + ":" + mac[6] + mac[7] + ":" + mac[8] + mac[9] + ":" + mac[10] + mac[11]); - #endregion - #region 启动游戏 - try - { - System.Diagnostics.Process.Start(Common.CommonSTA.LujingPSP + @"PPSSPPWindows64.exe", Common.CommonSTA.LujingISO + @"UJS00329.iso"); - } - catch (Exception) - { - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.MainContent = (FrameworkElement)Type.GetType("Mj.View.Page5View").GetConstructor(System.Type.EmptyTypes).Invoke(null)), null); - IndexViewModel.IndexModel.Select1 = 1; IndexViewModel.IndexModel.Select2 = 0; IndexViewModel.IndexModel.Select3 = 0; - MessageBox.Show("模拟器损坏,请重新初始化\n\r\n\r或请前往设置中指定您自己[PPSSPP]的位置"); - } - #endregion - break; - } - try - { - System.Net.NetworkInformation.PingReply pingReply = Common.CommonSTA.ping2.Send(Common.CommonSTA._ip); - if (pingReply.Status == System.Net.NetworkInformation.IPStatus.Success) - { - Common.CommonSTA.PING = true; - } - } - catch (Exception) - { - MessageBox.Show("网络异常"); break; - } - - if (Common.CommonSTA.PING == true && Common.CommonSTA.IsOK == true) - { - #region 启用网络 - IndexViewModel.psp.IniWriteValue("Network", "EnableWlan", "True"); - #endregion - #region 保险 - IndexViewModel.psp.IniWriteValue("SystemParam", "PSPModel", "1"); - if (IndexViewModel.ini.IniReadValue("setgame", "游戏名") != "") - { - IndexViewModel.psp.IniWriteValue("SystemParam", "NickName", Common.CommonSTA.PSPName); - } - if (IndexViewModel.ini.IniReadValue("setgame", "金手指") != "1") - { - IndexViewModel.psp.IniWriteValue("General", "EnableCheats", "False"); - if (System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini")) - { - System.IO.File.Delete(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini"); - } - } - else - { - IndexViewModel.psp.IniWriteValue("General", "EnableCheats", "True"); - try - { - if (!System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini")) - { - System.IO.File.WriteAllBytes(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini", Properties.Resources.ULJS00329); - } - } - catch (Exception) - { - MessageBox.Show("操作被禁止"); - } - } - if (System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ULJS00329_ppsspp.ini")) - { - System.IO.File.Delete(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ULJS00329_ppsspp.ini"); - } - IndexViewModel.psp.IniWriteValue("Graphics", "FullScreen ", " True"); - IndexViewModel.psp.IniWriteValue("CPU", "IOTimingMethod ", " 0"); - IndexViewModel.psp.IniWriteValue("Network", "PortOffset ", " 5000"); - IndexViewModel.psp.IniWriteValue("Network", "proAdhocServer ", " " + Common.CommonSTA._ip); - int[] mac = new int[] { new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16) }; - IndexViewModel.psp.IniWriteValue("SystemParam", "MacAddress ", " " + mac[0] + mac[1] + ":" + mac[2] + mac[3] + ":" + mac[4] + mac[5] + ":" + mac[6] + mac[7] + ":" + mac[8] + mac[9] + ":" + mac[10] + mac[11]); - #endregion - #region 启动游戏 - try - { - System.Diagnostics.Process.Start(Common.CommonSTA.LujingPSP + @"PPSSPPWindows64.exe", Common.CommonSTA.LujingISO + @"UJS00329.iso"); - } - catch (Exception) - { - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.MainContent = (FrameworkElement)Type.GetType("Mj.View.Page5View").GetConstructor(System.Type.EmptyTypes).Invoke(null)), null); - IndexViewModel.IndexModel.Select1 = 1; IndexViewModel.IndexModel.Select2 = 0; IndexViewModel.IndexModel.Select3 = 0; - MessageBox.Show("模拟器损坏,请重新初始化\n\r\n\r或请前往设置中指定您自己[PPSSPP]的位置"); - } - #endregion - break; - } - System.Threading.Thread.Sleep(1000); - } - }).ContinueWith((t) => - { - IndexViewModel.IndexModel.PlayContent = "立即开始"; - Common.CommonSTA.PING = false; - Common.CommonSTA.IsPlayStart = false; - IndexViewModel.IndexModel.ICO = "../Assets/logo128.ico"; - return 1; - }); - #endregion - } - else - { - #region 无网模式 - #region 悬浮窗关闭 - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.XfcView.Hide()), null); - Common.CommonSTA.Noping3 = 1; - Common.CommonSTA.XDS = 0; - #endregion - #region 关闭网络 - IndexViewModel.psp.IniWriteValue("Network", "EnableWlan", "False"); - #endregion - #region 保险 - IndexViewModel.psp.IniWriteValue("SystemParam", "PSPModel", "1"); - if (IndexViewModel.ini.IniReadValue("setgame", "游戏名") != "") - { - IndexViewModel.psp.IniWriteValue("SystemParam", "NickName", Common.CommonSTA.PSPName); - } - if (IndexViewModel.ini.IniReadValue("setgame", "金手指") != "1") - { - IndexViewModel.psp.IniWriteValue("General", "EnableCheats", "False"); - if (System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini")) - { - System.IO.File.Delete(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini"); - } - } - else - { - IndexViewModel.psp.IniWriteValue("General", "EnableCheats", "True"); - try - { - if (!System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini")) - { - System.IO.File.WriteAllBytes(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini", Properties.Resources.ULJS00329); - } - } - catch (Exception) - { - MessageBox.Show("操作被禁止"); - } - } - if (System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ULJS00329_ppsspp.ini")) - { - System.IO.File.Delete(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ULJS00329_ppsspp.ini"); - } - IndexViewModel.psp.IniWriteValue("Graphics", "FullScreen ", " True"); - IndexViewModel.psp.IniWriteValue("CPU", "IOTimingMethod ", " 0"); - IndexViewModel.psp.IniWriteValue("Network", "PortOffset ", " 5000"); - IndexViewModel.psp.IniWriteValue("Network", "proAdhocServer ", " " + Common.CommonSTA._ip); - int[] mac = new int[] { new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16) }; - IndexViewModel.psp.IniWriteValue("SystemParam", "MacAddress ", " " + mac[0] + mac[1] + ":" + mac[2] + mac[3] + ":" + mac[4] + mac[5] + ":" + mac[6] + mac[7] + ":" + mac[8] + mac[9] + ":" + mac[10] + mac[11]); - #endregion - #region 启动游戏 - try - { - System.Diagnostics.Process.Start(Common.CommonSTA.LujingPSP + @"PPSSPPWindows64.exe", Common.CommonSTA.LujingISO + @"UJS00329.iso"); - } - catch (Exception) - { - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.MainContent = (FrameworkElement)Type.GetType("Mj.View.Page5View").GetConstructor(System.Type.EmptyTypes).Invoke(null)), null); - IndexViewModel.IndexModel.Select1 = 1; IndexViewModel.IndexModel.Select2 = 0; IndexViewModel.IndexModel.Select3 = 0; - MessageBox.Show("模拟器损坏,请重新初始化\n\r\n\r或请前往设置中指定您自己[PPSSPP]的位置"); - } - #endregion - #endregion - Common.CommonSTA.IsPlayStart = false; - IndexViewModel.IndexModel.ICO = "../Assets/logo128.ico"; - } - #endregion - - }).ContinueWith((t) => - { - return 1; - }); - - } - else - { - #region 正常启动 - if (IndexViewModel.ini.IniReadValue("setgame", "联机") != "0") - { - #region 悬浮窗总执行 - if (IndexViewModel.IndexModel.IPtupian == "../Assets/ping-close.png")//AAA窗口开启的话 - { - IndexViewModel.IndexModel.XfcView.Hide(); - Common.CommonSTA.Noping3 = 1; - Common.CommonSTA.XDS = 0; - //AAA窗口关闭 - } - else - { - IndexViewModel.IndexModel.XfcView.Owner = this; - try - { - IndexViewModel.IndexModel.XfcView.Show(); - Common.CommonSTA.XDS = 1; - Common.CommonSTA.Noping3 = 0; - } - catch (Exception) - { - MessageBox.Show("要复活小电视嘛 = = "); - IndexViewModel.IndexModel.XfcView = new View.XfcView(); - IndexViewModel.IndexModel.XfcView.Show(); - Common.CommonSTA.XDS = 1; - Common.CommonSTA.Noping3 = 0; - } - } - #endregion - #region 有网模式 - try - { - System.Diagnostics.Process.Start(Common.CommonSTA.LujingFCN);//FCN - } - catch (Exception) - { - IndexViewModel.IndexModel.MainContent = (FrameworkElement)Type.GetType("Mj.View.Page5View").GetConstructor(System.Type.EmptyTypes).Invoke(null); - IndexViewModel.IndexModel.Select1 = 1; IndexViewModel.IndexModel.Select2 = 0; IndexViewModel.IndexModel.Select3 = 0; - MessageBox.Show("联机模块损坏,请重新初始化\n\r\n\r或请前往设置中指定您自己[联机模块]的位置"); - IndexViewModel.IndexModel.ICO = "../Assets/logo128.ico"; - IndexViewModel.IndexModel.PlayContent = "立即开始"; - Common.CommonSTA.IsPlayStart = false; - return; - } - Common.CommonSTA.Danji = false; - Common.CommonSTA.IsOK = false; - if (IndexViewModel.ini.IniReadValue("setgame", "不提示") != "1") - { - #region 显示弹窗 - try - { - IndexViewModel.IndexModel.Tishi.Show(); - } - catch (Exception) - { - IndexViewModel.IndexModel.Tishi = new View.UMessageBox(); - IndexViewModel.IndexModel.Tishi.Show(); - } - #endregion - #region 倒计时 - System.Threading.Tasks.Task.Run(() => - { - for (int i = 5; i > 0; i--) - { - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.Tishi.ZDL = "知道了(" + i + ")"), null); - System.Threading.Thread.Sleep(1000); - } - #region 自动关闭弹窗 - try - { - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.Tishi.Hide()), null); - } - catch (Exception) - { - ; - } - #endregion - Common.CommonSTA.IsOK = true; - }).ContinueWith((t) => - { - - return 1; - }); - #endregion - } - System.Threading.Tasks.Task.Run(() => - { - IndexViewModel.IndexModel.PlayContent = "等待选服/取消"; - while (true) - { - if (Common.CommonSTA.Stop == true) - { - Common.CommonSTA.Noping2 = 1; - break; - } - if (Common.CommonSTA.Danji == true) - { - #region 悬浮窗关闭 - View.IndexView.mainThreadSynContext.Post(new System.Threading.SendOrPostCallback(s => - IndexViewModel.IndexModel.XfcView.Hide()), null); - Common.CommonSTA.Noping3 = 1; - Common.CommonSTA.XDS = 0; - #endregion - #region 关闭网络 - IndexViewModel.psp.IniWriteValue("Network", "EnableWlan", "False"); - #endregion - #region 保险 - IndexViewModel.psp.IniWriteValue("SystemParam", "PSPModel", "1"); - if (IndexViewModel.ini.IniReadValue("setgame", "游戏名") != "") - { - IndexViewModel.psp.IniWriteValue("SystemParam", "NickName", Common.CommonSTA.PSPName); - } - if (IndexViewModel.ini.IniReadValue("setgame", "金手指") != "1") - { - IndexViewModel.psp.IniWriteValue("General", "EnableCheats", "False"); - if (System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini")) - { - System.IO.File.Delete(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini"); - } - } - else - { - IndexViewModel.psp.IniWriteValue("General", "EnableCheats", "True"); - try - { - if (!System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini")) - { - System.IO.File.WriteAllBytes(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini", Properties.Resources.ULJS00329); - } - } - catch (Exception) - { - MessageBox.Show("操作被禁止"); - } - } - if (System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ULJS00329_ppsspp.ini")) - { - System.IO.File.Delete(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ULJS00329_ppsspp.ini"); - } - IndexViewModel.psp.IniWriteValue("Graphics", "FullScreen ", " True"); - IndexViewModel.psp.IniWriteValue("CPU", "IOTimingMethod ", " 0"); - IndexViewModel.psp.IniWriteValue("Network", "PortOffset ", " 5000"); - IndexViewModel.psp.IniWriteValue("Network", "proAdhocServer ", " " + Common.CommonSTA._ip); - int[] mac = new int[] { new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16) }; - IndexViewModel.psp.IniWriteValue("SystemParam", "MacAddress ", " " + mac[0] + mac[1] + ":" + mac[2] + mac[3] + ":" + mac[4] + mac[5] + ":" + mac[6] + mac[7] + ":" + mac[8] + mac[9] + ":" + mac[10] + mac[11]); - #endregion - #region 启动游戏 - try - { - System.Diagnostics.Process.Start(Common.CommonSTA.LujingPSP + @"PPSSPPWindows64.exe", Common.CommonSTA.LujingISO + @"UJS00329.iso"); - } - catch (Exception) - { - IndexViewModel.IndexModel.MainContent = (FrameworkElement)Type.GetType("Mj.View.Page5View").GetConstructor(System.Type.EmptyTypes).Invoke(null); - IndexViewModel.IndexModel.Select1 = 1; IndexViewModel.IndexModel.Select2 = 0; IndexViewModel.IndexModel.Select3 = 0; - MessageBox.Show("模拟器损坏,请重新初始化\n\r\n\r或请前往设置中指定您自己[PPSSPP]的位置"); - } - #endregion - break; - } - - try - { - System.Net.NetworkInformation.PingReply pingReply = Common.CommonSTA.ping2.Send(Common.CommonSTA._ip); - if (pingReply.Status == System.Net.NetworkInformation.IPStatus.Success) - { - Common.CommonSTA.PING = true; - } - } - catch (Exception) - { - MessageBox.Show("网络异常"); break; - } - - if (Common.CommonSTA.PING == true && Common.CommonSTA.IsOK == true) - { - #region 启用网络 - IndexViewModel.psp.IniWriteValue("Network", "EnableWlan", "True"); - #endregion - #region 保险 - IndexViewModel.psp.IniWriteValue("SystemParam", "PSPModel", "1"); - if (IndexViewModel.ini.IniReadValue("setgame", "游戏名") != "") - { - IndexViewModel.psp.IniWriteValue("SystemParam", "NickName", Common.CommonSTA.PSPName); - } - if (IndexViewModel.ini.IniReadValue("setgame", "金手指") != "1") - { - IndexViewModel.psp.IniWriteValue("General", "EnableCheats", "False"); - if (System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini")) - { - System.IO.File.Delete(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini"); - } - } - else - { - IndexViewModel.psp.IniWriteValue("General", "EnableCheats", "True"); - try - { - if (!System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini")) - { - System.IO.File.WriteAllBytes(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini", Properties.Resources.ULJS00329); - } - } - catch (Exception) - { - MessageBox.Show("操作被禁止"); - } - } - if (System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ULJS00329_ppsspp.ini")) - { - System.IO.File.Delete(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ULJS00329_ppsspp.ini"); - } - IndexViewModel.psp.IniWriteValue("Graphics", "FullScreen ", " True"); - IndexViewModel.psp.IniWriteValue("CPU", "IOTimingMethod ", " 0"); - IndexViewModel.psp.IniWriteValue("Network", "PortOffset ", " 5000"); - IndexViewModel.psp.IniWriteValue("Network", "proAdhocServer ", " " + Common.CommonSTA._ip); - int[] mac = new int[] { new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16) }; - IndexViewModel.psp.IniWriteValue("SystemParam", "MacAddress ", " " + mac[0] + mac[1] + ":" + mac[2] + mac[3] + ":" + mac[4] + mac[5] + ":" + mac[6] + mac[7] + ":" + mac[8] + mac[9] + ":" + mac[10] + mac[11]); - #endregion - #region 启动游戏 - try - { - System.Diagnostics.Process.Start(Common.CommonSTA.LujingPSP + @"PPSSPPWindows64.exe", Common.CommonSTA.LujingISO + @"UJS00329.iso"); - } - catch (Exception) - { - IndexViewModel.IndexModel.MainContent = (FrameworkElement)Type.GetType("Mj.View.Page5View").GetConstructor(System.Type.EmptyTypes).Invoke(null); - IndexViewModel.IndexModel.Select1 = 1; IndexViewModel.IndexModel.Select2 = 0; IndexViewModel.IndexModel.Select3 = 0; - MessageBox.Show("模拟器损坏,请重新初始化\n\r\n\r或请前往设置中指定您自己[PPSSPP]的位置"); - } - #endregion - break; - } - System.Threading.Thread.Sleep(1000); - } - }).ContinueWith((t) => - { - IndexViewModel.IndexModel.PlayContent = "立即开始"; - Common.CommonSTA.PING = false; - Common.CommonSTA.IsPlayStart = false; - IndexViewModel.IndexModel.ICO = "../Assets/logo128.ico"; - return 1; - }); - #endregion - } - else - { - #region 无网模式 - #region 悬浮窗关闭 - IndexViewModel.IndexModel.XfcView.Hide(); - Common.CommonSTA.Noping3 = 1; - Common.CommonSTA.XDS = 0; - #endregion - #region 关闭网络 - IndexViewModel.psp.IniWriteValue("Network", "EnableWlan", "False"); - #endregion - #region 保险 - IndexViewModel.psp.IniWriteValue("SystemParam", "PSPModel", "1"); - if (IndexViewModel.ini.IniReadValue("setgame", "游戏名") != "") - { - IndexViewModel.psp.IniWriteValue("SystemParam", "NickName", Common.CommonSTA.PSPName); - } - if (IndexViewModel.ini.IniReadValue("setgame", "金手指") != "1") - { - IndexViewModel.psp.IniWriteValue("General", "EnableCheats", "False"); - if (System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini")) - { - System.IO.File.Delete(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini"); - } - } - else - { - IndexViewModel.psp.IniWriteValue("General", "EnableCheats", "True"); - try - { - if (!System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini")) - { - System.IO.File.WriteAllBytes(Common.CommonSTA.LujingPSP + @"memstick\PSP\Cheats\ULJS00329.ini", Properties.Resources.ULJS00329); - } - } - catch (Exception) - { - MessageBox.Show("操作被禁止"); - } - } - if (System.IO.File.Exists(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ULJS00329_ppsspp.ini")) - { - System.IO.File.Delete(Common.CommonSTA.LujingPSP + @"memstick\PSP\SYSTEM\ULJS00329_ppsspp.ini"); - } - IndexViewModel.psp.IniWriteValue("Graphics", "FullScreen ", " True"); - IndexViewModel.psp.IniWriteValue("CPU", "IOTimingMethod ", " 0"); - IndexViewModel.psp.IniWriteValue("Network", "PortOffset ", " 5000"); - IndexViewModel.psp.IniWriteValue("Network", "proAdhocServer ", " " + Common.CommonSTA._ip); - int[] mac = new int[] { new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16), new Random().Next(0, 16) }; - IndexViewModel.psp.IniWriteValue("SystemParam", "MacAddress ", " " + mac[0] + mac[1] + ":" + mac[2] + mac[3] + ":" + mac[4] + mac[5] + ":" + mac[6] + mac[7] + ":" + mac[8] + mac[9] + ":" + mac[10] + mac[11]); - #endregion - #region 启动游戏 - try - { - System.Diagnostics.Process.Start(Common.CommonSTA.LujingPSP + @"PPSSPPWindows64.exe", Common.CommonSTA.LujingISO + @"UJS00329.iso"); - } - catch (Exception) - { - IndexViewModel.IndexModel.MainContent = (FrameworkElement)Type.GetType("Mj.View.Page5View").GetConstructor(System.Type.EmptyTypes).Invoke(null); - IndexViewModel.IndexModel.Select1 = 1; IndexViewModel.IndexModel.Select2 = 0; IndexViewModel.IndexModel.Select3 = 0; - MessageBox.Show("模拟器损坏,请重新初始化\n\r\n\r或请前往设置中指定您自己[PPSSPP]的位置"); - } - #endregion - #endregion - Common.CommonSTA.IsPlayStart = false; - IndexViewModel.IndexModel.ICO = "../Assets/logo128.ico"; - IndexViewModel.IndexModel.PlayContent = "立即开始"; - } - #endregion - } - } + IndexViewModel.PlayButtonCommand.Execute(this); + }), null);//主体 + return 1; + });//新线程 } #endregion diff --git a/View/Page4View.xaml.cs b/View/Page4View.xaml.cs index a2ad2f4..7c0ab5f 100644 --- a/View/Page4View.xaml.cs +++ b/View/Page4View.xaml.cs @@ -39,6 +39,7 @@ public Page4View() if (ini.IniReadValue("setgame", "UE5") == "1") { ue5play.IsChecked = true; + ue5play.IsEnabled = true; } if (ini.IniReadValue("window", "禁用托盘") == "0") { @@ -104,6 +105,7 @@ private void UE5Play(object sender, RoutedEventArgs e) else { ini.IniWriteValue("setgame", "UE5", "0"); + ue5play.IsEnabled = false; } } private void Tuopan(object sender, RoutedEventArgs e) @@ -198,12 +200,6 @@ private void Chushihua(object sender, RoutedEventArgs e) } } ini.IniWriteValue("window", "Runed", "0"); - ini.IniWriteValue("window", "ManySame", "0"); - ini.IniWriteValue("window", "Yuanjiao", "0"); - ini.IniWriteValue("window", "主题", "幻影白"); - ini.IniWriteValue("window", "DPI", "0"); - ini.IniWriteValue("window", "禁用托盘", "0"); - ini.IniWriteValue("xfc", "big", "0.2"); ini.IniWriteValue("setgame", "FCN路径", Environment.CurrentDirectory + @"\FCN.exe"); ini.IniWriteValue("setgame", "PPSSPP路径", Environment.CurrentDirectory + @"\"); ini.IniWriteValue("setgame", "ISO路径", Environment.CurrentDirectory + @"\memstick\PSP\GAME\"); diff --git a/View/Page6View.xaml b/View/Page6View.xaml index d81cf1d..90d4f6b 100644 --- a/View/Page6View.xaml +++ b/View/Page6View.xaml @@ -198,7 +198,7 @@ - + diff --git a/View/Page6View.xaml.cs b/View/Page6View.xaml.cs index 267294d..8f94f4d 100644 --- a/View/Page6View.xaml.cs +++ b/View/Page6View.xaml.cs @@ -22,7 +22,7 @@ public Page6View() { InitializeComponent(); #region 配置文件setgame - if (ViewModel.IndexViewModel.ini.IniReadValue("window", "主题") == "幻影白") + if ((ViewModel.IndexViewModel.ini.IniReadValue("window", "主题") == "幻影白") || (ViewModel.IndexViewModel.ini.IniReadValue("window", "主题") == "")) { zhuti1.IsChecked = true; } diff --git a/View/XfcView.xaml.cs b/View/XfcView.xaml.cs index 15ef763..8bbb60b 100644 --- a/View/XfcView.xaml.cs +++ b/View/XfcView.xaml.cs @@ -22,64 +22,43 @@ public partial class XfcView : Window { private Common.IniBase ini = new Common.IniBase(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\IndexOfMagic\ppsspp\set");//启用 ini public ViewModel.XfcViewModel XfcViewModel = new ViewModel.XfcViewModel(); - #region DPI - [System.Runtime.InteropServices.DllImport("gdi32.dll", EntryPoint = "GetDeviceCaps", SetLastError = true)] - public static extern int GetDeviceCaps(IntPtr hdc, int nIndex); - enum DeviceCap - { - VERTRES = 10, - PHYSICALWIDTH = 110, - SCALINGFACTORX = 114, - DESKTOPVERTRES = 117, - } - public static double GetScreenScalingFactor() - { - var g = System.Drawing.Graphics.FromHwnd(IntPtr.Zero); - IntPtr desktop = g.GetHdc(); - var physicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES); - return physicalScreenHeight; - } - #endregion + public XfcView() { InitializeComponent(); this.DataContext = XfcViewModel; - //重制悬浮窗位置 - //ini.IniWriteValue("xfc", "自定义位置", "0"); + #region 大小 if (ini.IniReadValue("xfc", "自定义大小") == "1") { XfcViewModel.Zidingyibig = double.Parse(ini.IniReadValue("xfc", "big")); - #region DPI禁用 - if (ini.IniReadValue("window", "DPI") != "1") - { - xfcwindow.MaxHeight = 10000 * Common.CommonSTA.dpi; - xfcwindow.Height = (SystemParameters.PrimaryScreenHeight * XfcViewModel.Zidingyibig * Common.CommonSTA.dpi * Common.CommonSTA.dpi) + 5; - } - else - { - xfcwindow.Height = (SystemParameters.PrimaryScreenHeight * XfcViewModel.Zidingyibig) + 5; - } - #endregion - xfcwindow.Width = xfcwindow.Height * 0.904; - } - else - { - xfcwindow.Height = (SystemParameters.PrimaryScreenHeight * 0.2 * CommonSTA.dpi) + 5; + //xfcwindow.Height = (SystemParameters.PrimaryScreenHeight * Common.CommonSTA.dpi * XfcViewModel.Zidingyibig) + 5; + + //#region DPI禁用 + //if (ini.IniReadValue("window", "DPI") != "1") + //{ + // xfcwindow.MaxHeight = 10000 * Common.CommonSTA.dpi; + // xfcwindow.Height = (SystemParameters.PrimaryScreenHeight * XfcViewModel.Zidingyibig * Common.CommonSTA.dpi * Common.CommonSTA.dpi) + 5; + //} + //else + //{ + // xfcwindow.Height = (SystemParameters.PrimaryScreenHeight * XfcViewModel.Zidingyibig) + 5; + //} + //#endregion } - xfcwindow.Width = xfcwindow.Height * 0.904; + #endregion #region 位置 if (ini.IniReadValue("xfc", "自定义位置") == "1") { - xfcwindow.Top = SystemParameters.PrimaryScreenHeight * double.Parse(ini.IniReadValue("xfc", "top")); - xfcwindow.Left = SystemParameters.PrimaryScreenWidth * double.Parse(ini.IniReadValue("xfc", "left")); + xfcwindow.Top = SystemParameters.PrimaryScreenHeight / 2 + double.Parse(ini.IniReadValue("xfc", "top")); + xfcwindow.Left = SystemParameters.PrimaryScreenWidth / 2 + double.Parse(ini.IniReadValue("xfc", "left")); } else { - xfcwindow.Top = SystemParameters.PrimaryScreenHeight * 0.12; - xfcwindow.Left = SystemParameters.PrimaryScreenWidth * 0.7; + xfcwindow.Top = SystemParameters.PrimaryScreenHeight / 2 - 410; + xfcwindow.Left = SystemParameters.PrimaryScreenWidth / 2 + 383; } #endregion } @@ -93,8 +72,8 @@ private void XfcMove(object sender, MouseButtonEventArgs e) if (e.LeftButton == MouseButtonState.Released) { ini.IniWriteValue("xfc", "自定义位置", "1"); - ini.IniWriteValue("xfc", "top", Math.Round(xfcwindow.Top / SystemParameters.PrimaryScreenHeight, 2).ToString()); - ini.IniWriteValue("xfc", "left", Math.Round(xfcwindow.Left / SystemParameters.PrimaryScreenWidth, 2).ToString()); + ini.IniWriteValue("xfc", "top", Math.Round((xfcwindow.Top - SystemParameters.PrimaryScreenHeight / 2) , 4).ToString()); + ini.IniWriteValue("xfc", "left", Math.Round((xfcwindow.Left - SystemParameters.PrimaryScreenWidth / 2), 4).ToString()); } } #endregion @@ -132,7 +111,7 @@ private void Bs(object sender, RoutedEventArgs e) } try { - System.Net.NetworkInformation.PingReply pingReply = CommonSTA.ping2.Send(CommonSTA._ip); + System.Net.NetworkInformation.PingReply pingReply = CommonSTA.ping3.Send(CommonSTA._ip); if (pingReply.Status == System.Net.NetworkInformation.IPStatus.Success) { if (pingReply.RoundtripTime < 45) @@ -268,14 +247,14 @@ private void ZidingyiBig(object sender, RoutedEventArgs e) private void Chongzhibig(object sender, RoutedEventArgs e) { XfcViewModel.Zidingyibig = 0.2; - xfcwindow.Height = (System.Windows.SystemParameters.PrimaryScreenHeight * 0.2) + 5; + xfcwindow.Height = (System.Windows.SystemParameters.PrimaryScreenHeight * Common.CommonSTA.dpi * 0.2) + 5; xfcwindow.Width = xfcwindow.Height * 0.904; } #endregion #region 自定义大小应用 private void Yingyongbig(object sender, RoutedPropertyChangedEventArgs e) { - xfcwindow.Height = (System.Windows.SystemParameters.PrimaryScreenHeight * XfcViewModel.Zidingyibig) + 5; + xfcwindow.Height = (System.Windows.SystemParameters.PrimaryScreenHeight * Common.CommonSTA.dpi * XfcViewModel.Zidingyibig) + 5; xfcwindow.Width = xfcwindow.Height * 0.904; if (XfcViewModel.Zidingyibig != 0.2) { diff --git a/ViewModel/IndexViewModel.cs b/ViewModel/IndexViewModel.cs index 26c5009..9ba47e5 100644 --- a/ViewModel/IndexViewModel.cs +++ b/ViewModel/IndexViewModel.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Drawing; using System.Reflection; using System.Text; using System.Threading; @@ -17,7 +18,24 @@ public class IndexViewModel public static IniBase ini = new IniBase(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\IndexOfMagic\ppsspp\set");//启用 ini public IniBase ini5 = new IniBase(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\IndexOfMagic\unreal5\usebeta");//启用 ini public IniBase psp = new IniBase(ini.IniReadValue("setgame", "PPSSPP路径") + @"memstick\PSP\SYSTEM\ppsspp.ini");//启用 ini - + #region DPI所需接口 + [System.Runtime.InteropServices.DllImport("gdi32.dll", EntryPoint = "GetDeviceCaps", SetLastError = true)] + public static extern int GetDeviceCaps(IntPtr hdc, int nIndex); + enum DeviceCap + { + VERTRES = 10, + PHYSICALWIDTH = 110, + SCALINGFACTORX = 114, + DESKTOPVERTRES = 117, + } + public static double GetScreenScalingFactor() + { + var g = Graphics.FromHwnd(IntPtr.Zero); + IntPtr desktop = g.GetHdc(); + var physicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES); + return physicalScreenHeight; + } + #endregion //[System.Runtime.InteropServices.DllImport("user32.dll")] public static extern int MessageBoxTimeoutA(IntPtr hWnd, string msg, string Caps, int type, int Id, int time); //引用DLL @@ -30,6 +48,7 @@ public class IndexViewModel public CommandBase CloseWindowCommand { get; set; } public CommandBase PINGButtonCommand { get; set; } public CommandBase XFButtonCommand { get; set; } + public CommandBase XFLocationCommand { get; set; } public CommandBase NavChangedCommand { get; set; } public CommandBase SetGridChangeCommand { get; set; } public CommandBase PlayButtonCommand { get; set; } @@ -50,6 +69,9 @@ public class IndexViewModel //———————————————————————————————————————————————————————————————— public IndexViewModel() { + #region 获取DPI(其他窗口也用到 + Common.CommonSTA.dpi = double.Parse(GetScreenScalingFactor().ToString(), 0) / double.Parse(SystemParameters.PrimaryScreenHeight.ToString(), 0); + #endregion IndexModel = new IndexModel(); //———————————————————————————————————————————————————————————— //初始化封装 @@ -75,9 +97,9 @@ public IndexViewModel() IndexModel.Yuanjiao4 = "10,0,0,0"; }//圆角 #region 主题 - if (ini.IniReadValue("window", "主题") == "幻影白") + if ((ViewModel.IndexViewModel.ini.IniReadValue("window", "主题") == "幻影白") || (ViewModel.IndexViewModel.ini.IniReadValue("window", "主题") == "")) { - ; + //默认主题; } else if (ini.IniReadValue("window", "主题") == "深空灰") { @@ -384,6 +406,20 @@ public IndexViewModel() }); #endregion // + #region 悬浮窗位置重置XFLocationCommand + this.XFLocationCommand = new CommandBase(); + this.XFLocationCommand.DoExecute = new Action((o) => + { + ini.IniWriteValue("xfc", "自定义位置", "0"); + IndexModel.XfcView.Top = SystemParameters.PrimaryScreenHeight / 2 - 410; + IndexModel.XfcView.Left = SystemParameters.PrimaryScreenWidth / 2 + 383; + }); + this.XFLocationCommand.DoCanExecute = new Func((o) => + { + return true; + }); + #endregion + // #region 改变主页NavChangedCommand this.NavChangedCommand = new CommandBase(); this.NavChangedCommand.DoExecute = new Action((o) => @@ -556,7 +592,8 @@ public IndexViewModel() try { View.IndexView.mainThreadSynContext.Post(new SendOrPostCallback(s => - IndexModel.XfcView.Show()), null); + IndexModel.XfcView.Show() + ), null); CommonSTA.XDS = 1; CommonSTA.Noping3 = 0; } @@ -783,7 +820,7 @@ public IndexViewModel() #endregion break; } - System.Threading.Thread.Sleep(1000); + System.Threading.Thread.Sleep(500); } }).ContinueWith((t) => {