1
- using FreeControl . Utils ;
2
- using Sunny . UI ;
3
- using System ;
1
+ using System ;
4
2
using System . Collections . Generic ;
5
3
using System . ComponentModel ;
6
4
using System . Diagnostics ;
7
5
using System . Drawing ;
8
6
using System . IO ;
9
7
using System . IO . Compression ;
10
8
using System . Linq ;
11
- using System . Reflection ;
12
9
using System . Threading ;
13
10
using System . Threading . Tasks ;
14
11
using System . Windows . Forms ;
12
+ using FreeControl . Utils ;
13
+ using Sunny . UI ;
15
14
16
15
namespace FreeControl
17
16
{
@@ -25,11 +24,11 @@ public partial class Main : UIForm
25
24
/// <summary>
26
25
/// scrcpy版本
27
26
/// </summary>
28
- public static readonly string ScrcpyVersion = "scrcpy-win64-v2.4 " ;
27
+ public static readonly string ScrcpyVersion = "scrcpy-win32-v3.0 " ;
29
28
/// <summary>
30
29
/// scrcpy路径
31
30
/// </summary>
32
- public static readonly string ScrcpyPath = Path . Combine ( UserDataPath , ScrcpyVersion + "\\ " ) ;
31
+ public static string ScrcpyPath = Path . Combine ( UserDataPath , ScrcpyVersion + "\\ " ) ;
33
32
/// <summary>
34
33
/// 用户桌面路径
35
34
/// </summary>
@@ -68,19 +67,19 @@ public class Info
68
67
/// <summary>
69
68
/// 程序名称 不带空格
70
69
/// </summary>
71
- public static readonly string Name = "FreeControl" ;
70
+ public const string Name = "FreeControl" ;
72
71
/// <summary>
73
72
/// 程序名称 带空格
74
73
/// </summary>
75
- public static readonly string Name2 = "Free Control" ;
74
+ public const string Name2 = "Free Control" ;
76
75
/// <summary>
77
76
/// scrcpy标题
78
77
/// </summary>
79
- public static readonly string ScrcpyTitle = "FreeControlScrcpy" ;
78
+ public const string ScrcpyTitle = "FreeControlScrcpy" ;
80
79
/// <summary>
81
80
/// 程序名称 带版本号
82
81
/// </summary>
83
- public static string NameVersion { get ; set ; }
82
+ public static readonly string NameVersion = $ " { Name } v { Program . Version } " ;
84
83
}
85
84
86
85
/// <summary>
@@ -186,22 +185,21 @@ public static void SetUserData(Setting userData)
186
185
/// </summary>
187
186
public void InitPdone ( )
188
187
{
189
- // 获取程序集信息
190
- Assembly asm = Assembly . GetExecutingAssembly ( ) ;
191
- FileVersionInfo fvi = FileVersionInfo . GetVersionInfo ( asm . Location ) ;
188
+ if ( Directory . Exists ( _Setting . CustomScrcpyPath ) )
189
+ {
190
+ ScrcpyPath = _Setting . CustomScrcpyPath ;
191
+ if ( ! ScrcpyPath . EndsWith ( "/" ) && ! ScrcpyPath . EndsWith ( "\\ " ) )
192
+ {
193
+ ScrcpyPath += "/" ;
194
+ }
195
+ }
192
196
// adb路径
193
197
ADB . ADBPath = $@ "{ ScrcpyPath } ";
194
198
// 增加adb执行文件系统变量
195
199
ADB . AddEnvironmentPath ( ScrcpyPath ) ;
196
- // 是否重新加载资源包
197
- bool reload = false ;
198
- if ( _Setting . Version != fvi . ProductVersion )
199
- {
200
- reload = true ;
201
- _Setting . Version = fvi . ProductVersion ;
202
- }
200
+ _Setting . Version = Program . Version ;
203
201
// 提取资源
204
- ExtractResource ( reload ) ;
202
+ ExtractResource ( ) ;
205
203
if ( _Setting . MainWindowX != 0 || _Setting . MainWindowY != 0 )
206
204
{
207
205
// 避免异常坐标导致窗口无法看到 同时需要考虑双屏时的负坐标 三屏或以上暂时无法测试与兼容
@@ -277,7 +275,6 @@ public void InitPdone()
277
275
#endregion
278
276
279
277
#region 设置标题和图标
280
- Info . NameVersion = $ "FreeControl v{ fvi . ProductVersion } ";
281
278
Text = Info . NameVersion ;
282
279
ledTitle . Text = Info . NameVersion ;
283
280
ledTitle . CharCount = 19 ;
@@ -335,18 +332,14 @@ public void InitPdone()
335
332
/// <summary>
336
333
/// 提取内置资源
337
334
/// </summary>
338
- private void ExtractResource ( bool reload = false )
335
+ private void ExtractResource ( )
339
336
{
340
337
string tempFileName = "temp.zip" ;
341
- // 如果重新加载 且旧目录存在 删除后重新解压资源
342
- if ( reload && Directory . Exists ( ScrcpyPath ) )
343
- {
344
- Directory . Delete ( ScrcpyPath , true ) ;
345
- }
346
338
if ( ! Directory . Exists ( ScrcpyPath ) )
347
339
{
340
+ _Setting . CustomScrcpyPath = ScrcpyPath ;
348
341
Directory . CreateDirectory ( ScrcpyPath ) ;
349
- File . WriteAllBytes ( ScrcpyPath + tempFileName , Properties . Resources . scrcpy_win64_v2_4 ) ;
342
+ File . WriteAllBytes ( ScrcpyPath + tempFileName , Properties . Resources . scrcpy_win32_v3_0 ) ;
350
343
// 解压缩
351
344
ZipFile . ExtractToDirectory ( ScrcpyPath + tempFileName , UserDataPath ) ;
352
345
// 解压完成删除压缩包
0 commit comments