Skip to content

Commit

Permalink
新特性和问题修复
Browse files Browse the repository at this point in the history
1.增加无线访问记录历史IP
2.修复一些bug
  • Loading branch information
pdone committed Oct 13, 2023
1 parent 27d3aaf commit a4afdd9
Show file tree
Hide file tree
Showing 16 changed files with 435 additions and 348 deletions.
6 changes: 0 additions & 6 deletions FreeControl.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Debug|x86.ActiveCfg = Debug|x86
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Debug|x86.Build.0 = Debug|x86
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Release|Any CPU.Build.0 = Release|Any CPU
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Release|x86.ActiveCfg = Release|x86
{EF7540E1-F2E7-4682-80AB-92354C55A4C6}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions FreeControl/Controller.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 7 additions & 95 deletions FreeControl/Controller.cs
Original file line number Diff line number Diff line change
@@ -1,92 +1,31 @@
using FreeControl.Utils;
using Sunny.UI;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Timers;
using System.Windows.Forms;

namespace FreeControl
{
public partial class Controller : UIForm
{
[DllImport("user32.dll")]
public static extern bool GetWindowRect(IntPtr hWnd, out Rect lpRect);

[StructLayout(LayoutKind.Sequential)]
public struct Rect
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}

/// <summary>
/// 监听scrcpy窗体移动后的坐标
/// </summary>
private readonly System.Timers.Timer timer;
/// <summary>
/// scrcpy句柄
/// </summary>
private IntPtr scrcpyWindow = IntPtr.Zero;
/// <summary>
/// 进程名称
/// </summary>
private const string scrcpyWindowName = "scrcpy";
/// <summary>
/// 上一个有效的scrcpy坐标
/// </summary>
private Rect lastRect = new Rect();

public Controller()
{
InitializeComponent();
InitButton();
InitFormSizeAndLocation();

timer = new System.Timers.Timer
{
Interval = 15
};
timer.Elapsed += OnTimedEvent;
timer.Enabled = true;
Disposed += (s, e) =>
{
Main._Setting.ScrcpyPointX = lastRect.Left;
Main._Setting.ScrcpyPointY = lastRect.Top;
};
}

public void StopTimer()
{
timer.Stop();
timer.Enabled = false;
}

private void OnTimedEvent(Object source, ElapsedEventArgs e)
/// <summary>
/// 更新控制器位置
/// </summary>
public void UpdateLocation()
{
Action action = () =>
{
if (scrcpyWindow == IntPtr.Zero)
{
Process[] processes = Process.GetProcessesByName(scrcpyWindowName);
scrcpyWindow = processes[0].MainWindowHandle;
}
GetWindowRect(scrcpyWindow, out Rect rect);
if (rect.Top == lastRect.Top && rect.Left == lastRect.Left)
return;
if (rect.Left + rect.Top > 0)
{
rect.Left += 8;
rect.Top += 31;
lastRect = rect;
Location = new Point(rect.Left - 57, rect.Top);
}
// 减去控制器自身默认宽度
Location = new Point(Main._Setting.ScrcpyPointX - 57, Main._Setting.ScrcpyPointY);
};
if (InvokeRequired)
Invoke(action);
Invoke(action);
}

/// <summary>
Expand All @@ -108,26 +47,18 @@ void InitFormSizeAndLocation()
}
if (Main._Setting.ScrcpyPointX + Main._Setting.ScrcpyPointY > 0)
{
// Location = new Point(Main._Setting.ControllerStartPointX, Main._Setting.ControllerStartPointY);
StartPosition = FormStartPosition.Manual;
Location = new Point(Main._Setting.ScrcpyPointX - 57, Main._Setting.ScrcpyPointY);
}
else
{
StartPosition = FormStartPosition.CenterScreen;
}
// LocationChanged += (sender, e) =>
// {
// Main._Setting.ControllerStartPointX = Location.X;
// Main._Setting.ControllerStartPointY = Location.Y;
// };
SizeChanged += (sender, e) =>
{
Main._Setting.ControllerStartWidth = Width;
Main._Setting.ControllerStartHeight = Height;
};
// MouseDown += (s, e) => DragWindow();
// flowPanel.FlowLayoutPanel.MouseDown += (s, e) => DragWindow();
}

/// <summary>
Expand Down Expand Up @@ -159,24 +90,5 @@ void InitButton()
}
}
}

#region 拖动窗口
[DllImport("user32.dll")]//拖动无窗体的控件
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;

/// <summary>
/// 拖动窗体
/// </summary>
public void DragWindow()
{
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
#endregion
}
}
29 changes: 2 additions & 27 deletions FreeControl/FreeControl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,6 @@
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="SunnyUI, Version=2.2.6.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -142,9 +124,11 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Setting.cs" />
<Compile Include="Utils\ADB.cs" />
<Compile Include="Utils\Extend.cs" />
<Compile Include="Utils\FileHelper.cs" />
<Compile Include="Utils\JsonHelper.cs" />
<Compile Include="Utils\Logger.cs" />
<Compile Include="Utils\MoveListener.cs" />
<Compile Include="Utils\SysEnvironment.cs" />
<Compile Include="Utils\ZipHelper.cs" />
<EmbeddedResource Include="Controller.resx">
Expand All @@ -165,15 +149,6 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="SetProt.bat" />
</ItemGroup>
<ItemGroup>
Expand Down
Loading

0 comments on commit a4afdd9

Please sign in to comment.