Skip to content
This repository has been archived by the owner on Jul 13, 2024. It is now read-only.

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jul 17, 2022
1 parent 74589cf commit 72fa635
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 862 deletions.
3 changes: 2 additions & 1 deletion Common/CommonSTA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}

}
3 changes: 2 additions & 1 deletion View/IndexView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,8 @@
<hc:NotifyIcon.ContextMenu>
<ContextMenu>
<MenuItem Command="{Binding XFButtonCommand}" Header="显示/启用/禁用悬浮窗"/>
<MenuItem Command="{Binding PlayButtonCommand}" CommandParameter="{Binding ElementName=window}" Header="启动游戏"/>
<MenuItem Command="{Binding XFLocationCommand}" Header="悬浮窗位置重置"/>
<MenuItem Command="{Binding PlayButtonCommand}" CommandParameter="{Binding ElementName=window}" Header="启动游戏/停止选服"/>
<MenuItem Click="Jinyongtuopan" Header="禁用托盘"/>
<Separator></Separator>
<MenuItem Header="退出" Click="APPClose"/>
Expand Down
830 changes: 29 additions & 801 deletions View/IndexView.xaml.cs

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions View/Page4View.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public Page4View()
if (ini.IniReadValue("setgame", "UE5") == "1")
{
ue5play.IsChecked = true;
ue5play.IsEnabled = true;
}
if (ini.IniReadValue("window", "禁用托盘") == "0")
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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\");
Expand Down
2 changes: 1 addition & 1 deletion View/Page6View.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<CheckBox Grid.Column="1" Template="{StaticResource CheckButton}" Name="yuanjiao" FontSize="16" Foreground="#008dcc" Content="win11风格 " HorizontalAlignment="Left" VerticalAlignment="Center" Click="Yuanjiao"/>
<CheckBox Grid.Column="2" Template="{StaticResource CheckButton}" Name="dpi" FontSize="16" Foreground="#008dcc" Content="DPI " HorizontalAlignment="Left" VerticalAlignment="Center" Click="DPI"/>
<CheckBox Grid.Column="2" Template="{StaticResource CheckButton}" Name="dpi" FontSize="16" Foreground="#008dcc" Content="DPI " HorizontalAlignment="Left" VerticalAlignment="Center" Click="DPI" IsEnabled="False"/>
<!--<CheckBox Grid.Column="2" Template="{StaticResource CheckButton}" Margin="2,0,0,0" IsEnabled="False" Name="jinshouzhi" FontSize="16" Foreground="#008dcc" Content="金手指" HorizontalAlignment="Left" VerticalAlignment="Center" Click="Jinshouzhi"/>-->

</Grid>
Expand Down
2 changes: 1 addition & 1 deletion View/Page6View.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
71 changes: 25 additions & 46 deletions View/XfcView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<double> 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)
{
Expand Down
47 changes: 42 additions & 5 deletions ViewModel/IndexViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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; }
Expand All @@ -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();
//————————————————————————————————————————————————————————————
//初始化封装
Expand All @@ -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", "主题") == "深空灰")
{
Expand Down Expand Up @@ -384,6 +406,20 @@ public IndexViewModel()
});
#endregion
//
#region 悬浮窗位置重置XFLocationCommand
this.XFLocationCommand = new CommandBase();
this.XFLocationCommand.DoExecute = new Action<object>((o) =>
{
ini.IniWriteValue("xfc", "自定义位置", "0");
IndexModel.XfcView.Top = SystemParameters.PrimaryScreenHeight / 2 - 410;
IndexModel.XfcView.Left = SystemParameters.PrimaryScreenWidth / 2 + 383;
});
this.XFLocationCommand.DoCanExecute = new Func<object, bool>((o) =>
{
return true;
});
#endregion
//
#region 改变主页NavChangedCommand
this.NavChangedCommand = new CommandBase();
this.NavChangedCommand.DoExecute = new Action<object>((o) =>
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -783,7 +820,7 @@ public IndexViewModel()
#endregion
break;
}
System.Threading.Thread.Sleep(1000);
System.Threading.Thread.Sleep(500);
}
}).ContinueWith<int>((t) =>
{
Expand Down

0 comments on commit 72fa635

Please sign in to comment.