Skip to content

Commit a4afdd9

Browse files
committed
新特性和问题修复
1.增加无线访问记录历史IP 2.修复一些bug
1 parent 27d3aaf commit a4afdd9

16 files changed

+435
-348
lines changed

FreeControl.sln

-6
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,13 @@ EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
11-
Debug|x86 = Debug|x86
1211
Release|Any CPU = Release|Any CPU
13-
Release|x86 = Release|x86
1412
EndGlobalSection
1513
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1614
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1715
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
18-
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Debug|x86.ActiveCfg = Debug|x86
19-
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Debug|x86.Build.0 = Debug|x86
2016
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
2117
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Release|Any CPU.Build.0 = Release|Any CPU
22-
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Release|x86.ActiveCfg = Release|x86
23-
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Release|x86.Build.0 = Release|x86
2418
EndGlobalSection
2519
GlobalSection(SolutionProperties) = preSolution
2620
HideSolutionNode = FALSE

FreeControl/Controller.Designer.cs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeControl/Controller.cs

+7-95
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,31 @@
11
using FreeControl.Utils;
22
using Sunny.UI;
33
using System;
4-
using System.Diagnostics;
54
using System.Drawing;
6-
using System.Runtime.InteropServices;
7-
using System.Timers;
85
using System.Windows.Forms;
96

107
namespace FreeControl
118
{
129
public partial class Controller : UIForm
1310
{
14-
[DllImport("user32.dll")]
15-
public static extern bool GetWindowRect(IntPtr hWnd, out Rect lpRect);
16-
17-
[StructLayout(LayoutKind.Sequential)]
18-
public struct Rect
19-
{
20-
public int Left;
21-
public int Top;
22-
public int Right;
23-
public int Bottom;
24-
}
25-
26-
/// <summary>
27-
/// 监听scrcpy窗体移动后的坐标
28-
/// </summary>
29-
private readonly System.Timers.Timer timer;
30-
/// <summary>
31-
/// scrcpy句柄
32-
/// </summary>
33-
private IntPtr scrcpyWindow = IntPtr.Zero;
34-
/// <summary>
35-
/// 进程名称
36-
/// </summary>
37-
private const string scrcpyWindowName = "scrcpy";
38-
/// <summary>
39-
/// 上一个有效的scrcpy坐标
40-
/// </summary>
41-
private Rect lastRect = new Rect();
42-
4311
public Controller()
4412
{
4513
InitializeComponent();
4614
InitButton();
4715
InitFormSizeAndLocation();
48-
49-
timer = new System.Timers.Timer
50-
{
51-
Interval = 15
52-
};
53-
timer.Elapsed += OnTimedEvent;
54-
timer.Enabled = true;
55-
Disposed += (s, e) =>
56-
{
57-
Main._Setting.ScrcpyPointX = lastRect.Left;
58-
Main._Setting.ScrcpyPointY = lastRect.Top;
59-
};
6016
}
6117

62-
public void StopTimer()
63-
{
64-
timer.Stop();
65-
timer.Enabled = false;
66-
}
67-
68-
private void OnTimedEvent(Object source, ElapsedEventArgs e)
18+
/// <summary>
19+
/// 更新控制器位置
20+
/// </summary>
21+
public void UpdateLocation()
6922
{
7023
Action action = () =>
7124
{
72-
if (scrcpyWindow == IntPtr.Zero)
73-
{
74-
Process[] processes = Process.GetProcessesByName(scrcpyWindowName);
75-
scrcpyWindow = processes[0].MainWindowHandle;
76-
}
77-
GetWindowRect(scrcpyWindow, out Rect rect);
78-
if (rect.Top == lastRect.Top && rect.Left == lastRect.Left)
79-
return;
80-
if (rect.Left + rect.Top > 0)
81-
{
82-
rect.Left += 8;
83-
rect.Top += 31;
84-
lastRect = rect;
85-
Location = new Point(rect.Left - 57, rect.Top);
86-
}
25+
// 减去控制器自身默认宽度
26+
Location = new Point(Main._Setting.ScrcpyPointX - 57, Main._Setting.ScrcpyPointY);
8727
};
88-
if (InvokeRequired)
89-
Invoke(action);
28+
Invoke(action);
9029
}
9130

9231
/// <summary>
@@ -108,26 +47,18 @@ void InitFormSizeAndLocation()
10847
}
10948
if (Main._Setting.ScrcpyPointX + Main._Setting.ScrcpyPointY > 0)
11049
{
111-
// Location = new Point(Main._Setting.ControllerStartPointX, Main._Setting.ControllerStartPointY);
11250
StartPosition = FormStartPosition.Manual;
11351
Location = new Point(Main._Setting.ScrcpyPointX - 57, Main._Setting.ScrcpyPointY);
11452
}
11553
else
11654
{
11755
StartPosition = FormStartPosition.CenterScreen;
11856
}
119-
// LocationChanged += (sender, e) =>
120-
// {
121-
// Main._Setting.ControllerStartPointX = Location.X;
122-
// Main._Setting.ControllerStartPointY = Location.Y;
123-
// };
12457
SizeChanged += (sender, e) =>
12558
{
12659
Main._Setting.ControllerStartWidth = Width;
12760
Main._Setting.ControllerStartHeight = Height;
12861
};
129-
// MouseDown += (s, e) => DragWindow();
130-
// flowPanel.FlowLayoutPanel.MouseDown += (s, e) => DragWindow();
13162
}
13263

