Browse Source

Droid: adapt Android from 3 to 11
PC: set framework version to 4 for more compatible

HOME 3 years ago
parent
commit
bdc86d1df1

+ 6 - 0
MobileDroid/NuGet.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?> 
+<configuration> 
+  <config> 
+    <add key="repositorypath" value="C:\NuGetLocalRepo" /> 
+  </config> 
+</configuration>

+ 12 - 8
MobileDroid/ScrExtDroid/MainActivity.cs

@@ -19,15 +19,21 @@ namespace ScrExtDroid
 
         private string _target;
 
-        //
+        private string ConfigFilePath
+        {
+            get
+            {
+                var dataPath = Application.FilesDir.AbsolutePath;
+                if (Directory.Exists(dataPath) == false) Directory.CreateDirectory(dataPath);
+                return System.IO.Path.Combine(dataPath, "sxd_config.txt");
+            }
+        }
 
         private void AskAndConnect()
         {
-            var cfgPath = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.Path, "sxd_config.txt");
-
             EditText et = new EditText(this);
 
-            et.Text = File.Exists(cfgPath) ? File.ReadAllText(cfgPath) : "192.168.233.233:61234";
+            et.Text = File.Exists(ConfigFilePath) ? File.ReadAllText(ConfigFilePath) : "192.168.233.233:61234";
 
             AlertDialog.Builder ad = new AlertDialog.Builder(this);
             ad.SetTitle("Connect");
@@ -70,9 +76,7 @@ namespace ScrExtDroid
                         Toast.MakeText(this, "Connected", ToastLength.Short).Show();
                     });
 
