Add project
19
src/TCPCommanderXamarin.Android/Assets/AboutAssets.txt
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
Any raw assets you want to be deployed with your application can be placed in
|
||||||
|
this directory (and child directories) and given a Build Action of "AndroidAsset".
|
||||||
|
|
||||||
|
These files will be deployed with your package and will be accessible using Android's
|
||||||
|
AssetManager, like this:
|
||||||
|
|
||||||
|
public class ReadAsset : Activity
|
||||||
|
{
|
||||||
|
protected override void OnCreate (Bundle bundle)
|
||||||
|
{
|
||||||
|
base.OnCreate (bundle);
|
||||||
|
|
||||||
|
InputStream input = Assets.Open ("my_asset.txt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Additionally, some Android functions will automatically load asset files:
|
||||||
|
|
||||||
|
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
|
33
src/TCPCommanderXamarin.Android/MainActivity.cs
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
using Android.App;
|
||||||
|
using Android.Content.PM;
|
||||||
|
using Android.Runtime;
|
||||||
|
using Android.Views;
|
||||||
|
using Android.Widget;
|
||||||
|
using Android.OS;
|
||||||
|
|
||||||
|
namespace TCPCommanderXamarin.Droid
|
||||||
|
{
|
||||||
|
[Activity(Label = "TCPCommanderXamarin", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
|
||||||
|
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
|
||||||
|
{
|
||||||
|
protected override void OnCreate(Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
TabLayoutResource = Resource.Layout.Tabbar;
|
||||||
|
ToolbarResource = Resource.Layout.Toolbar;
|
||||||
|
|
||||||
|
base.OnCreate(savedInstanceState);
|
||||||
|
|
||||||
|
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
|
||||||
|
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
|
||||||
|
LoadApplication(new App());
|
||||||
|
}
|
||||||
|
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
|
||||||
|
{
|
||||||
|
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|
||||||
|
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
src/TCPCommanderXamarin.Android/Properties/AndroidManifest.xml
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.tcpcommanderxamarin" android:installLocation="preferExternal">
|
||||||
|
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
|
||||||
|
<application android:label="TCPCommanderXamarin.Android"></application>
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||||
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
</manifest>
|
34
src/TCPCommanderXamarin.Android/Properties/AssemblyInfo.cs
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using Android.App;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("TCPCommanderXamarin.Android")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("TCPCommanderXamarin.Android")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
|
||||||
|
// Add some common permissions, these can be removed if not needed
|
||||||
|
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
|
||||||
|
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
|
50
src/TCPCommanderXamarin.Android/Resources/AboutResources.txt
Executable file
@ -0,0 +1,50 @@
|
|||||||
|
Images, layout descriptions, binary blobs and string dictionaries can be included
|
||||||
|
in your application as resource files. Various Android APIs are designed to
|
||||||
|
operate on the resource IDs instead of dealing with images, strings or binary blobs
|
||||||
|
directly.
|
||||||
|
|
||||||
|
For example, a sample Android app that contains a user interface layout (main.xml),
|
||||||
|
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
|
||||||
|
would keep its resources in the "Resources" directory of the application:
|
||||||
|
|
||||||
|
Resources/
|
||||||
|
drawable-hdpi/
|
||||||
|
icon.png
|
||||||
|
|
||||||
|
drawable-ldpi/
|
||||||
|
icon.png
|
||||||
|
|
||||||
|
drawable-mdpi/
|
||||||
|
icon.png
|
||||||
|
|
||||||
|
layout/
|
||||||
|
main.xml
|
||||||
|
|
||||||
|
values/
|
||||||
|
strings.xml
|
||||||
|
|
||||||
|
In order to get the build system to recognize Android resources, set the build action to
|
||||||
|
"AndroidResource". The native Android APIs do not operate directly with filenames, but
|
||||||
|
instead operate on resource IDs. When you compile an Android application that uses resources,
|
||||||
|
the build system will package the resources for distribution and generate a class called
|
||||||
|
"Resource" that contains the tokens for each one of the resources included. For example,
|
||||||
|
for the above Resources layout, this is what the Resource class would expose:
|
||||||
|
|
||||||
|
public class Resource {
|
||||||
|
public class drawable {
|
||||||
|
public const int icon = 0x123;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class layout {
|
||||||
|
public const int main = 0x456;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class strings {
|
||||||
|
public const int first_string = 0xabc;
|
||||||
|
public const int second_string = 0xbcd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main
|
||||||
|
to reference the layout/main.xml file, or Resource.strings.first_string to reference the first
|
||||||
|
string in the dictionary file values/strings.xml.
|
11433
src/TCPCommanderXamarin.Android/Resources/Resource.designer.cs
generated
Executable file
11
src/TCPCommanderXamarin.Android/Resources/layout/Tabbar.xml
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/sliding_tabs"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||||
|
app:tabIndicatorColor="@android:color/white"
|
||||||
|
app:tabGravity="fill"
|
||||||
|
app:tabMode="fixed" />
|
9
src/TCPCommanderXamarin.Android/Resources/layout/Toolbar.xml
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||||
|
android:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
|
||||||
|
|
5
src/TCPCommanderXamarin.Android/Resources/mipmap-anydpi-v26/icon.xml
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@color/launcher_background" />
|
||||||
|
<foreground android:drawable="@mipmap/launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@color/launcher_background" />
|
||||||
|
<foreground android:drawable="@mipmap/launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
BIN
src/TCPCommanderXamarin.Android/Resources/mipmap-hdpi/icon.png
Executable file
After Width: | Height: | Size: 4.6 KiB |
BIN
src/TCPCommanderXamarin.Android/Resources/mipmap-hdpi/launcher_foreground.png
Executable file
After Width: | Height: | Size: 11 KiB |
BIN
src/TCPCommanderXamarin.Android/Resources/mipmap-mdpi/icon.png
Executable file
After Width: | Height: | Size: 2.7 KiB |
BIN
src/TCPCommanderXamarin.Android/Resources/mipmap-mdpi/launcher_foreground.png
Executable file
After Width: | Height: | Size: 6.3 KiB |
BIN
src/TCPCommanderXamarin.Android/Resources/mipmap-xhdpi/icon.png
Executable file
After Width: | Height: | Size: 6.9 KiB |
BIN
src/TCPCommanderXamarin.Android/Resources/mipmap-xhdpi/launcher_foreground.png
Executable file
After Width: | Height: | Size: 18 KiB |
BIN
src/TCPCommanderXamarin.Android/Resources/mipmap-xxhdpi/icon.png
Executable file
After Width: | Height: | Size: 12 KiB |
BIN
src/TCPCommanderXamarin.Android/Resources/mipmap-xxhdpi/launcher_foreground.png
Executable file
After Width: | Height: | Size: 33 KiB |
BIN
src/TCPCommanderXamarin.Android/Resources/mipmap-xxxhdpi/icon.png
Executable file
After Width: | Height: | Size: 19 KiB |
BIN
src/TCPCommanderXamarin.Android/Resources/mipmap-xxxhdpi/launcher_foreground.png
Executable file
After Width: | Height: | Size: 51 KiB |
7
src/TCPCommanderXamarin.Android/Resources/values/colors.xml
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="launcher_background">#FFFFFF</color>
|
||||||
|
<color name="colorPrimary">#3F51B5</color>
|
||||||
|
<color name="colorPrimaryDark">#303F9F</color>
|
||||||
|
<color name="colorAccent">#FF4081</color>
|
||||||
|
</resources>
|
30
src/TCPCommanderXamarin.Android/Resources/values/styles.xml
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<style name="MainTheme" parent="MainTheme.Base">
|
||||||
|
</style>
|
||||||
|
<!-- Base theme applied no matter what API -->
|
||||||
|
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
|
||||||
|
<item name="windowNoTitle">true</item>
|
||||||
|
<!--We will be using the toolbar so no need to show ActionBar-->
|
||||||
|
<item name="windowActionBar">false</item>
|
||||||
|
<!-- Set theme colors from https://aka.ms/material-colors -->
|
||||||
|
<!-- colorPrimary is used for the default action bar background -->
|
||||||
|
<item name="colorPrimary">#2196F3</item>
|
||||||
|
<!-- colorPrimaryDark is used for the status bar -->
|
||||||
|
<item name="colorPrimaryDark">#1976D2</item>
|
||||||
|
<!-- colorAccent is used as the default value for colorControlActivated
|
||||||
|
which is used to tint widgets -->
|
||||||
|
<item name="colorAccent">#FF4081</item>
|
||||||
|
<!-- You can also set colorControlNormal, colorControlActivated
|
||||||
|
colorControlHighlight and colorSwitchThumbNormal. -->
|
||||||
|
<item name="windowActionModeOverlay">true</item>
|
||||||
|
|
||||||
|
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
|
||||||
|
<item name="colorAccent">#FF4081</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
103
src/TCPCommanderXamarin.Android/TCPCommanderXamarin.Android.csproj
Executable file
@ -0,0 +1,103 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}</ProjectGuid>
|
||||||
|
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<TemplateGuid>{c9e5eea5-ca05-42a1-839b-61506e0a37df}</TemplateGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<RootNamespace>TCPCommanderXamarin.Droid</RootNamespace>
|
||||||
|
<AssemblyName>TCPCommanderXamarin.Android</AssemblyName>
|
||||||
|
<AndroidApplication>True</AndroidApplication>
|
||||||
|
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
|
||||||
|
<AndroidResgenClass>Resource</AndroidResgenClass>
|
||||||
|
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||||
|
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
|
||||||
|
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
|
||||||
|
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
|
||||||
|
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
|
||||||
|
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
|
||||||
|
<AndroidUseAapt2>true</AndroidUseAapt2>
|
||||||
|
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>portable</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AndroidLinkMode>None</AndroidLinkMode>
|
||||||
|
<AotAssemblies>false</AotAssemblies>
|
||||||
|
<EnableLLVM>false</EnableLLVM>
|
||||||
|
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
|
||||||
|
<BundleAssemblies>false</BundleAssemblies>
|
||||||
|
<MandroidI18n />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>portable</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release</OutputPath>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AndroidManagedSymbols>true</AndroidManagedSymbols>
|
||||||
|
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Mono.Android" />
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="System.Numerics" />
|
||||||
|
<Reference Include="System.Numerics.Vectors" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Xamarin.Forms" Version="4.2.0.709249" />
|
||||||
|
<PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="28.0.0.1" />
|
||||||
|
<PackageReference Include="Xamarin.Essentials" Version="1.2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="MainActivity.cs" />
|
||||||
|
<Compile Include="Resources\Resource.designer.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\AboutResources.txt" />
|
||||||
|
<None Include="Assets\AboutAssets.txt" />
|
||||||
|
<None Include="Properties\AndroidManifest.xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AndroidResource Include="Resources\layout\Tabbar.xml" />
|
||||||
|
<AndroidResource Include="Resources\layout\Toolbar.xml" />
|
||||||
|
<AndroidResource Include="Resources\values\styles.xml" />
|
||||||
|
<AndroidResource Include="Resources\values\colors.xml" />
|
||||||
|
<AndroidResource Include="Resources\mipmap-anydpi-v26\icon.xml" />
|
||||||
|
<AndroidResource Include="Resources\mipmap-anydpi-v26\icon_round.xml" />
|
||||||
|
<AndroidResource Include="Resources\mipmap-hdpi\icon.png" />
|
||||||
|
<AndroidResource Include="Resources\mipmap-hdpi\launcher_foreground.png" />
|
||||||
|
<AndroidResource Include="Resources\mipmap-mdpi\icon.png" />
|
||||||
|
<AndroidResource Include="Resources\mipmap-mdpi\launcher_foreground.png" />
|
||||||
|
<AndroidResource Include="Resources\mipmap-xhdpi\icon.png" />
|
||||||
|
<AndroidResource Include="Resources\mipmap-xhdpi\launcher_foreground.png" />
|
||||||
|
<AndroidResource Include="Resources\mipmap-xxhdpi\icon.png" />
|
||||||
|
<AndroidResource Include="Resources\mipmap-xxhdpi\launcher_foreground.png" />
|
||||||
|
<AndroidResource Include="Resources\mipmap-xxxhdpi\icon.png" />
|
||||||
|
<AndroidResource Include="Resources\mipmap-xxxhdpi\launcher_foreground.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Resources\drawable\" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\TCPCommanderXamarin\TCPCommanderXamarin.csproj">
|
||||||
|
<Project>{C103F413-7549-41AF-8418-64EE42E6C396}</Project>
|
||||||
|
<Name>TCPCommanderXamarin</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||||
|
</Project>
|
31
src/TCPCommanderXamarin.iOS/AppDelegate.cs
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
using Foundation;
|
||||||
|
using UIKit;
|
||||||
|
|
||||||
|
namespace TCPControllerXamarin.iOS
|
||||||
|
{
|
||||||
|
// The UIApplicationDelegate for the application. This class is responsible for launching the
|
||||||
|
// User Interface of the application, as well as listening (and optionally responding) to
|
||||||
|
// application events from iOS.
|
||||||
|
[Register("AppDelegate")]
|
||||||
|
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// This method is invoked when the application has loaded and is ready to run. In this
|
||||||
|
// method you should instantiate the window, load the UI into it and then make the window
|
||||||
|
// visible.
|
||||||
|
//
|
||||||
|
// You have 17 seconds to return from this method, or iOS will terminate your application.
|
||||||
|
//
|
||||||
|
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
|
||||||
|
{
|
||||||
|
global::Xamarin.Forms.Forms.Init();
|
||||||
|
LoadApplication(new App());
|
||||||
|
|
||||||
|
return base.FinishedLaunching(app, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
117
src/TCPCommanderXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Contents.json
Executable file
@ -0,0 +1,117 @@
|
|||||||
|
{
|
||||||
|
"images": [
|
||||||
|
{
|
||||||
|
"scale": "2x",
|
||||||
|
"size": "20x20",
|
||||||
|
"idiom": "iphone",
|
||||||
|
"filename": "Icon40.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "3x",
|
||||||
|
"size": "20x20",
|
||||||
|
"idiom": "iphone",
|
||||||
|
"filename": "Icon60.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "2x",
|
||||||
|
"size": "29x29",
|
||||||
|
"idiom": "iphone",
|
||||||
|
"filename": "Icon58.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "3x",
|
||||||
|
"size": "29x29",
|
||||||
|
"idiom": "iphone",
|
||||||
|
"filename": "Icon87.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "2x",
|
||||||
|
"size": "40x40",
|
||||||
|
"idiom": "iphone",
|
||||||
|
"filename": "Icon80.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "3x",
|
||||||
|
"size": "40x40",
|
||||||
|
"idiom": "iphone",
|
||||||
|
"filename": "Icon120.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "2x",
|
||||||
|
"size": "60x60",
|
||||||
|
"idiom": "iphone",
|
||||||
|
"filename": "Icon120.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "3x",
|
||||||
|
"size": "60x60",
|
||||||
|
"idiom": "iphone",
|
||||||
|
"filename": "Icon180.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "1x",
|
||||||
|
"size": "20x20",
|
||||||
|
"idiom": "ipad",
|
||||||
|
"filename": "Icon20.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "2x",
|
||||||
|
"size": "20x20",
|
||||||
|
"idiom": "ipad",
|
||||||
|
"filename": "Icon40.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "1x",
|
||||||
|
"size": "29x29",
|
||||||
|
"idiom": "ipad",
|
||||||
|
"filename": "Icon29.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "2x",
|
||||||
|
"size": "29x29",
|
||||||
|
"idiom": "ipad",
|
||||||
|
"filename": "Icon58.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "1x",
|
||||||
|
"size": "40x40",
|
||||||
|
"idiom": "ipad",
|
||||||
|
"filename": "Icon40.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "2x",
|
||||||
|
"size": "40x40",
|
||||||
|
"idiom": "ipad",
|
||||||
|
"filename": "Icon80.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "1x",
|
||||||
|
"size": "76x76",
|
||||||
|
"idiom": "ipad",
|
||||||
|
"filename": "Icon76.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "2x",
|
||||||
|
"size": "76x76",
|
||||||
|
"idiom": "ipad",
|
||||||
|
"filename": "Icon152.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "2x",
|
||||||
|
"size": "83.5x83.5",
|
||||||
|
"idiom": "ipad",
|
||||||
|
"filename": "Icon167.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scale": "1x",
|
||||||
|
"size": "1024x1024",
|
||||||
|
"idiom": "ios-marketing",
|
||||||
|
"filename": "Icon1024.png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"properties": {},
|
||||||
|
"info": {
|
||||||
|
"version": 1,
|
||||||
|
"author": "xcode"
|
||||||
|
}
|
||||||
|
}
|
BIN
src/TCPCommanderXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon1024.png
Executable file
After Width: | Height: | Size: 69 KiB |
BIN
src/TCPCommanderXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon120.png
Executable file
After Width: | Height: | Size: 3.7 KiB |
BIN
src/TCPCommanderXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon152.png
Executable file
After Width: | Height: | Size: 4.6 KiB |
BIN
src/TCPCommanderXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon167.png
Executable file
After Width: | Height: | Size: 4.6 KiB |
BIN
src/TCPCommanderXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon180.png
Executable file
After Width: | Height: | Size: 5.1 KiB |
BIN
src/TCPCommanderXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon20.png
Executable file
After Width: | Height: | Size: 1.3 KiB |
BIN
src/TCPCommanderXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon29.png
Executable file
After Width: | Height: | Size: 845 B |
BIN
src/TCPCommanderXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon40.png
Executable file
After Width: | Height: | Size: 1.1 KiB |
BIN
src/TCPCommanderXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon58.png
Executable file
After Width: | Height: | Size: 1.7 KiB |
BIN
src/TCPCommanderXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon60.png
Executable file
After Width: | Height: | Size: 2.5 KiB |
BIN
src/TCPCommanderXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon76.png
Executable file
After Width: | Height: | Size: 2.3 KiB |
BIN
src/TCPCommanderXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon80.png
Executable file
After Width: | Height: | Size: 2.4 KiB |
BIN
src/TCPCommanderXamarin.iOS/Assets.xcassets/AppIcon.appiconset/Icon87.png
Executable file
After Width: | Height: | Size: 2.7 KiB |
7
src/TCPCommanderXamarin.iOS/Entitlements.plist
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
|
|
38
src/TCPCommanderXamarin.iOS/Info.plist
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>UIDeviceFamily</key>
|
||||||
|
<array>
|
||||||
|
<integer>1</integer>
|
||||||
|
<integer>2</integer>
|
||||||
|
</array>
|
||||||
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>MinimumOSVersion</key>
|
||||||
|
<string>8.0</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>TCPControllerXamarin</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.companyname.TCPControllerXamarin</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>UILaunchStoryboardName</key>
|
||||||
|
<string>LaunchScreen</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>TCPControllerXamarin</string>
|
||||||
|
<key>XSAppIconAssets</key>
|
||||||
|
<string>Assets.xcassets/AppIcon.appiconset</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
20
src/TCPCommanderXamarin.iOS/Main.cs
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
using Foundation;
|
||||||
|
using UIKit;
|
||||||
|
|
||||||
|
namespace TCPControllerXamarin.iOS
|
||||||
|
{
|
||||||
|
public class Application
|
||||||
|
{
|
||||||
|
// This is the main entry point of the application.
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
// if you want to use a different Application Delegate class from "AppDelegate"
|
||||||
|
// you can specify it here.
|
||||||
|
UIApplication.Main(args, null, "AppDelegate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
src/TCPCommanderXamarin.iOS/Properties/AssemblyInfo.cs
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("TCPControllerXamarin.iOS")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("TCPControllerXamarin.iOS")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("72bdc44f-c588-44f3-b6df-9aace7daafdd")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
BIN
src/TCPCommanderXamarin.iOS/Resources/Default-568h@2x.png
Executable file
After Width: | Height: | Size: 8.7 KiB |
BIN
src/TCPCommanderXamarin.iOS/Resources/Default-Portrait.png
Executable file
After Width: | Height: | Size: 10 KiB |
BIN
src/TCPCommanderXamarin.iOS/Resources/Default-Portrait@2x.png
Executable file
After Width: | Height: | Size: 34 KiB |
BIN
src/TCPCommanderXamarin.iOS/Resources/Default.png
Executable file
After Width: | Height: | Size: 7.1 KiB |
BIN
src/TCPCommanderXamarin.iOS/Resources/Default@2x.png
Executable file
After Width: | Height: | Size: 8.2 KiB |
39
src/TCPCommanderXamarin.iOS/Resources/LaunchScreen.storyboard
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="X5k-f2-b5h">
|
||||||
|
<dependencies>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--View Controller-->
|
||||||
|
<scene sceneID="gAE-YM-kbH">
|
||||||
|
<objects>
|
||||||
|
<viewController id="X5k-f2-b5h" sceneMemberID="viewController">
|
||||||
|
<layoutGuides>
|
||||||
|
<viewControllerLayoutGuide type="top" id="Y8P-hJ-Z43"/>
|
||||||
|
<viewControllerLayoutGuide type="bottom" id="9ZL-r4-8FZ"/>
|
||||||
|
</layoutGuides>
|
||||||
|
<view key="view" contentMode="scaleToFill" id="yd7-JS-zBw">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" misplaced="YES" image="Icon-60.png" translatesAutoresizingMaskIntoConstraints="NO" id="23">
|
||||||
|
<rect key="frame" x="270" y="270" width="60" height="60"/>
|
||||||
|
<rect key="contentStretch" x="0.0" y="0.0" width="0.0" height="0.0"/>
|
||||||
|
</imageView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" red="0.20392156862745098" green="0.59607843137254901" blue="0.85882352941176465" alpha="1" colorSpace="calibratedRGB"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="23" firstAttribute="centerY" secondItem="yd7-JS-zBw" secondAttribute="centerY" priority="1" id="39"/>
|
||||||
|
<constraint firstItem="23" firstAttribute="centerX" secondItem="yd7-JS-zBw" secondAttribute="centerX" priority="1" id="41"/>
|
||||||
|
</constraints>
|
||||||
|
</view>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="XAI-xm-WK6" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="349" y="339"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
<resources>
|
||||||
|
<image name="Icon-60.png" width="180" height="180"/>
|
||||||
|
</resources>
|
||||||
|
</document>
|
133
src/TCPCommanderXamarin.iOS/TCPCommanderXamarin.iOS.csproj
Executable file
@ -0,0 +1,133 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
|
||||||
|
<ProductVersion>8.0.30703</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{188A8FDB-21B4-4A34-AEC1-6A302B05097C}</ProjectGuid>
|
||||||
|
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<TemplateGuid>{6143fdea-f3c2-4a09-aafa-6e230626515e}</TemplateGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>TCPControllerXamarin.iOS</RootNamespace>
|
||||||
|
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||||
|
<AssemblyName>TCPControllerXamarin.iOS</AssemblyName>
|
||||||
|
<MtouchEnableSGenConc>true</MtouchEnableSGenConc>
|
||||||
|
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<MtouchArch>x86_64</MtouchArch>
|
||||||
|
<MtouchLink>None</MtouchLink>
|
||||||
|
<MtouchDebug>true</MtouchDebug>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||||
|
<DebugType>none</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<MtouchLink>None</MtouchLink>
|
||||||
|
<MtouchArch>x86_64</MtouchArch>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\iPhone\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<MtouchArch>ARM64</MtouchArch>
|
||||||
|
<CodesignKey>iPhone Developer</CodesignKey>
|
||||||
|
<MtouchDebug>true</MtouchDebug>
|
||||||
|
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||||
|
<DebugType>none</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<MtouchArch>ARM64</MtouchArch>
|
||||||
|
<CodesignKey>iPhone Developer</CodesignKey>
|
||||||
|
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Main.cs" />
|
||||||
|
<Compile Include="AppDelegate.cs" />
|
||||||
|
<None Include="Entitlements.plist" />
|
||||||
|
<None Include="Info.plist" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
|
||||||
|
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json">
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</ImageAsset>
|
||||||
|
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon1024.png">
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</ImageAsset>
|
||||||
|
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon180.png">
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</ImageAsset>
|
||||||
|
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon167.png">
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</ImageAsset>
|
||||||
|
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon152.png">
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</ImageAsset>
|
||||||
|
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon120.png">
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</ImageAsset>
|
||||||
|
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon87.png">
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</ImageAsset>
|
||||||
|
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon80.png">
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</ImageAsset>
|
||||||
|
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon76.png">
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</ImageAsset>
|
||||||
|
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon60.png">
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</ImageAsset>
|
||||||
|
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon58.png">
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</ImageAsset>
|
||||||
|
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon40.png">
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</ImageAsset>
|
||||||
|
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon29.png">
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</ImageAsset>
|
||||||
|
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon20.png">
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</ImageAsset>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="Xamarin.iOS" />
|
||||||
|
<Reference Include="System.Numerics" />
|
||||||
|
<Reference Include="System.Numerics.Vectors" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Xamarin.Forms" Version="4.2.0.709249" />
|
||||||
|
<PackageReference Include="Xamarin.Essentials" Version="1.2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\TCPCommanderXamarin\TCPCommanderXamarin.csproj">
|
||||||
|
<Project>{C103F413-7549-41AF-8418-64EE42E6C396}</Project>
|
||||||
|
<Name>TCPCommanderXamarin</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
83
src/TCPCommanderXamarin.sln
Executable file
@ -0,0 +1,83 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.29519.87
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TCPCommanderXamarin.Android", "TCPCommanderXamarin.Android\TCPCommanderXamarin.Android.csproj", "{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TCPCommanderXamarin.iOS", "TCPCommanderXamarin.iOS\TCPCommanderXamarin.iOS.csproj", "{188A8FDB-21B4-4A34-AEC1-6A302B05097C}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TCPCommanderXamarin", "TCPCommanderXamarin\TCPCommanderXamarin.csproj", "{C103F413-7549-41AF-8418-64EE42E6C396}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Debug|iPhone = Debug|iPhone
|
||||||
|
Debug|iPhoneSimulator = Debug|iPhoneSimulator
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Release|iPhone = Release|iPhone
|
||||||
|
Release|iPhoneSimulator = Release|iPhoneSimulator
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Debug|iPhone.Deploy.0 = Debug|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Release|iPhone.ActiveCfg = Release|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Release|iPhone.Build.0 = Release|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Release|iPhone.Deploy.0 = Release|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||||
|
{99A7784B-414B-4BF3-A0F4-BEEC741F9A97}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Debug|Any CPU.Deploy.0 = Debug|iPhoneSimulator
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Debug|iPhone.ActiveCfg = Debug|iPhone
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Debug|iPhone.Build.0 = Debug|iPhone
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Debug|iPhone.Deploy.0 = Debug|iPhone
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Debug|iPhoneSimulator.Deploy.0 = Debug|iPhoneSimulator
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Release|Any CPU.ActiveCfg = Release|iPhone
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Release|Any CPU.Build.0 = Release|iPhone
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Release|Any CPU.Deploy.0 = Release|iPhone
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Release|iPhone.ActiveCfg = Release|iPhone
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Release|iPhone.Build.0 = Release|iPhone
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Release|iPhone.Deploy.0 = Release|iPhone
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||||
|
{188A8FDB-21B4-4A34-AEC1-6A302B05097C}.Release|iPhoneSimulator.Deploy.0 = Release|iPhoneSimulator
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Debug|iPhone.Deploy.0 = Debug|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Release|iPhone.ActiveCfg = Release|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Release|iPhone.Build.0 = Release|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Release|iPhone.Deploy.0 = Release|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||||
|
{C103F413-7549-41AF-8418-64EE42E6C396}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {DA4FB27C-F4DE-4753-969B-188613BF08AD}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
11
src/TCPCommanderXamarin/App.xaml
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<Application xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
x:Class="TCPCommanderXamarin.App">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
30
src/TCPCommanderXamarin/App.xaml.cs
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
|
namespace TCPCommanderXamarin
|
||||||
|
{
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
public App()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
MainPage = new NavigationPage(new MainPage());
|
||||||
|
|
||||||
|
protected override void OnStart()
|
||||||
|
{
|
||||||
|
// Handle when your app starts
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnSleep()
|
||||||
|
{
|
||||||
|
// Handle when your app sleeps
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnResume()
|
||||||
|
{
|
||||||
|
// Handle when your app resumes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
src/TCPCommanderXamarin/AssemblyInfo.cs
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
using Android.App;
|
||||||
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
|
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
|
29
src/TCPCommanderXamarin/Connection.cs
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
//using Android.App;
|
||||||
|
//using Android.Content;
|
||||||
|
//using Android.OS;
|
||||||
|
//using Android.Runtime;
|
||||||
|
//using Android.Views;
|
||||||
|
//using Android.Widget;
|
||||||
|
|
||||||
|
namespace TCPCommanderXamarin.Droid
|
||||||
|
{
|
||||||
|
public class Connection
|
||||||
|
{
|
||||||
|
private static Connection _instance;
|
||||||
|
public static Connection Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_instance == null) _instance = new Connection();
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public TcpClient client { get; set; }
|
||||||
|
}
|
||||||
|
}
|
25
src/TCPCommanderXamarin/FunctionsPage.xaml
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
x:Class="TCPCommanderXamarin.FunctionsPage">
|
||||||
|
<ContentPage.Content>
|
||||||
|
<StackLayout>
|
||||||
|
<Button x:Name="Test" Margin ="30, 15, 30, 0" Text="Send / Receive Test" Clicked="Test_Clicked"/>
|
||||||
|
|
||||||
|
<Button x:Name="Ping" Margin ="30, 5, 30, 0" Text="Ping" Clicked="Ping_Clicked"/>
|
||||||
|
|
||||||
|
<Button x:Name="Shutdown" Margin ="30, 5, 30, 0" Text="Shutdown System" Clicked="Shutdown_Clicked"/>
|
||||||
|
|
||||||
|
<Button x:Name="MonitorOn" Margin ="30, 5, 30, 0" Text="Turn Monitor On" Clicked="MonitorOn_Clicked"/>
|
||||||
|
|
||||||
|
<Button x:Name="MonitorOff" Margin ="30, 5, 30, 0" Text="Turn Monitor Off" Clicked="MonitorOff_Clicked"/>
|
||||||
|
|
||||||
|
<Button x:Name="TakeScreenshot" Margin="30, 5, 30, 0" Text="Take Screenshot" Clicked="TakeScreenshot_Clicked"/>
|
||||||
|
|
||||||
|
<Image x:Name="imageView"/>
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage.Content>
|
||||||
|
</ContentPage>
|
253
src/TCPCommanderXamarin/FunctionsPage.xaml.cs
Executable file
@ -0,0 +1,253 @@
|
|||||||
|
using Android;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TCPCommanderXamarin.Droid;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Platform.Android;
|
||||||
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
|
namespace TCPCommanderXamarin
|
||||||
|
{
|
||||||
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
|
public partial class FunctionsPage : ContentPage
|
||||||
|
{
|
||||||
|
public static string storedprivIP;
|
||||||
|
public bool pressedBackButton;
|
||||||
|
|
||||||
|
public FunctionsPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] buffer = new byte[1];
|
||||||
|
protected override void OnAppearing()
|
||||||
|
{
|
||||||
|
base.OnAppearing();
|
||||||
|
NavigationPage.SetHasBackButton(this, false);
|
||||||
|
|
||||||
|
Device.StartTimer(TimeSpan.FromSeconds(1), () =>
|
||||||
|
{
|
||||||
|
if (Connection.Instance.client != null)
|
||||||
|
{
|
||||||
|
if (MainPage.clientIsOpen)
|
||||||
|
{
|
||||||
|
if (Connection.Instance.client.Client.Poll(0, SelectMode.SelectRead))
|
||||||
|
{
|
||||||
|
if (Connection.Instance.client.Client.Receive(buffer, SocketFlags.Peek) == 0)
|
||||||
|
{
|
||||||
|
ClientDisconnected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
Device.StartTimer(TimeSpan.FromMilliseconds(250), () =>
|
||||||
|
{
|
||||||
|
if (pressedBackButton)
|
||||||
|
{
|
||||||
|
BackButtonPressed();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnBackButtonPressed()
|
||||||
|
{
|
||||||
|
pressedBackButton = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void BackButtonPressed()
|
||||||
|
{
|
||||||
|
pressedBackButton = false;
|
||||||
|
bool response = await DisplayAlert("Are You Sure?", "Do you wan't to disconnect and go to the login page?", "YES", "NO");
|
||||||
|
if (response)
|
||||||
|
{
|
||||||
|
Connection.Instance.client.GetStream().Close();
|
||||||
|
Connection.Instance.client.Close();
|
||||||
|
MainPage.clientIsOpen = false;
|
||||||
|
await Navigation.PushAsync(new MainPage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void ClientDisconnected()
|
||||||
|
{
|
||||||
|
Connection.Instance.client.GetStream().Close();
|
||||||
|
Connection.Instance.client.Close();
|
||||||
|
MainPage.clientIsOpen = false;
|
||||||
|
MainPage.lostConnection = true;
|
||||||
|
await Navigation.PushAsync(new MainPage());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Test_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
writeMessage("{TEST}");
|
||||||
|
|
||||||
|
byte[] bytes = getData(Connection.Instance.client);
|
||||||
|
|
||||||
|
string returnMessage = Encoding.ASCII.GetString(bytes);
|
||||||
|
|
||||||
|
if (returnMessage == "{TEST_RESPOND}")
|
||||||
|
{
|
||||||
|
DisplayAlert("Test Successful", "The server received the message and responded", "OK");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void Shutdown_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
bool response = await DisplayAlert("Shutdown System", "Are you sure you want to force shutdown your computer?", "YES", "NO");
|
||||||
|
|
||||||
|
if (response)
|
||||||
|
{
|
||||||
|
writeMessage("{SHUTDOWN}");
|
||||||
|
|
||||||
|
byte[] bytes = getData(Connection.Instance.client);
|
||||||
|
|
||||||
|
string returnMessage = Encoding.ASCII.GetString(bytes);
|
||||||
|
|
||||||
|
if (returnMessage == "{BEGAN_SHUTDOWN}")
|
||||||
|
{
|
||||||
|
await DisplayAlert("Shutdown Successful", "The server has received the message and has begun shutdown", "OK");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MonitorOn_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
writeMessage("{MONITOR_ON}");
|
||||||
|
|
||||||
|
byte[] bytes = getData(Connection.Instance.client);
|
||||||
|
|
||||||
|
string returnMessage = Encoding.ASCII.GetString(bytes);
|
||||||
|
|
||||||
|
if (returnMessage == "{MONITOR_TURNED_ON}")
|
||||||
|
{
|
||||||
|
DisplayAlert("Display Settings", "The server has received the message and has turned the monitor on", "OK");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MonitorOff_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
writeMessage("{MONITOR_OFF}");
|
||||||
|
|
||||||
|
byte[] bytes = getData(Connection.Instance.client);
|
||||||
|
|
||||||
|
string returnMessage = Encoding.ASCII.GetString(bytes);
|
||||||
|
|
||||||
|
if (returnMessage == "{MONITOR_TURNED_OFF}")
|
||||||
|
{
|
||||||
|
DisplayAlert("Display Settings", "The server has received the message and has turned the monitor off", "OK");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TakeScreenshot_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
writeMessage("{TAKE_SCREENSHOT}");
|
||||||
|
|
||||||
|
var data = getData(Connection.Instance.client);
|
||||||
|
imageView.Source = ImageSource.FromStream(() => new MemoryStream(data));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Ping p = new Ping();
|
||||||
|
PingReply reply;
|
||||||
|
private void Ping_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
int pingAmt = 8;
|
||||||
|
int testPing = 1;
|
||||||
|
|
||||||
|
string netInfo = "";
|
||||||
|
do
|
||||||
|
{
|
||||||
|
reply = p.Send(storedprivIP, 1000);
|
||||||
|
|
||||||
|
if (reply != null)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
|
||||||
|
if (i > testPing)
|
||||||
|
{
|
||||||
|
if (i <= pingAmt + 1)
|
||||||
|
{
|
||||||
|
netInfo += "Status : " + reply.Status.ToString() + " Time : " + reply.RoundtripTime + "\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
netInfo += "Status : " + reply.Status + " Time : " + reply.RoundtripTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
while (i <= pingAmt + testPing
|
||||||
|
);
|
||||||
|
|
||||||
|
DisplayAlert("Ping: " + storedprivIP, netInfo, "OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeMessage(string input)
|
||||||
|
{
|
||||||
|
TcpClient client = Connection.Instance.client;
|
||||||
|
NetworkStream ns = client.GetStream();
|
||||||
|
byte[] message = Encoding.ASCII.GetBytes(input);
|
||||||
|
ns.Write(message, 0, message.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getData(TcpClient client)
|
||||||
|
{
|
||||||
|
NetworkStream stream = client.GetStream();
|
||||||
|
byte[] fileSizeBytes = new byte[4];
|
||||||
|
int bytes = stream.Read(fileSizeBytes, 0, fileSizeBytes.Length);
|
||||||
|
int dataLength = BitConverter.ToInt32(fileSizeBytes, 0);
|
||||||
|
|
||||||
|
int bytesLeft = dataLength;
|
||||||
|
byte[] data = new byte[dataLength];
|
||||||
|
|
||||||
|
int buffersize = 1024;
|
||||||
|
int bytesRead = 0;
|
||||||
|
|
||||||
|
while (bytesLeft > 0)
|
||||||
|
{
|
||||||
|
int curDataSize = Math.Min(buffersize, bytesLeft);
|
||||||
|
if (client.Available < curDataSize)
|
||||||
|
{
|
||||||
|
curDataSize = client.Available;
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes = stream.Read(data, bytesRead, curDataSize);
|
||||||
|
bytesRead += curDataSize;
|
||||||
|
bytesLeft -= curDataSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string getBetween(string strSource, string strStart, string strEnd)
|
||||||
|
{
|
||||||
|
int Start, End;
|
||||||
|
if (strSource.Contains(strStart) && strSource.Contains(strEnd))
|
||||||
|
{
|
||||||
|
Start = strSource.IndexOf(strStart, 0) + strStart.Length;
|
||||||
|
End = strSource.IndexOf(strEnd, Start);
|
||||||
|
return strSource.Substring(Start, End - Start);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
src/TCPCommanderXamarin/MainPage.xaml
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
x:Class="TCPCommanderXamarin.MainPage">
|
||||||
|
|
||||||
|
<StackLayout>
|
||||||
|
<!-- Place new controls here -->
|
||||||
|
<Label Text="Connect to Server"
|
||||||
|
FontSize="Medium"
|
||||||
|
HorizontalOptions="Center"
|
||||||
|
Margin="20"/>
|
||||||
|
<Entry x:Name="ipAddress" Placeholder="IP Address" Keyboard="Telephone" TextChanged="IPAddress_OnTextChanged" />
|
||||||
|
<Entry x:Name="Port" Placeholder="Port Number" Keyboard="Telephone" TextChanged="Port_OnTextChanged" />
|
||||||
|
<Button x:Name="connectButton" Text="Connect to Computer" Clicked="Connect_Clicked"/>
|
||||||
|
</StackLayout>
|
||||||
|
|
||||||
|
</ContentPage>
|
238
src/TCPCommanderXamarin/MainPage.xaml.cs
Executable file
@ -0,0 +1,238 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using TCPCommanderXamarin.Droid;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using Plugin.Permissions;
|
||||||
|
using Plugin.Permissions.Abstractions;
|
||||||
|
using Android.Widget;
|
||||||
|
using System.IO;
|
||||||
|
using Android.Runtime;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using System.Net;
|
||||||
|
//using DroidOS = Android.OS;
|
||||||
|
//using Android.OS;
|
||||||
|
//using Android.App;
|
||||||
|
|
||||||
|
namespace TCPCommanderXamarin
|
||||||
|
{
|
||||||
|
// Learn more about making custom code visible in the Xamarin.Forms previewer
|
||||||
|
// by visiting https://aka.ms/xamarinforms-previewer
|
||||||
|
|
||||||
|
public partial class MainPage : ContentPage
|
||||||
|
{
|
||||||
|
public MainPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
||||||
|
string preferencesFile = "/prefs.xml";
|
||||||
|
bool prefsExist;
|
||||||
|
|
||||||
|
StoredData readStoredData;
|
||||||
|
public static bool clientIsOpen;
|
||||||
|
public static bool lostConnection;
|
||||||
|
public bool readFile;
|
||||||
|
protected override void OnAppearing()
|
||||||
|
{
|
||||||
|
base.OnAppearing();
|
||||||
|
if (!readFile)
|
||||||
|
{
|
||||||
|
if (Directory.GetFiles(folderPath).Length > 0)
|
||||||
|
{
|
||||||
|
if (File.Exists(folderPath + preferencesFile))
|
||||||
|
{
|
||||||
|
prefsExist = true;
|
||||||
|
|
||||||
|
XmlSerializer Serializer = new XmlSerializer(typeof(StoredData));
|
||||||
|
FileStream fs = new FileStream(folderPath + preferencesFile, FileMode.Open);
|
||||||
|
|
||||||
|
readStoredData = (StoredData)Serializer.Deserialize(fs);
|
||||||
|
ipAddress.Text = readStoredData.PrivateIPV4;
|
||||||
|
Port.Text = readStoredData.Port;
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lostConnection)
|
||||||
|
{
|
||||||
|
ConnectionLost();
|
||||||
|
}
|
||||||
|
|
||||||
|
NavigationPage.SetHasBackButton(this, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void ConnectionLost()
|
||||||
|
{
|
||||||
|
bool response = await DisplayAlert("Client Disconnected", "The client has lost connection to the server.\nWould you like to reconnect?", "YES", "NO");
|
||||||
|
|
||||||
|
if (response)
|
||||||
|
{
|
||||||
|
client.GetStream().Close();
|
||||||
|
client.Close();
|
||||||
|
Connect_Clicked(new object(), new EventArgs());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void lockButton(bool locked)
|
||||||
|
{
|
||||||
|
|
||||||
|
Device.BeginInvokeOnMainThread(() => { connectButton.IsEnabled = !locked; });
|
||||||
|
}
|
||||||
|
|
||||||
|
int tryConnectTime = 10000;
|
||||||
|
public async Task<TcpClient> tryConnect()
|
||||||
|
{
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
client = new TcpClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
var connectionTask = client.ConnectAsync(ipAddress.Text, Convert.ToInt32(Port.Text)).ContinueWith(task =>
|
||||||
|
{
|
||||||
|
return task.IsFaulted ? null : client;
|
||||||
|
}, TaskContinuationOptions.ExecuteSynchronously);
|
||||||
|
var timeoutTask = Task.Delay(tryConnectTime).ContinueWith<TcpClient>(task => null, TaskContinuationOptions.ExecuteSynchronously);
|
||||||
|
var resultTask = Task.WhenAny(connectionTask, timeoutTask).Unwrap();
|
||||||
|
resultTask.Wait();
|
||||||
|
var resultTcpClient = await resultTask;
|
||||||
|
|
||||||
|
return resultTcpClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MasterConnection()
|
||||||
|
{
|
||||||
|
lockButton(true);
|
||||||
|
client = tryConnect().Result;
|
||||||
|
lockButton(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
TcpClient client = new TcpClient();
|
||||||
|
private async void Connect_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MasterConnection();
|
||||||
|
|
||||||
|
if (client != null)
|
||||||
|
{
|
||||||
|
clientIsOpen = true;
|
||||||
|
Connection.Instance.client = client;
|
||||||
|
NavigationPage.SetHasBackButton(this, false);
|
||||||
|
await Navigation.PushAsync(new FunctionsPage());
|
||||||
|
|
||||||
|
await DisplayAlert("Connected", "Connected to server successfully!", "Ok");
|
||||||
|
FunctionsPage.storedprivIP = ipAddress.Text;
|
||||||
|
|
||||||
|
if (!prefsExist || ipAddress.Text != readStoredData.PrivateIPV4 || Port.Text != readStoredData.Port)
|
||||||
|
{
|
||||||
|
XmlSerializer Serializer = new XmlSerializer(typeof(StoredData));
|
||||||
|
StoredData SD = new StoredData();
|
||||||
|
SD.PrivateIPV4 = ipAddress.Text;
|
||||||
|
SD.Port = Port.Text;
|
||||||
|
|
||||||
|
TextWriter Writer = new StreamWriter(folderPath + preferencesFile);
|
||||||
|
Serializer.Serialize(Writer, SD);
|
||||||
|
Writer.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await DisplayAlert("Connection Unsuccessful", "Could not connect to the server!", "Ok");
|
||||||
|
clientIsOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await DisplayAlert("Error", "" + ex.ToString(), "Ok");
|
||||||
|
clientIsOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ipAddressIgnoreChange;
|
||||||
|
private void IPAddress_OnTextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (ipAddressIgnoreChange)
|
||||||
|
{
|
||||||
|
ipAddressIgnoreChange = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (Regex.IsMatch(ipAddress.Text, @"[^0-9.]"))
|
||||||
|
{
|
||||||
|
ipAddress.Text = Regex.Replace(ipAddress.Text, @"[^0-9.]", string.Empty);
|
||||||
|
ipAddressIgnoreChange = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ipAddress.Text.Contains(".."))
|
||||||
|
{
|
||||||
|
ipAddress.Text = ipAddress.Text.Replace("..", ".");
|
||||||
|
ipAddressIgnoreChange = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool portIgnoreChange;
|
||||||
|
private void Port_OnTextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (portIgnoreChange)
|
||||||
|
{
|
||||||
|
portIgnoreChange = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (Regex.IsMatch(Port.Text, @"[^0-9]"))
|
||||||
|
{
|
||||||
|
Port.Text = Regex.Replace(Port.Text, @"[^0-9]", string.Empty);
|
||||||
|
portIgnoreChange = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class StoredData
|
||||||
|
{
|
||||||
|
public string PrivateIPV4;
|
||||||
|
public string Port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class StringFunctions
|
||||||
|
{
|
||||||
|
public static string RemoveLetters(this string str)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 0; i < str.Length; i++)
|
||||||
|
{
|
||||||
|
if ((str[i] >= 'a' && str[i] <= 'A') || (str[i] >= 'z' && str[i] <= 'Z'))
|
||||||
|
{
|
||||||
|
sb.Append(str[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string RemoveSpecialChars(this string str)
|
||||||
|
{
|
||||||
|
string[] chars = new string[] { ",", ".", "/", "!", "@", "#", "$", "%", "^", "&", "*", "'", "\"", ";", "_", "(", ")", ":", "|", "[", "]" };
|
||||||
|
for (int i = 0; i < chars.Length; i++)
|
||||||
|
{
|
||||||
|
if (str.Contains(chars[i]))
|
||||||
|
{
|
||||||
|
str = str.Replace(chars[i], "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
src/TCPCommanderXamarin/Properties/launchSettings.json
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"TCPCommanderXamarin": {
|
||||||
|
"commandName": "Executable"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
src/TCPCommanderXamarin/TCPCommanderXamarin.csproj
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||||
|
<AssemblyName>TCPCommanderXamarin</AssemblyName>
|
||||||
|
<RootNamespace>TCPCommanderXamarin</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Plugin.Permissions" Version="3.0.0.12" />
|
||||||
|
<PackageReference Include="Xamarin.Forms" Version="4.2.0.709249" />
|
||||||
|
<PackageReference Include="Xamarin.Essentials" Version="1.2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Mono.Android">
|
||||||
|
<HintPath>..\..\..\Visual Studio\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v9.0\Mono.Android.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Xamarin.Android.Support.Compat">
|
||||||
|
<HintPath>C:\Microsoft\Xamarin\NuGet\xamarin.android.support.compat\28.0.0.1\lib\monoandroid90\Xamarin.Android.Support.Compat.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Xamarin.Forms.Platform.Android">
|
||||||
|
<HintPath>C:\Microsoft\Xamarin\NuGet\xamarin.forms\4.2.0.709249\lib\MonoAndroid90\Xamarin.Forms.Platform.Android.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Update="FunctionsPage.xaml">
|
||||||
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|