13364
/// <summary>
@@ -159,24 +90,5 @@ void InitButton()
15990
}
16091
}
16192
}
162-
163-
#region 拖动窗口
164-
[DllImport("user32.dll")]//拖动无窗体的控件
165-
public static extern bool ReleaseCapture();
166-
[DllImport("user32.dll")]
167-
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
168-
public const int WM_SYSCOMMAND = 0x0112;
169-
public const int SC_MOVE = 0xF010;
170-
public const int HTCAPTION = 0x0002;
171-
172-
/// <summary>
173-
/// 拖动窗体
174-
/// </summary>
175-
public void DragWindow()
176-
{
177-
ReleaseCapture();
178-
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
179-
}
180-
#endregion
18193
}
18294
}

FreeControl/FreeControl.csproj

+2-27
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,6 @@
6969
<PropertyGroup>
7070
<ApplicationManifest>app.manifest</ApplicationManifest>
7171
</PropertyGroup>
72-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
73-
<DebugSymbols>true</DebugSymbols>
74-
<OutputPath>bin\x86\Debug\</OutputPath>
75-
<DefineConstants>DEBUG;TRACE</DefineConstants>
76-
<DebugType>full</DebugType>
77-
<PlatformTarget>x86</PlatformTarget>
78-
<LangVersion>7.3</LangVersion>
79-
<ErrorReport>prompt</ErrorReport>
80-
</PropertyGroup>
81-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
82-
<OutputPath>bin\x86\Release\</OutputPath>
83-
<DefineConstants>TRACE</DefineConstants>
84-
<Optimize>true</Optimize>
85-
<DebugType>pdbonly</DebugType>
86-
<PlatformTarget>x86</PlatformTarget>
87-
<LangVersion>7.3</LangVersion>
88-
<ErrorReport>prompt</ErrorReport>
89-
</PropertyGroup>
9072
<ItemGroup>
9173
<Reference Include="SunnyUI, Version=2.2.6.0, Culture=neutral, processorArchitecture=MSIL">
9274
<SpecificVersion>False</SpecificVersion>
@@ -142,9 +124,11 @@
142124
<Compile Include="Properties\AssemblyInfo.cs" />
143125
<Compile Include="Setting.cs" />
144126
<Compile Include="Utils\ADB.cs" />
127+
<Compile Include="Utils\Extend.cs" />
145128
<Compile Include="Utils\FileHelper.cs" />
146129
<Compile Include="Utils\JsonHelper.cs" />
147130
<Compile Include="Utils\Logger.cs" />
131+
<Compile Include="Utils\MoveListener.cs" />
148132
<Compile Include="Utils\SysEnvironment.cs" />
149133
<Compile Include="Utils\ZipHelper.cs" />
150134
<EmbeddedResource Include="Controller.resx">
@@ -165,15 +149,6 @@
165149
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
166150
</EmbeddedResource>
167151
<None Include="app.manifest" />
168-
<None Include="Properties\Settings.settings">
169-
<Generator>SettingsSingleFileGenerator</Generator>
170-
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
171-
</None>
172-
<Compile Include="Properties\Settings.Designer.cs">
173-
<AutoGen>True</AutoGen>
174-
<DependentUpon>Settings.settings</DependentUpon>
175-
<DesignTimeSharedInput>True</DesignTimeSharedInput>
176-
</Compile>
177152
<EmbeddedResource Include="SetProt.bat" />
178153
</ItemGroup>
179154
<ItemGroup>

0 commit comments

Comments
 (0)