-                    var cfgPath = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.Path, "sxd_config.txt");
-
-                    File.WriteAllText(cfgPath, _target);
+                    File.WriteAllText(ConfigFilePath, _target);
                 }
                 catch (Exception e)
                 {
@@ -103,7 +107,7 @@ namespace ScrExtDroid
                 ns.ReadTimeout = 1000;
 
                 var r = new BinaryReader(ns);
-                
+
                 try
                 {
                     do

+ 1 - 0
MobileDroid/ScrExtDroid/ScrExtDroid.csproj

@@ -76,6 +76,7 @@
     <AndroidResource Include="Resources\drawable\Icon.png" />
   </ItemGroup>
   <ItemGroup>
+    <None Include="packages.config" />
     <None Include="Properties\AndroidManifest.xml" />
   </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />

+ 3 - 0
MobileDroid/ScrExtDroid/packages.config

@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+</packages>

+ 5 - 0
MobileDroid/ScreenExtenderDroid.sln

@@ -5,6 +5,11 @@ VisualStudioVersion = 14.0.23107.0
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScrExtDroid", "ScrExtDroid\ScrExtDroid.csproj", "{646161A3-7C3A-47CC-BD49-5F67E6D5FC46}"
 EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{24A9F71E-46A0-47AB-BD2C-5D88CA652D9C}"
+	ProjectSection(SolutionItems) = preProject
+		NuGet.config = NuGet.config
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU

+ 6 - 0
PcWin/NuGet.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?> 
+<configuration> 
+  <config> 
+    <add key="repositorypath" value="C:\NuGetLocalRepo" /> 
+  </config> 
+</configuration>

+ 5 - 0
PcWin/ScreenExtender.sln

@@ -5,6 +5,11 @@ VisualStudioVersion = 16.0.30804.86
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScreenExtender", "ScreenExtender\ScreenExtender.csproj", "{B778FF7E-15CA-467C-8161-0BB92438AF49}"
 EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{514810B5-F6FD-46B8-8D11-CD2075B8A6DD}"
+	ProjectSection(SolutionItems) = preProject
+		NuGet.config = NuGet.config
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU

+ 1 - 9
PcWin/ScreenExtender/Resources/index.html

@@ -13,15 +13,7 @@
     </style>
 </head>
 <body class="fill">
-    <a href="https://www.runoob.com/try/try.php?filename=tryhtml5_video_all">asdf</a>
-    <br />
-
-<video autoplay loop controls width="200" height="200">
-    <source type="video/3gpp" src="http://192.168.5.33/sample_640x360.3gp" >
-</video>
-
-    <br />
-
+   
     <canvas id="tar"></canvas>
 
     <script>

+ 20 - 2
PcWin/ScreenExtender/ScreenExtender.csproj

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="C:\NuGetLocalRepo\ILRepack.2.0.18\build\ILRepack.props" Condition="Exists('C:\NuGetLocalRepo\ILRepack.2.0.18\build\ILRepack.props')" />
   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -8,10 +9,13 @@
     <OutputType>WinExe</OutputType>
     <RootNamespace>ScreenExtender</RootNamespace>
     <AssemblyName>ScreenExtender</AssemblyName>
-    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
     <Deterministic>true</Deterministic>
+    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+    <NuGetPackageImportStamp>
+    </NuGetPackageImportStamp>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -70,6 +74,20 @@
     <EmbeddedResource Include="Resources\index.html" />
     <Content Include="Utility\Spy\SOURCE.txt" />
   </ItemGroup>
-  <ItemGroup />
+  <ItemGroup>
+    <None Include="app.config" />
+    <None Include="packages.config" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('C:\NuGetLocalRepo\ILRepack.2.0.18\build\ILRepack.props')" Text="$([System.String]::Format('$(ErrorText)', 'C:\NuGetLocalRepo\ILRepack.2.0.18\build\ILRepack.props'))" />
+  </Target>
+  <PropertyGroup>
+    <PostBuildEvent>if $(ConfigurationName) == Release if not exist "$(TargetDir)Packed" md "$(TargetDir)Packed"
+if $(ConfigurationName) == Release $(ILRepack) /ndebug "/out:$(TargetDir)Packed\$(TargetFileName)" "$(TargetPath)"
+if $(ConfigurationName) == Release if exist "$(TargetDir)Packed\$(TargetFileName).config" del "$(TargetDir)Packed\$(TargetFileName).config"</PostBuildEvent>
+  </PropertyGroup>
 </Project>

+ 0 - 3
PcWin/ScreenExtender/ScreenExtenderProgram.cs

@@ -1,7 +1,4 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 using System.Windows.Forms;
 
 namespace ScreenExtender

+ 4 - 5
PcWin/ScreenExtender/ScreenExtenderServer.cs

@@ -1,5 +1,4 @@
-using System;
-using System.IO;
+using System.IO;
 using System.Net;
 using System.Net.Sockets;
 using System.Text;
@@ -28,7 +27,7 @@ namespace ScreenExtender
             _server.Listen(1);
 
             _isRunning = true;
-            Task.Run(ServerProc);
+            Task.Factory.StartNew(ServerProc);
         }
 
         public void Stop()
@@ -43,7 +42,7 @@ namespace ScreenExtender
             while (_isRunning)
             {
                 var client = _server.Accept();
-                Task.Run(() => RequestProc(client));
+                Task.Factory.StartNew(() => RequestProc(client));
             }
         }
 
@@ -74,7 +73,7 @@ namespace ScreenExtender
                 {
                     Thread.Sleep(100);
                     var rBuf = _mainForm.FrameBytes;
-                    if (rBuf == null)  continue;
+                    if (rBuf == null) continue;
 
                     try
                     {

+ 1 - 6
PcWin/ScreenExtender/Utility/ExStringFormatter.cs

@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Drawing;
 
 namespace ScreenExtender.Utility
 {

+ 3 - 3
PcWin/ScreenExtender/Utility/Spy/SpyAgent.cs

@@ -22,7 +22,7 @@ namespace ScreenExtender.Utility.Spy
         private void OnTimerTicked(object sender, EventArgs e)
         {
             ShowLocator();
-            if (!Control.MouseButtons.HasFlag(MouseButtons.Left)) return;
+            if (0 == (Control.MouseButtons & MouseButtons.Left)) return;
             EndSpying();
             _selectedAction(GetHoveredWindow());
         }
@@ -128,12 +128,12 @@ namespace ScreenExtender.Utility.Spy
 
             public static implicit operator Point(POINT p)
             {
-                return new Point(p.X, p.Y);
+                return new(p.X, p.Y);
             }
 
             public static implicit operator POINT(Point p)
             {
-                return new POINT(p.X, p.Y);
+                return new(p.X, p.Y);
             }
         }
 

+ 3 - 0
PcWin/ScreenExtender/app.config

@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration>

+ 4 - 0
PcWin/ScreenExtender/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="ILRepack" version="2.0.18" targetFramework="net35-client" />
+</packages>