Skip to content

Commit

Permalink
更新scrcpy版本
Browse files Browse the repository at this point in the history
增加自定义scrcpy参数
  • Loading branch information
pdone committed Nov 26, 2024
1 parent df82252 commit b01c0ad
Show file tree
Hide file tree
Showing 22 changed files with 112 additions and 498 deletions.
6 changes: 3 additions & 3 deletions FreeControl/Controller.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using FreeControl.Utils;
using Sunny.UI;
using System;
using System;
using System.Drawing;
using System.Windows.Forms;
using FreeControl.Utils;
using Sunny.UI;

namespace FreeControl
{
Expand Down
3 changes: 1 addition & 2 deletions FreeControl/FreeControl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@
<Compile Include="Utils\Logger.cs" />
<Compile Include="Utils\MoveListener.cs" />
<Compile Include="Utils\SysEnvironment.cs" />
<Compile Include="Utils\ZipHelper.cs" />
<EmbeddedResource Include="Controller.resx">
<DependentUpon>Controller.cs</DependentUpon>
</EmbeddedResource>
Expand All @@ -283,7 +282,7 @@
</EmbeddedResource>
<EmbeddedResource Include="SetProt.bat" />
<None Include="packages.config" />
<None Include="Resources\scrcpy-win64-v2.4.zip" />
<None Include="Resources\scrcpy-win32-v3.0.zip" />
<None Include="Update.en.md" />
<None Include="Update.md" />
</ItemGroup>
Expand Down
25 changes: 25 additions & 0 deletions FreeControl/FreeControl.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeControl", "FreeControl.csproj", "{A51E6D71-ECD5-4EFA-AEF5-DEB23B09F28C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A51E6D71-ECD5-4EFA-AEF5-DEB23B09F28C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A51E6D71-ECD5-4EFA-AEF5-DEB23B09F28C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A51E6D71-ECD5-4EFA-AEF5-DEB23B09F28C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A51E6D71-ECD5-4EFA-AEF5-DEB23B09F28C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B0513970-9479-420D-9EED-BD31B7489F5E}
EndGlobalSection
EndGlobal
51 changes: 22 additions & 29 deletions FreeControl/Main.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using FreeControl.Utils;
using Sunny.UI;
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using FreeControl.Utils;
using Sunny.UI;

namespace FreeControl
{
Expand All @@ -25,11 +24,11 @@ public partial class Main : UIForm
/// <summary>
/// scrcpy版本
/// </summary>
public static readonly string ScrcpyVersion = "scrcpy-win64-v2.4";
public static readonly string ScrcpyVersion = "scrcpy-win32-v3.0";
/// <summary>
/// scrcpy路径
/// </summary>
public static readonly string ScrcpyPath = Path.Combine(UserDataPath, ScrcpyVersion + "\\");
public static string ScrcpyPath = Path.Combine(UserDataPath, ScrcpyVersion + "\\");
/// <summary>
/// 用户桌面路径
/// </summary>
Expand Down Expand Up @@ -68,19 +67,19 @@ public class Info
/// <summary>
/// 程序名称 不带空格
/// </summary>
public static readonly string Name = "FreeControl";
public const string Name = "FreeControl";
/// <summary>
/// 程序名称 带空格
/// </summary>
public static readonly string Name2 = "Free Control";
public const string Name2 = "Free Control";
/// <summary>
/// scrcpy标题
/// </summary>
public static readonly string ScrcpyTitle = "FreeControlScrcpy";
public const string ScrcpyTitle = "FreeControlScrcpy";
/// <summary>
/// 程序名称 带版本号
/// </summary>
public static string NameVersion { get; set; }
public static readonly string NameVersion = $"{Name} v{Program.Version}";
}

/// <summary>
Expand Down Expand Up @@ -186,22 +185,21 @@ public static void SetUserData(Setting userData)
/// </summary>
public void InitPdone()
{
// 获取程序集信息
Assembly asm = Assembly.GetExecutingAssembly();
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(asm.Location);
if (Directory.Exists(_Setting.CustomScrcpyPath))
{
ScrcpyPath = _Setting.CustomScrcpyPath;
if (!ScrcpyPath.EndsWith("/") && !ScrcpyPath.EndsWith("\\"))
{
ScrcpyPath += "/";
}
}
// adb路径
ADB.ADBPath = $@"{ScrcpyPath}";
// 增加adb执行文件系统变量
ADB.AddEnvironmentPath(ScrcpyPath);
// 是否重新加载资源包
bool reload = false;
if (_Setting.Version != fvi.ProductVersion)
{
reload = true;
_Setting.Version = fvi.ProductVersion;
}
_Setting.Version = Program.Version;
// 提取资源
ExtractResource(reload);
ExtractResource();
if (_Setting.MainWindowX != 0 || _Setting.MainWindowY != 0)
{
// 避免异常坐标导致窗口无法看到 同时需要考虑双屏时的负坐标 三屏或以上暂时无法测试与兼容
Expand Down Expand Up @@ -277,7 +275,6 @@ public void InitPdone()
#endregion

#region 设置标题和图标
Info.NameVersion = $"FreeControl v{fvi.ProductVersion}";
Text = Info.NameVersion;
ledTitle.Text = Info.NameVersion;
ledTitle.CharCount = 19;
Expand Down Expand Up @@ -335,18 +332,14 @@ public void InitPdone()
/// <summary>
/// 提取内置资源
/// </summary>
private void ExtractResource(bool reload = false)
private void ExtractResource()
{
string tempFileName = "temp.zip";
// 如果重新加载 且旧目录存在 删除后重新解压资源
if (reload && Directory.Exists(ScrcpyPath))
{
Directory.Delete(ScrcpyPath, true);
}
if (!Directory.Exists(ScrcpyPath))
{
_Setting.CustomScrcpyPath = ScrcpyPath;
Directory.CreateDirectory(ScrcpyPath);
File.WriteAllBytes(ScrcpyPath + tempFileName, Properties.Resources.scrcpy_win64_v2_4);
File.WriteAllBytes(ScrcpyPath + tempFileName, Properties.Resources.scrcpy_win32_v3_0);
// 解压缩
ZipFile.ExtractToDirectory(ScrcpyPath + tempFileName, UserDataPath);
// 解压完成删除压缩包
Expand Down
24 changes: 22 additions & 2 deletions FreeControl/Program.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
using FreeControl.Utils;
using System;
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using FreeControl;
using FreeControl.Utils;

[assembly: AssemblyTitle("在PC上控制Android设备")]//在PC上控制Android设备。
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Pdone Technology Ltd.")]
[assembly: AssemblyProduct("Free Control")]
[assembly: AssemblyCopyright("Copyright © 2024 awaw.cc")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("ef7540e1-f2e7-4682-80ab-92354c55a4c6")]

[assembly: AssemblyFileVersion(Program.Version)]
[assembly: AssemblyVersion(Program.Version)]

namespace FreeControl
{
static class Program
{
public const string Version = "1.7.3";
/// <summary>
/// 应用程序的主入口点。
/// </summary>
Expand Down
38 changes: 1 addition & 37 deletions FreeControl/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("在PC上控制Android设备")]//在PC上控制Android设备。
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Pdone Technology Ltd.")]
[assembly: AssemblyProduct("Free Control")]
[assembly: AssemblyCopyright("Copyright © 2024 awaw.cc")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]

// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("ef7540e1-f2e7-4682-80ab-92354c55a4c6")]

// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.7.2")]
[assembly: AssemblyVersion("1.7.2")]

4 changes: 2 additions & 2 deletions FreeControl/Properties/Resources.Designer.cs

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

4 changes: 2 additions & 2 deletions FreeControl/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@
<data name="pcm" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\pcm.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="scrcpy_win64_v2_4" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\scrcpy-win64-v2.4.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="scrcpy_win32_v3_0" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\scrcpy-win32-v3.0.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="shortcut_en" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\shortcut_en.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
Expand Down
Binary file modified FreeControl/Resources/en.FreeControl.resources.dll
Binary file not shown.
Binary file added FreeControl/Resources/scrcpy-win32-v3.0.zip
Binary file not shown.
Binary file removed FreeControl/Resources/scrcpy-win64-v2.4.zip
Binary file not shown.
10 changes: 6 additions & 4 deletions FreeControl/Setting.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace FreeControl
{
Expand Down Expand Up @@ -216,5 +213,10 @@ public List<string> ControllerButton
/// 自定义参数
/// </summary>
public string CustomArgs { get; set; } = "--keyboard=uhid";

/// <summary>
/// 自定义Scrcpy路径
/// </summary>
public string CustomScrcpyPath { get; set; } = "";
}
}
4 changes: 2 additions & 2 deletions FreeControl/Trusteeship.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FreeControl.Utils;
using System.Windows.Forms;
using System.Windows.Forms;
using FreeControl.Utils;

namespace FreeControl
{
Expand Down
4 changes: 4 additions & 0 deletions FreeControl/Update.en.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Free Control Update Record

## v1.7.3
- Based on scrcpy v3.0(x32)
- Add 'CustomScrcpyPath' parameter to customize Scrcpy directory

## v1.7.2
- Fix bug

Expand Down
4 changes: 4 additions & 0 deletions FreeControl/Update.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Free Control 更新记录

## v1.7.3
- 基于scrcpy v3.0(x32)
- 增加 `CustomScrcpyPath` 参数用于自定义Scrcpy目录

## v1.7.2
- 修复了一些bug

Expand Down
4 changes: 0 additions & 4 deletions FreeControl/Utils/ADB.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace FreeControl.Utils
{
Expand Down
1 change: 0 additions & 1 deletion FreeControl/Utils/Extend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms.VisualStyles;

namespace FreeControl.Utils
{
Expand Down
6 changes: 1 addition & 5 deletions FreeControl/Utils/FileHelper.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.IO;
using System.Reflection;
using System.Text;

namespace FreeControl.Utils
{
Expand Down
1 change: 0 additions & 1 deletion FreeControl/Utils/MoveListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Timers;

namespace FreeControl.Utils
Expand Down
8 changes: 2 additions & 6 deletions FreeControl/Utils/SysEnvironment.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System;
using Microsoft.Win32;

namespace FreeControl.Utils
{
Expand Down
Loading

0 comments on commit b01c0ad

Please sign in to comment.