Merge branch 'develop' of github.com:Vocaluxe/Vocaluxe into develop

This commit is contained in:
Florian Küpper committed 2013-05-07 11:41:08 +02:00
commit 94e3652db0
132 files changed
+6993 -505

No files matched your search

+13
View File
@@ -39,3 +39,16 @@ Output/Songs
*.Cache
/GstreamerHelper/bin/*
/VocaluxeLib/bin
/ClientServerLib/ClientServerLib/ClientServerLib.csproj.user
/ClientServerLib/ClientServerLib/bin/Debug/ClientServerLib.dll
/ClientServerLib/ClientTest/bin/Debug/ClientServerLib.dll
/ClientServerLib/ClientTest/bin/Release/ClientServerLib.dll
/ClientServerLib/ClientServerLib/bin/ClientServerLib.dll
ClientTest.exe
*.vshost.*
*.userprefs
AndroidRemote.dll.mdb
/ClientServerLib/AndroidRemote/bin/Newtonsoft.Json.MonoDroid.dll
/ClientServerLib/AndroidRemote/bin/AndroidRemote.dll
/ClientServerLib/ClientTest/bin/Debug/Newtonsoft.Json.dll
*.apk
+20
View File
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndroidRemote", "AndroidRemote\AndroidRemote.csproj", "{D97EF6F3-7C3F-439F-B022-647948E206D2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D97EF6F3-7C3F-439F-B022-647948E206D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D97EF6F3-7C3F-439F-B022-647948E206D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D97EF6F3-7C3F-439F-B022-647948E206D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D97EF6F3-7C3F-439F-B022-647948E206D2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = AndroidRemote.csproj
EndGlobalSection
EndGlobal
@@ -0,0 +1,94 @@
<?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>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D97EF6F3-7C3F-439F-B022-647948E206D2}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>AndroidRemote</RootNamespace>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AssemblyName>AndroidRemote</AssemblyName>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;MONO</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<ConsolePause>false</ConsolePause>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<DefineConstants>MONO</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Mono.Android" />
<Reference Include="Newtonsoft.Json.MonoDroid">
<HintPath>Newtonsoft.Json.MonoDroid.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="..\ClientServerLib\CClient.cs">
<Link>ClientServerLib\CClient.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\CConnection.cs">
<Link>ClientServerLib\CConnection.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\Structs.cs">
<Link>ClientServerLib\Structs.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\DeffieHellman\BigInt.cs">
<Link>ClientServerLib\DeffieHellman\BigInt.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\DeffieHellman\DeffieHellman.cs">
<Link>ClientServerLib\DeffieHellman\DeffieHellman.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\DeffieHellman\StrongNumberProvider.cs">
<Link>ClientServerLib\DeffieHellman\StrongNumberProvider.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\Vocaluxe\CCommands.cs">
<Link>ClientServerLib\Vocaluxe\CCommands.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\Vocaluxe\VocaluxeStructs.cs">
<Link>ClientServerLib\Vocaluxe\VocaluxeStructs.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="Resources\AboutResources.txt" />
<None Include="Properties\AndroidManifest.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\Main.axml" />
<AndroidResource Include="Resources\values\Strings.xml" />
<AndroidResource Include="Resources\drawable\Icon.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
<ItemGroup>
<Folder Include="ClientServerLib\" />
<Folder Include="Assets\" />
</ItemGroup>
</Project>
@@ -0,0 +1,237 @@
using System;
using System.Collections.Generic;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Graphics;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Provider;
using ClientServerLib;
using Vocaluxe.Base.Server;
namespace AndroidRemote
{
[Activity (Label = "Vocaluxe Remote", MainLauncher = true)]
public class Activity1 : Activity
{
CClient client = new CClient();
Button bConnect;
Button bLogin;
Button bUp;
Button bDown;
Button bSendAvatar;
bool loggedIn;
byte[] fileBytes;
ImageView imageView;
Java.IO.File file;
Java.IO.File dir;
System.IO.FileStream fs;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
loggedIn = false;
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
bConnect = FindViewById<Button> (Resource.Id.btConnect);
bConnect.Click += delegate { Connect(); };
bLogin = FindViewById<Button> (Resource.Id.btLogin);
bLogin.Click += delegate { Login(); };
bUp = FindViewById<Button> (Resource.Id.btUp);
bUp.Click += delegate {
client.SendMessage (CCommands.CreateCommandWithoutParams (CCommands.CommandSendKeyUp), OnResponse);
};
bDown = FindViewById<Button> (Resource.Id.btDown);
bDown.Click += delegate {
client.SendMessage (CCommands.CreateCommandWithoutParams (CCommands.CommandSendKeyDown), OnResponse);
};
imageView = FindViewById<ImageView>(Resource.Id.imageView1);
bSendAvatar = FindViewById<Button> (Resource.Id.btSendAvatar);
bSendAvatar.Click += SendAvatar;
}
protected override void OnStop ()
{
base.OnStop();
//client.Close();
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
// make it available in the gallery
Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
Android.Net.Uri contentUri = Android.Net.Uri.FromFile(file);
mediaScanIntent.SetData(contentUri);
SendBroadcast(mediaScanIntent);
System.IO.FileInfo fi = new System.IO.FileInfo(file.Path);
fs = new System.IO.FileStream(file.Path, System.IO.FileMode.Open);
fileBytes = new byte[fi.Length];
fs.BeginRead (fileBytes, 0, (int)fi.Length, new AsyncCallback(OnFileRead), null);
}
private void OnFileRead(IAsyncResult ar)
{
if (fileBytes == null)
return;
fs.Flush();
fs.Close();
client.SendMessage (CCommands.CreateCommandSendAvatarPictureJpg(fileBytes), OnResponse);
}
private bool IsThereAnAppToTakePictures()
{
Intent intent = new Intent(MediaStore.ActionImageCapture);
IList<ResolveInfo> availableActivities = PackageManager.QueryIntentActivities(intent, PackageInfoFlags.MatchDefaultOnly);
return availableActivities != null && availableActivities.Count > 0;
}
private void SendAvatar(object sender, EventArgs eventArgs)
{
if (!IsThereAnAppToTakePictures())
return;
Intent intent = new Intent(MediaStore.ActionImageCapture);
dir = new Java.IO.File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), "AndroidRemote");
if (dir.Exists())
{
dir.Mkdirs();
}
file = new Java.IO.File(dir, String.Format("myPhoto_{0}.jpg", Guid.NewGuid()));
intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(file));
StartActivityForResult(intent, 0);
}
private void Connect()
{
if (!client.Connected)
client.Connect("192.168.178.57", 3000, OnConnectionChanged);
else
client.Disconnect();
}
private void Login()
{
if (!loggedIn)
client.SendMessage (CCommands.CreateCommandLogin("vocaluxe"), OnResponse);
else
client.Disconnect();
}
private void OnConnectionChanged(bool Connected)
{
RunOnUiThread (() => UpdateConnectionStatus(Connected));
}
private void OnResponse(byte[] Message)
{
if (Message == null)
return;
if (Message.Length < 4)
return;
int command = BitConverter.ToInt32(Message, 0);
switch (command)
{
case CCommands.ResponseLoginFailed:
RunOnUiThread (() => Toast.MakeText(this, "Login Failed", ToastLength.Short).Show());
break;
case CCommands.ResponseLoginWrongPassword:
RunOnUiThread (() => Toast.MakeText(this, "Wrong Password", ToastLength.Short).Show());
break;
case CCommands.ResponseLoginOK:
RunOnUiThread (() => UpdateLoginStatus(true));
break;
default:
break;
}
}
private void UpdateConnectionStatus(bool Connected)
{
if (Connected)
{
bLogin.Enabled = true;
bConnect.Text = Resources.GetString(Resource.String.button_disconnect);
Toast.MakeText(this, Resource.String.message_connected, ToastLength.Short).Show();
}
else
{
client.Disconnect();
bLogin.Enabled = false;
bLogin.Text = Resources.GetString(Resource.String.button_login);
bConnect.Text = Resources.GetString(Resource.String.button_connect);
bUp.Enabled = false;
bDown.Enabled = false;
Toast.MakeText(this, Resources.GetString(Resource.String.message_disconnected), ToastLength.Short).Show();
}
}
private void UpdateLoginStatus(bool LoggedIn)
{
loggedIn = LoggedIn;
if (LoggedIn)
{
bUp.Enabled = LoggedIn;
bDown.Enabled = LoggedIn;
bLogin.Text = Resources.GetString(Resource.String.button_logout);
Toast.MakeText(this, "Logged In", ToastLength.Short).Show();
}
else
Toast.MakeText(this, "Not Logged In", ToastLength.Short).Show();
}
}
public static class BitmapHelpers
{
public static Bitmap LoadAndResizeBitmap(this string fileName, int width, int height)
{
// First we get the the dimensions of the file on disk
BitmapFactory.Options options = new BitmapFactory.Options { InJustDecodeBounds = true };
BitmapFactory.DecodeFile(fileName, options);
// Next we calculate the ratio that we need to resize the image by
// in order to fit the requested dimensions.
int outHeight = options.OutHeight;
int outWidth = options.OutWidth;
int inSampleSize = 1;
if (outHeight > height || outWidth > width)
{
inSampleSize = outWidth > outHeight
? outHeight / height
: outWidth / width;
}
// Now we will load the image and have BitmapFactory resize it for us.
options.InSampleSize = inSampleSize;
options.InJustDecodeBounds = false;
Bitmap resizedBitmap = BitmapFactory.DecodeFile(fileName, options);
return resizedBitmap;
}
}
}
@@ -0,0 +1,7 @@
<?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="AndroidRemote.AndroidRemote">
<uses-sdk />
<application android:label="AndroidRemote" android:icon="@drawable/icon"></application>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
@@ -0,0 +1,28 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using Android.App;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("AndroidRemote")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Alex")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
@@ -0,0 +1,44 @@
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.axml),
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/
icon.png
layout/
main.axml
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 "R"
(this is an Android convention) that contains the tokens for each one of the resources
included. For example, for the above Resources layout, this is what the R class would expose:
public class R {
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 R.layout.main
to reference the layout/main.axml file, or R.strings.first_string to reference the first
string in the dictionary file values/strings.xml.
@@ -0,0 +1,203 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.18034
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
[assembly: global::Android.Runtime.ResourceDesignerAttribute("AndroidRemote.Resource", IsApplication=true)]
namespace AndroidRemote
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
public partial class Resource
{
static Resource()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
public static void UpdateIdValues()
{
}
public partial class Attribute
{
static Attribute()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Attribute()
{
}
}
public partial class Drawable
{
// aapt resource value: 0x7f020000
public const int Icon = 2130837504;
// aapt resource value: 0x7f020001
public const int monoandroidsplash = 2130837505;
static Drawable()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Drawable()
{
}
}
public partial class Id
{
// aapt resource value: 0x7f060002
public const int btConnect = 2131099650;
// aapt resource value: 0x7f060007
public const int btDown = 2131099655;
// aapt resource value: 0x7f060005
public const int btLogin = 2131099653;
// aapt resource value: 0x7f060008
public const int btSendAvatar = 2131099656;
// aapt resource value: 0x7f060006
public const int btUp = 2131099654;
// aapt resource value: 0x7f060009
public const int imageView1 = 2131099657;
// aapt resource value: 0x7f060001
public const int tbIP = 2131099649;
// aapt resource value: 0x7f060004
public const int tbPassword = 2131099652;
// aapt resource value: 0x7f060000
public const int textView1 = 2131099648;
// aapt resource value: 0x7f060003
public const int textView2 = 2131099651;
static Id()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Id()
{
}
}
public partial class Layout
{
// aapt resource value: 0x7f030000
public const int Main = 2130903040;
// aapt resource value: 0x7f030001
public const int monoandroidsplash = 2130903041;
static Layout()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Layout()
{
}
}
public partial class String
{
// aapt resource value: 0x7f040000
public const int app_name = 2130968576;
// aapt resource value: 0x7f040001
public const int button_connect = 2130968577;
// aapt resource value: 0x7f040002
public const int button_disconnect = 2130968578;
// aapt resource value: 0x7f040006
public const int button_down = 2130968582;
// aapt resource value: 0x7f040003
public const int button_login = 2130968579;
// aapt resource value: 0x7f040004
public const int button_logout = 2130968580;
// aapt resource value: 0x7f040007
public const int button_send_avatar = 2130968583;
// aapt resource value: 0x7f040005
public const int button_up = 2130968581;
// aapt resource value: 0x7f04000e
public const int ip_address = 2130968590;
// aapt resource value: 0x7f040008
public const int message_connected = 2130968584;
// aapt resource value: 0x7f040009
public const int message_disconnected = 2130968585;
// aapt resource value: 0x7f04000a
public const int message_logged_in = 2130968586;
// aapt resource value: 0x7f04000b
public const int message_logged_out = 2130968587;
// aapt resource value: 0x7f04000f
public const int password = 2130968591;
// aapt resource value: 0x7f04000c
public const int text_ip_address = 2130968588;
// aapt resource value: 0x7f04000d
public const int text_password = 2130968589;
static String()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private String()
{
}
}
public partial class Style
{
// aapt resource value: 0x7f050000
public const int Mono_Android_Theme_Splash = 2131034112;
static Style()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Style()
{
}
}
}
}
#pragma warning restore 1591
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:text="@string/text_ip_address"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:linksClickable="false" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tbIP"
android:text="@string/ip_address" />
<Button
android:text="@string/button_connect"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/btConnect" />
<TextView
android:text="@string/text_password"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/textView2" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/tbPassword"
android:text="@string/password" />
<Button
android:text="@string/button_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/btLogin"
android:enabled="false" />
<Button
android:text="@string/button_up"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/btUp"
android:enabled="false" />
<Button
android:text="@string/button_down"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/btDown"
android:enabled="false" />
<Button
android:text="@string/button_send_avatar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/btSendAvatar"
android:enabled="true" />
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="@+id/imageView1" />
</LinearLayout>
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">AndroidRemote</string>
<string name="button_connect">Connect</string>
<string name="button_disconnect">Disconnect</string>
<string name="button_login">Login</string>
<string name="button_logout">Logout</string>
<string name="button_up">Up</string>
<string name="button_down">Down</string>
<string name="button_send_avatar">Send Avatar Picture</string>
<string name="message_connected">Connected</string>
<string name="message_disconnected">Disconnected</string>
<string name="message_logged_in">Logged in</string>
<string name="message_logged_out">Logged out</string>
<string name="text_ip_address">IP Address of Vocaluxe Server:</string>
<string name="text_password">Password:</string>
<string name="ip_address">192.168.178.57</string>
<string name="password">vocaluxe</string>
</resources>
+42
View File
@@ -0,0 +1,42 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C# Express 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientServerLib", "ClientServerLib\ClientServerLib.csproj", "{EC5167E4-CCFB-4CEE-987C-CF816F1062A3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientTest", "ClientTest\ClientTest.csproj", "{48A825C6-728F-4EBF-B98E-3D4665B3BC9E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EC5167E4-CCFB-4CEE-987C-CF816F1062A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC5167E4-CCFB-4CEE-987C-CF816F1062A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC5167E4-CCFB-4CEE-987C-CF816F1062A3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{EC5167E4-CCFB-4CEE-987C-CF816F1062A3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{EC5167E4-CCFB-4CEE-987C-CF816F1062A3}.Debug|x86.ActiveCfg = Debug|Any CPU
{EC5167E4-CCFB-4CEE-987C-CF816F1062A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC5167E4-CCFB-4CEE-987C-CF816F1062A3}.Release|Any CPU.Build.0 = Release|Any CPU
{EC5167E4-CCFB-4CEE-987C-CF816F1062A3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{EC5167E4-CCFB-4CEE-987C-CF816F1062A3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{EC5167E4-CCFB-4CEE-987C-CF816F1062A3}.Release|x86.ActiveCfg = Release|Any CPU
{48A825C6-728F-4EBF-B98E-3D4665B3BC9E}.Debug|Any CPU.ActiveCfg = Debug|x86
{48A825C6-728F-4EBF-B98E-3D4665B3BC9E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{48A825C6-728F-4EBF-B98E-3D4665B3BC9E}.Debug|Mixed Platforms.Build.0 = Debug|x86
{48A825C6-728F-4EBF-B98E-3D4665B3BC9E}.Debug|x86.ActiveCfg = Debug|x86
{48A825C6-728F-4EBF-B98E-3D4665B3BC9E}.Debug|x86.Build.0 = Debug|x86
{48A825C6-728F-4EBF-B98E-3D4665B3BC9E}.Release|Any CPU.ActiveCfg = Release|x86
{48A825C6-728F-4EBF-B98E-3D4665B3BC9E}.Release|Mixed Platforms.ActiveCfg = Release|x86
{48A825C6-728F-4EBF-B98E-3D4665B3BC9E}.Release|Mixed Platforms.Build.0 = Release|x86
{48A825C6-728F-4EBF-B98E-3D4665B3BC9E}.Release|x86.ActiveCfg = Release|x86
{48A825C6-728F-4EBF-B98E-3D4665B3BC9E}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
+327
View File
@@ -0,0 +1,327 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace ClientServerLib
{
public class CClient
{
private bool doConnect;
private bool connected;
private bool running;
private int bufferLength = 8192;
private Thread clientThread;
private IPEndPoint serverEndPoint;
private string ip;
private int port;
private CConnection connection;
private List<SRequest> requests;
private List<SRequest> responses;
private Object mutexRequests = new Object();
private OnConnectionChanged onConnectionChanged;
private OnSend onSend;
private OnReceived onReceived;
public bool Connected
{
get { return connected; }
}
public CClient()
{
doConnect = false;
connected = false;
running = true;
requests = new List<SRequest>();
responses = new List<SRequest>();
connection = new CConnection(new TcpClient(), -1);
clientThread = new Thread(new ThreadStart(Runner));
clientThread.Start();
}
public void Connect(string IP = "127.0.0.1", int Port = 3000,
OnConnectionChanged OnConnectionChanged = null,
OnSend OnSend = null,
OnReceived OnReceived = null)
{
if (!doConnect)
{
onConnectionChanged = OnConnectionChanged;
onSend = OnSend;
onReceived = OnReceived;
ip = IP;
port = Port;
doConnect = true;
}
}
public void Disconnect()
{
if (doConnect)
{
doConnect = false;
lock (mutexRequests)
{
requests.Clear();
}
lock (responses)
{
responses.Clear();
}
}
}
public void Close()
{
Disconnect();
running = false;
clientThread.Join(100);
}
public void SendMessage(byte[] Message, ResponseCallback Callback)
{
SRequest req = new SRequest();
req.Command = Message;
req.Callback = Callback;
req.Response = null;
lock (mutexRequests)
{
requests.Add(req);
}
}
private void Runner()
{
while (running)
{
if (!connected && doConnect)
{
try
{
serverEndPoint = new IPEndPoint(IPAddress.Parse(ip), port);
connection.TcpClient.Connect(serverEndPoint);
connected = true;
RaiseOnConnectionChanged();
}
catch
{
connected = false;
RaiseOnConnectionChanged();
for (int i = 0; i < 500; i++)
{
if (doConnect)
Thread.Sleep(10);
else
break;
}
}
}
if (connected && !doConnect)
{
try
{
connection.TcpClient.Close();
connection = new CConnection(new TcpClient(), -1);
}
catch
{
}
connected = false;
RaiseOnConnectionChanged();
}
if (doConnect && connected)
{
try
{
Communicate();
}
catch
{
connected = false;
RaiseOnConnectionChanged();
}
}
}
}
private void Communicate()
{
NetworkStream clientStream = connection.TcpClient.GetStream();
byte[] data = new byte[bufferLength];
int bytesRead;
if (!connection.KeySet)
{
bytesRead = 0;
try
{
bytesRead = clientStream.Read(data, 0, bufferLength);
}
catch
{
return;
}
if (bytesRead == 0)
return;
byte[] serverParam = new byte[bytesRead];
Array.Copy(data, serverParam, bytesRead);
RaiseOnReceived(serverParam);
byte[] clientResponse = connection.CreateClientKey(serverParam);
RaiseOnSend(clientResponse);
clientStream.Write(clientResponse, 0, clientResponse.Length);
clientStream.Flush();
}
else
{
try
{
while (requests.Count > 0)
{
SRequest res = HandleRequest(requests[0]);
lock (responses)
{
responses.Add(res);
}
lock (mutexRequests)
{
requests.RemoveAt(0);
}
}
}
catch { };
lock (responses)
{
while (responses.Count > 0)
{
try
{
if (responses[0].Callback != null)
responses[0].Callback(responses[0].Response);
}
finally
{
responses.RemoveAt(0);
}
}
}
}
}
private SRequest HandleRequest(SRequest request)
{
SRequest response = new SRequest();
response.Command = request.Command;
response.Callback = request.Callback;
response.Response = null;
NetworkStream clientStream = connection.TcpClient.GetStream();
RaiseOnSend(request.Command);
byte[] encrypted = connection.Encrypt(request.Command);
int sendBytes = 0;
while(sendBytes < encrypted.Length)
{
int bytesToSend = encrypted.Length - sendBytes;
if (bytesToSend > bufferLength)
bytesToSend = bufferLength;
clientStream.Write(encrypted, sendBytes, bytesToSend);
sendBytes += bytesToSend;
}
clientStream.Flush();
byte[] data = new byte[bufferLength];
int bytesRead = 0;
try
{
bytesRead = clientStream.Read(data, 0, bufferLength);
}
catch
{
return response;
}
if (bytesRead == 0)
return response;
int messageLength = BitConverter.ToInt32(data, 0);
while (messageLength > bytesRead)
{
if (data.Length < messageLength + bufferLength)
Array.Resize<byte>(ref data, messageLength + bufferLength);
bytesRead += clientStream.Read(data, bytesRead, bufferLength);
}
encrypted = new byte[bytesRead];
Array.Copy(data, encrypted, bytesRead);
response.Response = connection.Decrypt(encrypted);
RaiseOnReceived(response.Response);
return response;
}
private void RaiseOnConnectionChanged()
{
if (onConnectionChanged == null)
return;
try
{
onConnectionChanged(connected);
}
catch {}
}
private void RaiseOnSend(byte[] Message)
{
if (onSend == null)
return;
try
{
onSend(Message);
}
catch { }
}
private void RaiseOnReceived(byte[] Message)
{
if (onReceived == null)
return;
try
{
onReceived(Message);
}
catch { }
}
}
}
@@ -0,0 +1,153 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using DiffieHellman;
namespace ClientServerLib
{
internal class CConnection
{
private bool keySet;
private CDiffieHellman dh;
private UTF8Encoding encoder;
private int connectionID;
public TcpClient TcpClient;
public bool KeySet
{
get { return keySet; }
}
public int ConnectionID
{
get { return connectionID; }
}
public CConnection(TcpClient client, int ConnectionID)
{
TcpClient = client;
client.NoDelay = true;
keySet = false;
connectionID = ConnectionID;
encoder = new UTF8Encoding();
}
public byte[] GetKeyParams()
{
if (dh == null)
dh = new CDiffieHellman(256).GenerateRequest();
return encoder.GetBytes(dh.ToString());
}
public byte[] CreateClientKey(byte[] serverParam)
{
if (serverParam == null)
return null;
dh = new CDiffieHellman(256).GenerateResponse(
encoder.GetString(serverParam, 0, serverParam.Length));
keySet = true;
return encoder.GetBytes(dh.ToString());
}
public void CreateServerKey(byte[] clientResponse)
{
if (dh == null)
return;
dh.HandleResponse(encoder.GetString(clientResponse, 0, clientResponse.Length));
keySet = true;
}
public byte[] Encrypt(byte[] Data)
{
if (Data == null || !keySet)
return Data;
using (Aes aes = new AesManaged())
{
aes.Key = dh.Key;
aes.GenerateIV();
byte[] dataLength = BitConverter.GetBytes(Data.Length);
using (var encryptor = aes.CreateEncryptor(aes.Key, aes.IV))
using (var memoryStream = new MemoryStream())
using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
{
cryptoStream.Write(Data, 0, Data.Length);
cryptoStream.FlushFinalBlock();
byte[] encrypted = memoryStream.ToArray();
int len = 4 + aes.IV.Length + dataLength.Length + encrypted.Length;
byte[] messageLength = BitConverter.GetBytes(len);
MemoryStream stream = new MemoryStream();
stream.Write(messageLength, 0, messageLength.Length);
stream.Write(aes.IV, 0, aes.IV.Length);
stream.Write(dataLength, 0, dataLength.Length);
stream.Write(encrypted, 0, encrypted.Length);
return stream.ToArray();
}
}
}
public byte[] Decrypt(byte[] Data)
{
if (Data == null || !keySet)
return Data;
if (Data.Length < 25)
return null;
int messageLength = BitConverter.ToInt32(Data, 0);
if (messageLength > Data.Length)
return null;
byte[] IV = new byte[16];
Array.Copy(Data, 4, IV, 0, 16);
int dataLength = BitConverter.ToInt32(Data, 20);
using (Aes aes = new AesManaged())
{
aes.Key = dh.Key;
aes.IV = IV;
byte[] encrypted = new byte[messageLength - 24];
Array.Copy(Data, 24, encrypted, 0, encrypted.Length);
try
{
using (var decryptor = aes.CreateDecryptor(aes.Key, aes.IV))
using (var memoryStream = new MemoryStream())
using (var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Write))
{
cryptoStream.Write(encrypted, 0, encrypted.Length);
cryptoStream.FlushFinalBlock();
cryptoStream.Close();
byte[] decrypted = memoryStream.ToArray();
byte[] message = new byte[dataLength];
Array.Copy(decrypted, message, dataLength);
return message;
}
}
catch
{
return null;
}
}
}
}
}
+174
View File
@@ -0,0 +1,174 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace ClientServerLib
{
public class CServer
{
private TcpListener tcpListener;
private Thread listenThread;
private int port;
private int bufferLength = 8192;
private bool running;
private HandleRequest requestCallback;
private Dictionary<int, CConnection> clients;
private Queue<int> ids;
public CServer(HandleRequest RequestCallback, int Port = 3000)
{
port = Port;
running = false;
requestCallback = RequestCallback;
clients = new Dictionary<int, CConnection>();
ids = new Queue<int>(1000);
for (int i = 0; i < 1000; i++)
ids.Enqueue(i);
}
public void Start()
{
if (!running)
{
running = true;
tcpListener = new TcpListener(IPAddress.Any, port);
listenThread = new Thread(new ThreadStart(ListenForClients));
listenThread.Start();
}
}
public void Stop()
{
if (running)
{
running = false;
tcpListener.Stop();
Thread.Sleep(100);
listenThread.Join();
lock (clients)
{
int[] cIDs = new int[clients.Count];
clients.Keys.CopyTo(cIDs, 0);
foreach (int id in cIDs)
{
clients.Remove(id);
ids.Enqueue(id);
}
}
}
}
private void ListenForClients()
{
tcpListener.Start();
TcpClient client;
while (running)
{
//wait for new client
try
{
client = tcpListener.AcceptTcpClient();
}
catch
{
client = null;
}
if (client != null)
{
int id = ids.Dequeue();
CConnection connection = new CConnection(client, id);
lock (clients)
{
clients.Add(id, connection);
}
Thread clientThread = new Thread(new ParameterizedThreadStart(HandleClientCom));
NetworkStream clientStream = client.GetStream();
byte[] serverParams = connection.GetKeyParams();
clientStream.Write(serverParams, 0, serverParams.Length);
clientStream.Flush();
clientThread.Start(connection);
}
}
}
private void HandleClientCom(object client)
{
CConnection connection = (CConnection)client;
TcpClient tcpClient = (TcpClient)connection.TcpClient;
NetworkStream clientStream = tcpClient.GetStream();
byte[] data = new byte[bufferLength];
int bytesRead;
while (running)
{
bytesRead = 0;
try
{
bytesRead = clientStream.Read(data, 0, bufferLength);
}
catch
{
break;
}
if (bytesRead == 0)
break;
if (!connection.KeySet)
{
byte[] clientResponse = new byte[bytesRead];
Array.Copy(data, clientResponse, bytesRead);
connection.CreateServerKey(clientResponse);
}
else
{
//receive message
int messageLength = BitConverter.ToInt32(data, 0);
while (messageLength > bytesRead)
{
if (data.Length < messageLength + bufferLength)
Array.Resize<byte>(ref data, messageLength + bufferLength);
bytesRead += clientStream.Read(data, bytesRead, bufferLength);
}
byte[] message = new byte[bytesRead];
Array.Copy(data, message, bytesRead);
byte[] decrypted = connection.Decrypt(message);
byte[] answer = HandleClientMessage(decrypted, connection);
//send message
byte[] encrypted = connection.Encrypt(answer);
clientStream.Write(encrypted, 0, encrypted.Length);
clientStream.Flush();
}
}
}
private byte[] HandleClientMessage(byte[] Message, CConnection connection)
{
return requestCallback(connection.ConnectionID, Message);
}
}
}
@@ -0,0 +1,66 @@
<?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)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{EC5167E4-CCFB-4CEE-987C-CF816F1062A3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ClientServerLib</RootNamespace>
<AssemblyName>ClientServerLib</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CClient.cs" />
<Compile Include="CConnection.cs" />
<Compile Include="CServer.cs" />
<Compile Include="DeffieHellman\BigInt.cs" />
<Compile Include="DeffieHellman\DeffieHellman.cs" />
<Compile Include="DeffieHellman\StrongNumberProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Structs.cs" />
<Compile Include="Vocaluxe\CCommands.cs" />
<Compile Include="Vocaluxe\VocaluxeStructs.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,178 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
namespace DiffieHellman
{
/// <summary>
/// Represents the Diffie-Hellman algorithm.
/// </summary>
public class CDiffieHellman : IDisposable
{
#region - Util -
static StrongNumberProvider _strongRng = new StrongNumberProvider();
#endregion
#region - Fields -
/// <summary>
/// The number of bits to generate.
/// </summary>
private int bits = 256;
/// <summary>
/// The shared prime.
/// </summary>
BigInteger prime;
/// <summary>
/// The shared base.
/// </summary>
BigInteger g;
/// <summary>
/// The private prime.
/// </summary>
BigInteger mine;
/// <summary>
/// The final key.
/// </summary>
byte[] key;
/// <summary>
/// The string representation/packet.
/// </summary>
string representation;
#endregion
#region - Properties -
/// <summary>
/// Gets the final key to use for encryption.
/// </summary>
public byte[] Key
{
get { return key; }
}
#endregion
#region - Ctor -
public CDiffieHellman()
{
}
public CDiffieHellman(int bits)
{
this.bits = bits;
}
~CDiffieHellman()
{
Dispose();
}
#endregion
#region - Implementation Methods -
#region Flow
/// <summary>
/// Generates a request packet.
/// </summary>
/// <returns></returns>
public CDiffieHellman GenerateRequest()
{
// Generate the parameters.
prime = BigInteger.GenPseudoPrime(bits, 30, _strongRng);
mine = BigInteger.GenPseudoPrime(bits, 30, _strongRng);
g = (BigInteger)5;
// Gemerate the string.
StringBuilder rep = new StringBuilder();
rep.Append(prime.ToString(36));
rep.Append("|");
rep.Append(g.ToString(36));
rep.Append("|");
// Generate the send BigInt.
using (BigInteger send = g.ModPow(mine, prime))
{
rep.Append(send.ToString(36));
}
representation = rep.ToString();
return this;
}
/// <summary>
/// Generate a response packet.
/// </summary>
/// <param name="request">The string representation of the request.</param>
/// <returns></returns>
public CDiffieHellman GenerateResponse(string request)
{
string[] parts = request.Split('|');
// Generate the would-be fields.
using (BigInteger prime = new BigInteger(parts[0], 36))
using (BigInteger g = new BigInteger(parts[1], 36))
using (BigInteger mine = BigInteger.GenPseudoPrime(bits, 30, _strongRng))
{
// Generate the key.
using (BigInteger given = new BigInteger(parts[2], 36))
using (BigInteger key = given.ModPow(mine, prime))
{
this.key = key.GetBytes();
}
// Generate the response.
using (BigInteger send = g.ModPow(mine, prime))
{
this.representation = send.ToString(36);
}
}
return this;
}
/// <summary>
/// Generates the key after a response is received.
/// </summary>
/// <param name="response">The string representation of the response.</param>
public void HandleResponse(string response)
{
// Get the response and modpow it with the stored prime.
using (BigInteger given = new BigInteger(response, 36))
using (BigInteger key = given.ModPow(mine, prime))
{
this.key = key.GetBytes();
}
Dispose();
}
#endregion
public override string ToString()
{
return representation;
}
#endregion
#region IDisposable Members
/// <summary>
/// Ends the calculation. The key will still be available.
/// </summary>
public void Dispose()
{
if (!Object.ReferenceEquals(prime, null))
prime.Dispose();
if (!Object.ReferenceEquals(mine, null))
mine.Dispose();
if (!Object.ReferenceEquals(g, null))
g.Dispose();
prime = null;
mine = null;
g = null;
representation = null;
GC.Collect();
GC.Collect();
}
#endregion
}
}
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
namespace DiffieHellman
{
internal class StrongNumberProvider
{
private static RNGCryptoServiceProvider csp = new RNGCryptoServiceProvider();
public uint NextUInt32()
{
byte[] res = new byte[4];
csp.GetBytes(res);
return BitConverter.ToUInt32(res, 0);
}
public int NextInt()
{
byte[] res = new byte[4];
csp.GetBytes(res);
return BitConverter.ToInt32(res, 0);
}
public Single NextSingle()
{
float numerator = NextUInt32();
float denominator = uint.MaxValue;
return numerator / denominator;
}
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("ClientServerLib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClientServerLib")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("53f89645-1948-420f-b64a-7dc705ca8820")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ClientServerLib
{
public delegate void ResponseCallback(byte[] Response);
public delegate byte[] HandleRequest(int ConnectionID, byte[] Message);
public delegate void OnConnectionChanged(bool Connected);
public delegate void OnSend(byte[] Message);
public delegate void OnReceived(byte[] Message);
public struct SRequest
{
public byte[] Command;
public byte[] Response;
public ResponseCallback Callback;
}
}
@@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
namespace Vocaluxe.Base.Server
{
public static class CCommands
{
private static UTF8Encoding encoder = new UTF8Encoding();
public static SHA256Managed SHA256 = new SHA256Managed();
#region Commands
public const int ResponseOK = 1;
public const int ResponseNOK = 2;
public const int CommandLogin = 20;
public const int ResponseLoginWrongPassword = 21;
public const int ResponseLoginFailed = 22;
public const int ResponseLoginOK = 23;
public const int CommandSendKeyStroke = 100;
public const int CommandSendKeyUp = 110;
public const int CommandSendKeyDown = 111;
public const int CommandSendKeyLeft = 112;
public const int CommandSendKeyRight = 113;
public const int CommandSendMouseMoveEvent = 200;
public const int CommandSendMouseLBDownEvent = 220;
public const int CommandSendMouseLBUpEvent = 221;
public const int CommandSendMouseRBDownEvent = 230;
public const int CommandSendMouseRBUpEvent = 231;
public const int ComamndSendMouseMBDownEvent = 240;
public const int ComamndSendMouseMBUpEvent = 241;
public const int CommandSendMouseWheelEvent = 250;
public const int CommandSendAvatarPicture = 500;
public const int CommandSendAvatarPictureJpg = 501;
#endregion Commands
#region General
public static byte[] CreateCommandWithoutParams(int Command)
{
return BitConverter.GetBytes(Command);
}
#endregion General
#region Login
public static byte[] CreateCommandLogin(string Password)
{
SLoginData data = new SLoginData();
data.SHA256 = SHA256.ComputeHash(Encoding.UTF8.GetBytes(Password));
return Serialize<SLoginData>(CommandLogin, data);
}
public static bool DecodeCommandLogin(byte[] Message, out SLoginData LoginData)
{
return TryDeserialize<SLoginData>(Message, out LoginData);
}
#endregion Login
#region Keyboard
#endregion Keyboard
#region Avatar
public static byte[] CreateCommandSendAvatarPicture(int Width, int Height, byte[] data)
{
SAvatarPicture ap = new SAvatarPicture();
ap.Height = Height;
ap.Width = Width;
ap.data = new byte[data.Length];
Array.Copy(data, ap.data, data.Length);
return Serialize<SAvatarPicture>(CommandSendAvatarPicture, ap);
}
public static bool DecodeCommandSendAvatarPicture(byte[] Message, out SAvatarPicture AvatarPicture)
{
return TryDeserialize<SAvatarPicture>(Message, out AvatarPicture);
}
public static byte[] CreateCommandSendAvatarPictureJpg(byte[] data)
{
SAvatarPicture ap = new SAvatarPicture();
ap.Height = 0;
ap.Width = 0;
ap.data = new byte[data.Length];
Array.Copy(data, ap.data, data.Length);
return Serialize<SAvatarPicture>(CommandSendAvatarPictureJpg, ap);
}
#endregion Avatar
#region Serializing
private static byte[] Serialize<T>(int Command, T obj)
{
byte[] command = BitConverter.GetBytes(Command);
MemoryStream stream = new MemoryStream();
stream.Write(command, 0, command.Length);
byte[] data;
using (MemoryStream ms = new MemoryStream())
{
string json = JsonConvert.SerializeObject(obj);
data = encoder.GetBytes(json);
}
stream.Write(data, 0, data.Length);
return stream.ToArray();
}
private static bool TryDeserialize<T>(byte[] message, out T obj)
{
obj = default(T);
if (message == null)
return false;
if (message.Length < 5)
return false;
byte[] data = new byte[message.Length - 4];
Array.Copy(message, 4, data, 0, data.Length);
using (MemoryStream ms = new MemoryStream(data))
{
try
{
obj = JsonConvert.DeserializeObject<T>(encoder.GetString(data));
return true;
}
catch
{
return false;
}
}
}
#endregion Serializing
}
}
@@ -0,0 +1,16 @@
using System;
namespace Vocaluxe.Base.Server
{
public struct SLoginData
{
public byte[] SHA256;
}
public struct SAvatarPicture
{
public int Width;
public int Height;
public byte[] data;
}
}
+298
View File
@@ -0,0 +1,298 @@
namespace ClientTest
{
partial class ClientTest
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.lbConnectionStatus = new System.Windows.Forms.ToolStripStatusLabel();
this.lbConnectionStatusText = new System.Windows.Forms.ToolStripStatusLabel();
this.tbDataSending = new System.Windows.Forms.TextBox();
this.lbDateSending = new System.Windows.Forms.Label();
this.lbDataReceiving = new System.Windows.Forms.Label();
this.tbDataReceiving = new System.Windows.Forms.TextBox();
this.lbPort = new System.Windows.Forms.Label();
this.tbPort = new System.Windows.Forms.TextBox();
this.tbServerIP = new System.Windows.Forms.TextBox();
this.btConnect = new System.Windows.Forms.Button();
this.lbServerIP = new System.Windows.Forms.Label();
this.tbPassword = new System.Windows.Forms.TextBox();
this.lbPassword = new System.Windows.Forms.Label();
this.btLogin = new System.Windows.Forms.Button();
this.btLeft = new System.Windows.Forms.Button();
this.btRight = new System.Windows.Forms.Button();
this.btUp = new System.Windows.Forms.Button();
this.btDown = new System.Windows.Forms.Button();
this.btSendAvatar = new System.Windows.Forms.Button();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.lbConnectionStatus,
this.lbConnectionStatusText});
this.statusStrip1.Location = new System.Drawing.Point(0, 528);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(1008, 22);
this.statusStrip1.TabIndex = 4;
this.statusStrip1.Text = "statusStrip1";
//
// lbConnectionStatus
//
this.lbConnectionStatus.Name = "lbConnectionStatus";
this.lbConnectionStatus.Size = new System.Drawing.Size(107, 17);
this.lbConnectionStatus.Text = "Connection Status:";
//
// lbConnectionStatusText
//
this.lbConnectionStatusText.Name = "lbConnectionStatusText";
this.lbConnectionStatusText.Size = new System.Drawing.Size(79, 17);
this.lbConnectionStatusText.Text = "Disconnected";
//
// tbDataSending
//
this.tbDataSending.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbDataSending.Location = new System.Drawing.Point(12, 25);
this.tbDataSending.Multiline = true;
this.tbDataSending.Name = "tbDataSending";
this.tbDataSending.Size = new System.Drawing.Size(810, 120);
this.tbDataSending.TabIndex = 7;
//
// lbDateSending
//
this.lbDateSending.AutoSize = true;
this.lbDateSending.Location = new System.Drawing.Point(12, 9);
this.lbDateSending.Name = "lbDateSending";
this.lbDateSending.Size = new System.Drawing.Size(75, 13);
this.lbDateSending.TabIndex = 6;
this.lbDateSending.Text = "Data Sending:";
//
// lbDataReceiving
//
this.lbDataReceiving.AutoSize = true;
this.lbDataReceiving.Location = new System.Drawing.Point(12, 197);
this.lbDataReceiving.Name = "lbDataReceiving";
this.lbDataReceiving.Size = new System.Drawing.Size(84, 13);
this.lbDataReceiving.TabIndex = 8;
this.lbDataReceiving.Text = "Data Receiving:";
//
// tbDataReceiving
//
this.tbDataReceiving.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbDataReceiving.Location = new System.Drawing.Point(12, 213);
this.tbDataReceiving.Multiline = true;
this.tbDataReceiving.Name = "tbDataReceiving";
this.tbDataReceiving.Size = new System.Drawing.Size(810, 120);
this.tbDataReceiving.TabIndex = 9;
//
// lbPort
//
this.lbPort.AutoSize = true;
this.lbPort.Location = new System.Drawing.Point(828, 41);
this.lbPort.Name = "lbPort";
this.lbPort.Size = new System.Drawing.Size(29, 13);
this.lbPort.TabIndex = 1;
this.lbPort.Text = "Port:";
//
// tbPort
//
this.tbPort.Location = new System.Drawing.Point(910, 38);
this.tbPort.Name = "tbPort";
this.tbPort.Size = new System.Drawing.Size(86, 20);
this.tbPort.TabIndex = 3;
this.tbPort.Text = "3000";
//
// tbServerIP
//
this.tbServerIP.Location = new System.Drawing.Point(910, 12);
this.tbServerIP.Name = "tbServerIP";
this.tbServerIP.Size = new System.Drawing.Size(86, 20);
this.tbServerIP.TabIndex = 2;
this.tbServerIP.Text = "127.0.0.1";
//
// btConnect
//
this.btConnect.Location = new System.Drawing.Point(831, 64);
this.btConnect.Name = "btConnect";
this.btConnect.Size = new System.Drawing.Size(165, 23);
this.btConnect.TabIndex = 5;
this.btConnect.Text = "Connect";
this.btConnect.UseVisualStyleBackColor = true;
this.btConnect.Click += new System.EventHandler(this.btConnect_Click);
//
// lbServerIP
//
this.lbServerIP.AutoSize = true;
this.lbServerIP.Location = new System.Drawing.Point(828, 15);
this.lbServerIP.Name = "lbServerIP";
this.lbServerIP.Size = new System.Drawing.Size(54, 13);
this.lbServerIP.TabIndex = 0;
this.lbServerIP.Text = "Server IP:";
//
// tbPassword
//
this.tbPassword.Location = new System.Drawing.Point(910, 128);
this.tbPassword.Name = "tbPassword";
this.tbPassword.Size = new System.Drawing.Size(86, 20);
this.tbPassword.TabIndex = 6;
this.tbPassword.UseSystemPasswordChar = true;
//
// lbPassword
//
this.lbPassword.AutoSize = true;
this.lbPassword.Location = new System.Drawing.Point(828, 131);
this.lbPassword.Name = "lbPassword";
this.lbPassword.Size = new System.Drawing.Size(56, 13);
this.lbPassword.TabIndex = 7;
this.lbPassword.Text = "Password:";
//
// btLogin
//
this.btLogin.Enabled = false;
this.btLogin.Location = new System.Drawing.Point(831, 154);
this.btLogin.Name = "btLogin";
this.btLogin.Size = new System.Drawing.Size(165, 23);
this.btLogin.TabIndex = 8;
this.btLogin.Text = "Login";
this.btLogin.UseVisualStyleBackColor = true;
this.btLogin.Click += new System.EventHandler(this.btLogin_Click);
//
// btLeft
//
this.btLeft.Enabled = false;
this.btLeft.Location = new System.Drawing.Point(831, 238);
this.btLeft.Name = "btLeft";
this.btLeft.Size = new System.Drawing.Size(69, 23);
this.btLeft.TabIndex = 10;
this.btLeft.Text = "Left";
this.btLeft.UseVisualStyleBackColor = true;
this.btLeft.Click += new System.EventHandler(this.btLeft_Click);
//
// btRight
//
this.btRight.Enabled = false;
this.btRight.Location = new System.Drawing.Point(927, 238);
this.btRight.Name = "btRight";
this.btRight.Size = new System.Drawing.Size(69, 23);
this.btRight.TabIndex = 11;
this.btRight.Text = "Right";
this.btRight.UseVisualStyleBackColor = true;
this.btRight.Click += new System.EventHandler(this.brRight_Click);
//
// btUp
//
this.btUp.Enabled = false;
this.btUp.Location = new System.Drawing.Point(877, 209);
this.btUp.Name = "btUp";
this.btUp.Size = new System.Drawing.Size(69, 23);
this.btUp.TabIndex = 12;
this.btUp.Text = "Up";
this.btUp.UseVisualStyleBackColor = true;
this.btUp.Click += new System.EventHandler(this.btUp_Click);
//
// btDown
//
this.btDown.Enabled = false;
this.btDown.Location = new System.Drawing.Point(877, 267);
this.btDown.Name = "btDown";
this.btDown.Size = new System.Drawing.Size(69, 23);
this.btDown.TabIndex = 13;
this.btDown.Text = "Down";
this.btDown.UseVisualStyleBackColor = true;
this.btDown.Click += new System.EventHandler(this.btDown_Click);
//
// btSendAvatar
//
this.btSendAvatar.Enabled = false;
this.btSendAvatar.Location = new System.Drawing.Point(831, 310);
this.btSendAvatar.Name = "btSendAvatar";
this.btSendAvatar.Size = new System.Drawing.Size(165, 23);
this.btSendAvatar.TabIndex = 14;
this.btSendAvatar.Text = "Send Avatar";
this.btSendAvatar.UseVisualStyleBackColor = true;
this.btSendAvatar.Click += new System.EventHandler(this.btSendAvatar_Click);
//
// ClientTest
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1008, 550);
this.Controls.Add(this.btSendAvatar);
this.Controls.Add(this.btDown);
this.Controls.Add(this.btUp);
this.Controls.Add(this.btRight);
this.Controls.Add(this.btLeft);
this.Controls.Add(this.btLogin);
this.Controls.Add(this.tbDataReceiving);
this.Controls.Add(this.lbPassword);
this.Controls.Add(this.lbDataReceiving);
this.Controls.Add(this.tbPassword);
this.Controls.Add(this.lbDateSending);
this.Controls.Add(this.lbServerIP);
this.Controls.Add(this.tbDataSending);
this.Controls.Add(this.btConnect);
this.Controls.Add(this.tbServerIP);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.tbPort);
this.Controls.Add(this.lbPort);
this.Name = "ClientTest";
this.Text = "ClientTest";
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel lbConnectionStatus;
private System.Windows.Forms.ToolStripStatusLabel lbConnectionStatusText;
private System.Windows.Forms.TextBox tbDataSending;
private System.Windows.Forms.Label lbDateSending;
private System.Windows.Forms.Label lbDataReceiving;
private System.Windows.Forms.TextBox tbDataReceiving;
private System.Windows.Forms.Label lbPort;
private System.Windows.Forms.TextBox tbPort;
private System.Windows.Forms.TextBox tbServerIP;
private System.Windows.Forms.Button btConnect;
private System.Windows.Forms.Label lbServerIP;
private System.Windows.Forms.TextBox tbPassword;
private System.Windows.Forms.Label lbPassword;
private System.Windows.Forms.Button btLogin;
private System.Windows.Forms.Button btLeft;
private System.Windows.Forms.Button btRight;
private System.Windows.Forms.Button btUp;
private System.Windows.Forms.Button btDown;
private System.Windows.Forms.Button btSendAvatar;
}
}
+228
View File
@@ -0,0 +1,228 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Windows.Forms;
using ClientServerLib;
using Vocaluxe.Base.Server;
namespace ClientTest
{
public partial class ClientTest : Form
{
CClient client;
private bool loggedIn;
public ClientTest()
{
client = new CClient();
loggedIn = false;
InitializeComponent();
}
protected override void OnClosing(CancelEventArgs e)
{
client.Close();
base.OnClosing(e);
}
private void btConnect_Click(object sender, EventArgs e)
{
if (!client.Connected)
Connect();
else
Disconnect();
}
private void btLogin_Click(object sender, EventArgs e)
{
if (!client.Connected)
return;
client.SendMessage(CCommands.CreateCommandLogin(tbPassword.Text), OnResponse);
}
private void Connect()
{
int port = 3000;
if (!int.TryParse(tbPort.Text, out port))
{
MessageBox.Show("Error parsing port number", "Port Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
IPAddress ip;
if (!IPAddress.TryParse(tbServerIP.Text, out ip))
{
MessageBox.Show("Error parsing ip address", "IP Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
lbConnectionStatusText.Text = "Connecting...";
client.Connect(tbServerIP.Text, port, OnConnectionChanged, OnSend, OnReceived);
}
private void Disconnect()
{
client.Disconnect();
}
private void OnResponse(byte[] Message)
{
if (Message == null)
return;
if (Message.Length < 4)
return;
int command = BitConverter.ToInt32(Message, 0);
switch (command)
{
case CCommands.ResponseLoginFailed:
MessageBox.Show("Unknown Error on login", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
case CCommands.ResponseLoginWrongPassword:
MessageBox.Show("Wrong Password", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
case CCommands.ResponseLoginOK:
loggedIn = true;
this.Invoke((MethodInvoker)delegate
{
lbConnectionStatusText.Text = "Logged in";
});
break;
default:
break;
}
}
private void OnConnectionChanged(bool Connected)
{
if (Connected)
{
this.Invoke((MethodInvoker)delegate
{
lbConnectionStatusText.Text = "Connected";
btConnect.Text = "Disconnect";
btLogin.Enabled = true;
btUp.Enabled = true;
btDown.Enabled = true;
btLeft.Enabled = true;
btRight.Enabled = true;
btSendAvatar.Enabled = true;
});
}
else
{
this.Invoke((MethodInvoker)delegate
{
client.Disconnect();
lbConnectionStatusText.Text = "Disconnected";
btConnect.Text = "Connect";
btLogin.Text = "Login";
btLogin.Enabled = false;
loggedIn = false;
btUp.Enabled = false;
btDown.Enabled = false;
btLeft.Enabled = false;
btRight.Enabled = false;
btSendAvatar.Enabled = false;
});
}
}
private void OnSend(byte[] Message)
{
if (Message == null)
return;
string text = String.Empty;
int max = Message.Length;
if (max > 1000)
max = 1000;
for (int i = 0; i < max; i++)
{
text += Message[i].ToString() + " ";
}
this.Invoke((MethodInvoker)delegate
{
tbDataSending.Text = text;
});
}
private void OnReceived(byte[] Message)
{
if (Message == null)
return;
string text = String.Empty;
int max = Message.Length;
if (max > 1000)
max = 1000;
for (int i = 0; i < max; i++)
{
text += Message[i].ToString() + " ";
}
this.Invoke((MethodInvoker)delegate
{
tbDataReceiving.Text = text;
});
}
private void btUp_Click(object sender, EventArgs e)
{
if (!client.Connected || !loggedIn)
return;
client.SendMessage(CCommands.CreateCommandWithoutParams(CCommands.CommandSendKeyUp), null);
}
private void btLeft_Click(object sender, EventArgs e)
{
if (!client.Connected || !loggedIn)
return;
client.SendMessage(CCommands.CreateCommandWithoutParams(CCommands.CommandSendKeyLeft), null);
}
private void btDown_Click(object sender, EventArgs e)
{
if (!client.Connected || !loggedIn)
return;
client.SendMessage(CCommands.CreateCommandWithoutParams(CCommands.CommandSendKeyDown), null);
}
private void brRight_Click(object sender, EventArgs e)
{
if (!client.Connected || !loggedIn)
return;
client.SendMessage(CCommands.CreateCommandWithoutParams(CCommands.CommandSendKeyRight), null);
}
private void btSendAvatar_Click(object sender, EventArgs e)
{
if (!client.Connected || !loggedIn)
return;
byte[] data = new byte[512 * 512 * 4];
for (int i = 0; i < data.Length; i++)
{
data[i] = (byte) (i % 255);
}
client.SendMessage(CCommands.CreateCommandSendAvatarPicture(512, 512, data), null);
}
}
}
@@ -0,0 +1,93 @@
<?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)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{48A825C6-728F-4EBF-B98E-3D4665B3BC9E}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ClientTest</RootNamespace>
<AssemblyName>ClientTest</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ClientTest.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ClientTest.Designer.cs">
<DependentUpon>ClientTest.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="ClientTest.resx">
<DependentUpon>ClientTest.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ClientServerLib\ClientServerLib.csproj">
<Project>{EC5167E4-CCFB-4CEE-987C-CF816F1062A3}</Project>
<Name>ClientServerLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+123
View File
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
+21
View File
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace ClientTest
{
static class Program
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ClientTest());
}
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("ClientTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClientTest")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("0bde3ff1-7eb7-4b60-9813-32ff42c0ceff")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.18034
//
// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn
// der Code neu generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ClientTest.Properties
{
/// <summary>
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
/// </summary>
// Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse
// über ein Tool wie ResGen oder Visual Studio automatisch generiert.
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
// mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ClientTest.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
/// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18034
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ClientTest.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
Binary file not shown.
+18
View File
@@ -0,0 +1,18 @@
Copyright (c) 2007 James Newton-King
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file not shown.
@@ -21,6 +21,7 @@ using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using VocaluxeLib.Menu;
using VocaluxeLib.Profile;
[assembly: ComVisible(false)]
@@ -532,7 +533,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _SetTeamNames()
{
SProfile[] profiles = CBase.Profiles.GetProfiles();
CProfile[] profiles = CBase.Profiles.GetProfiles();
if (profiles == null)
{
@@ -21,6 +21,7 @@ using System;
using System.Collections.Generic;
using System.Windows.Forms;
using VocaluxeLib.Menu;
using VocaluxeLib.Profile;
namespace VocaluxeLib.PartyModes.Challenge
{
@@ -379,7 +380,7 @@ namespace VocaluxeLib.PartyModes.Challenge
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
{
_Texts[_TextNextPlayerMessage].Visible = true;
SProfile[] profiles = CBase.Profiles.GetProfiles();
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{
int pid = _GameState.Combs[_GameState.CurrentRoundNr - 1].Player[i];
@@ -491,7 +492,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _UpdateRoundsTable()
{
SProfile[] profile = CBase.Profiles.GetProfiles();
CProfile[] profile = CBase.Profiles.GetProfiles();
for (int i = 0; i < _RoundsTable.Count; i++)
{
for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++)
@@ -585,7 +586,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _UpdatePlayerTable()
{
SProfile[] profiles = CBase.Profiles.GetProfiles();
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _PlayerTable.Count; i++)
{
@@ -657,7 +658,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private string _GetPlayerWinString()
{
string s = "";
SProfile[] profiles = CBase.Profiles.GetProfiles();
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _GameState.ResultTable.Count; i++)
{
@@ -21,8 +21,10 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.InteropServices;
using VocaluxeLib.Game;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib.Songs;
using VocaluxeLib.Profile;
[assembly: ComVisible(false)]
@@ -577,7 +579,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _SetTeamNames()
{
SProfile[] profiles = CBase.Profiles.GetProfiles();
CProfile[] profiles = CBase.Profiles.GetProfiles();
if (profiles == null)
{
@@ -21,6 +21,7 @@ using System;
using System.Collections.Generic;
using System.Windows.Forms;
using VocaluxeLib.Menu;
using VocaluxeLib.Profile;
namespace VocaluxeLib.PartyModes.ChallengeMedley
{
@@ -379,7 +380,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
{
_Texts[_TextNextPlayerMessage].Visible = true;
SProfile[] profiles = CBase.Profiles.GetProfiles();
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{
int pid = _GameState.Combs[_GameState.CurrentRoundNr - 1].Player[i];
@@ -491,7 +492,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdateRoundsTable()
{
SProfile[] profile = CBase.Profiles.GetProfiles();
CProfile[] profile = CBase.Profiles.GetProfiles();
for (int i = 0; i < _RoundsTable.Count; i++)
{
for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++)
@@ -585,7 +586,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdatePlayerTable()
{
SProfile[] profiles = CBase.Profiles.GetProfiles();
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _PlayerTable.Count; i++)
{
@@ -657,7 +658,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private string _GetPlayerWinString()
{
string s = "";
SProfile[] profiles = CBase.Profiles.GetProfiles();
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _GameState.ResultTable.Count; i++)
{
@@ -21,6 +21,7 @@ using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using VocaluxeLib.Menu;
using VocaluxeLib.Profile;
[assembly: ComVisible(false)]
@@ -725,7 +726,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (players.Length < 2)
return;
SProfile[] profiles = CBase.Profiles.GetProfiles();
CProfile[] profiles = CBase.Profiles.GetProfiles();
CRound r = _GameData.Rounds[roundNr];
bool isDuet = CBase.Songs.GetSongByID(r.SongID).IsDuet;
@@ -21,7 +21,8 @@ using System;
using System.Collections.Generic;
using System.Windows.Forms;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib.Songs;
using VocaluxeLib.Profile;
namespace VocaluxeLib.PartyModes.TicTacToe
{
@@ -513,7 +514,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Texts[_TextNextPlayerT2].Visible = true;
_Texts[_TextNextPlayerNameT1].Visible = true;
_Texts[_TextNextPlayerNameT2].Visible = true;
SProfile[] profiles = CBase.Profiles.GetProfiles();
CProfile[] profiles = CBase.Profiles.GetProfiles();
_Texts[_TextNextPlayerNameT1].Text = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].PlayerName;
_Texts[_TextNextPlayerNameT2].Text = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].PlayerName;
_Statics[_StaticAvatarT1].Visible = true;
@@ -552,7 +553,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Texts[_TextNextPlayerT2].Visible = true;
_Texts[_TextNextPlayerNameT1].Visible = true;
_Texts[_TextNextPlayerNameT2].Visible = true;
SProfile[] profiles = CBase.Profiles.GetProfiles();
CProfile[] profiles = CBase.Profiles.GetProfiles();
_Texts[_TextNextPlayerNameT1].Text = profiles[_GameData.ProfileIDsTeam1[_GameData.Rounds[_SelectedField].SingerTeam1]].PlayerName;
_Texts[_TextNextPlayerNameT2].Text = profiles[_GameData.ProfileIDsTeam2[_GameData.Rounds[_SelectedField].SingerTeam2]].PlayerName;
_Statics[_StaticAvatarT1].Visible = true;
+2 -2
View File
@@ -23,8 +23,8 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using Vocaluxe.Base;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib;
using VocaluxeLib.Songs;
namespace Vocaluxe.Base
{
+7 -1
View File
@@ -28,6 +28,7 @@ using System.Windows.Forms;
using System.Xml;
using Vocaluxe.Lib.Sound;
using Vocaluxe.Lib.Webcam;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Base
@@ -112,6 +113,11 @@ namespace Vocaluxe.Base
public static EWebcamLib WebcamLib = EWebcamLib.OpenCV;
public static SWebcamConfig WebcamConfig;
// Server
public static EOffOn Server = EOffOn.TR_CONFIG_ON;
public static int ServerPort = 3000;
public static string ServerPassword = "vocaluxe";
//Lists to save parameters and values
private static readonly List<string> _Params = new List<string>();
private static readonly List<string> _Values = new List<string>();
@@ -806,7 +812,7 @@ namespace Vocaluxe.Base
continue;
for (int i = 0; i < CProfiles.Profiles.Length; i++)
{
if (Path.GetFileName(CProfiles.Profiles[i].ProfileFile) == Players[j] && CProfiles.Profiles[i].Active == EOffOn.TR_CONFIG_ON)
if (Path.GetFileName(CProfiles.Profiles[i].FileName) == Players[j] && CProfiles.Profiles[i].Active == EOffOn.TR_CONFIG_ON)
{
//Update Game-infos with player
CGame.Players[j].ProfileID = i;
+70 -13
View File
@@ -17,62 +17,119 @@
// */
#endregion
using System;
using System.Collections.Generic;
using Vocaluxe.Base.Server;
using Vocaluxe.Lib.Input;
using Vocaluxe.Lib.Input.WiiMote;
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Base
{
static class CController
{
private static IController _Controller;
private static List<IController> _Controller;
private static List<SKeyEvent> _KeysPool;
private static List<SMouseEvent> _MousePool;
public static void Init()
{
_Controller = new CWiiMote();
_Controller = new List<IController>();
_KeysPool = new List<SKeyEvent>();
_MousePool = new List<SMouseEvent>();
_Controller.Add(new CWiiMote());
_Controller.Add(CVocaluxeServer.Controller);
_Controller.Init();
foreach (IController controller in _Controller)
{
controller.Init();
}
}
public static void Close()
{
_Controller.Close();
_Controller = null;
foreach (IController controller in _Controller)
{
controller.Close();
}
_Controller = new List<IController>();
}
public static void Connect()
{
_Controller.Connect();
foreach (IController controller in _Controller)
{
controller.Connect();
}
}
public static void Disconnect()
{
_Controller.Disconnect();
foreach (IController controller in _Controller)
{
controller.Disconnect();
}
}
public static bool IsConnected()
{
return _Controller.IsConnected();
//return _Controller.IsConnected();
return false; //should be changed
}
public static void Update()
{
_Controller.Update();
foreach (IController controller in _Controller)
{
controller.Update();
SKeyEvent ke = new SKeyEvent();
while (controller.PollKeyEvent(ref ke))
{
_KeysPool.Add(ke);
}
SMouseEvent me = new SMouseEvent();
while (controller.PollMouseEvent(ref me))
{
_MousePool.Add(me);
}
}
}
public static bool PollKeyEvent(ref SKeyEvent keyEvent)
{
return _Controller.PollKeyEvent(ref keyEvent);
if (_KeysPool.Count > 0)
{
keyEvent = _KeysPool[0];
_KeysPool.RemoveAt(0);
return true;
}
return false;
}
public static bool PollMouseEvent(ref SMouseEvent mouseEvent)
{
return _Controller.PollMouseEvent(ref mouseEvent);
if (_MousePool.Count > 0)
{
mouseEvent = _MousePool[0];
_MousePool.RemoveAt(0);
return true;
}
return false;
}
public static void SetRumble(float duration)
{
_Controller.SetRumble(duration);
foreach (IController controller in _Controller)
{
controller.SetRumble(duration);
}
}
}
}
+1
View File
@@ -23,6 +23,7 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Base
+2 -2
View File
@@ -35,8 +35,8 @@ using SQLiteCommand = Mono.Data.Sqlite.SqliteCommand;
using SQLiteDataReader = Mono.Data.Sqlite.SqliteDataReader;
#endif
using Community.CsharpSqlite;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib;
using VocaluxeLib.Songs;
namespace Vocaluxe.Base
{
+1
View File
@@ -22,6 +22,7 @@ using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Vocaluxe.Lib.Draw;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Base
+3 -3
View File
@@ -20,9 +20,9 @@
using System;
using System.Collections.Generic;
using Vocaluxe.SongQueue;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SingNotes;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib;
using VocaluxeLib.Game;
using VocaluxeLib.Songs;
namespace Vocaluxe.Base
{
+1
View File
@@ -24,6 +24,7 @@ using System.Drawing;
using System.Windows.Forms;
using Vocaluxe.Base.Font;
using Vocaluxe.Screens;
using VocaluxeLib;
using VocaluxeLib.Menu;
using VocaluxeLib.PartyModes;
+1
View File
@@ -23,6 +23,7 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Base
+10 -1
View File
@@ -22,8 +22,12 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using Vocaluxe.Base.Font;
using VocaluxeLib;
using VocaluxeLib.Game;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib.Songs;
using VocaluxeLib.Profile;
namespace Vocaluxe.Base
{
@@ -370,6 +374,11 @@ namespace Vocaluxe.Base
CDraw.DrawTextureReflection(texture, rect, color, bounds, reflectionSpace, reflectionHeight);
}
public STexture AddTexture(string fileName)
{
return CDraw.AddTexture(fileName);
}
public void RemoveTexture(ref STexture texture)
{
CDraw.RemoveTexture(ref texture);
@@ -538,7 +547,7 @@ namespace Vocaluxe.Base
class CBprofiles : IProfiles
{
public SProfile[] GetProfiles()
public CProfile[] GetProfiles()
{
return CProfiles.Profiles;
}
+1
View File
@@ -22,6 +22,7 @@ using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using VocaluxeLib;
using VocaluxeLib.Menu;
using VocaluxeLib.PartyModes;
+2 -1
View File
@@ -23,8 +23,9 @@ using System.Collections.ObjectModel;
using System.IO;
using System.Text;
using Vocaluxe.Lib.Playlist;
using VocaluxeLib;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib.Songs;
namespace Vocaluxe.Base
{
+51 -108
View File
@@ -22,17 +22,18 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using VocaluxeLib.Menu;
using VocaluxeLib;
using VocaluxeLib.Game;
using VocaluxeLib.Profile;
namespace Vocaluxe.Base
{
static class CProfiles
{
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
private static List<SProfile> _Profiles;
private static readonly List<SAvatar> _Avatars = new List<SAvatar>();
private static List<CProfile> _Profiles;
private static readonly List<CAvatar> _Avatars = new List<CAvatar>();
public static SProfile[] Profiles
public static CProfile[] Profiles
{
get { return _Profiles.ToArray(); }
}
@@ -42,7 +43,7 @@ namespace Vocaluxe.Base
get { return _Profiles.Count; }
}
public static SAvatar[] Avatars
public static CAvatar[] Avatars
{
get { return _Avatars.ToArray(); }
}
@@ -54,17 +55,12 @@ namespace Vocaluxe.Base
public static void Init()
{
_Settings.Indent = true;
_Settings.Encoding = Encoding.UTF8;
_Settings.ConformanceLevel = ConformanceLevel.Document;
LoadAvatars();
LoadProfiles();
}
public static string GetPlayerName(int profileID, int playerNum = 0)
{
if (IsProfileIDValid(profileID))
if (ICProfileIDValid(profileID))
return _Profiles[profileID].PlayerName;
string playerName = CLanguage.Translate("TR_SCREENNAMES_PLAYER");
if (playerNum > 0)
@@ -74,17 +70,17 @@ namespace Vocaluxe.Base
public static int NewProfile(string fileName = "")
{
SProfile profile = new SProfile
CProfile profile = new CProfile
{
PlayerName = String.Empty,
Difficulty = EGameDifficulty.TR_CONFIG_EASY,
Avatar = new SAvatar(-1),
Avatar = new CAvatar(-1),
GuestProfile = EOffOn.TR_CONFIG_OFF,
Active = EOffOn.TR_CONFIG_ON,
ProfileFile = fileName != "" ? Path.Combine(CSettings.FolderProfiles, fileName) : String.Empty
FileName = fileName != "" ? Path.Combine(CSettings.FolderProfiles, fileName) : String.Empty
};
if (File.Exists(profile.ProfileFile))
if (File.Exists(profile.FileName))
return -1;
_Profiles.Add(profile);
@@ -100,7 +96,8 @@ namespace Vocaluxe.Base
public static void LoadProfiles()
{
_Profiles = new List<SProfile>();
LoadAvatars();
_Profiles = new List<CProfile>();
List<string> files = new List<string>();
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.xml", true, true));
@@ -128,10 +125,9 @@ namespace Vocaluxe.Base
foreach (string file in files)
{
STexture tex = CDraw.AddTexture(file);
if (tex.Index != -1)
{
SAvatar avatar = new SAvatar {Texture = tex, FileName = Path.GetFileName(file)};
CAvatar avatar = new CAvatar(-1) {Texture = tex, FileName = Path.GetFileName(file)};
_Avatars.Add(avatar);
}
}
@@ -139,10 +135,10 @@ namespace Vocaluxe.Base
public static string AddGetPlayerName(int profileID, char chr)
{
if (!IsProfileIDValid(profileID))
if (!ICProfileIDValid(profileID))
return String.Empty;
SProfile profile = _Profiles[profileID];
CProfile profile = _Profiles[profileID];
profile.PlayerName += chr;
_Profiles[profileID] = profile;
@@ -151,10 +147,10 @@ namespace Vocaluxe.Base
public static string GetDeleteCharInPlayerName(int profileID)
{
if (!IsProfileIDValid(profileID))
if (!ICProfileIDValid(profileID))
return String.Empty;
SProfile profile = _Profiles[profileID];
CProfile profile = _Profiles[profileID];
if (profile.PlayerName != "")
profile.PlayerName = profile.PlayerName.Remove(profile.PlayerName.Length - 1);
_Profiles[profileID] = profile;
@@ -162,58 +158,58 @@ namespace Vocaluxe.Base
return profile.PlayerName;
}
public static bool IsProfileIDValid(int profileID)
public static bool ICProfileIDValid(int profileID)
{
return profileID >= 0 && profileID < _Profiles.Count;
}
public static EGameDifficulty GetDifficulty(int profileID)
{
return IsProfileIDValid(profileID) ? _Profiles[profileID].Difficulty : EGameDifficulty.TR_CONFIG_NORMAL;
return ICProfileIDValid(profileID) ? _Profiles[profileID].Difficulty : EGameDifficulty.TR_CONFIG_NORMAL;
}
public static void SetDifficulty(int profileID, EGameDifficulty difficulty)
{
if (!IsProfileIDValid(profileID))
if (!ICProfileIDValid(profileID))
return;
SProfile profile = _Profiles[profileID];
CProfile profile = _Profiles[profileID];
profile.Difficulty = difficulty;
_Profiles[profileID] = profile;
}
public static EOffOn GetGuestProfile(int profileID)
{
return IsProfileIDValid(profileID) ? _Profiles[profileID].GuestProfile : EOffOn.TR_CONFIG_OFF;
return ICProfileIDValid(profileID) ? _Profiles[profileID].GuestProfile : EOffOn.TR_CONFIG_OFF;
}
public static EOffOn GetActive(int profileID)
{
return IsProfileIDValid(profileID) ? _Profiles[profileID].Active : EOffOn.TR_CONFIG_OFF;
return ICProfileIDValid(profileID) ? _Profiles[profileID].Active : EOffOn.TR_CONFIG_OFF;
}
public static void SetGuestProfile(int profileID, EOffOn option)
{
if (!IsProfileIDValid(profileID))
if (!ICProfileIDValid(profileID))
return;
SProfile profile = _Profiles[profileID];
CProfile profile = _Profiles[profileID];
profile.GuestProfile = option;
_Profiles[profileID] = profile;
}
public static void SetActive(int profileID, EOffOn option)
{
if (!IsProfileIDValid(profileID))
if (!ICProfileIDValid(profileID))
return;
SProfile profile = _Profiles[profileID];
CProfile profile = _Profiles[profileID];
profile.Active = option;
_Profiles[profileID] = profile;
}
public static bool IsGuestProfile(int profileID)
{
if (!IsProfileIDValid(profileID))
if (!ICProfileIDValid(profileID))
return true; // this will prevent from saving dummy profiles to highscore db
return _Profiles[profileID].GuestProfile == EOffOn.TR_CONFIG_ON;
@@ -221,24 +217,24 @@ namespace Vocaluxe.Base
public static bool IsActive(int profileID)
{
if (!IsProfileIDValid(profileID))
if (!ICProfileIDValid(profileID))
return false;
return _Profiles[profileID].Active == EOffOn.TR_CONFIG_ON;
}
public static void SetAvatar(int profileID, int avatarNr)
{
if (!IsProfileIDValid(profileID) || avatarNr < 0 || avatarNr >= _Avatars.Count)
if (!ICProfileIDValid(profileID) || avatarNr < 0 || avatarNr >= _Avatars.Count)
return;
SProfile profile = _Profiles[profileID];
CProfile profile = _Profiles[profileID];
profile.Avatar = _Avatars[avatarNr];
_Profiles[profileID] = profile;
}
public static int GetAvatarNr(int profileID)
{
if (!IsProfileIDValid(profileID))
if (!ICProfileIDValid(profileID))
return 0;
for (int i = 0; i < _Avatars.Count; i++)
@@ -252,22 +248,22 @@ namespace Vocaluxe.Base
public static void DeleteProfile(int profileID)
{
if (!IsProfileIDValid(profileID))
if (!ICProfileIDValid(profileID))
return;
if (_Profiles[profileID].ProfileFile == "")
if (_Profiles[profileID].FileName == "")
return;
try
{
//Check if profile saved in config
for (int i = 0; i < CConfig.Players.Length; i++)
{
if (CConfig.Players[i] == _Profiles[profileID].ProfileFile)
if (CConfig.Players[i] == _Profiles[profileID].FileName)
{
CConfig.Players[i] = string.Empty;
CConfig.SaveConfig();
}
}
File.Delete(_Profiles[profileID].ProfileFile);
File.Delete(_Profiles[profileID].FileName);
_Profiles.RemoveAt(profileID);
//Check if profile is selected in game
for (int i = 0; i < CGame.Players.Length; i++)
@@ -280,7 +276,7 @@ namespace Vocaluxe.Base
}
catch (Exception)
{
CLog.LogError("Can't delete Profile File " + _Profiles[profileID].ProfileFile + ".xml");
CLog.LogError("Can't delete Profile File " + _Profiles[profileID].FileName + ".xml");
}
}
@@ -289,28 +285,28 @@ namespace Vocaluxe.Base
_Profiles.Sort(_CompareByPlayerName);
}
private static int _CompareByPlayerName(SProfile a, SProfile b)
private static int _CompareByPlayerName(CProfile a, CProfile b)
{
return String.CompareOrdinal(a.PlayerName, b.PlayerName);
}
#region private methods
private static SAvatar _GetAvatar(string fileName)
private static CAvatar _GetAvatar(string fileName)
{
foreach (SAvatar avatar in _Avatars)
foreach (CAvatar avatar in _Avatars)
{
if (fileName == avatar.FileName)
return avatar;
}
return new SAvatar(-1);
return new CAvatar(-1);
}
private static void _SaveProfile(int profileID)
{
if (!IsProfileIDValid(profileID))
if (!ICProfileIDValid(profileID))
return;
if (_Profiles[profileID].ProfileFile == "")
if (_Profiles[profileID].FileName == "")
{
string filename = string.Empty;
foreach (char chr in _Profiles[profileID].PlayerName)
@@ -330,75 +326,22 @@ namespace Vocaluxe.Base
filename += i;
}
SProfile profile = _Profiles[profileID];
profile.ProfileFile = Path.Combine(CSettings.FolderProfiles, filename + ".xml");
CProfile profile = _Profiles[profileID];
profile.FileName = Path.Combine(CSettings.FolderProfiles, filename + ".xml");
_Profiles[profileID] = profile;
}
XmlWriter writer;
try
{
writer = XmlWriter.Create(_Profiles[profileID].ProfileFile, _Settings);
}
catch (Exception e)
{
CLog.LogError("Error creating/opening Profile File " + _Profiles[profileID].ProfileFile + ": " + e.Message);
return;
}
try
{
writer.WriteStartDocument();
writer.WriteStartElement("root");
writer.WriteStartElement("Info");
writer.WriteElementString("PlayerName", _Profiles[profileID].PlayerName);
writer.WriteElementString("Difficulty", Enum.GetName(typeof(EGameDifficulty), _Profiles[profileID].Difficulty));
writer.WriteElementString("Avatar", _Profiles[profileID].Avatar.FileName);
writer.WriteElementString("GuestProfile", Enum.GetName(typeof(EOffOn), _Profiles[profileID].GuestProfile));
writer.WriteElementString("Active", Enum.GetName(typeof(EOffOn), _Profiles[profileID].Active));
writer.WriteEndElement();
writer.WriteEndElement(); //end of root
writer.WriteEndDocument();
writer.Flush();
}
finally
{
writer.Close();
}
_Profiles[profileID].SaveProfile();
}
private static void _LoadProfile(string fileName)
{
SProfile profile = new SProfile {ProfileFile = Path.Combine(CSettings.FolderProfiles, fileName)};
CXMLReader xmlReader = CXMLReader.OpenFile(profile.ProfileFile);
if (xmlReader == null)
return;
string value = String.Empty;
if (xmlReader.GetValue("//root/Info/PlayerName", out value, value))
CProfile profile = new CProfile {FileName = Path.Combine(CSettings.FolderProfiles, fileName)};
if (profile.LoadProfile())
{
profile.PlayerName = value;
profile.Difficulty = EGameDifficulty.TR_CONFIG_EASY;
xmlReader.TryGetEnumValue("//root/Info/Difficulty", ref profile.Difficulty);
profile.Avatar = new SAvatar(-1);
if (xmlReader.GetValue("//root/Info/Avatar", out value, value))
profile.Avatar = _GetAvatar(value);
profile.GuestProfile = EOffOn.TR_CONFIG_OFF;
xmlReader.TryGetEnumValue("//root/Info/GuestProfile", ref profile.GuestProfile);
profile.Active = EOffOn.TR_CONFIG_ON;
xmlReader.TryGetEnumValue("//root/Info/Active", ref profile.Active);
profile.Avatar = _GetAvatar(profile.AvatarFileName);
_Profiles.Add(profile);
}
else
CLog.LogError("Can't find PlayerName in Profile File: " + fileName);
}
#endregion private methods
}
+1 -1
View File
@@ -21,7 +21,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Base
{
+2 -1
View File
@@ -20,8 +20,9 @@
using System;
using System.Collections.Generic;
using System.Text;
using VocaluxeLib.Menu;
using VocaluxeLib;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib.Songs;
namespace Vocaluxe.Base
{
+2 -2
View File
@@ -20,8 +20,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib;
using VocaluxeLib.Songs;
namespace Vocaluxe.Base
{
+2 -2
View File
@@ -20,8 +20,8 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib;
using VocaluxeLib.Songs;
namespace Vocaluxe.Base
{
+2
View File
@@ -22,8 +22,10 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using VocaluxeLib;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib.Songs;
namespace Vocaluxe.Base
{
+1 -1
View File
@@ -22,7 +22,7 @@ using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using Vocaluxe.Lib.Sound;
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Base
{
+1
View File
@@ -24,6 +24,7 @@ using System.Text;
using System.Windows.Forms;
using System.Xml;
using Vocaluxe.Base.Font;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Base
+1 -1
View File
@@ -21,7 +21,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Base
{
+1 -1
View File
@@ -20,7 +20,7 @@
using System.Diagnostics;
using System.Drawing;
using Vocaluxe.Lib.Video;
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Base
{
+1 -1
View File
@@ -19,7 +19,7 @@
using System.Drawing;
using Vocaluxe.Lib.Webcam;
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Base
{
+1
View File
@@ -21,6 +21,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Text;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Base.Font
+1
View File
@@ -23,6 +23,7 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Base.Font
+1
View File
@@ -22,6 +22,7 @@ using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Base.Font
+24
View File
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Vocaluxe.Base;
using Vocaluxe.Lib.Input;
using VocaluxeLib.Menu;
namespace Vocaluxe.Base.Server
{
internal class CClientHandler
{
public int ConnectionID;
public bool LoggedIn;
public CClientHandler(int ConnectionID)
{
this.ConnectionID = ConnectionID;
LoggedIn = false;
}
}
}
+179
View File
@@ -0,0 +1,179 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Linq;
using System.IO;
using System.Text;
using System.Windows.Forms;
using ClientServerLib;
using Vocaluxe.Base;
using Vocaluxe.Lib.Input;
using VocaluxeLib;
namespace Vocaluxe.Base.Server
{
static class CVocaluxeServer
{
private static CServer _Server;
private static Dictionary<int, CClientHandler> _Clients;
public static CControllerFramework Controller = new CControllerFramework();
public static void Init()
{
_Clients = new Dictionary<int, CClientHandler>();
_Server = new CServer(RequestHandler, CConfig.ServerPort);
Controller.Init();
}
public static void Start()
{
if (CConfig.Server == EOffOn.TR_CONFIG_ON)
_Server.Start();
}
public static void Close()
{
_Server.Stop();
_Clients = new Dictionary<int, CClientHandler>();
}
private static byte[] RequestHandler(int ConnectionID, byte[] Message)
{
byte[] answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseNOK);
if (Message == null)
return answer;
if (Message.Length < 4)
return answer;
bool loggedIn = false;
lock (_Clients)
{
if (!_Clients.ContainsKey(ConnectionID))
{
CClientHandler client = new CClientHandler(ConnectionID);
_Clients.Add(ConnectionID, client);
}
loggedIn = _Clients[ConnectionID].LoggedIn;
}
int command = BitConverter.ToInt32(Message, 0);
switch (command)
{
case CCommands.CommandLogin:
SLoginData data;
if (!CCommands.DecodeCommandLogin(Message, out data))
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseLoginFailed);
else
{
byte[] serverPW = CCommands.SHA256.ComputeHash(Encoding.UTF8.GetBytes(CConfig.ServerPassword));
if (!serverPW.SequenceEqual(data.SHA256))
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseLoginWrongPassword);
else
{
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseLoginOK);
_Clients[ConnectionID].LoggedIn = true;
}
}
break;
}
if (!loggedIn)
return answer;
switch (command)
{
case CCommands.CommandSendKeyUp:
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK);
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, Keys.Up));
break;
case CCommands.CommandSendKeyDown:
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK);
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, Keys.Down));
break;
case CCommands.CommandSendKeyLeft:
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK);
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, Keys.Left));
break;
case CCommands.CommandSendKeyRight:
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK);
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, Keys.Right));
break;
case CCommands.CommandSendAvatarPicture:
SAvatarPicture avatarPicture;
if (CCommands.DecodeCommandSendAvatarPicture(Message, out avatarPicture))
{
Bitmap bmp = null;
bool success = false;
try
{
bmp = new Bitmap(avatarPicture.Width, avatarPicture.Height);
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
Marshal.Copy(avatarPicture.data, 0, bmpData.Scan0, avatarPicture.data.Length);
bmp.UnlockBits(bmpData);
const string filename = "snapshot";
int i = 0;
while (File.Exists(Path.Combine(CSettings.FolderProfiles, filename + i + ".png")))
i++;
bmp.Save(Path.Combine(CSettings.FolderProfiles, filename + i + ".png"), ImageFormat.Png);
success = true;
}
finally
{
if (bmp != null)
bmp.Dispose();
}
if (success)
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK);
}
break;
case CCommands.CommandSendAvatarPictureJpg:
SAvatarPicture avatarPictureJpg;
if (CCommands.DecodeCommandSendAvatarPicture(Message, out avatarPictureJpg))
{
bool success = false;
try
{
string filename = Path.Combine(CSettings.FolderProfiles, "snapshot");
int i = 0;
while (File.Exists(filename + i + ".jpg"))
i++;
FileStream fs = File.Create(filename + i + ".jpg");
fs.Write(avatarPictureJpg.data, 0, avatarPictureJpg.data.Length);
fs.Flush();
fs.Close();
success = true;
}
catch {}
if (success)
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK);
}
break;
default:
break;
}
return answer;
}
}
}
+1 -1
View File
@@ -18,7 +18,7 @@
#endregion
using Vocaluxe.Base;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib.Songs;
namespace Vocaluxe.GameModes
{
+2 -2
View File
@@ -19,8 +19,8 @@
using System.Collections.Generic;
using Vocaluxe.Base;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib;
using VocaluxeLib.Songs;
namespace Vocaluxe.GameModes
{
+1 -1
View File
@@ -17,7 +17,7 @@
// */
#endregion
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib.Songs;
namespace Vocaluxe.GameModes
{
+1
View File
@@ -32,6 +32,7 @@ using System.Windows.Forms;
using SlimDX.Windows;
using Vocaluxe.Base;
using Vocaluxe.Base.Font;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Lib.Draw
+1
View File
@@ -28,6 +28,7 @@ using System.Threading;
using System.Windows.Forms;
using Vocaluxe.Base;
using Vocaluxe.Base.Font;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Lib.Draw
+1
View File
@@ -31,6 +31,7 @@ using System.Runtime.InteropServices;
using System.Windows.Forms;
using Vocaluxe.Base;
using Vocaluxe.Base.Font;
using VocaluxeLib;
using VocaluxeLib.Menu;
using BeginMode = OpenTK.Graphics.OpenGL.BeginMode;
using BlendingFactorDest = OpenTK.Graphics.OpenGL.BlendingFactorDest;
+1
View File
@@ -19,6 +19,7 @@
using System;
using System.Drawing;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Lib.Draw
+104
View File
@@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VocaluxeLib;
namespace Vocaluxe.Lib.Input
{
public class CControllerFramework : IController
{
private List<SKeyEvent> _KeysPool;
private List<SKeyEvent> _CurrentKeysPool;
private readonly Object _KeyCopyLock = new Object();
private List<SMouseEvent> _MousePool;
private List<SMouseEvent> _CurrentMousePool;
private readonly Object _MouseCopyLock = new Object();
public virtual void Init()
{
_KeysPool = new List<SKeyEvent>();
_CurrentKeysPool = new List<SKeyEvent>();
_MousePool = new List<SMouseEvent>();
_CurrentMousePool = new List<SMouseEvent>();
}
public virtual void Close()
{
}
public virtual void Connect()
{
}
public virtual void Disconnect()
{
}
public virtual bool IsConnected()
{
return true;
}
public virtual void Update()
{
lock (_KeyCopyLock)
{
foreach (SKeyEvent e in _KeysPool)
_CurrentKeysPool.Add(e);
_KeysPool.Clear();
}
lock (_MouseCopyLock)
{
foreach (SMouseEvent e in _MousePool)
_CurrentMousePool.Add(e);
_MousePool.Clear();
}
}
public virtual bool PollKeyEvent(ref SKeyEvent keyEvent)
{
if (_CurrentKeysPool.Count > 0)
{
keyEvent = _CurrentKeysPool[0];
_CurrentKeysPool.RemoveAt(0);
return true;
}
return false;
}
public virtual bool PollMouseEvent(ref SMouseEvent mouseEvent)
{
if (_CurrentMousePool.Count > 0)
{
mouseEvent = _CurrentMousePool[0];
_CurrentMousePool.RemoveAt(0);
return true;
}
return false;
}
public virtual void SetRumble(float duration)
{
}
public void AddKeyEvent(SKeyEvent keyEvent)
{
lock (_KeyCopyLock)
{
_KeysPool.Add(keyEvent);
}
}
public void AddMouseEvent(SMouseEvent mouseEvent)
{
lock (_MousePool)
{
_MousePool.Add(mouseEvent);
}
}
}
}
+1 -1
View File
@@ -20,7 +20,7 @@
using System;
using System.Diagnostics;
using System.Drawing;
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Lib.Input
{
+1 -1
View File
@@ -23,7 +23,7 @@ using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using Vocaluxe.Base;
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Lib.Input.WiiMote
{
+1 -1
View File
@@ -21,7 +21,7 @@ using System;
using System.Drawing;
using System.Threading;
using Vocaluxe.Base;
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Lib.Input.WiiMote
{
+2 -1
View File
@@ -23,8 +23,9 @@ using System.IO;
using System.Text;
using System.Xml;
using Vocaluxe.Base;
using VocaluxeLib;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib.Songs;
namespace Vocaluxe.Lib.Playlist
{
+1 -1
View File
@@ -19,7 +19,7 @@
using System.Collections.Generic;
using System.Linq;
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Lib.Video
{
+1 -1
View File
@@ -25,7 +25,7 @@ using System.Runtime.InteropServices;
using System.Threading;
using Vocaluxe.Base;
using Vocaluxe.Lib.Video.Acinerella;
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Lib.Video
{
+1 -1
View File
@@ -20,7 +20,7 @@
using System;
using Vocaluxe.Base;
using Vocaluxe.Lib.Video.Gstreamer;
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Lib.Video
{
+1 -1
View File
@@ -17,7 +17,7 @@
// */
#endregion
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Lib.Video
{
+1 -1
View File
@@ -24,7 +24,7 @@ using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using Vocaluxe.Base;
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Lib.Webcam
{
+1 -1
View File
@@ -19,7 +19,7 @@
using System.Collections.Generic;
using System.Drawing;
using VocaluxeLib.Menu;
using VocaluxeLib;
namespace Vocaluxe.Lib.Webcam
{
+11 -1
View File
@@ -26,6 +26,7 @@ using System.Windows.Forms;
using Vocaluxe.Base;
using System.Runtime.ExceptionServices;
using Vocaluxe.Base.Font;
using Vocaluxe.Base.Server;
namespace Vocaluxe
{
@@ -183,6 +184,13 @@ namespace Vocaluxe
Application.DoEvents();
// Init Server
CLog.StartBenchmark(0, "Init Server");
CVocaluxeServer.Init();
CLog.StopBenchmark(0, "Init Server");
Application.DoEvents();
// Init Input
CLog.StartBenchmark(0, "Init Input");
CController.Init();
@@ -210,6 +218,7 @@ namespace Vocaluxe
// Start Main Loop
_SplashScreen.Close();
CVocaluxeServer.Start();
CDraw.MainLoop();
}
@@ -219,7 +228,7 @@ namespace Vocaluxe
// Unloading
try
{
CLog.CloseAll();
CVocaluxeServer.Close();
CController.Close();
CSound.RecordCloseAll();
CSound.CloseAllStreams();
@@ -227,6 +236,7 @@ namespace Vocaluxe
CDraw.Unload();
CDataBase.CloseConnections();
CWebcam.Close();
CLog.CloseAll();
}
catch (Exception) {}
Environment.Exit(Environment.ExitCode);
@@ -20,6 +20,7 @@
using System;
using System.Windows.Forms;
using Vocaluxe.Base;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Screens
@@ -18,6 +18,7 @@
#endregion
using Vocaluxe.Base;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Screens
+1
View File
@@ -22,6 +22,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using Vocaluxe.Base;
using VocaluxeLib;
using VocaluxeLib.Menu;
enum EDirection
+3 -1
View File
@@ -22,8 +22,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Vocaluxe.Base;
using VocaluxeLib;
using VocaluxeLib.Game;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
using VocaluxeLib.Songs;
namespace Vocaluxe.Screens
{
+1
View File
@@ -21,6 +21,7 @@ using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
using Vocaluxe.Base;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Screens
+1
View File
@@ -20,6 +20,7 @@
using System.Windows.Forms;
using Vocaluxe.Base;
using Vocaluxe.Base.Font;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Screens
+7 -6
View File
@@ -21,6 +21,7 @@ using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Vocaluxe.Base;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Screens
@@ -169,7 +170,7 @@ namespace Vocaluxe.Screens
//Update Game-infos with new player
CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = _SelectedPlayerNr;
//Update config for default players.
CConfig.Players[_SelectingFastPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile;
CConfig.Players[_SelectingFastPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].FileName;
CConfig.SaveConfig();
//Update texture and name
_Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture;
@@ -417,7 +418,7 @@ namespace Vocaluxe.Screens
//Update Game-infos with new player
CGame.Players[_SelectingSwitchNr].ProfileID = CGame.Players[i].ProfileID;
//Update config for default players.
CConfig.Players[_SelectingSwitchNr] = CProfiles.Profiles[i].ProfileFile;
CConfig.Players[_SelectingSwitchNr] = CProfiles.Profiles[i].FileName;
//Update texture and name
_Statics[_StaticPlayerAvatar[_SelectingSwitchNr]].Texture = CProfiles.Profiles[CGame.Players[i].ProfileID].Avatar.Texture;
_Texts[_TextPlayer[_SelectingSwitchNr]].Text = CProfiles.Profiles[CGame.Players[i].ProfileID].PlayerName;
@@ -435,7 +436,7 @@ namespace Vocaluxe.Screens
//Update Game-infos with new player
CGame.Players[i].ProfileID = _SelectedPlayerNr;
//Update config for default players.
CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile;
CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].FileName;
CConfig.SaveConfig();
//Update texture and name
_Statics[_StaticPlayerAvatar[i]].Texture = _ChooseAvatarStatic.Texture;
@@ -475,7 +476,7 @@ namespace Vocaluxe.Screens
//Update Game-infos with new player
CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = _SelectedPlayerNr;
//Update config for default players.
CConfig.Players[_SelectingFastPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile;
CConfig.Players[_SelectingFastPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].FileName;
CConfig.SaveConfig();
//Update texture and name
_Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture;
@@ -518,7 +519,7 @@ namespace Vocaluxe.Screens
//Update Game-infos with new player
CGame.Players[i].ProfileID = _SelectedPlayerNr;
//Update config for default players.
CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile;
CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].FileName;
CConfig.SaveConfig();
//Update texture and name
_Statics[_StaticPlayerAvatar[i]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture;
@@ -622,7 +623,7 @@ namespace Vocaluxe.Screens
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
{
_Statics[_StaticPlayerAvatar[i]].Texture = CProfiles.IsProfileIDValid(CGame.Players[i].ProfileID) ?
_Statics[_StaticPlayerAvatar[i]].Texture = CProfiles.ICProfileIDValid(CGame.Players[i].ProfileID) ?
CProfiles.Profiles[CGame.Players[i].ProfileID].Avatar.Texture :
_OriginalPlayerAvatarTextures[i];
_Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(CGame.Players[i].ProfileID, i + 1);
+1
View File
@@ -19,6 +19,7 @@
using System.Windows.Forms;
using Vocaluxe.Base;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Screens
+1
View File
@@ -19,6 +19,7 @@
using System.Windows.Forms;
using Vocaluxe.Base;
using VocaluxeLib;
using VocaluxeLib.Menu;
namespace Vocaluxe.Screens
Loaded 100 of 132 files, more files were not shown because too many files have changed in this diff. Show more