v4.0 - Design Update - Needs fixes; Uploaded other related projects too.

This commit is contained in:
szatmari.norbert.peter 2015-03-26 19:36:18 +00:00
parent a0ca8ad5a8
commit 88a421ff72
900 changed files with 32478 additions and 1011 deletions

View file

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Handwriting program", "Handwriting program\Handwriting program.csproj", "{9DED0C68-3F97-4B14-88D8-F76A749F8943}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9DED0C68-3F97-4B14-88D8-F76A749F8943}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9DED0C68-3F97-4B14-88D8-F76A749F8943}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9DED0C68-3F97-4B14-88D8-F76A749F8943}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9DED0C68-3F97-4B14-88D8-F76A749F8943}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Binary file not shown.

View file

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

View file

@ -0,0 +1,112 @@
namespace Handwriting_program
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.trackBar1 = new System.Windows.Forms.TrackBar();
this.button1 = new System.Windows.Forms.Button();
this.handwriting1 = new Handwriting_program.Handwriting();
this.button2 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
this.SuspendLayout();
//
// trackBar1
//
this.trackBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.trackBar1.LargeChange = 20;
this.trackBar1.Location = new System.Drawing.Point(12, 198);
this.trackBar1.Maximum = 100;
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(260, 45);
this.trackBar1.SmallChange = 10;
this.trackBar1.TabIndex = 1;
this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged);
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(12, 249);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(260, 23);
this.button1.TabIndex = 2;
this.button1.Text = "Clear";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// handwriting1
//
this.handwriting1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.handwriting1.Location = new System.Drawing.Point(60, 29);
this.handwriting1.Name = "handwriting1";
this.handwriting1.PaintColor = System.Drawing.Color.Black;
this.handwriting1.PaintSize = 1;
this.handwriting1.Size = new System.Drawing.Size(150, 154);
this.handwriting1.TabIndex = 0;
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.button2.Location = new System.Drawing.Point(12, 278);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(260, 23);
this.button2.TabIndex = 3;
this.button2.Text = "Save";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 319);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.trackBar1);
this.Controls.Add(this.handwriting1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Handwriting handwriting1;
private System.Windows.Forms.TrackBar trackBar1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
}
}

View file

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Handwriting_program
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void trackBar1_ValueChanged(object sender, EventArgs e)
{
handwriting1.PaintSize = trackBar1.Value;
}
private void button1_Click(object sender, EventArgs e)
{
handwriting1.Clear();
}
private void button2_Click(object sender, EventArgs e)
{
handwriting1.GetBitmap().Save("bmp.bmp");
}
}
}

View file

@ -0,0 +1,120 @@
<?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>
</root>

View file

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9DED0C68-3F97-4B14-88D8-F76A749F8943}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Handwriting_program</RootNamespace>
<AssemblyName>Handwriting program</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</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|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</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="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Handwriting.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Handwriting.Designer.cs">
<DependentUpon>Handwriting.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Handwriting.resx">
<DependentUpon>Handwriting.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>
<DesignTime>True</DesignTime>
</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>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\colorpicker.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\erase.png" />
</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>

View file

@ -0,0 +1,142 @@
namespace Handwriting_program
{
partial class Handwriting
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.colorbtn = new System.Windows.Forms.Button();
this.erasebtn = new System.Windows.Forms.Button();
this.trackBar1 = new System.Windows.Forms.TrackBar();
this.sendbtn = new System.Windows.Forms.Button();
this.flowLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.White;
this.panel1.Cursor = System.Windows.Forms.Cursors.Cross;
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(439, 129);
this.panel1.TabIndex = 0;
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.Handwriting_Paint);
this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Handwriting_MouseDown);
this.panel1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Handwriting_MouseUp);
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.Controls.Add(this.colorbtn);
this.flowLayoutPanel1.Controls.Add(this.erasebtn);
this.flowLayoutPanel1.Controls.Add(this.trackBar1);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 129);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(514, 40);
this.flowLayoutPanel1.TabIndex = 1;
//
// colorbtn
//
this.colorbtn.FlatAppearance.BorderColor = System.Drawing.Color.Blue;
this.colorbtn.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Red;
this.colorbtn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Aqua;
this.colorbtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.colorbtn.Image = global::Handwriting_program.Properties.Resources.colorpicker;
this.colorbtn.Location = new System.Drawing.Point(3, 3);
this.colorbtn.Name = "colorbtn";
this.colorbtn.Size = new System.Drawing.Size(32, 32);
this.colorbtn.TabIndex = 0;
this.colorbtn.UseVisualStyleBackColor = false;
this.colorbtn.Click += new System.EventHandler(this.colorbtn_Click);
//
// erasebtn
//
this.erasebtn.FlatAppearance.BorderColor = System.Drawing.Color.Blue;
this.erasebtn.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Red;
this.erasebtn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Aqua;
this.erasebtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.erasebtn.Image = global::Handwriting_program.Properties.Resources.erase;
this.erasebtn.Location = new System.Drawing.Point(41, 3);
this.erasebtn.Name = "erasebtn";
this.erasebtn.Size = new System.Drawing.Size(32, 32);
this.erasebtn.TabIndex = 1;
this.erasebtn.UseVisualStyleBackColor = true;
this.erasebtn.Click += new System.EventHandler(this.erasebtn_Click);
//
// trackBar1
//
this.trackBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.trackBar1.Location = new System.Drawing.Point(79, 3);
this.trackBar1.Maximum = 50;
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(130, 45);
this.trackBar1.TabIndex = 2;
this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);
//
// sendbtn
//
this.sendbtn.Dock = System.Windows.Forms.DockStyle.Right;
this.sendbtn.Location = new System.Drawing.Point(439, 0);
this.sendbtn.Name = "sendbtn";
this.sendbtn.Size = new System.Drawing.Size(75, 129);
this.sendbtn.TabIndex = 2;
this.sendbtn.Text = "send";
this.sendbtn.UseVisualStyleBackColor = true;
//
// Handwriting
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.panel1);
this.Controls.Add(this.sendbtn);
this.Controls.Add(this.flowLayoutPanel1);
this.Cursor = System.Windows.Forms.Cursors.Default;
this.Name = "Handwriting";
this.Size = new System.Drawing.Size(514, 169);
this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Button colorbtn;
private System.Windows.Forms.Button erasebtn;
private System.Windows.Forms.TrackBar trackBar1;
public System.Windows.Forms.Button sendbtn;
}
}

View file

@ -0,0 +1,310 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace Handwriting_program
{
public partial class Handwriting : UserControl //2014.09.11-12.
{
public Handwriting()
{
InitializeComponent();
/*pictureBox1.Image = new Bitmap(this.Width, this.Height);
pictureBox1.SizeMode = PictureBoxSizeMode.Normal;*/
//pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
//this.ResizeRedraw = true;
pen = new Pen(PaintColor, PaintSize);
//pen.Brush = new SolidBrush(PaintColor);
pen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
pen.StartCap = LineCap.Round;
pen.EndCap = LineCap.Round;
//gr = this.CreateGraphics();
gr = panel1.CreateGraphics(); //2014.11.08.
gr.SmoothingMode = SmoothingMode.HighQuality;
thread = new Thread(new ThreadStart(ThreadFunc));
thread.IsBackground = true;
MainT = Thread.CurrentThread;
thread.Start();
//bmp = new Bitmap(this.Width, this.Height);
//bmp = new Bitmap(panel1.Width, panel1.Height, PixelFormat.Format64bppArgb); //2014.11.08. - 2014.12.05. - PixelFormat
bmp = new Bitmap(panel1.Width, panel1.Height);
}
private Color paintcolor = Color.Black;
public Color PaintColor
{
get
{
return paintcolor;
}
set
{
paintcolor = value;
//pen.Dispose();
//pen = new Pen(PaintColor, PaintSize);
pen.Color = value;
}
}
private int paintsize = 1;
public int PaintSize
{
get
{
return paintsize;
}
set
{
paintsize = value;
//pen.Dispose();
//pen = new Pen(PaintColor, PaintSize);
pen.Width = value;
}
}
public bool Erase { get; set; }
//private Timer timer = new Timer();
//private Timer resizeT = new Timer();
private Thread thread;
//private bool resizing = false;
private Pen pen;
private Point prevp;
private Graphics gr;
private Graphics bmpgr;
private Bitmap bmp;
private bool drawing = false;
private Thread MainT;
private void Handwriting_MouseDown(object sender, MouseEventArgs e)
{
/*timer.Interval = 100;
timer.Tick += timer_Tick;
timer.Start();*/
drawing = true;
}
//void timer_Tick(object sender, EventArgs e)
void ThreadFunc()
{
while (MainT.IsAlive)
{
if (!drawing)
{
prevp = new Point();
continue;
}
//GC.Collect();
/*var bm = new Bitmap(pictureBox1.Image);
Point p = pictureBox1.PointToClient(Cursor.Position);*/
Point p = new Point();
//this.Invoke(new Action(() => p = this.PointToClient(Cursor.Position)));
this.Invoke(new Action(() => p = panel1.PointToClient(Cursor.Position))); //2014.11.08.
//Graphics gr = this.CreateGraphics();
//this.Invoke(new Action(() => gr = this.CreateGraphics()));
this.Invoke(new Action(() => gr = panel1.CreateGraphics())); //2014.11.08.
/*if (bmp != null)
{
bmp.Dispose();
bmp = null;
}
bmp = new Bitmap(this.Width, this.Height);*/
this.Invoke(new Action(() => bmpgr = Graphics.FromImage(bmp)));
var tmppen = (Pen)pen.Clone();
if (Erase)
tmppen.Color = Color.White; //2014.11.08.
gr.DrawLine(tmppen, p, ((prevp.X != 0 && prevp.Y != 0) ? prevp : p));
//if (Erase)
//tmppen.Color = Color.Transparent; //2014.11.08.
//tmppen.Color = Color.Empty; //2014.12.05.
bmpgr.DrawLine(tmppen, p, ((prevp.X != 0 && prevp.Y != 0) ? prevp : p));
if (Erase)
bmp.MakeTransparent(Color.White); //2014.12.05.
prevp = p;
//Bitmap tmpbmp = new Bitmap(this.Width, this.Height);
//Bitmap tmpbmp = new Bitmap(panel1.Width, panel1.Height, PixelFormat.Format64bppArgb); //2014.11.08. - 2014.12.05. - PixelFormat
Bitmap tmpbmp = new Bitmap(panel1.Width, panel1.Height);
using (Graphics g = Graphics.FromImage(tmpbmp))
//g.DrawImage(bmp, 0, 0, this.Width, this.Height);
g.DrawImage(bmp, 0, 0, panel1.Width, panel1.Height); //2014.11.08.
bmp.Dispose();
bmp = tmpbmp;
/*if (bmp != null)
{
bmp.Dispose();
bmp = null;
}
bmp = new Bitmap(this.Width, this.Height);
this.Invoke(new Action(() => this.DrawToBitmap(bmp, new Rectangle(new Point(), this.Size))));*/
GC.Collect();
}
/*if (p.X < 0 || p.X >= bm.Width || p.Y < 0 || p.Y >= bm.Height)
return;
for (int i = 0; i < PaintSize; i++)
{
*try { bm.SetPixel(p.X - i, p.Y - i, PaintColor); }
catch (ArgumentOutOfRangeException)
{
}*
if (p.X - i >= 0 && p.Y - i >= 0)
bm.SetPixel(p.X - i, p.Y - i, PaintColor);
if (p.X - i >= 0 && p.Y + i < bm.Height)
bm.SetPixel(p.X - i, p.Y + i, PaintColor);
if (p.X + i < bm.Width && p.Y - i >= 0)
bm.SetPixel(p.X + i, p.Y - i, PaintColor);
if (p.X + i < bm.Width && p.Y + i < bm.Height)
bm.SetPixel(p.X + i, p.Y + i, PaintColor);
if (p.Y - i >= 0)
bm.SetPixel(p.X, p.Y - i, PaintColor);
if (p.Y + i < bm.Height)
bm.SetPixel(p.X, p.Y + i, PaintColor);
if (p.X - i >= 0)
bm.SetPixel(p.X - i, p.Y, PaintColor);
if (p.X + i < bm.Width)
bm.SetPixel(p.X + i, p.Y, PaintColor);
for (int j = 0; j < i; j++)
{
if (p.X - j >= 0 && p.Y + i < bm.Height)
bm.SetPixel(p.X - j, p.Y + i, PaintColor);
if (p.X + j < bm.Width && p.Y + i < bm.Height)
bm.SetPixel(p.X + j, p.Y + i, PaintColor);
if (p.X - j >= 0 && p.Y - i >= 0)
bm.SetPixel(p.X - j, p.Y - i, PaintColor);
if (p.X + j < bm.Width && p.Y - i >= 0)
bm.SetPixel(p.X + j, p.Y - i, PaintColor);
//}
//for (int j = 0; j < i; j++)
//{
if (p.X - i >= 0 && p.Y + j < bm.Height)
bm.SetPixel(p.X - i, p.Y + j, PaintColor);
if (p.X + i < bm.Height && p.Y + j < bm.Height)
bm.SetPixel(p.X + i, p.Y + j, PaintColor);
if (p.X - i >= 0 && p.Y - j >= 0)
bm.SetPixel(p.X - i, p.Y - j, PaintColor);
if (p.X + i < bm.Width && p.Y - j >= 0)
bm.SetPixel(p.X + i, p.Y - j, PaintColor);
}
}
pictureBox1.Image.Dispose();
pctureBox1.Image = bm;*/
}
private void Handwriting_MouseUp(object sender, MouseEventArgs e)
{
//timer.Stop();
drawing = false;
//prevp = null;
prevp = new Point();
}
public void Clear()
{
//pictureBox1.Image = new Bitmap(this.Width, this.Height);
//Graphics gr = this.CreateGraphics();
//gr.Clear(this.BackColor);
gr.Clear(panel1.BackColor); //2014.11.08.
bmpgr = Graphics.FromImage(bmp);
bmpgr.Clear(Color.Transparent);
}
/*private void pictureBox1_Resize(object sender, EventArgs e)
{
if(!resizeT.Enabled)
{
resizeT.Interval = 100;
resizeT.Tick += resizeT_Tick;
resizeT.Start();
}
resizing = true;
//pictureBox1.Size = this.Size;
/*try
{
var tmp = pictureBox1.Image;
pictureBox1.Image = new Bitmap(pictureBox1.Image, this.Size);
tmp.Dispose();
}
catch (ArgumentException)
{
}*/
//Refresh();
//}
/*void resizeT_Tick(object sender, EventArgs e)
{
if (!resizing)
{
pictureBox1.Size = this.Size;
try
{
var tmp = pictureBox1.Image;
pictureBox1.Image = new Bitmap(pictureBox1.Image, this.Size);
tmp.Dispose();
}
catch (ArgumentException)
{
}
Refresh();
resizeT.Stop();
}
else
resizing = false; //If true set it to false and if it doesn't turn back to true then the resizing is done
}*/
public Bitmap GetBitmap()
{
/*var bmp = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(bmp, new Rectangle(new Point(), this.Size));*/
return bmp;
}
private void Handwriting_Paint(object sender, PaintEventArgs e)
{
/*var bmp = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(bmp, new Rectangle(new Point(), this.Size));*/
if (bmp != null)
e.Graphics.DrawImage(bmp, new Point());
}
private void colorbtn_Click(object sender, EventArgs e)
{
var cpicker = new ColorDialog();
if (cpicker.ShowDialog() == DialogResult.Cancel)
return;
PaintColor = cpicker.Color;
}
private void erasebtn_Click(object sender, EventArgs e)
{
if (Erase)
{
Erase = false;
//erasebtn.Text = "erase"; //Képekkel helyettesíteni
erasebtn.FlatAppearance.BorderSize = 1; //2014.11.08.
}
else
{
Erase = true;
//erasebtn.Text = "draw"; //Képekkel helyettesíteni
erasebtn.FlatAppearance.BorderSize = 3; //2014.11.08.
}
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
pen.Width = trackBar1.Value;
}
/*private void Handwriting_MouseClick(object sender, MouseEventArgs e)
{
Handwriting_MouseUp(sender, e);
}*/
}
}

View file

@ -0,0 +1,120 @@
<?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>
</root>

View file

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Handwriting_program
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Handwriting program")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Handwriting program")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ca0951cd-7f48-49c9-ab87-0efba0a54df8")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,83 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Handwriting_program.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[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>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Handwriting_program.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap colorpicker {
get {
object obj = ResourceManager.GetObject("colorpicker", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap erase {
get {
object obj = ResourceManager.GetObject("erase", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View file

@ -0,0 +1,127 @@
<?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>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="colorpicker" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\colorpicker.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="erase" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\erase.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View file

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Handwriting_program.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.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;
}
}
}
}

View file

@ -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.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View file

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

View file

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

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View file

@ -0,0 +1,19 @@
D:\Z - Norbi cucca\0 Projektek\Handwriting program\Handwriting program\bin\Debug\Handwriting program.pdb
D:\Z - Norbi cucca\0 Projektek\Handwriting program\Handwriting program\obj\Debug\Handwriting_program.Form1.resources
D:\Z - Norbi cucca\0 Projektek\Handwriting program\Handwriting program\obj\Debug\Handwriting_program.Handwriting.resources
D:\Z - Norbi cucca\0 Projektek\Handwriting program\Handwriting program\obj\Debug\Handwriting_program.Properties.Resources.resources
D:\Z - Norbi cucca\0 Projektek\Handwriting program\Handwriting program\obj\Debug\Handwriting program.csproj.GenerateResource.Cache
D:\Z - Norbi cucca\0 Projektek\Handwriting program\Handwriting program\obj\Debug\Handwriting program.pdb
D:\Z - Norbi cucca\0 Projektek\Handwriting program\Handwriting program\bin\Debug\Handwriting program.dll.config
D:\Z - Norbi cucca\0 Projektek\Handwriting program\Handwriting program\bin\Debug\Handwriting program.dll
D:\Z - Norbi cucca\0 Projektek\Handwriting program\Handwriting program\obj\Debug\Handwriting program.dll
D:\Z - Norbi cucca\0 Projektek\MSGer.tk\0 Repository\Handwriting program\Handwriting program\bin\Debug\Handwriting program.dll.config
D:\Z - Norbi cucca\0 Projektek\MSGer.tk\0 Repository\Handwriting program\Handwriting program\bin\Debug\Handwriting program.dll
D:\Z - Norbi cucca\0 Projektek\MSGer.tk\0 Repository\Handwriting program\Handwriting program\bin\Debug\Handwriting program.pdb
D:\Z - Norbi cucca\0 Projektek\MSGer.tk\0 Repository\Handwriting program\Handwriting program\obj\Debug\Handwriting_program.Form1.resources
D:\Z - Norbi cucca\0 Projektek\MSGer.tk\0 Repository\Handwriting program\Handwriting program\obj\Debug\Handwriting_program.Handwriting.resources
D:\Z - Norbi cucca\0 Projektek\MSGer.tk\0 Repository\Handwriting program\Handwriting program\obj\Debug\Handwriting_program.Properties.Resources.resources
D:\Z - Norbi cucca\0 Projektek\MSGer.tk\0 Repository\Handwriting program\Handwriting program\obj\Debug\Handwriting program.csproj.GenerateResource.Cache
D:\Z - Norbi cucca\0 Projektek\MSGer.tk\0 Repository\Handwriting program\Handwriting program\obj\Debug\Handwriting program.dll
D:\Z - Norbi cucca\0 Projektek\MSGer.tk\0 Repository\Handwriting program\Handwriting program\obj\Debug\Handwriting program.pdb
D:\Z - Norbi cucca\0 Projektek\MSGer.tk\0 Repository\Handwriting program\Handwriting program\obj\Debug\Handwriting program.csprojResolveAssemblyReference.cache

View file

@ -9,7 +9,7 @@ using System.Windows.Forms;
namespace MSGer.tk
{
partial class AboutBox1 : Form
partial class AboutBox1 : ThemedForms
{
public AboutBox1()
{

View file

@ -11,7 +11,7 @@ using System.Windows.Forms;
namespace MSGer.tk
{
public partial class AddPartner : Form
public partial class AddPartner : ThemedForms
{
public AddPartner()
{
@ -20,7 +20,7 @@ namespace MSGer.tk
label1.Text = Language.Translate("addcontact");
label2.Text = Language.Translate("addcontact_nameemail");
searchbtn.Text = Language.Translate("addcontact_search");
glacialList1.Columns[0].Text = Language.Translate("reg_username");
glacialList1.Columns[0].Text = Language.Translate("username");
gobtn.Text = Language.Translate("addcontact_add");
}

68
MSGer.tk/BeforeLogin.Designer.cs generated Normal file
View file

@ -0,0 +1,68 @@
namespace MSGer.tk
{
partial class BeforeLogin
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(0, 24);
this.label1.TabIndex = 0;
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// BeforeLogin
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(362, 53);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.Name = "BeforeLogin";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "BeforeLogin";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.BeforeLogin_FormClosed);
this.TextChanged += new System.EventHandler(this.BeforeLogin_TextChanged);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
}
}

64
MSGer.tk/BeforeLogin.cs Normal file
View file

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MSGer.tk
{
public partial class BeforeLogin : ThemedForms
{
private static BeforeLogin mInstance;
private static bool done = false;
private static string ttext { get; set; }
public static void Create()
{
var t = new System.Threading.Thread(() =>
{
Thread.Sleep(1000);
if (done)
return;
mInstance = new BeforeLogin();
mInstance.FormClosed += (s, e) => mInstance = null;
Application.Run(mInstance);
});
t.SetApartmentState(System.Threading.ApartmentState.STA);
t.IsBackground = true;
t.Start();
}
public static void Destroy()
{
done = true;
if (mInstance != null) mInstance.Invoke(new Action(() => mInstance.Close()));
}
public static void SetText(string text)
{
if (mInstance != null) mInstance.Invoke((MethodInvoker)delegate { mInstance.Text = text; });
ttext = text;
}
private BeforeLogin()
{ //2014.09.06.
InitializeComponent();
Text = ttext;
}
private void BeforeLogin_TextChanged(object sender, EventArgs e)
{
label1.Text = this.Text;
}
private void BeforeLogin_FormClosed(object sender, FormClosedEventArgs e)
{
if (!done)
Program.Exit(false);
}
}
}

120
MSGer.tk/BeforeLogin.resx Normal file
View file

@ -0,0 +1,120 @@
<?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>
</root>

View file

@ -28,171 +28,22 @@
/// </summary>
private void InitializeComponent()
{
this.messageTextBox = new Khendys.Controls.ExRichTextBox();
this.recentMsgTextBox = new Khendys.Controls.ExRichTextBox();
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.statusLabel = new Khendys.Controls.ExRichTextBox();
this.partnerMsg = new Khendys.Controls.ExRichTextBox();
this.partnerName = new Khendys.Controls.ExRichTextBox();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.showicons = new System.Windows.Forms.CheckBox();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// messageTextBox
//
this.messageTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.messageTextBox.BackColor = System.Drawing.Color.White;
this.messageTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.messageTextBox.DetectUrls = false;
this.messageTextBox.ForeColor = System.Drawing.Color.Black;
this.messageTextBox.HiglightColor = Khendys.Controls.RtfColor.White;
this.messageTextBox.Location = new System.Drawing.Point(147, 310);
this.messageTextBox.Name = "messageTextBox";
this.messageTextBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
this.messageTextBox.Size = new System.Drawing.Size(418, 75);
this.messageTextBox.TabIndex = 0;
this.messageTextBox.Text = "";
this.messageTextBox.TextColor = Khendys.Controls.RtfColor.Black;
this.messageTextBox.TextChanged += new System.EventHandler(this.MessageTextChanged);
this.messageTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SendMessage);
//
// recentMsgTextBox
//
this.recentMsgTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.recentMsgTextBox.BackColor = System.Drawing.Color.White;
this.recentMsgTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.recentMsgTextBox.ForeColor = System.Drawing.Color.Black;
this.recentMsgTextBox.HiglightColor = Khendys.Controls.RtfColor.White;
this.recentMsgTextBox.Location = new System.Drawing.Point(147, 76);
this.recentMsgTextBox.Name = "recentMsgTextBox";
this.recentMsgTextBox.ReadOnly = true;
this.recentMsgTextBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
this.recentMsgTextBox.Size = new System.Drawing.Size(418, 228);
this.recentMsgTextBox.TabIndex = 1;
this.recentMsgTextBox.Text = "";
this.recentMsgTextBox.TextColor = Khendys.Controls.RtfColor.Black;
this.recentMsgTextBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.OpenLink);
//
// panel1
//
this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(141, 422);
this.panel1.TabIndex = 3;
//
// panel2
//
this.panel2.Controls.Add(this.statusLabel);
this.panel2.Controls.Add(this.partnerMsg);
this.panel2.Controls.Add(this.partnerName);
this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
this.panel2.Location = new System.Drawing.Point(141, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(423, 70);
this.panel2.TabIndex = 4;
//
// statusLabel
//
this.statusLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.statusLabel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(150)))), ((int)(((byte)(200)))));
this.statusLabel.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.statusLabel.ForeColor = System.Drawing.Color.Black;
this.statusLabel.HiglightColor = Khendys.Controls.RtfColor.White;
this.statusLabel.Location = new System.Drawing.Point(9, 52);
this.statusLabel.Multiline = false;
this.statusLabel.Name = "statusLabel";
this.statusLabel.Size = new System.Drawing.Size(390, 16);
this.statusLabel.TabIndex = 5;
this.statusLabel.Text = "statusLabel";
this.statusLabel.TextColor = Khendys.Controls.RtfColor.Black;
//
// partnerMsg
//
this.partnerMsg.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.partnerMsg.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(150)))), ((int)(((byte)(200)))));
this.partnerMsg.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.partnerMsg.ForeColor = System.Drawing.Color.Black;
this.partnerMsg.HiglightColor = Khendys.Controls.RtfColor.White;
this.partnerMsg.Location = new System.Drawing.Point(9, 30);
this.partnerMsg.Multiline = false;
this.partnerMsg.Name = "partnerMsg";
this.partnerMsg.Size = new System.Drawing.Size(390, 24);
this.partnerMsg.TabIndex = 4;
this.partnerMsg.Text = "partnerMsg";
this.partnerMsg.TextColor = Khendys.Controls.RtfColor.Black;
//
// partnerName
//
this.partnerName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.partnerName.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(150)))), ((int)(((byte)(200)))));
this.partnerName.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.partnerName.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.partnerName.ForeColor = System.Drawing.Color.Black;
this.partnerName.HiglightColor = Khendys.Controls.RtfColor.White;
this.partnerName.Location = new System.Drawing.Point(9, 7);
this.partnerName.Multiline = false;
this.partnerName.Name = "partnerName";
this.partnerName.ReadOnly = true;
this.partnerName.Size = new System.Drawing.Size(399, 25);
this.partnerName.TabIndex = 3;
this.partnerName.Text = "partnerName";
this.partnerName.TextColor = Khendys.Controls.RtfColor.Black;
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
//
// showicons
//
this.showicons.AutoSize = true;
this.showicons.Location = new System.Drawing.Point(150, 392);
this.showicons.Name = "showicons";
this.showicons.Size = new System.Drawing.Size(76, 17);
this.showicons.TabIndex = 5;
this.showicons.Text = "showicons";
this.showicons.UseVisualStyleBackColor = true;
this.showicons.CheckedChanged += new System.EventHandler(this.showicons_CheckedChanged);
//
// ChatForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(150)))), ((int)(((byte)(200)))));
this.ClientSize = new System.Drawing.Size(564, 422);
this.Controls.Add(this.showicons);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.recentMsgTextBox);
this.Controls.Add(this.messageTextBox);
this.Name = "ChatForm";
this.Text = "Beszélgetés";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ChatForm_FormClosing);
this.Load += new System.EventHandler(this.ChatForm_Load);
this.panel2.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Khendys.Controls.ExRichTextBox messageTextBox;
private Khendys.Controls.ExRichTextBox recentMsgTextBox;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
public Khendys.Controls.ExRichTextBox partnerName;
public Khendys.Controls.ExRichTextBox partnerMsg;
public Khendys.Controls.ExRichTextBox statusLabel;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.CheckBox showicons;
}
}

View file

@ -21,198 +21,19 @@ using HdSystemLibrary.IO;
namespace MSGer.tk
{
public partial class ChatForm : Form
public partial class ChatForm : ThemedForms
{
public static List<ChatForm> ChatWindows = new List<ChatForm>();
public List<int> ChatPartners = new List<int>();
public ChatForm()
{
InitializeComponent();
//Amint létrehozom, ez a kód lefut - Nem számit, hogy megjelenik-e
this.Text = Language.Translate("chat_title");
showicons.Text = Language.Translate("chat_showicons");
}
private void ChatForm_Load(object sender, EventArgs e)
{
if (ChatPartners.Count == 0)
MessageBox.Show(Language.Translate("error") + ": " + Language.Translate("chat_nowindow"));
if (ChatPartners.Count == 1)
{
partnerName.Text = UserInfo.Select(ChatPartners[0]).Name;
TextFormat.Parse(partnerName);
partnerMsg.Text = UserInfo.Select(ChatPartners[0]).Message;
TextFormat.Parse(partnerMsg);
switch (UserInfo.Select(ChatPartners[0]).State)
{
case 0:
{
statusLabel.Text = Language.Translate("offline");
break;
}
case 1:
{
statusLabel.Text = Language.Translate("menu_file_status_online");
break;
}
case 2:
{
statusLabel.Text = Language.Translate("menu_file_status_busy");
break;
}
case 3:
{
statusLabel.Text = Language.Translate("menu_file_status_away");
break;
}
default:
{
statusLabel.Text = Language.Translate("networking_alone");
break;
}
}
}
}
public bool InternalMessageChange = false;
public int SelectionStart = 0;
public int SelectionLength = 0;
public int TextLength = 0;
private void SendMessage(object sender, KeyEventArgs e)
{
//SendMessage
if (e.KeyCode != Keys.Enter || e.Shift || messageTextBox.Text.Length == 0)
return;
messageTextBox.ReadOnly = true;
if (!Networking.SendChatMessage(this, messageTextBox.Text))
MessageBox.Show(Language.Translate("networking_alone"));
messageTextBox.Focus();
messageTextBox.Text = "";
messageTextBox.ReadOnly = false;
}
private void MessageTextChanged(object sender, EventArgs e)
{
if (!InternalMessageChange)
{
if (messageTextBox.Text == "\n")
messageTextBox.Text = "";
#if emoticons
TextFormat.Parse((ExExRichTextBox)sender);
#endif
}
}
private void OpenLink(object sender, LinkClickedEventArgs e)
{
Process.Start(e.LinkText);
this.Text = Language.Translate("chat_title", this);
}
private void ChatForm_FormClosing(object sender, FormClosingEventArgs e)
{
ChatWindows.Remove(this);
}
public static ChatForm GetChatFormByUsers(IEnumerable<int> users) //2014.08.08. - IEnumerable: 2014.08.16.
{
int i;
for (i = 0; i < ChatWindows.Count; i++)
{
if (ChatWindows[i].ChatPartners.HasSameElementsAs(users))
break;
}
return (i != ChatWindows.Count) ? ChatWindows[i] : null; //== --> !=: 2014.09.22.
}
public string TMessage;
public int SetThreadValues()
{
recentMsgTextBox.AppendText(TMessage);
TextFormat.Parse(recentMsgTextBox);
TMessage = "";
recentMsgTextBox.SelectionStart = recentMsgTextBox.TextLength; //2014.04.10.
recentMsgTextBox.ScrollToCaret(); //2014.04.10.
return 0;
}
public void OpenSendFile(SelectPartnerForm spform)
{
//A küldő a szerver - 2014.06.15.
//Fogadás: //sendfile üzenet
if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
return;
Stream st = new FileStream(openFileDialog1.FileName, FileMode.Open);
try
{
if (new FileInfo(openFileDialog1.FileName).Length > Int64.Parse(Storage.Settings["filelen"]))
{
List<byte> buf = new List<byte>();
int b;
do
{
b = st.ReadByte();
buf.Add((byte)b);
}
while (b != -1);
st = new MemoryStream(buf.ToArray(), false);
}
}
catch (OutOfMemoryException)
{ //A MemoryStream-et nem hozza létre, ezzel elméletileg memóriát felszabadítva
st.Seek(0, SeekOrigin.Begin);
}
IPHostEntry host;
IPAddress localIP = IPAddress.Parse("127.0.0.1");
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
localIP = ip;
break;
}
}
//string ret = Networking.SendRequest("setip", spform.Partners[0] + 'ͦ' + localIP.ToString() + ":" + Settings.Default.port + ":" + openFileDialog1.FileName, 0, true);
//var ipAddr = IPAddress.Parse(ret);
IPAddress ipAddr = null; //Használja fel a partner ismert IP-címét
Socket sListener;
SocketPermission permission;
permission = new SocketPermission(NetworkAccess.Accept, TransportType.Tcp, "", SocketPermission.AllPorts);
sListener = new Socket(ipAddr.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
var ipEndPoint = new IPEndPoint(ipAddr, Int32.Parse(Storage.Settings["port"]));
sListener.Listen(1);
ST = st; //Átadja az adatfolyamot a nyilvánosabb változónak
AsyncCallback aCallback = new AsyncCallback(SendFile_AcceptCallback);
sListener.BeginAccept(aCallback, sListener);
}
private Stream ST;
private void SendFile_AcceptCallback(IAsyncResult ar)
{
Socket listener = (Socket)ar.AsyncState;
Socket handler = listener.EndAccept(ar);
var ns = new NetworkStream(handler);
ns.CopyFrom(ST, new CopyFromArguments(new ProgressChange(SendFile_ProgressChange)));
}
private void SendFile_ProgressChange(long bytesRead, long totalBytesToRead)
{
Console.WriteLine("SendFile: " + bytesRead + " / " + totalBytesToRead);
}
public string CurrentMessage = "";
private void showicons_CheckedChanged(object sender, EventArgs e)
{
if (showicons.Checked)
{
CurrentMessage = messageTextBox.Text;
messageTextBox.Enabled = false;
TextFormat.Parse(messageTextBox);
}
else
{
messageTextBox.Text = CurrentMessage;
messageTextBox.Enabled = true;
}
//chatPanel.Close();
}
}
}

View file

@ -117,7 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

296
MSGer.tk/ChatPanel.Designer.cs generated Normal file
View file

@ -0,0 +1,296 @@
namespace MSGer.tk
{
partial class ChatPanel
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.messageTextBox = new Khendys.Controls.ExRichTextBox();
this.recentMsgTextBox = new Khendys.Controls.ExRichTextBox();
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.partnerName = new Khendys.Controls.ExRichTextBox();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.showicons = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.masterPanel = new System.Windows.Forms.Panel();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit();
this.splitContainer3.Panel1.SuspendLayout();
this.splitContainer3.Panel2.SuspendLayout();
this.splitContainer3.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.masterPanel.SuspendLayout();
this.SuspendLayout();
//
// messageTextBox
//
this.messageTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.messageTextBox.BackColor = System.Drawing.Color.White;
this.messageTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.messageTextBox.DetectUrls = false;
this.messageTextBox.ForeColor = System.Drawing.Color.Black;
this.messageTextBox.HiglightColor = Khendys.Controls.RtfColor.White;
this.messageTextBox.Location = new System.Drawing.Point(0, 3);
this.messageTextBox.Name = "messageTextBox";
this.messageTextBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
this.messageTextBox.Size = new System.Drawing.Size(391, 113);
this.messageTextBox.TabIndex = 0;
this.messageTextBox.Text = "";
this.messageTextBox.TextColor = Khendys.Controls.RtfColor.Black;
this.messageTextBox.TextChanged += new System.EventHandler(this.MessageTextChanged);
this.messageTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SendMessage);
//
// recentMsgTextBox
//
this.recentMsgTextBox.BackColor = System.Drawing.Color.White;
this.recentMsgTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.recentMsgTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.recentMsgTextBox.ForeColor = System.Drawing.Color.Black;
this.recentMsgTextBox.HiglightColor = Khendys.Controls.RtfColor.White;
this.recentMsgTextBox.Location = new System.Drawing.Point(0, 0);
this.recentMsgTextBox.Name = "recentMsgTextBox";
this.recentMsgTextBox.ReadOnly = true;
this.recentMsgTextBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
this.recentMsgTextBox.Size = new System.Drawing.Size(391, 160);
this.recentMsgTextBox.TabIndex = 4;
this.recentMsgTextBox.Text = "";
this.recentMsgTextBox.TextColor = Khendys.Controls.RtfColor.Black;
this.recentMsgTextBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.OpenLink);
//
// panel1
//
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(169, 363);
this.panel1.TabIndex = 0;
//
// panel2
//
this.panel2.Controls.Add(this.partnerName);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(391, 39);
this.panel2.TabIndex = 0;
//
// partnerName
//
this.partnerName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.partnerName.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(150)))), ((int)(((byte)(200)))));
this.partnerName.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.partnerName.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.partnerName.ForeColor = System.Drawing.Color.Black;
this.partnerName.HiglightColor = Khendys.Controls.RtfColor.White;
this.partnerName.Location = new System.Drawing.Point(9, 7);
this.partnerName.Multiline = false;
this.partnerName.Name = "partnerName";
this.partnerName.ReadOnly = true;
this.partnerName.Size = new System.Drawing.Size(337, 25);
this.partnerName.TabIndex = 3;
this.partnerName.Text = "partnerName";
this.partnerName.TextColor = Khendys.Controls.RtfColor.Black;
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
//
// showicons
//
this.showicons.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.showicons.AutoSize = true;
this.showicons.Location = new System.Drawing.Point(2, 126);
this.showicons.Name = "showicons";
this.showicons.Size = new System.Drawing.Size(76, 17);
this.showicons.TabIndex = 1;
this.showicons.Text = "showicons";
this.showicons.UseVisualStyleBackColor = true;
this.showicons.CheckedChanged += new System.EventHandler(this.showicons_CheckedChanged);
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(313, 122);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 2;
this.button1.Text = "handwriting";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.panel1);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
this.splitContainer1.Size = new System.Drawing.Size(564, 363);
this.splitContainer1.SplitterDistance = 169;
this.splitContainer1.TabIndex = 7;
this.splitContainer1.TabStop = false;
//
// splitContainer2
//
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.Location = new System.Drawing.Point(0, 0);
this.splitContainer2.Name = "splitContainer2";
this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer2.Panel1
//
this.splitContainer2.Panel1.Controls.Add(this.splitContainer3);
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.showicons);
this.splitContainer2.Panel2.Controls.Add(this.button1);
this.splitContainer2.Panel2.Controls.Add(this.messageTextBox);
this.splitContainer2.Size = new System.Drawing.Size(391, 363);
this.splitContainer2.SplitterDistance = 203;
this.splitContainer2.TabIndex = 2;
this.splitContainer2.TabStop = false;
//
// splitContainer3
//
this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer3.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer3.Location = new System.Drawing.Point(0, 0);
this.splitContainer3.Name = "splitContainer3";
this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer3.Panel1
//
this.splitContainer3.Panel1.Controls.Add(this.panel2);
//
// splitContainer3.Panel2
//
this.splitContainer3.Panel2.Controls.Add(this.recentMsgTextBox);
this.splitContainer3.Size = new System.Drawing.Size(391, 203);
this.splitContainer3.SplitterDistance = 39;
this.splitContainer3.TabIndex = 2;
this.splitContainer3.TabStop = false;
//
// menuStrip1
//
this.menuStrip1.BackgroundImage = global::MSGer.tk.Properties.Resources.Menü_2;
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
this.menuStrip1.Size = new System.Drawing.Size(564, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// masterPanel
//
this.masterPanel.Controls.Add(this.splitContainer1);
this.masterPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.masterPanel.Location = new System.Drawing.Point(0, 24);
this.masterPanel.Name = "masterPanel";
this.masterPanel.Size = new System.Drawing.Size(564, 363);
this.masterPanel.TabIndex = 0;
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "File";
//
// ChatPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(150)))), ((int)(((byte)(200)))));
this.Controls.Add(this.masterPanel);
this.Controls.Add(this.menuStrip1);
this.Name = "ChatPanel";
this.Size = new System.Drawing.Size(564, 387);
this.Load += new System.EventHandler(this.ChatForm_Load);
this.panel2.ResumeLayout(false);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel2.ResumeLayout(false);
this.splitContainer2.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
this.splitContainer2.ResumeLayout(false);
this.splitContainer3.Panel1.ResumeLayout(false);
this.splitContainer3.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit();
this.splitContainer3.ResumeLayout(false);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.masterPanel.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Khendys.Controls.ExRichTextBox messageTextBox;
private Khendys.Controls.ExRichTextBox recentMsgTextBox;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
public Khendys.Controls.ExRichTextBox partnerName;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.CheckBox showicons;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.SplitContainer splitContainer3;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.Panel masterPanel;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
}
}

370
MSGer.tk/ChatPanel.cs Normal file
View file

@ -0,0 +1,370 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Net.Sockets;
using HdSystemLibrary.IO;
using System.Diagnostics;
using Handwriting_program;
namespace MSGer.tk
{
public partial class ChatPanel : UserControl
{
//public static List<ChatForm> ChatWindows = new List<ChatForm>();
public static List<ChatPanel> ChatWindows = new List<ChatPanel>();
public List<UserInfo> ChatPartners = new List<UserInfo>();
private string chatname = "";
public string ChatName //2014.12.13. - A beszélgetés neve
{
get
{
return chatname;
}
set
{
chatname = value;
this.Text = chatname;
}
}
public ChatPanel()
{
InitializeComponent();
//Amint létrehozom, ez a kód lefut - Nem számit, hogy megjelenik-e
this.Text = Language.Translate("chat_title", this);
showicons.Text = Language.Translate("chat_showicons", showicons);
}
private void ChatForm_Load(object sender, EventArgs e)
{
if (ChatPartners.Count == 0)
MessageBox.Show(Language.Translate("error") + ": " + Language.Translate("chat_nowindow"));
/*if (ChatPartners.Count == 1) - A partnerinformációkat bal oldalt jelezze, akárhányan vannak, hogy egységes legyen
{ - Felül a csoportnév látszódjon
partnerName.Text = ChatPartners[0].Name;
TextFormat.Parse(partnerName);
partnerMsg.Text = ChatPartners[0].Message;
TextFormat.Parse(partnerMsg);
switch (ChatPartners[0].State)
{
case 0:
{
statusLabel.Text = Language.Translate("offline");
break;
}
case 1:
{
statusLabel.Text = Language.Translate("menu_file_status_online");
break;
}
case 2:
{
statusLabel.Text = Language.Translate("menu_file_status_busy");
break;
}
case 3:
{
statusLabel.Text = Language.Translate("menu_file_status_away");
break;
}
default:
{
statusLabel.Text = Language.Translate("networking_alone");
break;
}
}
}*/
if (ChatName.Length == 0)
{
this.Text = "";
foreach (var item in ChatPartners)
this.Text += item.Name + ", ";
this.Text = this.Text.Remove(this.Text.Length - 2);
partnerName.Text = this.Text;
this.Text += " - " + Language.Translate("chat_title");
Language.ReloadEvent += delegate
{
if (ChatName.Length != 0)
return;
this.Text = "";
foreach (var item in ChatPartners)
this.Text += item.Name + ", ";
this.Text = this.Text.Remove(this.Text.Length - 2);
partnerName.Text = this.Text;
this.Text += " - " + Language.Translate("chat_title");
};
}
else
{
this.Text = ChatName;
}
Parent.Parent.Text = this.Text; //2014.12.22.
messageTextBox.Select();
}
public bool InternalMessageChange = false;
public int SelectionStart = 0;
public int SelectionLength = 0;
public int TextLength = 0;
private void SendMessage(object sender, KeyEventArgs e)
{
//SendMessage
if (e.KeyCode != Keys.Enter || e.Shift || messageTextBox.Text.Length == 0 || !messageTextBox.Visible) //Visible: 2014.11.07.
return;
messageTextBox.ReadOnly = true;
if (!Networking.SendChatMessage(this, messageTextBox.Text))
MessageBox.Show(Language.Translate("networking_alone"));
else //else: 2014.10.31.
messageTextBox.Text = "";
//messageTextBox.Focus();
messageTextBox.Select(); //2014.12.13.
messageTextBox.ReadOnly = false;
}
private void MessageTextChanged(object sender, EventArgs e)
{
if (!InternalMessageChange)
{
if (messageTextBox.Text == "\n")
messageTextBox.Text = "";
#if emoticons
TextFormat.Parse((ExExRichTextBox)sender);
#endif
}
}
private void OpenLink(object sender, LinkClickedEventArgs e)
{
Process.Start(e.LinkText);
}
/*private void ChatForm_FormClosing(object sender, FormClosingEventArgs e)
{
ChatWindows.Remove(this);
}*/
public static ChatPanel GetChatFormByUsers(IEnumerable<UserInfo> users) //2014.08.08. - IEnumerable: 2014.08.16.
{
int i;
for (i = 0; i < ChatWindows.Count; i++)
{
if (ChatWindows[i].ChatPartners.HasSameElementsAs(users))
break;
}
return (i != ChatWindows.Count) ? ChatWindows[i] : null;
}
public string TMessage;
public int SetThreadValues()
{
recentMsgTextBox.AppendText(TMessage);
TextFormat.Parse(recentMsgTextBox);
TMessage = "";
recentMsgTextBox.SelectionStart = recentMsgTextBox.TextLength; //2014.04.10.
recentMsgTextBox.ScrollToCaret(); //2014.04.10.
return 0;
}
public void OpenSendFile(SelectPartnerForm spform)
{
//A küldő a szerver - 2014.06.15.
//Fogadás: //sendfile üzenet
if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
return;
Stream st = new FileStream(openFileDialog1.FileName, FileMode.Open);
try
{
if (new FileInfo(openFileDialog1.FileName).Length > Int64.Parse(Storage.Settings["filelen"]))
{
List<byte> buf = new List<byte>();
int b;
do
{
b = st.ReadByte();
buf.Add((byte)b);
}
while (b != -1);
st = new MemoryStream(buf.ToArray(), false);
}
}
catch (OutOfMemoryException)
{ //A MemoryStream-et nem hozza létre, ezzel elméletileg memóriát felszabadítva
st.Seek(0, SeekOrigin.Begin);
}
IPHostEntry host;
IPAddress localIP = IPAddress.Parse("127.0.0.1");
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
localIP = ip;
break;
}
}
//string ret = Networking.SendRequest("setip", spform.Partners[0] + 'ͦ' + localIP.ToString() + ":" + Settings.Default.port + ":" + openFileDialog1.FileName, 0, true);
//var ipAddr = IPAddress.Parse(ret);
IPAddress ipAddr = null; //Használja fel a partner ismert IP-címét
Socket sListener;
SocketPermission permission;
permission = new SocketPermission(NetworkAccess.Accept, TransportType.Tcp, "", SocketPermission.AllPorts);
sListener = new Socket(ipAddr.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
var ipEndPoint = new IPEndPoint(ipAddr, Int32.Parse(Storage.Settings["port"]));
sListener.Listen(1);
ST = st; //Átadja az adatfolyamot a nyilvánosabb változónak
AsyncCallback aCallback = new AsyncCallback(SendFile_AcceptCallback);
sListener.BeginAccept(aCallback, sListener);
}
private Stream ST;
private void SendFile_AcceptCallback(IAsyncResult ar)
{
Socket listener = (Socket)ar.AsyncState;
Socket handler = listener.EndAccept(ar);
var ns = new NetworkStream(handler);
ns.CopyFrom(ST, new CopyFromArguments(new ProgressChange(SendFile_ProgressChange)));
}
private void SendFile_ProgressChange(long bytesRead, long totalBytesToRead)
{
Console.WriteLine("SendFile: " + bytesRead + " / " + totalBytesToRead);
}
public string CurrentMessage = "";
private void showicons_CheckedChanged(object sender, EventArgs e)
{
if (showicons.Checked)
{
CurrentMessage = messageTextBox.Text;
messageTextBox.Enabled = false;
TextFormat.Parse(messageTextBox);
}
else
{
messageTextBox.Text = CurrentMessage;
messageTextBox.Enabled = true;
}
}
public void Close()
{
ChatWindows.Remove(this);
if (Storage.Settings["chatwindow"] == "0" ^ SettingsForm.ApplyingSettings) //Ha az új beállítás szerint(!) külön ablakokban kell megjeleníteni, akkor hajtsa végre
{ //2014.10.31.
this.Dispose();
if (ChatIcon != null) //Most már nem feltétlenül változik a beállítás
ChatIcon.Dispose();
}
/*else
((Form)this.Parent).Close();*/
}
public void Init()
{ //2014.10.28.
if (!Storage.LoggedInSettings.ContainsKey("chatwindow")) //2014.12.05.
Storage.LoggedInSettings.Add("chatwindow", "0"); //2014.12.05.
if (Storage.Settings["chatwindow"] == "1")
{
//ChatForm a ChatPanel-lel
var cf = new ChatForm();
cf.Controls.Add(this);
cf.FormClosing += cf_FormClosing;
this.Dock = DockStyle.Fill;
cf.Show();
//cf.Focus();
cf.Select(); //2014.12.13.
}
else
{
Program.MainF.Controls.Add(this);
Program.MainF.PlaceChatIcon(this);
this.BringToFront();
this.Show();
}
}
void cf_FormClosing(object sender, FormClosingEventArgs e)
{
this.Close();
}
internal static void ReopenChatWindows(bool settingchanged)
{
for (int i = 0; i < ChatWindows.Count; i++)
{
var tmp = ChatWindows[i].ChatPartners;
if (settingchanged)
{
if (Storage.Settings["chatwindow"] == "0") //Ha az új beállítás szerint(!) külön ablakokban kell megjeleníteni, akkor hajtsa végre
((Form)ChatWindows[i].Parent.Parent).Close(); //Ezzel meghívja a saját Close()-ját is
else
ChatWindows[i].Close();
}
else
{
if (Storage.Settings["chatwindow"] == "1") //Ha a régi beállítás szerint(!) külön ablakokban kell megjeleníteni, akkor hajtsa végre
((Form)ChatWindows[i].Parent.Parent).Close(); //Ezzel meghívja a saját Close()-ját is
else
ChatWindows[i].Close();
}
var tmp2 = new ChatPanel();
tmp2.ChatPartners = tmp;
tmp2.Init();
ChatWindows.Add(tmp2);
}
}
public new void Show()
{
if (Storage.Settings["chatwindow"] == "0")
{
foreach (var item in ChatWindows)
{
item.Hide();
}
//this.Location = new Point(this.ChatIcon.Location.X + 150, this.ChatIcon.Location.Y);
//A ChatIcon-hoz a legközelebbi helyre rakja - Vagy fedje be kb. a partnerlistát, úgyis elég nagy
this.Location = new Point(150, Program.MainF.contactList.Location.Y);
}
base.Show();
}
public PictureBox ChatIcon { get; set; }
public Handwriting handw;
private void button1_Click(object sender, EventArgs e)
{
if (messageTextBox.Visible)
{
if (handw == null)
{
handw = new Handwriting();
handw.Parent = this.splitContainer2.Panel2;
handw.Bounds = messageTextBox.Bounds;
handw.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
handw.sendbtn.Text = Language.Translate("sendbtn_send", handw.sendbtn);
handw.sendbtn.Click += Handw_sendbtn_Click;
}
else
handw.Show();
messageTextBox.Hide();
}
else
{
handw.Hide();
messageTextBox.Show();
}
}
void Handw_sendbtn_Click(object sender, EventArgs e)
{
handw.GetBitmap().Save("test.bmp");
}
}
}

126
MSGer.tk/ChatPanel.resx Normal file
View file

@ -0,0 +1,126 @@
<?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="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>157, 17</value>
</metadata>
</root>

View file

@ -131,7 +131,8 @@ namespace MSGer.tk
SendUpdate();
}
}
public static IPAddress IP;
//public static IPAddress IP;
public static List<IPAddress> IPs;
public static string[] Keys
{ //2014.09.08-09.
get
@ -170,6 +171,21 @@ namespace MSGer.tk
Storage.LoggedInSettings["currentuser_keys"] = value.ToString();
}
}
public static int PicUpdateTime
{
get
{
if (!Storage.LoggedInSettings.ContainsKey("currentuser_picupdatetime"))
Storage.LoggedInSettings.Add("currentuser_picupdatetime", "0");
return Int32.Parse(Storage.LoggedInSettings["currentuser_picupdatetime"]);
}
set
{
if (!Storage.LoggedInSettings.ContainsKey("currentuser_picupdatetime"))
Storage.LoggedInSettings.Add("currentuser_picupdatetime", "0");
Storage.LoggedInSettings["currentuser_picupdatetime"] = value.ToString();
}
}
public static bool SendChanges = false;
public static void SendUpdate()
@ -188,20 +204,24 @@ namespace MSGer.tk
retstr += UserID + "_email=" + Email + "\n";
retstr += UserID + "_ispartner=" + false + "\n"; //Ellenőrizze le, amikor megkapja
retstr += UserID + "_lastupdate=" + Program.DateTimeToUnixTime(DateTime.Now);
while (true)
{
byte[][] resp = Networking.SendUpdate(Networking.UpdateType.ListUpdate, Encoding.Unicode.GetBytes(retstr), false);
bool fine = false;
if (resp == null || resp.Length == 0)
break;
foreach (var item in resp) //Ha sehonnan nem kapott választ (egy perc után), újrapróbálkozik
{
if (Networking.ParsePacket(item).Data[0] == 0x01) //2014.09.19.
fine = true;
}
if (fine)
break;
}
retstr += UserID + "_picupdatetime=" + PicUpdateTime;
//while (true)
//{
//byte[][] resp = Networking.SendUpdate(Networking.UpdateType.ListUpdate, Encoding.Unicode.GetBytes(retstr), false);
//bool fine = false; //Elvileg így az event működésekor is tudja használni, és utána ha minden rendben, akkor törli az objectet
Networking.SendUpdateInThread(Networking.UpdateType.ListUpdate, Encoding.Unicode.GetBytes(retstr), null);
/*(e, resp) =>
{
if (resp == null || resp.Length == 0)
fine = true;
foreach (var item in resp) //Ha sehonnan nem kapott választ (egy perc után), újrapróbálkozik
{
if (Networking.ParsePacket(item).Data[0] == 0x01) //2014.09.19.
fine = true;
}*/
/*if (fine)
break;*/
//}
}
}
}

54
MSGer.tk/ICMPPacket.cs Normal file
View file

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace MSGer.tk
{
public static class ICMPPacket
{
public const byte Type = ICMP_ECHO;
public const byte SubCode = 0;
public const byte RespType = ICMP_TIME_EXCEEDED;
public const byte RespCode = 1;
public const UInt16 CheckSum = 0;
public const UInt16 Identifier = 52;
public const UInt16 SequenceNumber = 84;
public static readonly byte[] Data = Encoding.Unicode.GetBytes("MSGer.tk connection");
public const byte ICMP_ECHO = 8;
public const byte ICMP_REPLY = 0;
public const byte ICMP_TIME_EXCEEDED = 11;
public static byte[] CreateRequest() //2015.02.05.
{
var data = new List<byte>();
data.Add(Type);
data.Add(SubCode);
data.AddRange(BitConverter.GetBytes(CheckSum));
data.AddRange(BitConverter.GetBytes(Identifier));
data.AddRange(BitConverter.GetBytes(SequenceNumber));
data.AddRange(Data);
return data.ToArray();
}
public static byte[] CreateReply()
{
//ICMPPacket packet = new ICMPPacket();
var data = new List<byte>();
data.Add(RespType);
data.Add(RespCode);
data.AddRange(BitConverter.GetBytes(CheckSum));
data.AddRange(BitConverter.GetBytes((int)0)); //4 bytes unused
data.AddRange(CreateRequest()); //Original packet
return data.ToArray();
}
public static bool IsPacketGood(byte[] bytes)
{
return (bytes[0] == ICMP_TIME_EXCEEDED);
}
}
}

View file

@ -10,7 +10,7 @@ using System.Windows.Forms;
namespace MSGer.tk
{
public partial class InvitePartner : Form
public partial class InvitePartner : ThemedForms
{
public InvitePartner()
{

View file

@ -15,6 +15,8 @@ namespace MSGer.tk
public Dictionary<string, string> Strings = new Dictionary<string, string>();
private static Dictionary<Control, string> Controls = new Dictionary<Control, string>();
private Language(string lang)
{
UsedLangs.Add(lang, this);
@ -33,7 +35,16 @@ namespace MSGer.tk
{
string[] lines = File.ReadAllLines(files[x]);
var dict = lines.Select(l => l.Split('=')).ToDictionary(a => a[0], a => a[1]);
new Language(new FileInfo(files[x]).Name.Split('.')[0]).Strings = dict; //(FileInfo: 2014.09.01.) - Eltárol egy új nyelvet, majd a szövegeket hozzátársítja
var finaldict = new Dictionary<string, string>();
foreach(var item in dict)
{
var spl = item.Key.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach(var key in spl)
{
finaldict.Add(key, item.Value); //Hozzáadja az összes felsorolt keyt külön, ugyanazzal az értékkel
}
}
new Language(new FileInfo(files[x]).Name.Split('.')[0]).Strings = finaldict; //(FileInfo: 2014.09.01.) - Eltárol egy új nyelvet, majd a szövegeket hozzátársítja
}
/*if (Language.FromString(Storage.Settings["lang"]) == null)
@ -66,20 +77,32 @@ namespace MSGer.tk
UsedLangs.TryGetValue(value, out tmp);
return tmp;
}
public static Language GetCuurentLanguage()
public static Language GetCurrentLanguage() //Javítva Cuurent-ről Current-re: 2014.12.13. - Már régóta ki akartam javítani
{
return Language.FromString(Storage.Settings["lang"]);
}
public static string Translate(string id)
public static string Translate(string id, Control defaultevent = null) //Csak akkor kell az event, ha látszódik az adott ablak, amikor átállítódik - Tehát csak MainForm és ChatForm
{ //2014.08.19.
Language lang = GetCuurentLanguage();
Language lang = GetCurrentLanguage();
if (lang.Strings.ContainsKey(id))
{
if (defaultevent != null) //2014.12.22.
ReloadEvent += delegate { defaultevent.Text = lang.Strings[id]; }; //2014.12.22.
return lang.Strings[id];
}
else
{
MessageBox.Show("Translation string not found: " + id + "\nIn file: " + lang + ".txt");
return "Str not found";
}
}
public static event EventHandler ReloadEvent;
public static void ReloadLangs()
{
ChatPanel.ReopenChatWindows(false);
ReloadEvent(null, null);
Program.MainF.contactList.Items.Clear();
Program.MainF.LoadPartnerList();
}
}
}

49
MSGer.tk/Logging.cs Normal file
View file

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace MSGer.tk
{
public class Logging
{
public enum LogType
{
Network
}
public static void Log(string message, LogType logtype) //2014.12.31.
{
if (!Directory.Exists("logs"))
Directory.CreateDirectory("logs");
string path;
switch (logtype)
{
case LogType.Network:
path = "network";
break;
default:
throw new NotImplementedException("Log type not implemented.");
}
string finaltext = "[" + Process.GetCurrentProcess().Id + ": " + Thread.CurrentThread.Name + " | " + DateTime.Now.ToString("yyyy.MM.dd. HH:mm:ss") + "] " + message + Environment.NewLine;
Console.WriteLine(logtype.ToString() + " - " + finaltext);
while(true)
{
bool retry = false;
try
{
File.AppendAllText("logs\\" + path + ".txt", finaltext);
}
catch(IOException)
{
retry = true;
}
if (!retry)
break;
}
}
}
}

View file

@ -173,6 +173,15 @@
this.Text = "Bejelentkezés";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.LoginForm_FormClosing);
this.Load += new System.EventHandler(this.LoginForm_Load);
this.Controls.SetChildIndex(this.label1, 0);
this.Controls.SetChildIndex(this.label2, 0);
this.Controls.SetChildIndex(this.textBox1, 0);
this.Controls.SetChildIndex(this.label3, 0);
this.Controls.SetChildIndex(this.textBox2, 0);
this.Controls.SetChildIndex(this.button1, 0);
this.Controls.SetChildIndex(this.textBox3, 0);
this.Controls.SetChildIndex(this.linkLabel1, 0);
this.Controls.SetChildIndex(this.linkLabel2, 0);
this.ResumeLayout(false);
this.PerformLayout();

View file

@ -0,0 +1,206 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MSGer.tk
{
partial class LoginForm
{
public static string UserText = ""; //2014.02.14.
public static string PassText = "";
public static string LButtonText = "";
public static bool RegistLinkEn = true;
public static bool Closeable = false;
public static HttpWebRequest Request; //2014.03.27. - A megállitáshoz
public void LoginUser()
{
//Állitson vissza minden változót, hogy újra belerakja az értekeket - 2014.02.28.
UserText = "";
PassText = "";
RegistLinkEn = false; //2014.03.27.
LButtonText = Language.Translate("button_cancel");
this.Invoke(new MyDelegate(SetLoginValues));
//HttpWebRequest httpWReq =
// (HttpWebRequest)WebRequest.Create("http://msger.tk/client.php");
#if LOCAL_SERVER
HttpWebRequest httpWReq =
(HttpWebRequest)WebRequest.Create("http://localhost/ChatWithWords/client.php");
#else
HttpWebRequest httpWReq =
(HttpWebRequest)WebRequest.Create("http://msger.url.ph/client.php");
#endif
Request = httpWReq; //2014.03.27.
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "username=" + UserText;
postData += "&password=" + CalculateMD5Hash(PassText).ToLower(); //ToLower: 2014.10.24. 1:22 - Most már a PHP-nak is titkosítania kell többek közt MD5-tel
postData += "&key=cas1fe4a6feFEFEFE1616CE8099VFE1444cdasf48c1ase5dg";
postData += "&port=" + Storage.Settings["port"]; //2014.08.29.
//postData += "&isserver=" + Storage.Settings["isserver"]; //2014.09.26.
/*postData += "&myip=" + Dns.GetHostEntry(Dns.GetHostName()).AddressList.Single(entry =>
entry.AddressFamily == AddressFamily.InterNetwork
&& (entry.ToString().Contains("192.168.0.") || entry.ToString().Contains("192.168.1.") || entry.ToString().Contains("10.0.0.") || entry.ToString().Contains("172.16.0.")) //Helyi IP-k
); //2014.11.15. - Pontok téve az IP-prefixek után, hogy pontos legyen az egyezés: 2014.12.22.
*/ //Nincs már szükség rá; IPv6
byte[] data = encoding.GetBytes(postData);
httpWReq.Method = "POST";
httpWReq.ContentType = "application/x-www-form-urlencoded";
httpWReq.ContentLength = data.Length;
try
{
using (Stream stream = httpWReq.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
}
catch (WebException e)
{
if (e.Status != WebExceptionStatus.RequestCanceled)
{
MessageBox.Show(Language.Translate("connecterror") + "\n" + e.Message, Language.Translate("error"));
this.Invoke(new MyDelegate(ResetAfterLogin));
return;
}
else
{
return;
}
}
HttpWebResponse response;
try
{
response = (HttpWebResponse)httpWReq.GetResponse();
}
catch (WebException e)
{
if (e.Status != WebExceptionStatus.RequestCanceled)
{
MessageBox.Show(Language.Translate("connecterror") + "\n" + e.Message, Language.Translate("error"));
this.Invoke(new MyDelegate(ResetAfterLogin));
return;
}
else
{
return;
}
}
string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
try
{
if (responseString[0] == '<')
{
this.Invoke(new MyDelegate(ResetAfterLogin));
MessageBox.Show(Language.Translate("error") + ":\n" + responseString);
return;
}
else
responseString = responseString.Remove(responseString.IndexOf('<'));
}
catch
{
}
if (String.Compare(responseString, "Fail") == 0)
{
this.Invoke(new MyDelegate(ResetAfterLogin));
MessageBox.Show(Language.Translate("error") + ": " + Language.Translate("login_badnamepass"), Language.Translate("error"));
}
else
{
//Elmenti az E-mail-t
if (!Storage.Settings["email"].Contains(UserText))
{
if (Storage.Settings["email"].Length != 0) //2014.07.08.
Storage.Settings["email"] += ",";
Storage.Settings["email"] += UserText;
}
//else - 2014.10.02. - Egyszer észrevettem a Google Code összehasonlítójával, hogy ez nem kéne ide
Storage.Settings["lastusedemail"] = Storage.Settings["email"].Split(',').ToList<string>().IndexOf(UserText).ToString();
/*
* respstr:
* 0: uid
* 1: username
* 2: myip
* 3: server ips
* 4: non-server ips
* 5: server same ips
* 6: non-server same ips
* 7: password
*/
string[] respstr = responseString.Split('ͦ');
//if (respstr[3].Contains("Fail"))
if(respstr.Any(entry=>entry.Contains("Fail"))) //2014.12.05.
{
this.Invoke(new MyDelegate(ResetAfterLogin));
//MessageBox.Show(respstr[3]);
try
{
MessageBox.Show(respstr.Single(entry => entry.Contains("Fail"))); //2014.12.05.
}
catch { }
return;
}
//string[] entries = respstr[(int)LoginInfo.ServerIPs].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
string[] entries = respstr[(int)LoginInfo.IPs].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
IEnumerable<IPEndPoint> ips = entries.Select(entry => ((entry != ":") ? new IPEndPoint(IPAddress.Parse(entry.Split(':')[0]), Int32.Parse(entry.Split(':')[1])) : new IPEndPoint(IPAddress.Loopback, 0)));
UserInfo.IPs = new HashSet<IPEndPoint>(ips); //2014.08.30.
//UserInfo.IPs = new HashSet<IPEndPoint>(ips.Select(entry => new IPEndPoint(entry, true))); //2014.11.23.
//CurrentUser.IP = IPAddress.Parse(respstr[(int)LoginInfo.MyIP]); //2014.10.24. - Most már csak ott lehet rá hivatkozni, felesleges eltárolni
CurrentUser.IPs = new List<IPAddress>(respstr[(int)LoginInfo.MyIP].Split(new char[] { ';' }).Select(entry => IPAddress.Parse(entry)));
/*entries = respstr[(int)LoginInfo.NonServerIPs].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
ips = entries.Select(entry => ((entry != ":") ? new IPEndPoint(IPAddress.Parse(entry.Split(':')[0]), Int32.Parse(entry.Split(':')[1])) : new IPEndPoint(IPAddress.Loopback, 0)));
foreach (var item in ips)
UserInfo.IPs.Add(new IPEndPoint(item, false)); //2014.11.23.*/
/*entries = respstr[(int)LoginInfo.ServerIPsOnNAT].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); //2014.12.18.
ips = entries.Select(entry => ((entry != ":") ? new IPEndPoint(IPAddress.Parse(entry.Split(':')[0]), Int32.Parse(entry.Split(':')[1])) : new IPEndPoint(IPAddress.Loopback, 0))); //2014.12.18.
foreach (var item in ips) //2014.12.18.
UserInfo.IPs.Add(new IPEndPoint(item, true)); //2014.12.18.*/
/*entries = respstr[(int)LoginInfo.NonServerIPsOnNat].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); //2014.12.18.
ips = entries.Select(entry => ((entry != ":") ? new IPEndPoint(IPAddress.Parse(entry.Split(':')[0]), Int32.Parse(entry.Split(':')[1])) : new IPEndPoint(IPAddress.Loopback, 0))); //2014.12.18.
foreach (var item in ips) //2014.12.18.
UserInfo.IPs.Add(new IPEndPoint(item, false)); //2014.12.18.*/
/*entries = respstr[(int)LoginInfo.IPs].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
ips = entries.Select(entry => ((entry != ":") ? new IPEndPoint(IPAddress.Parse(entry.Split(':')[0]), Int32.Parse(entry.Split(':')[1])) : new IPEndPoint(IPAddress.Loopback, 0)));
f*oreach (var item in ips)
UserInfo.IPs.Add(item);*/
//2014.09.19. - Bejelentkezés elküldése áthelyezve a MainForm-ba
CurrentUser.UserID = Int32.Parse(respstr[(int)LoginInfo.UserID]); //2014.09.01. - Áthelyeztem, hogy addig ne higgye bejelentkezettnek, amíg el nem küldi a többieknek
Storage.SaltKey = CalculateMD5Hash(PassText); //2014.08.07.
Storage.FileName = respstr[(int)LoginInfo.UserID] + ".db"; //2014.09.01. - Felesleges számmá alakítani, majd vissza
CurrentUser.UserName = UserText; //2014.09.01. - Ha semmit nem tud saját magáról, és más sem, de nem ismerőse saját magának, akkor az itt beállított felhasználónév érvényesül
CurrentUser.Name = UserText; //2014.09.01.
string ReceivedPass = respstr[(int)LoginInfo.Password]; //2014.10.24. 1:39
LoginForm.UserCode = CalculateMD5Hash(ReceivedPass + " Some text because why not " + CurrentUser.UserID).ToLower();
Closeable = true;
this.Invoke(new MyDelegate(SetLoginValues));
}
}
}
}

View file

@ -10,7 +10,7 @@ using System.Windows.Forms;
namespace MSGer.tk
{
public partial class LoginForm_RegistrationForm : Form
public partial class LoginForm_RegistrationForm : ThemedForms
{
public LoginForm_RegistrationForm()
{

View file

@ -14,10 +14,11 @@ using System.IO;
using System.Security.Cryptography;
using System.Configuration;
using System.Threading;
using System.Net.Sockets;
namespace MSGer.tk
{
public partial class LoginForm : Form
public partial class LoginForm : ThemedForms
{
public static string UserCode = "";
public static Thread LThread;
@ -127,148 +128,18 @@ namespace MSGer.tk
{ //2014.09.01.
return ResetAfterLogin(false); //Ha a thread hívja meg, ne állítsa le a thread-et
}
public static string UserText = ""; //2014.02.14.
public static string PassText = "";
public static string LButtonText = "";
public static bool RegistLinkEn = true;
public static bool Closeable = false;
public static HttpWebRequest Request; //2014.03.27. - A megállitáshoz
public void LoginUser()
public enum LoginInfo
{
//Állitson vissza minden változót, hogy újra belerakja az értekeket - 2014.02.28.
UserText = "";
PassText = "";
RegistLinkEn = false; //2014.03.27.
LButtonText = Language.Translate("button_cancel");
this.Invoke(new MyDelegate(SetLoginValues));
//HttpWebRequest httpWReq =
// (HttpWebRequest)WebRequest.Create("http://msger.tk/client.php");
#if LOCAL_SERVER
HttpWebRequest httpWReq =
(HttpWebRequest)WebRequest.Create("http://localhost/ChatWithWords/client.php");
#else
HttpWebRequest httpWReq =
(HttpWebRequest)WebRequest.Create("http://msger.url.ph/client.php");
#endif
Request = httpWReq; //2014.03.27.
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "username=" + UserText;
postData += "&password=" + CalculateMD5Hash(PassText).ToLower(); //ToLower: 2014.10.24. 1:22 - Most már a PHP-nak is titkosítania kell többek közt MD5-tel
postData += "&key=cas1fe4a6feFEFEFE1616CE8099VFE1444cdasf48c1ase5dg";
postData += "&port=" + Storage.Settings["port"]; //2014.08.29.
postData += "&isserver=" + Storage.Settings["isserver"]; //2014.09.26.
byte[] data = encoding.GetBytes(postData);
httpWReq.Method = "POST";
httpWReq.ContentType = "application/x-www-form-urlencoded";
httpWReq.ContentLength = data.Length;
try
{
using (Stream stream = httpWReq.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
}
catch (WebException e)
{
if (e.Status != WebExceptionStatus.RequestCanceled)
{
MessageBox.Show(Language.Translate("connecterror") + "\n" + e.Message, Language.Translate("error"));
this.Invoke(new MyDelegate(ResetAfterLogin));
return;
}
else
{
return;
}
}
HttpWebResponse response;
try
{
response = (HttpWebResponse)httpWReq.GetResponse();
}
catch (WebException e)
{
if (e.Status != WebExceptionStatus.RequestCanceled)
{
MessageBox.Show(Language.Translate("connecterror") + "\n" + e.Message, Language.Translate("error"));
this.Invoke(new MyDelegate(ResetAfterLogin));
return;
}
else
{
return;
}
}
string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
try
{
if (responseString[0] == '<')
{
this.Invoke(new MyDelegate(ResetAfterLogin));
MessageBox.Show(Language.Translate("error") + ":\n" + responseString);
return;
}
else
responseString = responseString.Remove(responseString.IndexOf('<'));
}
catch
{
}
if (String.Compare(responseString, "Fail") == 0)
{
this.Invoke(new MyDelegate(ResetAfterLogin));
MessageBox.Show(Language.Translate("error") + ": " + Language.Translate("login_badnamepass"), Language.Translate("error"));
}
else
{
//Elmenti az E-mail-t
if (!Storage.Settings["email"].Contains(UserText))
{
if (Storage.Settings["email"].Length != 0) //2014.07.08.
Storage.Settings["email"] += ",";
Storage.Settings["email"] += UserText;
}
//else - 2014.10.02. - Egyszer észrevettem a Google Code összehasonlítójával, hogy ez nem kéne ide
Storage.Settings["lastusedemail"] = Storage.Settings["email"].Split(',').ToList<string>().IndexOf(UserText).ToString();
string[] respstr = responseString.Split('ͦ');
if (respstr[3].Contains("Fail"))
{
this.Invoke(new MyDelegate(ResetAfterLogin));
MessageBox.Show(respstr[3]);
return;
}
string[] entries = respstr[3].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
IEnumerable<IPEndPoint> ips = entries.Select(entry => ((entry != ":") ? new IPEndPoint(IPAddress.Parse(entry.Split(':')[0]), Int32.Parse(entry.Split(':')[1])) : new IPEndPoint(IPAddress.Loopback, 0)));
UserInfo.IPs = new HashSet<IPEndPoint>(ips); //2014.08.30.
CurrentUser.IP = IPAddress.Parse(respstr[2]); //2014.10.24. - Most már csak ott lehet rá hivatkozni, felesleges eltárolni
//2014.09.19. - Bejelentkezés elküldése áthelyezve a MainForm-ba
CurrentUser.UserID = Int32.Parse(respstr[0]); //2014.09.01. - Áthelyeztem, hogy addig ne higgye bejelentkezettnek, amíg el nem küldi a többieknek
Storage.SaltKey = CalculateMD5Hash(PassText); //2014.08.07.
Storage.FileName = respstr[0] + ".db"; //2014.09.01. - Felesleges számmá alakítani, majd vissza
CurrentUser.UserName = UserText; //2014.09.01. - Ha semmit nem tud saját magáról, és más sem, de nem ismerőse saját magának, akkor az itt beállított felhasználónév érvényesül
CurrentUser.Name = UserText; //2014.09.01.
string ReceivedPass = respstr[4]; //2014.10.24. 1:39
LoginForm.UserCode = CalculateMD5Hash(ReceivedPass + " Some text because why not " + CurrentUser.UserID).ToLower();
Closeable = true;
this.Invoke(new MyDelegate(SetLoginValues));
}
UserID,
UserName,
MyIP,
//ServerIPs,
//NonServerIPs,
//ServerIPsOnNAT,
//NonServerIPsOnNat,
IPs,
Password
}
public static string CalculateMD5Hash(string input)

View file

@ -11,6 +11,7 @@
<AssemblyName>MSGer.tk</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@ -23,7 +24,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
@ -45,6 +45,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<NoWin32Manifest>true</NoWin32Manifest>
@ -94,8 +95,15 @@
<Compile Include="ChatForm.Designer.cs">
<DependentUpon>ChatForm.cs</DependentUpon>
</Compile>
<Compile Include="ChatPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ChatPanel.Designer.cs">
<DependentUpon>ChatPanel.cs</DependentUpon>
</Compile>
<Compile Include="CurrentUser.cs" />
<Compile Include="ErrorHandling.cs" />
<Compile Include="ICMPPacket.cs" />
<Compile Include="InvitePartner.cs">
<SubType>Form</SubType>
</Compile>
@ -103,6 +111,7 @@
<DependentUpon>InvitePartner.cs</DependentUpon>
</Compile>
<Compile Include="Language.cs" />
<Compile Include="Logging.cs" />
<Compile Include="LoginForm.RegistrationForm.cs">
<SubType>Form</SubType>
</Compile>
@ -121,7 +130,12 @@
<Compile Include="LoginForm.Designer.cs">
<DependentUpon>LoginForm.cs</DependentUpon>
</Compile>
<Compile Include="MainForm.Events.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Networking.CreateParse.cs" />
<Compile Include="Networking.cs" />
<Compile Include="Networking.SendRequest.cs" />
<Compile Include="Notifier.cs">
<SubType>Form</SubType>
</Compile>
@ -144,6 +158,13 @@
<Compile Include="Storage.cs" />
<Compile Include="StreamHelper.cs" />
<Compile Include="TextFormat.cs" />
<Compile Include="Theme.cs" />
<Compile Include="ThemedForms.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ThemedForms.Designer.cs">
<DependentUpon>ThemedForms.cs</DependentUpon>
</Compile>
<Compile Include="UpdateListAndChat.cs" />
<Compile Include="_MyNotifier.cs" />
<Compile Include="Program.cs" />
@ -172,6 +193,9 @@
<EmbeddedResource Include="ChatForm.resx">
<DependentUpon>ChatForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ChatPanel.resx">
<DependentUpon>ChatPanel.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="InvitePartner.resx">
<DependentUpon>InvitePartner.cs</DependentUpon>
</EmbeddedResource>
@ -193,6 +217,7 @@
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="SelectPartnerForm.resx">
<DependentUpon>SelectPartnerForm.cs</DependentUpon>
@ -200,6 +225,14 @@
<EmbeddedResource Include="SettingsForm.resx">
<DependentUpon>SettingsForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ThemedForms.resx">
<DependentUpon>ThemedForms.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="LoginForm.LoginUser.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Networking.SendUpdate.cs" />
<Compile Include="Networking.Threads.cs" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@ -255,11 +288,26 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\RichListView\RichListView\RichListView\RichListView.csproj">
<Project>{AE5CA7F1-D19E-479B-B06B-39C1280C5005}</Project>
<ProjectReference Include="..\Handwriting program\Handwriting program\Handwriting program.csproj">
<Project>{9ded0c68-3f97-4b14-88d8-f76a749f8943}</Project>
<Name>Handwriting program</Name>
</ProjectReference>
<ProjectReference Include="..\RichListView\RichListView\RichListView.csproj">
<Project>{ae5ca7f1-d19e-479b-b06b-39c1280c5005}</Project>
<Name>RichListView</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<COMReference Include="NATUPNPLib">
<Guid>{1C565858-F302-471E-B409-F180AA4ABEC6}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</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.

View file

@ -1,11 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.21005.1
VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSGer.tk", "MSGer.tk.csproj", "{F60940C0-05FC-46C0-948E-6DBECBBE38DD}"
ProjectSection(ProjectDependencies) = postProject
{FCEAE638-329B-4392-8A9E-FEABEACBA077} = {FCEAE638-329B-4392-8A9E-FEABEACBA077}
{9DED0C68-3F97-4B14-88D8-F76A749F8943} = {9DED0C68-3F97-4B14-88D8-F76A749F8943}
{AE5CA7F1-D19E-479B-B06B-39C1280C5005} = {AE5CA7F1-D19E-479B-B06B-39C1280C5005}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RichListView", "..\..\..\RichListView\RichListView\RichListView\RichListView.csproj", "{AE5CA7F1-D19E-479B-B06B-39C1280C5005}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Handwriting program", "..\Handwriting program\Handwriting program\Handwriting program.csproj", "{9DED0C68-3F97-4B14-88D8-F76A749F8943}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RichListView", "..\RichListView\RichListView\RichListView.csproj", "{AE5CA7F1-D19E-479B-B06B-39C1280C5005}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "..\Updater\Updater.csproj", "{FCEAE638-329B-4392-8A9E-FEABEACBA077}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -17,10 +26,18 @@ Global
{F60940C0-05FC-46C0-948E-6DBECBBE38DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F60940C0-05FC-46C0-948E-6DBECBBE38DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F60940C0-05FC-46C0-948E-6DBECBBE38DD}.Release|Any CPU.Build.0 = Release|Any CPU
{9DED0C68-3F97-4B14-88D8-F76A749F8943}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9DED0C68-3F97-4B14-88D8-F76A749F8943}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9DED0C68-3F97-4B14-88D8-F76A749F8943}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9DED0C68-3F97-4B14-88D8-F76A749F8943}.Release|Any CPU.Build.0 = Release|Any CPU
{AE5CA7F1-D19E-479B-B06B-39C1280C5005}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE5CA7F1-D19E-479B-B06B-39C1280C5005}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE5CA7F1-D19E-479B-B06B-39C1280C5005}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE5CA7F1-D19E-479B-B06B-39C1280C5005}.Release|Any CPU.Build.0 = Release|Any CPU
{FCEAE638-329B-4392-8A9E-FEABEACBA077}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCEAE638-329B-4392-8A9E-FEABEACBA077}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCEAE638-329B-4392-8A9E-FEABEACBA077}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCEAE638-329B-4392-8A9E-FEABEACBA077}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Binary file not shown.

View file

@ -32,16 +32,16 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
SzNPProjects.RichListViewColumn richListViewColumn1 = new SzNPProjects.RichListViewColumn();
SzNPProjects.RichListViewColumn richListViewColumn2 = new SzNPProjects.RichListViewColumn();
SzNPProjects.RichListViewColumn richListViewColumn3 = new SzNPProjects.RichListViewColumn();
SzNPProjects.RichListViewColumn richListViewColumn4 = new SzNPProjects.RichListViewColumn();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.iconMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator18 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem8 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem9 = new System.Windows.Forms.ToolStripMenuItem();
this.button1 = new System.Windows.Forms.Button();
this.panel2 = new System.Windows.Forms.Panel();
this.textBox1 = new System.Windows.Forms.TextBox();
this.panel1 = new System.Windows.Forms.Panel();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fájlToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.kijelentkezésToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -104,25 +104,22 @@
this.toolStripSeparator13 = new System.Windows.Forms.ToolStripSeparator();
this.névjegyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.partnerImages = new System.Windows.Forms.ImageList(this.components);
this.partnerMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.üzenetküldésToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.emailKüldéseemailToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.információToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator14 = new System.Windows.Forms.ToolStripSeparator();
this.ismerősLetiltásaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ismerősTörléseToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator15 = new System.Windows.Forms.ToolStripSeparator();
this.becenévSzerkesztéseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator16 = new System.Windows.Forms.ToolStripSeparator();
this.eseményértesitésekToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator17 = new System.Windows.Forms.ToolStripSeparator();
this.beszélgetésnaplóMegnyitásaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contactList = new SzNPProjects.RichListView();
this.MainPanel = new System.Windows.Forms.Panel();
this.searchListView = new SzNPProjects.RichListView();
this.statusStrip2 = new System.Windows.Forms.StatusStrip();
this.servers = new System.Windows.Forms.ToolStripStatusLabel();
this.onlineservers = new System.Windows.Forms.ToolStripStatusLabel();
this.mainserver = new System.Windows.Forms.ToolStripStatusLabel();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
this.chatIconMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.listPartnerMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.iconMenu.SuspendLayout();
this.panel2.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.partnerMenu.SuspendLayout();
this.MainPanel.SuspendLayout();
this.statusStrip2.SuspendLayout();
this.SuspendLayout();
//
// notifyIcon1
@ -170,16 +167,6 @@
this.toolStripMenuItem9.Text = "Kilépés";
this.toolStripMenuItem9.Click += new System.EventHandler(this.ExitProgram);
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button1.Location = new System.Drawing.Point(519, 104);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(35, 23);
this.button1.TabIndex = 4;
this.button1.UseVisualStyleBackColor = true;
//
// panel2
//
this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@ -187,10 +174,12 @@
this.panel2.BackgroundImage = global::MSGer.tk.Properties.Resources.Keresősáv;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel2.Controls.Add(this.textBox1);
this.panel2.Location = new System.Drawing.Point(0, 96);
this.panel2.Cursor = System.Windows.Forms.Cursors.IBeam;
this.panel2.Location = new System.Drawing.Point(3, 3);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(513, 31);
this.panel2.Size = new System.Drawing.Size(494, 31);
this.panel2.TabIndex = 5;
this.panel2.Click += new System.EventHandler(this.panel2_Click);
//
// textBox1
//
@ -201,23 +190,13 @@
this.textBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(137)))), ((int)(((byte)(161)))), ((int)(((byte)(194)))));
this.textBox1.Location = new System.Drawing.Point(6, 8);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(504, 13);
this.textBox1.Size = new System.Drawing.Size(485, 13);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "Ismerősök keresése...";
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
this.textBox1.Enter += new System.EventHandler(this.ClearSearchBar);
this.textBox1.Leave += new System.EventHandler(this.PutTextInSearchBar);
//
// panel1
//
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel1.BackgroundImage = global::MSGer.tk.Properties.Resources.Blue_Wallpaper_HD_2;
this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel1.Location = new System.Drawing.Point(0, 27);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(624, 63);
this.panel1.TabIndex = 2;
//
// menuStrip1
//
this.menuStrip1.BackColor = System.Drawing.Color.Black;
@ -231,7 +210,7 @@
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
this.menuStrip1.Size = new System.Drawing.Size(624, 24);
this.menuStrip1.Size = new System.Drawing.Size(799, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
@ -666,102 +645,6 @@
this.partnerImages.ImageSize = new System.Drawing.Size(16, 16);
this.partnerImages.TransparentColor = System.Drawing.Color.Transparent;
//
// partnerMenu
//
this.partnerMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.üzenetküldésToolStripMenuItem,
this.emailKüldéseemailToolStripMenuItem,
this.toolStripMenuItem2,
this.információToolStripMenuItem,
this.toolStripSeparator14,
this.ismerősLetiltásaToolStripMenuItem,
this.ismerősTörléseToolStripMenuItem1,
this.toolStripSeparator15,
this.becenévSzerkesztéseToolStripMenuItem,
this.toolStripSeparator16,
this.eseményértesitésekToolStripMenuItem,
this.toolStripSeparator17,
this.beszélgetésnaplóMegnyitásaToolStripMenuItem});
this.partnerMenu.Name = "partnerMenu";
this.partnerMenu.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
this.partnerMenu.Size = new System.Drawing.Size(238, 226);
//
// üzenetküldésToolStripMenuItem
//
this.üzenetküldésToolStripMenuItem.Name = "üzenetküldésToolStripMenuItem";
this.üzenetküldésToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
this.üzenetküldésToolStripMenuItem.Text = "Üzenetküldés";
this.üzenetküldésToolStripMenuItem.Click += new System.EventHandler(this.PartnerMenu_SendMessage);
//
// emailKüldéseemailToolStripMenuItem
//
this.emailKüldéseemailToolStripMenuItem.Name = "emailKüldéseemailToolStripMenuItem";
this.emailKüldéseemailToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
this.emailKüldéseemailToolStripMenuItem.Text = "E-mail küldése (email)";
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(237, 22);
this.toolStripMenuItem2.Text = "E-mail másolása";
//
// információToolStripMenuItem
//
this.információToolStripMenuItem.Name = "információToolStripMenuItem";
this.információToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
this.információToolStripMenuItem.Text = "Információ";
this.információToolStripMenuItem.Click += new System.EventHandler(this.információToolStripMenuItem_Click);
//
// toolStripSeparator14
//
this.toolStripSeparator14.Name = "toolStripSeparator14";
this.toolStripSeparator14.Size = new System.Drawing.Size(234, 6);
//
// ismerősLetiltásaToolStripMenuItem
//
this.ismerősLetiltásaToolStripMenuItem.Name = "ismerősLetiltásaToolStripMenuItem";
this.ismerősLetiltásaToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
this.ismerősLetiltásaToolStripMenuItem.Text = "Ismerős letiltása";
//
// ismerősTörléseToolStripMenuItem1
//
this.ismerősTörléseToolStripMenuItem1.Name = "ismerősTörléseToolStripMenuItem1";
this.ismerősTörléseToolStripMenuItem1.Size = new System.Drawing.Size(237, 22);
this.ismerősTörléseToolStripMenuItem1.Text = "Ismerős törlése";
//
// toolStripSeparator15
//
this.toolStripSeparator15.Name = "toolStripSeparator15";
this.toolStripSeparator15.Size = new System.Drawing.Size(234, 6);
//
// becenévSzerkesztéseToolStripMenuItem
//
this.becenévSzerkesztéseToolStripMenuItem.Name = "becenévSzerkesztéseToolStripMenuItem";
this.becenévSzerkesztéseToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
this.becenévSzerkesztéseToolStripMenuItem.Text = "Becenév szerkesztése";
//
// toolStripSeparator16
//
this.toolStripSeparator16.Name = "toolStripSeparator16";
this.toolStripSeparator16.Size = new System.Drawing.Size(234, 6);
//
// eseményértesitésekToolStripMenuItem
//
this.eseményértesitésekToolStripMenuItem.Name = "eseményértesitésekToolStripMenuItem";
this.eseményértesitésekToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
this.eseményértesitésekToolStripMenuItem.Text = "Eseményértesitések";
//
// toolStripSeparator17
//
this.toolStripSeparator17.Name = "toolStripSeparator17";
this.toolStripSeparator17.Size = new System.Drawing.Size(234, 6);
//
// beszélgetésnaplóMegnyitásaToolStripMenuItem
//
this.beszélgetésnaplóMegnyitásaToolStripMenuItem.Name = "beszélgetésnaplóMegnyitásaToolStripMenuItem";
this.beszélgetésnaplóMegnyitásaToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
this.beszélgetésnaplóMegnyitásaToolStripMenuItem.Text = "Beszélgetésnapló megnyitása...";
//
// contactList
//
this.contactList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -780,25 +663,131 @@
richListViewColumn2};
this.contactList.HeaderHeight = 0;
this.contactList.ItemHeight = 50;
this.contactList.Location = new System.Drawing.Point(0, 134);
this.contactList.Location = new System.Drawing.Point(3, 40);
this.contactList.Name = "contactList";
this.contactList.SelectedIndex = -1;
this.contactList.SelectionColor = System.Drawing.Color.Aqua;
this.contactList.Size = new System.Drawing.Size(624, 311);
this.contactList.TabIndex = 8;
this.contactList.Size = new System.Drawing.Size(494, 468);
this.contactList.TabIndex = 0;
this.contactList.ItemDoubleClicked += new System.EventHandler<int>(this.contactList_ItemDoubleClicked);
this.contactList.ItemRightClicked += new System.EventHandler<int>(this.contactList_ItemRightClicked);
//
// MainPanel
//
this.MainPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.MainPanel.Controls.Add(this.searchListView);
this.MainPanel.Controls.Add(this.contactList);
this.MainPanel.Controls.Add(this.statusStrip2);
this.MainPanel.Controls.Add(this.panel2);
this.MainPanel.Location = new System.Drawing.Point(150, 27);
this.MainPanel.Name = "MainPanel";
this.MainPanel.Size = new System.Drawing.Size(500, 533);
this.MainPanel.TabIndex = 9;
//
// searchListView
//
this.searchListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.searchListView.AutoScroll = true;
this.searchListView.AutoUpdate = true;
this.searchListView.AutoValidate = System.Windows.Forms.AutoValidate.EnablePreventFocusChange;
this.searchListView.ColumnAutoFill = true;
richListViewColumn3.Text = null;
richListViewColumn3.Width = 50;
richListViewColumn4.Text = null;
richListViewColumn4.Width = 100;
this.searchListView.Columns = new SzNPProjects.RichListViewColumn[] {
richListViewColumn3,
richListViewColumn4};
this.searchListView.HeaderHeight = 0;
this.searchListView.ItemHeight = 50;
this.searchListView.Location = new System.Drawing.Point(3, 32);
this.searchListView.Name = "searchListView";
this.searchListView.SelectedIndex = -1;
this.searchListView.SelectionColor = System.Drawing.Color.Aqua;
this.searchListView.Size = new System.Drawing.Size(494, 363);
this.searchListView.TabIndex = 7;
this.searchListView.Visible = false;
//
// statusStrip2
//
this.statusStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.servers,
this.onlineservers,
this.mainserver});
this.statusStrip2.Location = new System.Drawing.Point(0, 511);
this.statusStrip2.Name = "statusStrip2";
this.statusStrip2.Size = new System.Drawing.Size(500, 22);
this.statusStrip2.SizingGrip = false;
this.statusStrip2.TabIndex = 6;
//
// servers
//
this.servers.Name = "servers";
this.servers.Size = new System.Drawing.Size(43, 17);
this.servers.Text = "servers";
//
// onlineservers
//
this.onlineservers.Name = "onlineservers";
this.onlineservers.Size = new System.Drawing.Size(76, 17);
this.onlineservers.Text = "onlineservers";
//
// mainserver
//
this.mainserver.Name = "mainserver";
this.mainserver.Size = new System.Drawing.Size(366, 17);
this.mainserver.Spring = true;
this.mainserver.Text = "mainserver";
this.mainserver.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.flowLayoutPanel1.AutoScroll = true;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 27);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(150, 533);
this.flowLayoutPanel1.TabIndex = 10;
this.flowLayoutPanel1.WrapContents = false;
this.flowLayoutPanel1.Click += new System.EventHandler(this.flowLayoutPanel1_Click);
//
// flowLayoutPanel2
//
this.flowLayoutPanel2.AutoScroll = true;
this.flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Right;
this.flowLayoutPanel2.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel2.Location = new System.Drawing.Point(649, 24);
this.flowLayoutPanel2.Name = "flowLayoutPanel2";
this.flowLayoutPanel2.Size = new System.Drawing.Size(150, 538);
this.flowLayoutPanel2.TabIndex = 11;
this.flowLayoutPanel2.WrapContents = false;
this.flowLayoutPanel2.Click += new System.EventHandler(this.flowLayoutPanel1_Click);
//
// chatIconMenu
//
this.chatIconMenu.Name = "contextMenuStrip1";
this.chatIconMenu.Size = new System.Drawing.Size(61, 4);
//
// listPartnerMenu
//
this.listPartnerMenu.Name = "listPartnerMenu";
this.listPartnerMenu.Size = new System.Drawing.Size(61, 4);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.LightSkyBlue;
this.ClientSize = new System.Drawing.Size(624, 442);
this.Controls.Add(this.contactList);
this.Controls.Add(this.panel2);
this.Controls.Add(this.button1);
this.Controls.Add(this.panel1);
this.ClientSize = new System.Drawing.Size(799, 562);
this.Controls.Add(this.MainPanel);
this.Controls.Add(this.flowLayoutPanel2);
this.Controls.Add(this.flowLayoutPanel1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "MainForm";
@ -811,7 +800,10 @@
this.panel2.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.partnerMenu.ResumeLayout(false);
this.MainPanel.ResumeLayout(false);
this.MainPanel.PerformLayout();
this.statusStrip2.ResumeLayout(false);
this.statusStrip2.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -879,25 +871,9 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator13;
private System.Windows.Forms.ToolStripMenuItem névjegyToolStripMenuItem;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.ImageList partnerImages;
private System.Windows.Forms.ContextMenuStrip partnerMenu;
private System.Windows.Forms.ToolStripMenuItem üzenetküldésToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem emailKüldéseemailToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
private System.Windows.Forms.ToolStripMenuItem információToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator14;
private System.Windows.Forms.ToolStripMenuItem ismerősLetiltásaToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ismerősTörléseToolStripMenuItem1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator15;
private System.Windows.Forms.ToolStripMenuItem becenévSzerkesztéseToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator16;
private System.Windows.Forms.ToolStripMenuItem eseményértesitésekToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator17;
private System.Windows.Forms.ToolStripMenuItem beszélgetésnaplóMegnyitásaToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
private System.Windows.Forms.ContextMenuStrip iconMenu;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator18;
@ -906,6 +882,16 @@
public System.Windows.Forms.ToolStripMenuItem toolStripMenuItem9;
internal System.Windows.Forms.NotifyIcon notifyIcon1;
internal SzNPProjects.RichListView contactList;
private System.Windows.Forms.Panel MainPanel;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2;
private System.Windows.Forms.StatusStrip statusStrip2;
private System.Windows.Forms.ToolStripStatusLabel servers;
private System.Windows.Forms.ToolStripStatusLabel onlineservers;
private System.Windows.Forms.ToolStripStatusLabel mainserver;
private System.Windows.Forms.ContextMenuStrip chatIconMenu;
private System.Windows.Forms.ContextMenuStrip listPartnerMenu;
internal SzNPProjects.RichListView searchListView;
}
}

316
MSGer.tk/MainForm.Events.cs Normal file
View file

@ -0,0 +1,316 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MSGer.tk
{
partial class MainForm
{
private void PopupCloseClick(object sender, EventArgs e)
{
MessageBox.Show("Close");
}
private void PopupClick(object sender, EventArgs e)
{
MessageBox.Show("Click");
}
private void LoginNewUser(object sender, EventArgs e)
{
Storage.Save(true); //2014.09.19.
Process.Start(((Program.ProcessName.Contains("vshost")) ? Program.ProcessName.Replace(".vshost", "") : Program.ProcessName) + ".exe", "multi");
}
public void SetOnlineState(object sender, EventArgs e)
{
int state = 0;
if (sender == elérhetőToolStripMenuItem)
state = 1;
if (sender == elfoglaltToolStripMenuItem)
state = 2;
if (sender == nincsAGépnélToolStripMenuItem)
state = 3;
if (sender == null) //2014.08.30. - Erre nagyon sokáig nem volt felkészítve, és ezt kihasználtam a kijelentkezéshez
{
if (Networking.SendRequest("setstate", 0 + "", 0, true).Contains("Fail")) //Kijelentkezés - if: 2014.11.15.
MessageBox.Show(Language.Translate("error"));
//byte[] tmpb = Encoding.Unicode.GetBytes(CurrentUser.IP.ToString());
string str = "";
foreach (var ip in CurrentUser.IPs)
str += ip + ";";
byte[] tmpb = Encoding.Unicode.GetBytes(str);
byte[] sendb = new byte[4 + tmpb.Length];
Array.Copy(BitConverter.GetBytes(tmpb.Length), sendb, 4);
Array.Copy(tmpb, 0, sendb, 4, tmpb.Length);
//Networking.SendUpdate(Networking.UpdateType.LogoutUser, sendb, false);
Networking.SendUpdateInThread(Networking.UpdateType.LogoutUser, sendb, null);
CurrentUser.SendChanges = false; //2014.12.31.
}
CurrentUser.State = state; //2014.08.28.
}
private void SelectPartner(object sender, EventArgs e)
{
var form = new SelectPartnerForm((ToolStripMenuItem)sender);
DialogResult dr = form.ShowDialog();
if (dr == DialogResult.OK)
{
//2014.04.25.
string[] partners = form.Partners;
ChatPanel tmpchat = new ChatPanel();
for (int i = 0; i < partners.Length; i++)
{
if (partners[i] != "") //2014.04.17.
{
for (int j = 0; j < UserInfo.KnownUsers.Count; j++)
{
if (!UserInfo.KnownUsers[j].IsPartner)
continue;
int tmp; //2014.04.17.
if (!Int32.TryParse(partners[i], out tmp))
tmp = -1;
if (UserInfo.KnownUsers[j].UserName == partners[i] || UserInfo.KnownUsers[j].Email == partners[i] || UserInfo.KnownUsers[j].UserID == tmp)
{ //Egyezik a név, E-mail vagy ID - UserName: 2014.04.17.
tmpchat.ChatPartners.Add(UserInfo.KnownUsers[j]); //2014.08.28.
}
}
}
}
if (tmpchat.ChatPartners.Count != 0)
{
ChatPanel.ChatWindows.Add(tmpchat);
if (sender == fájlKüldéseToolStripMenuItem)
{
//tmpchat.Show();
tmpchat.Init();
tmpchat.OpenSendFile(form);
}
if (sender == azonnaliÜzenetKüldéseToolStripMenuItem)
{
//tmpchat.Show();
tmpchat.Init();
}
}
}
}
private void ClearSearchBar(object sender, EventArgs e)
{
if (textBox1.Text == Language.Translate("searchbar"))
textBox1.Clear();
}
private void PutTextInSearchBar(object sender, EventArgs e)
{
if (textBox1.Text == "")
textBox1.Text = Language.Translate("searchbar");
}
//public static int RightClickedPartner = -1;
public static void OpenSendMessage(int uid)
{
var uinfo = UserInfo.Select(uid);
//Üzenetküldő form
int ChatNum = -1;
for (int i = 0; i < ChatPanel.ChatWindows.Count; i++)
{
if (ChatPanel.ChatWindows[i].ChatPartners.Count == 1 && ChatPanel.ChatWindows[i].ChatPartners.Contains(uinfo))
{ //Vele, és csak vele beszél
ChatNum = i;
break;
}
}
if (ChatNum == -1)
{ //Nincs még chatablaka
ChatPanel.ChatWindows.Add(new ChatPanel());
//ChatPanel.ChatWindows[ChatPanel.ChatWindows.Count - 1].ChatPartners.Add(uid);
//ChatPanel.ChatWindows[ChatPanel.ChatWindows.Count - 1].Show();
//ChatPanel.ChatWindows[ChatPanel.ChatWindows.Count - 1].Focus(); //2014.08.08.
var cf = ChatPanel.ChatWindows[ChatPanel.ChatWindows.Count - 1];
cf.ChatPartners.Add(uinfo);
cf.Init();
}
else
{
ChatPanel.ChatWindows[ChatNum].Show();
ChatPanel.ChatWindows[ChatNum].Focus();
}
}
private void OnMainFormLoad(object sender, EventArgs e)
{
if (CurrentUser.UserID == 0)
Program.Exit();
LoadPartnerList(); //Be kell töltenie a MainForm-nak, hogy hivatkozhasson rá
CurrentUser.SendChanges = true; //2014.08.30.
}
private void InvitePartner(object sender, EventArgs e)
{
(new InvitePartner()).ShowDialog();
}
private void BeforeExit(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
}
private void toolStripMenuItem4_Click(object sender, EventArgs e)
{
if (CurrentUser.UserID != 0) //2014.04.18.
{
this.Show();
this.Focus();
}
}
private void ExitProgram(object sender, EventArgs e)
{
Program.Exit();
}
private void ismerősFelvételeToolStripMenuItem_Click(object sender, EventArgs e)
{
(new AddPartner()).ShowDialog();
}
private void névjegyToolStripMenuItem_Click(object sender, EventArgs e)
{
(new AboutBox1()).ShowDialog();
}
private void mindigLegfelülToolStripMenuItem_Click(object sender, EventArgs e)
{
this.TopMost = mindigLegfelülToolStripMenuItem.Checked;
}
private void beállitásokToolStripMenuItem_Click(object sender, EventArgs e)
{
//(new SettingsForm()).Show();
if (Program.SettingsF == null)
{
Program.SettingsF = new SettingsForm();
Program.SettingsF.Show();
}
}
private void contactList_ItemDoubleClicked(object sender, int e)
{
int uid = UserInfo.GetUserIDFromListID(e);
OpenSendMessage(uid);
}
private void bezárásToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Hide();
}
private void információToolStripMenuItem_Click(object sender, EventArgs e)
{
/*if (RightClickedPartner == -1)
return;*/
for (int i = 0; i < UserInfo.KnownUsers.Count; i++)
{
if (UserInfo.KnownUsers[i].TMPListID != (int)((ToolStripMenuItem)sender).GetCurrentParent().Tag)
continue;
(new PartnerInformation(UserInfo.KnownUsers[i])).ShowDialog();
break;
}
}
private void contactList_ItemRightClicked(object sender, int e)
{
contactList.Items[e].Selected = true;
//RightClickedPartner = e;
//partnerMenu.Show(Cursor.Position);
listPartnerMenu.Tag = e;
listPartnerMenu.Show(Cursor.Position);
}
private void PartnerMenu_SendMessage(object sender, EventArgs e)
{
/*if (RightClickedPartner == -1)
return;
int uid = UserInfo.GetUserIDFromListID(RightClickedPartner);
OpenSendMessage(uid);
RightClickedPartner = -1;*/
int uid = UserInfo.GetUserIDFromListID((int)((ToolStripMenuItem)sender).GetCurrentParent().Tag); //Erre kattintott jobb gombbal
OpenSendMessage(uid);
}
private void panel2_Click(object sender, EventArgs e)
{ //2014.10.31.
textBox1.Focus();
}
private System.Windows.Forms.Timer searchbartimer = new System.Windows.Forms.Timer();
//private RichListView searchlist = new RichListView();
private void textBox1_TextChanged(object sender, EventArgs e)
{ //2014.11.30. 1:33
var searchlist = searchListView; //2014.12.14. 1:46
/*if (textBox1.Text.Length == 0 || textBox1.Text == Language.Translate("searchbar")) //text==translate...: 2014.12.05.
{
searchlist.Items.Clear();
searchlist.Visible = false;
contactList.Visible = true;
return;
}*/
if (searchbartimer.Enabled)
return;
searchbartimer.Interval = 1000;
searchbartimer.Tick += delegate
{
searchbartimer.Stop();
if (textBox1.Text.Length == 0 || textBox1.Text == Language.Translate("searchbar")) //text==translate...: 2014.12.05.
{
//searchlist.Items.Clear();
searchlist.Visible = false;
contactList.Visible = true;
return;
}
contactList.Visible = false;
searchlist.Parent = contactList.Parent; //2014.12.05.
searchlist.Bounds = contactList.Bounds;
//var tmpcol = new RichListViewColumn[contactList.Columns.Length]; //2014.12.05.
//contactList.Columns.CopyTo(tmpcol, 0); //2014.12.05.
//searchlist.Columns = tmpcol; //2014.12.05.
searchlist.Items.Clear(); //2014.12.05.
//searchlist.Visible = true;
searchlist.AutoUpdate = false;
foreach (var item in UserInfo.KnownUsers)
{
if (!item.IsPartner)
continue;
if (item.Name.ToLower().Contains(textBox1.Text.ToLower()) || item.Email.ToLower().Contains(textBox1.Text.ToLower()) || item.UserName.ToLower().Contains(textBox1.Text.ToLower())) //ToLower: 2014.12.14. 1:53
{
/*searchlist.Items.Add(new RichListViewItem(contactList.Columns.Length));
searchlist.Items.Last().SubItems[0] = new PictureBox();
(searchlist.Items.Last().SubItems[0] as PictureBox).ImageLocation = item.GetImage();
searchlist.Items.Last().SubItems[1].Text = "";*/
item.CreateListItem(searchlist, searchlist.Items.Count);
}
}
searchlist.AutoUpdate = true;
searchlist.Visible = true;
};
searchbartimer.Start();
}
private void flowLayoutPanel1_Click(object sender, EventArgs e)
{
foreach (var item in ChatPanel.ChatWindows)
{
item.Hide();
}
}
}
}

View file

@ -20,7 +20,7 @@ using System.Net.NetworkInformation;
namespace MSGer.tk
{
public partial class MainForm : Form
public partial class MainForm : ThemedForms
{
public static LoginForm LoginDialog;
public static Thread LThread;
@ -29,6 +29,7 @@ namespace MSGer.tk
public MainForm()
{
BeforeLogin.SetText("Starting...");
Program.MainF = this;
InitializeComponent();
Thread.CurrentThread.Name = "Main Thread";
toolStripMenuItem4.Enabled = false; //2014.04.12.
@ -59,78 +60,131 @@ namespace MSGer.tk
//try
//{
fájlToolStripMenuItem.Text = Language.Translate("menu_file");
Language.ReloadEvent += delegate { fájlToolStripMenuItem.Text = Language.Translate("menu_file"); };
kijelentkezésToolStripMenuItem.Text = Language.Translate("menu_file_logout");
Language.ReloadEvent += delegate { kijelentkezésToolStripMenuItem.Text = Language.Translate("menu_file_logout"); };
toolStripMenuItem1.Text = Language.Translate("menu_file_loginnewuser");
Language.ReloadEvent += delegate { toolStripMenuItem1.Text = Language.Translate("menu_file_loginnewuser"); };
állapotToolStripMenuItem.Text = Language.Translate("menu_file_status");
Language.ReloadEvent += delegate { állapotToolStripMenuItem.Text = Language.Translate("menu_file_status"); };
elérhetőToolStripMenuItem.Text = Language.Translate("menu_file_status_online");
Language.ReloadEvent += delegate { elérhetőToolStripMenuItem.Text = Language.Translate("menu_file_status_online"); };
elfoglaltToolStripMenuItem.Text = Language.Translate("menu_file_status_busy");
Language.ReloadEvent += delegate { elfoglaltToolStripMenuItem.Text = Language.Translate("menu_file_status_busy"); };
nincsAGépnélToolStripMenuItem.Text = Language.Translate("menu_file_status_away");
Language.ReloadEvent += delegate { nincsAGépnélToolStripMenuItem.Text = Language.Translate("menu_file_status_away"); };
rejtveKapcsolódikToolStripMenuItem.Text = Language.Translate("menu_file_status_hidden");
Language.ReloadEvent += delegate { rejtveKapcsolódikToolStripMenuItem.Text = Language.Translate("menu_file_status_hidden"); };
fájlKüldéseToolStripMenuItem.Text = Language.Translate("menu_file_sendfile");
Language.ReloadEvent += delegate { fájlKüldéseToolStripMenuItem.Text = Language.Translate("menu_file_sendfile"); };
beérkezettFájlokMappájánakMegnyitásaToolStripMenuItem.Text = Language.Translate("menu_file_openreceivedfiles");
Language.ReloadEvent += delegate { beérkezettFájlokMappájánakMegnyitásaToolStripMenuItem.Text = Language.Translate("menu_file_openreceivedfiles"); };
üzenetekElőzményeinekMegtekintéseToolStripMenuItem.Text = Language.Translate("menu_file_openrecentmsgs");
Language.ReloadEvent += delegate { üzenetekElőzményeinekMegtekintéseToolStripMenuItem.Text = Language.Translate("menu_file_openrecentmsgs"); };
bezárásToolStripMenuItem.Text = Language.Translate("menu_file_close");
Language.ReloadEvent += delegate { bezárásToolStripMenuItem.Text = Language.Translate("menu_file_close"); };
kilépésToolStripMenuItem.Text = Language.Translate("menu_file_exit");
Language.ReloadEvent += delegate { kilépésToolStripMenuItem.Text = Language.Translate("menu_file_exit"); };
ismerősökToolStripMenuItem.Text = Language.Translate("menu_contacts");
Language.ReloadEvent += delegate { ismerősökToolStripMenuItem.Text = Language.Translate("menu_contacts"); };
ismerősFelvételeToolStripMenuItem.Text = Language.Translate("menu_contacts_add");
Language.ReloadEvent += delegate { ismerősFelvételeToolStripMenuItem.Text = Language.Translate("menu_contacts_add"); };
ismerősSzerkesztéseToolStripMenuItem.Text = Language.Translate("menu_contacts_edit");
Language.ReloadEvent += delegate { ismerősSzerkesztéseToolStripMenuItem.Text = Language.Translate("menu_contacts_edit"); };
ismerősTörléseToolStripMenuItem.Text = Language.Translate("menu_contacts_remove");
Language.ReloadEvent += delegate { ismerősTörléseToolStripMenuItem.Text = Language.Translate("menu_contacts_remove"); };
toolStripMenuItem3.Text = Language.Translate("menu_contacts_invite");
Language.ReloadEvent += delegate { toolStripMenuItem3.Text = Language.Translate("menu_contacts_invite"); };
csoportLétrehozásaToolStripMenuItem.Text = Language.Translate("menu_contacts_makegroup");
Language.ReloadEvent += delegate { csoportLétrehozásaToolStripMenuItem.Text = Language.Translate("menu_contacts_makegroup"); };
kategóriaLétrehozásaToolStripMenuItem.Text = Language.Translate("menu_contacts_makecategory");
Language.ReloadEvent += delegate { kategóriaLétrehozásaToolStripMenuItem.Text = Language.Translate("menu_contacts_makecategory"); };
kategóriaSzerkesztéseToolStripMenuItem.Text = Language.Translate("menu_contacts_editcategory");
Language.ReloadEvent += delegate { kategóriaSzerkesztéseToolStripMenuItem.Text = Language.Translate("menu_contacts_editcategory"); };
kategóriaTörléseToolStripMenuItem.Text = Language.Translate("menu_contacts_removecategory");
Language.ReloadEvent += delegate { kategóriaTörléseToolStripMenuItem.Text = Language.Translate("menu_contacts_removecategory"); };
műveletekToolStripMenuItem.Text = Language.Translate("menu_operations");
Language.ReloadEvent += delegate { műveletekToolStripMenuItem.Text = Language.Translate("menu_operations"); };
azonnaliÜzenetKüldéseToolStripMenuItem.Text = Language.Translate("menu_operations_sendmsg");
Language.ReloadEvent += delegate { azonnaliÜzenetKüldéseToolStripMenuItem.Text = Language.Translate("menu_operations_sendmsg"); };
egyébKüldéseToolStripMenuItem.Text = Language.Translate("menu_operations_sendother");
Language.ReloadEvent += delegate { egyébKüldéseToolStripMenuItem.Text = Language.Translate("menu_operations_sendother"); };
emailKüldéseToolStripMenuItem.Text = Language.Translate("menu_operations_sendother_sendmail");
Language.ReloadEvent += delegate { emailKüldéseToolStripMenuItem.Text = Language.Translate("menu_operations_sendother_sendmail"); };
fájlKüldéseToolStripMenuItem1.Text = Language.Translate("menu_file_sendfile"); //Ugyanaz a szöveg
Language.ReloadEvent += delegate { fájlKüldéseToolStripMenuItem1.Text = Language.Translate("menu_file_sendfile"); };
ismerősSzámitógépénekFelhivásaToolStripMenuItem.Text = Language.Translate("menu_operations_callcontact");
Language.ReloadEvent += delegate { ismerősSzámitógépénekFelhivásaToolStripMenuItem.Text = Language.Translate("menu_operations_callcontact"); };
videóhivásInditásaToolStripMenuItem.Text = Language.Translate("menu_operations_videocall");
Language.ReloadEvent += delegate { videóhivásInditásaToolStripMenuItem.Text = Language.Translate("menu_operations_videocall"); };
onlineFájlokMegtekintéseToolStripMenuItem.Text = Language.Translate("menu_operations_showonlinefiles");
Language.ReloadEvent += delegate { onlineFájlokMegtekintéseToolStripMenuItem.Text = Language.Translate("menu_operations_showonlinefiles"); };
közösJátékToolStripMenuItem.Text = Language.Translate("menu_operations_playgame");
Language.ReloadEvent += delegate { közösJátékToolStripMenuItem.Text = Language.Translate("menu_operations_playgame"); };
távsegitségKéréseToolStripMenuItem.Text = Language.Translate("menu_operations_askforhelp");
Language.ReloadEvent += delegate { távsegitségKéréseToolStripMenuItem.Text = Language.Translate("menu_operations_askforhelp"); };
eszközökToolStripMenuItem.Text = Language.Translate("menu_tools");
Language.ReloadEvent += delegate { eszközökToolStripMenuItem.Text = Language.Translate("menu_tools"); };
mindigLegfelülToolStripMenuItem.Text = Language.Translate("menu_tools_alwaysontop");
Language.ReloadEvent += delegate { mindigLegfelülToolStripMenuItem.Text = Language.Translate("menu_tools_alwaysontop"); };
hangulatjelekToolStripMenuItem.Text = Language.Translate("menu_tools_emoticons");
Language.ReloadEvent += delegate { hangulatjelekToolStripMenuItem.Text = Language.Translate("menu_tools_emoticons"); };
megjelenitendőKépVáltásaToolStripMenuItem.Text = Language.Translate("menu_tools_changeimage");
Language.ReloadEvent += delegate { megjelenitendőKépVáltásaToolStripMenuItem.Text = Language.Translate("menu_tools_changeimage"); };
háttérMódositásaToolStripMenuItem.Text = Language.Translate("menu_tools_changebackground");
Language.ReloadEvent += delegate { háttérMódositásaToolStripMenuItem.Text = Language.Translate("menu_tools_changebackground"); };
hangokÉsVideóBeállitásaToolStripMenuItem.Text = Language.Translate("menu_tools_voicevideosettings");
Language.ReloadEvent += delegate { hangokÉsVideóBeállitásaToolStripMenuItem.Text = Language.Translate("menu_tools_voicevideosettings"); };
beállitásokToolStripMenuItem.Text = Language.Translate("menu_tools_settings");
Language.ReloadEvent += delegate { beállitásokToolStripMenuItem.Text = Language.Translate("menu_tools_settings"); };
súgóToolStripMenuItem.Text = Language.Translate("menu_help");
Language.ReloadEvent += delegate { súgóToolStripMenuItem.Text = Language.Translate("menu_help"); };
témakörökToolStripMenuItem.Text = Language.Translate("menu_help_contents");
Language.ReloadEvent += delegate { témakörökToolStripMenuItem.Text = Language.Translate("menu_help_contents"); };
aSzolgáltatásÁllapotsaToolStripMenuItem.Text = Language.Translate("menu_help_status");
Language.ReloadEvent += delegate { aSzolgáltatásÁllapotsaToolStripMenuItem.Text = Language.Translate("menu_help_status"); };
adatvédelmiNyilatkozatToolStripMenuItem.Text = Language.Translate("menu_help_privacypolicy");
Language.ReloadEvent += delegate { adatvédelmiNyilatkozatToolStripMenuItem.Text = Language.Translate("menu_help_privacypolicy"); };
használatiFeltételekToolStripMenuItem.Text = Language.Translate("menu_help_termsofuse");
Language.ReloadEvent += delegate { használatiFeltételekToolStripMenuItem.Text = Language.Translate("menu_help_termsofuse"); };
visszaélésBejelentéseToolStripMenuItem.Text = Language.Translate("menu_help_report");
Language.ReloadEvent += delegate { visszaélésBejelentéseToolStripMenuItem.Text = Language.Translate("menu_help_report"); };
segitsenAProgramTökéletesitésébenToolStripMenuItem.Text = Language.Translate("menu_help_improveprogram");
Language.ReloadEvent += delegate { segitsenAProgramTökéletesitésébenToolStripMenuItem.Text = Language.Translate("menu_help_improveprogram"); };
névjegyToolStripMenuItem.Text = Language.Translate("menu_help_about");
Language.ReloadEvent += delegate { névjegyToolStripMenuItem.Text = Language.Translate("menu_help_about"); };
textBox1.Text = Language.Translate("searchbar");
textBox1.Text = Language.Translate("searchbar", textBox1);
//contactList.Items[0].SubItems[0].Text = Language.Translate("loading"); - 2014.08.28. - Nincs már rá szükség (hibát is ír, mivel nincs listaelem)
üzenetküldésToolStripMenuItem.Text = Language.Translate("menu_operations_sendmsg");
emailKüldéseemailToolStripMenuItem.Text = Language.Translate("contact_sendemail");
toolStripMenuItem2.Text = Language.Translate("contact_copyemail");
információToolStripMenuItem.Text = Language.Translate("contact_info");
ismerősLetiltásaToolStripMenuItem.Text = Language.Translate("contact_block");
ismerősTörléseToolStripMenuItem.Text = Language.Translate("contact_remove");
becenévSzerkesztéseToolStripMenuItem.Text = Language.Translate("contact_editname");
eseményértesitésekToolStripMenuItem.Text = Language.Translate("contact_eventnotifications");
beszélgetésnaplóMegnyitásaToolStripMenuItem.Text = Language.Translate("contact_openchatlog");
//üzenetküldésToolStripMenuItem.Text = Language.Translate("menu_operations_sendmsg");
//emailKüldéseemailToolStripMenuItem.Text = Language.Translate("contact_sendemail");
//toolStripMenuItem2.Text = Language.Translate("contact_copyemail");
//információToolStripMenuItem.Text = Language.Translate("contact_info");
//ismerősLetiltásaToolStripMenuItem.Text = Language.Translate("contact_block");
//ismerősTörléseToolStripMenuItem.Text = Language.Translate("contact_remove"); - Kétszer benne volt, ugyanilyen névvel, csak 1-re végződve lett volna a megfelelő
//becenévSzerkesztéseToolStripMenuItem.Text = Language.Translate("contact_editname");
//eseményértesitésekToolStripMenuItem.Text = Language.Translate("contact_eventnotifications");
//beszélgetésnaplóMegnyitásaToolStripMenuItem.Text = Language.Translate("contact_openchatlog");
toolStripMenuItem4.Text = Language.Translate("iconmenu_show");
Language.ReloadEvent += delegate { toolStripMenuItem4.Text = Language.Translate("iconmenu_show"); };
toolStripMenuItem8.Text = Language.Translate("menu_file_logout");
Language.ReloadEvent += delegate { toolStripMenuItem8.Text = Language.Translate("menu_file_logout"); };
toolStripMenuItem9.Text = Language.Translate("menu_file_exit");
Language.ReloadEvent += delegate { toolStripMenuItem9.Text = Language.Translate("menu_file_exit"); };
//}
//catch
//{
//MessageBox.Show("Error while loading translations.");
//}
LoadMenu(MenuType.ChatIconMenu); //2014.12.12.
LoadMenu(MenuType.PartnerMenu); //2014.12.13.
#endregion
BeforeLogin.SetText(Language.Translate("beforelogin_loadtextformat"));
@ -146,19 +200,60 @@ namespace MSGer.tk
{
var res = MessageBox.Show(Language.Translate("outofdate"), Language.Translate("outofdate_caption"), MessageBoxButtons.YesNo);
if (res == DialogResult.Yes)
System.Diagnostics.Process.Start("http://msger.url.ph/download.php?version=latest");
//System.Diagnostics.Process.Start("http://msger.url.ph/download.php?version=latest");
//(new UpdateDialog()).Show(); //2014.12.13. - Elvileg át lehet nevezni a programot, miközben fut (ami érdekes) - De inkább csinálok külön programot
{ //2014.12.13.
Process.Start("Updater.exe", "\"" + Language.Translate("updater") + "\" \"" + Language.Translate("updater_info") + "\"");
Program.Exit(false);
}
}
else if (response != "fine")
MessageBox.Show(Language.Translate("error") + ": " + response);
//BeforeLogin.SetText(Language.Translate("beforelogin_server")); //2015.01.07.
//2014.09.06.
if (Storage.Settings["isserver"] == "")
/*if (Storage.Settings["isserver"] == "")
{
if (MessageBox.Show(Language.Translate("isserver_msg"), "", MessageBoxButtons.YesNo) == DialogResult.Yes)
Storage.Settings["isserver"] = "1";
else
Storage.Settings["isserver"] = "0";
}
}*/
/*if(Storage.Settings["isserver"]=="1") //2015.01.07.
{
NATUPNPLib.UPnPNAT upnpnat = new NATUPNPLib.UPnPNAT();
NATUPNPLib.IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;
if (mappings == null)
{
//MessageBox.Show(Language.Translate("portforward_noaccess"));
}
//else
//{
foreach (NATUPNPLib.IStaticPortMapping mapping in mappings)
{
if (mapping.Protocol == "UDP" && mapping.InternalPort.ToString() == Storage.Settings["port"])
{
if (MessageBox.Show(Language.Translate("portforward_existsremove"), "", MessageBoxButtons.YesNo) == DialogResult.Yes)
mappings.Remove(mapping.ExternalPort, "UDP");
else
Storage.Settings["port"] = (Int32.Parse(Storage.Settings["port"]) + 1).ToString();
}
}
int port = int.Parse(Storage.Settings["port"]);
mappings.Add(port, "UDP", port, Dns.GetHostEntry(Dns.GetHostName()).AddressList.Single(entry =>
entry.AddressFamily == AddressFamily.InterNetwork
&& (entry.ToString().Contains("192.168.0.") || entry.ToString().Contains("192.168.1.") || entry.ToString().Contains("10.0.0.") || entry.ToString().Contains("172.16.0.")) //Helyi IP-k
).ToString(), true, "MSGer.tk chat program");
Networking.ReceiverConnection = new UdpClient(Int32.Parse(Storage.Settings["port"]));
//}
}*/
//TO!DO: Nem kell az "isserver" beállítás, először kliensként próbáljon meg csatlakozni, majd szerverként fogadja az új klienseket
// a pwnat segítségével
//2015.03.15. - Nem kell az sem: IPv6 - A legtöbb eszköz már támogatja
BeforeLogin.SetText(Language.Translate("beforelogin_loginform"));
try
@ -182,11 +277,14 @@ namespace MSGer.tk
LThread = new Thread(new ThreadStart(new UpdateListAndChat().Run));
LThread.Name = "Update Partnerlist and Chat";
Thread keepupthread = new Thread(new ThreadStart(Networking.KeepUpThread));
/*Thread keepupthread = new Thread(new ThreadStart(Networking.KeepUpThread));
keepupthread.Name = "Keep Up Thread";
Thread keepupuserst = new Thread(new ThreadStart(Networking.KeepUpUsersThread)); //2014.09.26.
keepupuserst.Name = "Keep Up Users Thread";
keepupuserst.Name = "Keep Up Users Thread";*/
Thread networkthread = new Thread(new ThreadStart(Networking.NetworkThread)); //2014.12.31.
networkthread.Name = "Network Thread";
Storage.Load(true); //2014.08.07.
@ -208,33 +306,124 @@ namespace MSGer.tk
// Start the thread
LThread.Start();
keepupthread.Start();
//keepupthread.Start();
keepupuserst.Start();
//keepupuserst.Start();
networkthread.Start();
//2014.08.19. - Küldje el a bejelentkezés hírét, hogy frissítéseket kapjon
byte[] strb = Encoding.Unicode.GetBytes(CurrentUser.IP.ToString());
byte[] tmpfinal = new byte[8 * UserInfo.KnownUsers.Count + strb.Length + 4]; //Hosszúság, IP, ismert felh. ID, frissítési idő
/*byte[] strb = Encoding.Unicode.GetBytes(CurrentUser.IP.ToString());
byte[] tmpfinal = new byte[8 * UserInfo.KnownUsers.Count + strb.Length + 4 + 1]; //Hosszúság, IP, ismert felh. ID, frissítési idő
Array.Copy(BitConverter.GetBytes(strb.Length), tmpfinal, 4);
Array.Copy(strb, 0, tmpfinal, 4, strb.Length);
//if (tmpfinal.Length != 0)
if (UserInfo.KnownUsers.Count != 0)
for (int i = 0; i < UserInfo.KnownUsers.Count; i++) //Ha a count 0, nem fogja végrehajtani
{
for (int i = 0; i < UserInfo.KnownUsers.Count; i++)
{
byte[] tmptmp = BitConverter.GetBytes(UserInfo.KnownUsers[i].UserID);
Array.Copy(tmptmp, 0, tmpfinal, i * 4 + strb.Length + 4, 4);
tmptmp = BitConverter.GetBytes(UserInfo.KnownUsers[i].LastUpdate);
Array.Copy(tmptmp, 0, tmpfinal, i * 4 + strb.Length + 4, 4);
}
byte[] tmptmp = BitConverter.GetBytes(UserInfo.KnownUsers[i].UserID);
Array.Copy(tmptmp, 0, tmpfinal, i * 4 + strb.Length + 4, 4);
tmptmp = BitConverter.GetBytes(UserInfo.KnownUsers[i].LastUpdate);
Array.Copy(tmptmp, 0, tmpfinal, i * 4 + strb.Length + 4, 4);
}
Networking.ParseUpdateInfo(Networking.SendUpdate(Networking.UpdateType.LoginUser, tmpfinal, false));
tmpfinal[tmpfinal.Length - 1] = (Storage.Settings["isserver"] == "1") ? (byte)0x01 : (byte)0x00; //Mivel bejelentkezéstől függetlenül menti el, gépfüggő, hogy itt mit küld el
Networking.ParseUpdateInfo(Networking.SendUpdate(Networking.UpdateType.LoginUser, tmpfinal, false));*/
while (!networkthread.IsAlive) ;
SendLoginToUsers(); //2014.12.18.
notifyIcon1.Visible = true; //2014.09.22.
taskbarNotifier.Show("Teszt cím", "Teszt tartalom\nMásodik sor");
Language.ReloadEvent += delegate { textBox1.Text = Language.Translate("searchbar"); }; //2014.12.22. - Nyelvváltáskor törölni fogja a beírt szöveget
}
private void LoadPartnerList() //2014.08.28.
private void SendLoginToUsers()
{ //2014.12.18.
var bytes = new List<byte>();
//var tmpb = Encoding.Unicode.GetBytes(CurrentUser.IP.ToString());
//bytes.AddRange(BitConverter.GetBytes(tmpb.Length));
//bytes.AddRange(tmpb);
for (int i = 0; i < UserInfo.KnownUsers.Count; i++) //Ha a count 0, nem fogja végrehajtani
{
bytes.AddRange(BitConverter.GetBytes(UserInfo.KnownUsers[i].UserID));
bytes.AddRange(BitConverter.GetBytes(UserInfo.KnownUsers[i].LastUpdate));
}
//bytes.Add((Storage.Settings["isserver"] == "1") ? (byte)0x01 : (byte)0x00); //Mivel bejelentkezéstől függetlenül menti el, gépfüggő, hogy itt mit küld el
//Networking.ParseUpdateInfo(Networking.SendUpdate(Networking.UpdateType.LoginUser, bytes.ToArray(), false));
Networking.SendUpdateInThread(Networking.UpdateType.LoginUser, bytes.ToArray(), new EventHandler<byte[][]>(
(e, resp) => Networking.ParseUpdateInfo(resp)));
}
enum MenuType
{
ChatIconMenu,
PartnerMenu
}
private void LoadMenu(MenuType mt)
{
switch(mt) //2014.12.13.
{
case MenuType.ChatIconMenu:
chatIconMenu.Items.Add(Language.Translate("close"), null,
new EventHandler((sender, e) => ((ChatPanel)chatIconMenu.Tag).Close())); //Tag: A chatikon
chatIconMenu.Items[chatIconMenu.Items.Count-1].Name="close"; //2014.12.22.
Language.ReloadEvent += delegate { chatIconMenu.Items["close"].Text = Language.Translate("close"); }; //2014.12.22.
chatIconMenu.Items.Add(new ToolStripSeparator());
/*chatIconMenu.Items.AddRange(
partnerMenu.Items.Cast<ToolStripItem>().Select(entry=>{
return new ToolStripMenuItem((ToolStripItem)entry.Clone();
}).ToArray()); //Alapvetően eltávolítaná az eredeti menüből, és hibát jelezne*/
LoadMenuPrep(chatIconMenu);
break;
case MenuType.PartnerMenu:
listPartnerMenu.Items.Add(Language.Translate("menu_operations_sendmsg"), null, PartnerMenu_SendMessage);
listPartnerMenu.Items[listPartnerMenu.Items.Count-1].Name="menu_operations_sendmsg"; //2014.12.22.
Language.ReloadEvent += delegate { listPartnerMenu.Items["menu_operations_sendmsg"].Text = Language.Translate("menu_operations_sendmsg"); }; //2014.12.22.
listPartnerMenu.Items.Add(new ToolStripSeparator());
//listPartnerMenu.Items.AddRange(partnerMenu.Items.Cast<ToolStripItem>().ToArray());
LoadMenuPrep(listPartnerMenu);
break;
default:
throw new NotImplementedException("Menu type not implemented.");
}
}
private void LoadMenuPrep(ContextMenuStrip menu) //Csak a menüelemeket készíti elő
{ //2014.12.13.
menu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { //A dizájnerből, átalakítva, hogy rögtön le is fordítsa
new ToolStripMenuItem(Language.Translate("contact_sendemail")), //Ide jönnek majd az event handlerek is
new ToolStripMenuItem(Language.Translate("contact_copyemail")),
new ToolStripMenuItem(Language.Translate("contact_info")),
new ToolStripSeparator(),
new ToolStripMenuItem(Language.Translate("contact_block")),
new ToolStripMenuItem(Language.Translate("contact_remove")),
new ToolStripSeparator(),
new ToolStripMenuItem(Language.Translate("contact_editname")),
new ToolStripSeparator(),
new ToolStripMenuItem(Language.Translate("contact_eventnotifications")),
new ToolStripSeparator(),
new ToolStripMenuItem(Language.Translate("contact_openchatlog"))});
Language.ReloadEvent += delegate
{
int i = menu.Items.Count - 1;
menu.Items[i].Text = Language.Translate("contact_openchatlog");
i--;
menu.Items[i].Text = Language.Translate("contact_eventnotifications");
i--;
menu.Items[i].Text = Language.Translate("contact_editname");
i--;
menu.Items[i].Text = Language.Translate("contact_remove");
i--;
menu.Items[i].Text = Language.Translate("contact_block");
i--;
menu.Items[i].Text = Language.Translate("contact_info");
i--;
menu.Items[i].Text = Language.Translate("contact_copyemail");
i--;
menu.Items[i].Text = Language.Translate("contact_sendemail");
};
}
public void LoadPartnerList() //2014.08.28.
{
contactList.AutoUpdate = false;
UserInfo.AutoUpdate = false; //2014.09.26.
@ -274,16 +463,6 @@ namespace MSGer.tk
contactList.Refresh();
}
private void PopupCloseClick(object sender, EventArgs e)
{
MessageBox.Show("Close");
}
private void PopupClick(object sender, EventArgs e)
{
MessageBox.Show("Click");
}
private void LogoutUser(object sender, EventArgs e)
{
this.Hide();
@ -296,9 +475,9 @@ namespace MSGer.tk
Storage.Dispose();
LThread = null;
CurrentUser.SendChanges = false; //2014.08.30.
while (ChatForm.ChatWindows.Count > 0)
while (ChatPanel.ChatWindows.Count > 0)
{ //2014.09.06. - A Close() hatására törli a gyűjteményből, ezért sorra végig fog haladni rajta
ChatForm.ChatWindows[0].Close();
ChatPanel.ChatWindows[0].Close();
}
LoginDialog = new LoginForm(); //2014.04.04.
LoginDialog.ShowDialog();
@ -310,8 +489,8 @@ namespace MSGer.tk
toolStripMenuItem8.Enabled = true; //2014.04.12.
CurrentUser.SendChanges = true; //2014.08.30.
contactList.Items.Clear(); //2014.10.09. - Kijelentkezéskor hozzáad egy üres listelemet egy (Nem elérhető) felirattal, ezt tünteti el
LoadPartnerList();
this.Show();
//LoadPartnerList();
//this.Show();
// Create the thread object, passing in the Alpha.Beta method
// via a ThreadStart delegate. This does not start the thread.
LThread = new Thread(new ThreadStart(new UpdateListAndChat().Run));
@ -319,210 +498,91 @@ namespace MSGer.tk
// Start the thread
LThread.Start();
SendLoginToUsers(); //2014.12.18.
LoadPartnerList();
this.Show();
}
private void LoginNewUser(object sender, EventArgs e)
public void PlaceChatIcon(ChatPanel cp)
{
Storage.Save(true); //2014.09.19.
Process.Start(((Program.ProcessName.Contains("vshost")) ? Program.ProcessName.Replace(".vshost", "") : Program.ProcessName) + ".exe", "multi");
}
public void SetOnlineState(object sender, EventArgs e)
{
int state = 0;
if (sender == elérhetőToolStripMenuItem)
state = 1;
if (sender == elfoglaltToolStripMenuItem)
state = 2;
if (sender == nincsAGépnélToolStripMenuItem)
state = 3;
if (sender == null) //2014.08.30. - Erre nagyon sokáig nem volt felkészítve, és ezt kihasználtam a kijelentkezéshez
{
Networking.SendRequest("setstate", 0 + "", 0, true); //Kijelentkezés
byte[] tmpb = Encoding.Unicode.GetBytes(CurrentUser.IP.ToString());
byte[] sendb = new byte[4 + tmpb.Length];
Array.Copy(BitConverter.GetBytes(tmpb.Length), sendb, 4);
Array.Copy(tmpb, 0, sendb, 4, tmpb.Length);
Networking.SendUpdate(Networking.UpdateType.LogoutUser, sendb, false);
}
CurrentUser.State = state; //2014.08.28.
}
private void SelectPartner(object sender, EventArgs e)
{
var form = new SelectPartnerForm((ToolStripMenuItem)sender);
DialogResult dr = form.ShowDialog();
if (dr == DialogResult.OK)
{
//2014.04.25.
string[] partners = form.Partners;
ChatForm tmpchat = new ChatForm();
for (int i = 0; i < partners.Length; i++)
{
if (partners[i] != "") //2014.04.17.
{
for (int j = 0; j < UserInfo.KnownUsers.Count; j++)
{
if (!UserInfo.KnownUsers[j].IsPartner)
continue;
int tmp; //2014.04.17.
if (!Int32.TryParse(partners[i], out tmp))
tmp = -1;
if (UserInfo.KnownUsers[j].UserName == partners[i] || UserInfo.KnownUsers[j].Email == partners[i] || UserInfo.KnownUsers[j].UserID == tmp)
{ //Egyezik a név, E-mail vagy ID - UserName: 2014.04.17.
tmpchat.ChatPartners.Add(UserInfo.KnownUsers[j].UserID); //2014.08.28.
}
}
}
var newicon = new PictureBox();
//newicon.ImageLocation = cp.ChatPartners[0].GetImage();
newicon.ImageLocation = cp.ChatPartners[0].ImagePath; //2014.12.31.
newicon.Size = new Size(100, 100);
newicon.SizeMode = PictureBoxSizeMode.Zoom;
newicon.Click += new EventHandler((a, b) => cp.Show());
newicon.MouseClick += new MouseEventHandler((s, e) => {
if (e.Button == MouseButtons.Middle)
cp.Close();
else if (e.Button == MouseButtons.Right) //Chat menü
{ //2014.12.13.
chatIconMenu.Tag = cp;
chatIconMenu.Show(Cursor.Position);
}
if (tmpchat.ChatPartners.Count != 0)
{
ChatForm.ChatWindows.Add(tmpchat);
if (sender == fájlKüldéseToolStripMenuItem)
{
tmpchat.Show();
tmpchat.OpenSendFile(form);
}
if (sender == azonnaliÜzenetKüldéseToolStripMenuItem)
{
tmpchat.Show();
}
}
}
}
private void ClearSearchBar(object sender, EventArgs e)
{
if (textBox1.Text == Language.Translate("searchbar"))
textBox1.Clear();
}
private void PutTextInSearchBar(object sender, EventArgs e)
{
if (textBox1.Text == "")
textBox1.Text = Language.Translate("searchbar");
}
public static int RightClickedPartner = -1;
public static void OpenSendMessage(int uid)
{
//Üzenetküldő form
int ChatNum = -1;
for (int i = 0; i < ChatForm.ChatWindows.Count; i++)
});
cp.ChatIcon = newicon;
//---------------------------------------------------------------------
int size = 0;
bool putright = false;
foreach (Control item in flowLayoutPanel1.Controls)
{
if (ChatForm.ChatWindows[i].ChatPartners.Count == 1 && ChatForm.ChatWindows[i].ChatPartners.Contains(uid))
{ //Vele, és csak vele beszél
ChatNum = i;
break;
}
size += item.Size.Height;
}
if (ChatNum == -1)
{ //Nincs még chatablaka
ChatForm.ChatWindows.Add(new ChatForm());
ChatForm.ChatWindows[ChatForm.ChatWindows.Count - 1].ChatPartners.Add(uid);
ChatForm.ChatWindows[ChatForm.ChatWindows.Count - 1].Show();
ChatForm.ChatWindows[ChatForm.ChatWindows.Count - 1].Focus(); //2014.08.08.
size += newicon.Size.Height;
if (size > flowLayoutPanel1.Size.Height)
putright = true; //Ha nem fér el bal oldalt, rakja jobbra
//---------------------------------------------------------------------
size = 0;
foreach (Control item in flowLayoutPanel2.Controls)
{
size += item.Size.Height;
}
size += newicon.Size.Height;
if (size > flowLayoutPanel2.Size.Height)
putright = false; //Ha jobbra sem fér el, csak rakja balra
//---------------------------------------------------------------------
if (!putright)
flowLayoutPanel1.Controls.Add(newicon);
else
flowLayoutPanel2.Controls.Add(newicon);
}
public enum StatType
{
MainServer,
Servers,
OnlineServers
}
public void UpdateStats(StatType type, int value)
{ //Elvileg ha van forgalom, gyorsan frissíti a nyelvet is
switch (type)
{
ChatForm.ChatWindows[ChatNum].Show();
ChatForm.ChatWindows[ChatNum].Focus();
case StatType.MainServer:
if (value == 0)
{
mainserver.Text = Language.Translate("stats_mainserver") + ": " + Language.Translate("stats_nonetwork");
mainserver.ForeColor = Color.Red;
}
else if (value == 1)
{
mainserver.Text = Language.Translate("stats_mainserver") + ": " + Language.Translate("stats_retrying");
mainserver.ForeColor = Color.Orange;
}
else if (value == 2)
{
mainserver.Text = Language.Translate("stats_mainserver") + ": " + Language.Translate("stats_connected");
mainserver.ForeColor = Color.Green;
}
break;
case StatType.Servers:
servers.Text = Language.Translate("stats_servers") + ": " + value;
break;
case StatType.OnlineServers:
onlineservers.Text = Language.Translate("stats_onlineservers") + ": " + value;
break;
}
}
private void OnMainFormLoad(object sender, EventArgs e)
{
if (CurrentUser.UserID == 0)
Program.Exit();
LoadPartnerList(); //Be kell töltenie a MainForm-nak, hogy hivatkozhasson rá
CurrentUser.SendChanges = true; //2014.08.30.
}
private void InvitePartner(object sender, EventArgs e)
{
(new InvitePartner()).ShowDialog();
}
private void BeforeExit(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
}
private void toolStripMenuItem4_Click(object sender, EventArgs e)
{
if (CurrentUser.UserID != 0) //2014.04.18.
{
this.Show();
this.Focus();
}
}
private void ExitProgram(object sender, EventArgs e)
{
Program.Exit();
}
private void ismerősFelvételeToolStripMenuItem_Click(object sender, EventArgs e)
{
(new AddPartner()).ShowDialog();
}
private void névjegyToolStripMenuItem_Click(object sender, EventArgs e)
{
(new AboutBox1()).ShowDialog();
}
private void mindigLegfelülToolStripMenuItem_Click(object sender, EventArgs e)
{
this.TopMost = mindigLegfelülToolStripMenuItem.Checked;
}
private void beállitásokToolStripMenuItem_Click(object sender, EventArgs e)
{
(new SettingsForm()).Show();
}
private void contactList_ItemDoubleClicked(object sender, int e)
{
int uid = UserInfo.GetUserIDFromListID(e);
OpenSendMessage(uid);
}
private void bezárásToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Hide();
}
private void információToolStripMenuItem_Click(object sender, EventArgs e)
{
if (RightClickedPartner == -1)
return;
for (int i = 0; i < UserInfo.KnownUsers.Count; i++)
{
if (UserInfo.KnownUsers[i].ListID != RightClickedPartner)
continue;
(new PartnerInformation(UserInfo.KnownUsers[i])).ShowDialog();
break;
}
}
private void contactList_ItemRightClicked(object sender, int e)
{
contactList.Items[e].Selected = true;
RightClickedPartner = e;
partnerMenu.Show(Cursor.Position);
}
private void PartnerMenu_SendMessage(object sender, EventArgs e)
{
if (RightClickedPartner == -1)
return;
int uid = UserInfo.GetUserIDFromListID(RightClickedPartner);
OpenSendMessage(uid);
RightClickedPartner = -1;
}
}
}

View file

@ -130,7 +130,13 @@
<metadata name="partnerImages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>245, 17</value>
</metadata>
<metadata name="partnerMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>375, 17</value>
<metadata name="statusStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>791, 17</value>
</metadata>
<metadata name="chatIconMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>636, 17</value>
</metadata>
<metadata name="listPartnerMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>907, 17</value>
</metadata>
</root>

View file

@ -0,0 +1,142 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MSGer.tk
{
partial class Networking
{
public static string[] GetStrings(byte[] bytes, int startIndex)
{
List<string> strs = new List<string>();
int pos = startIndex;
while (pos < bytes.Length)
{
int len = BitConverter.ToInt32(bytes, pos);
pos += 4;
strs.Add(Encoding.Unicode.GetString(bytes, pos, len));
}
return strs.ToArray();
}
public static void ParsePacket(byte[] bytes, out byte response, out UpdateType updatetype, out int keyversion, out int port, out int userid, out byte[] data)
{ //2014.09.15.
/*if (CurrentUser.Keys[CurrentUser.KeyIndex] != null)
bytes = Storage.Decrypt(bytes, true, CurrentUser.Keys[CurrentUser.KeyIndex]);
else
bytes = Storage.Decrypt(bytes, true, "ihavenokeys");*/
response = bytes[0];
updatetype = (UpdateType)bytes[1];
int pos = 2;
//keyversion = BitConverter.ToInt32(bytes, 1 + 1);
keyversion = BitConverter.ToInt32(bytes, pos);
pos += sizeof(int);
port = BitConverter.ToInt32(bytes, pos); //2014.12.19.
pos += sizeof(int);
var encryptedBytes = new byte[bytes.Length - pos];
//Array.Copy(bytes, 6, encryptedBytes, 0, encryptedBytes.Length);
Array.Copy(bytes, pos, encryptedBytes, 0, encryptedBytes.Length);
if (CurrentUser.Keys[CurrentUser.KeyIndex] != null)
bytes = Storage.Decrypt(encryptedBytes, true, CurrentUser.Keys[CurrentUser.KeyIndex]);
else
bytes = Storage.Decrypt(encryptedBytes, true, "ihavenokeys");
/*userid = BitConverter.ToInt32(bytes, 1 + 1 + 4);
data = new byte[bytes.Length - 1 - 1 - 4 - 4];
Array.Copy(bytes, 2 + 4 + 4, data, 0, data.Length);*/
userid = BitConverter.ToInt32(bytes, 0); //2014.12.18.
data = new byte[bytes.Length - 4];
Array.Copy(bytes, 4, data, 0, data.Length);
}
public static void ParseUpdateInfo(byte[][] bytes)
{
if (bytes == null)
return;
for (int i = 0; i < bytes.Length; i++)
{
byte[] data = ParsePacket(bytes[i]).Data;
string[] strs = Encoding.Unicode.GetString(data).Split(new string[] { "\n", "\n\r" }, StringSplitOptions.RemoveEmptyEntries); //2014.09.19.
string str = "";
for (int j = 0; j < strs.Length; j++)
{
string[] spl = strs[j].Split('_'); //2014.08.30.
int uid = Int32.Parse(spl[0]); //2014.08.30.
string[] keyvalue = spl[1].Split('='); //2014.08.30.
UserInfo user = UserInfo.Select(uid); //2014.12.31.
if (keyvalue[0] == "ispartner")
{ //2014.08.30.
string resp = Networking.SendRequest("ispartner", uid + "", 0, true);
if (resp == "yes")
str += "userinfo_" + uid + "_ispartner=True";
else if (resp == "no")
str += "userinfo_" + uid + "_ispartner=False";
else
MessageBox.Show("ispartner:\n" + resp);
}
else if (keyvalue[0] == "picupdatetime")
{ //2014.12.31.
user.GetImage(Int32.Parse(keyvalue[1])); //Megvizsgálja, hogy kell-e frissítés és ha kell, letölti
}
else
str += "userinfo_" + strs[j];
if (j + 1 != strs.Length)
str += "\n";
user.Update(); //2014.12.31.
}
Storage.Parse(str);
}
}
public static PacketParts ParsePacket(byte[] bytes)
{ //2014.09.15.
/*if (CurrentUser.Keys[CurrentUser.KeyIndex] != null)
bytes = Storage.Encrypt(bytes, CurrentUser.Keys[CurrentUser.KeyIndex]);
else
bytes = Storage.Encrypt(bytes, "ihavenokeys");*/
var ret = new PacketParts();
ret.Response = (bytes[0] == 0x01) ? true : false;
ret.UpdateType = (UpdateType)bytes[1];
int pos = 2; //2014.12.19.
//ret.KeyVersion = BitConverter.ToInt32(bytes, 1 + 1);
ret.KeyVersion = BitConverter.ToInt32(bytes, pos);
pos += sizeof(int);
ret.Port = BitConverter.ToInt32(bytes, pos); //2014.12.19.
pos += sizeof(int);
byte[] encryptedBytes = new byte[bytes.Length - pos]; //2014.12.22. - A hátralévő rész titkosított
Array.Copy(bytes, pos, encryptedBytes, 0, encryptedBytes.Length); //2014.12.22.
if (CurrentUser.Keys[CurrentUser.KeyIndex] != null)
bytes = Storage.Decrypt(encryptedBytes, true, CurrentUser.Keys[CurrentUser.KeyIndex]);
else
bytes = Storage.Decrypt(encryptedBytes, true, "ihavenokeys");
//ret.UserID = BitConverter.ToInt32(bytes, 1 + 1 + 4);
pos = 0; //2014.12.22. - Új tömb lett a visszafejtés után
ret.UserID = BitConverter.ToInt32(bytes, pos);
pos += sizeof(int);
//ret.Data = new byte[bytes.Length - 1 - 1 - 4 - 4];
ret.Data = new byte[bytes.Length - pos];
//Array.Copy(bytes, 2 + 4 + 4, ret.Data, 0, ret.Data.Length);
Array.Copy(bytes, pos, ret.Data, 0, ret.Data.Length);
return ret;
}
public static byte[] CreatePacket(bool response, byte updatetype, byte[] data)
{ //2014.09.15.
List<byte> senddata = new List<byte>();
senddata.Add((response) ? (byte)0x01 : (byte)0x00); //0x00: Kérelem/Adatküldés, 0x01: Válasz
senddata.Add(updatetype);
senddata.AddRange(BitConverter.GetBytes(CurrentUser.KeyIndex));
senddata.AddRange(BitConverter.GetBytes(Int32.Parse(Storage.Settings["port"]))); //2014.12.19.
List<byte> sendd = new List<byte>();
sendd.AddRange(BitConverter.GetBytes(CurrentUser.UserID));
sendd.AddRange(data);
if (CurrentUser.Keys[CurrentUser.KeyIndex] != null)
senddata.AddRange(Storage.Encrypt(sendd.ToArray(), CurrentUser.Keys[CurrentUser.KeyIndex]));
else
senddata.AddRange(Storage.Encrypt(sendd.ToArray(), "ihavenokeys"));
return senddata.ToArray();
}
}
}

View file

@ -0,0 +1,124 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MSGer.tk
{
partial class Networking
{
private static int Tries = 0;
public static string SendRequest(string action, string data, int remnum, bool loggedin) //2014.02.18.
{
if (!IsNetworkAvailable()) //2014.11.15.
{
if (Program.MainF != null)
{ //2014.11.21.
if (Program.MainF.InvokeRequired) //2014.11.21.
{ //2014.11.21.
Program.MainF.Invoke(new Action<MainForm.StatType, int>(Program.MainF.UpdateStats), //2014.11.21.
MainForm.StatType.MainServer, 0); //2014.11.21.
}
else //2014.11.21.
{ //2014.11.21.
Program.MainF.UpdateStats(MainForm.StatType.MainServer, 0); //2014.11.21.
}
}
return "Fail: " + Language.Translate("error_no_network");
}
#if LOCAL_SERVER //2014.07.07. 22:00
HttpWebRequest httpWReq =
(HttpWebRequest)WebRequest.Create("http://localhost/ChatWithWords/client.php");
#else
HttpWebRequest httpWReq =
(HttpWebRequest)WebRequest.Create("http://msger.url.ph/client.php");
#endif
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "action=" + action;
if (loggedin) //2014.03.14.
postData += "&uid=" + CurrentUser.UserID;
postData += "&key=cas1fe4a6feFEFEFE1616CE8099VFE1444cdasf48c1ase5dg";
if (loggedin) //2014.03.14.
postData += "&code=" + LoginForm.UserCode; //2014.02.13.
postData += "&data=" + Uri.EscapeUriString(data); //2014.02.13.
byte[] datax = encoding.GetBytes(postData);
httpWReq.Method = "POST";
httpWReq.ContentType = "application/x-www-form-urlencoded";
httpWReq.ContentLength = datax.Length;
using (Stream stream = httpWReq.GetRequestStream())
{
stream.Write(datax, 0, datax.Length);
}
HttpWebResponse response;
try
{
response = (HttpWebResponse)httpWReq.GetResponse();
}
catch (Exception e)
{
if (Tries > 10)
{
MessageBox.Show(Language.Translate("error_network") + ":\n" + e.Message + "\n\n" + Language.Translate("error_network2"), Language.Translate("error")); //2014.04.25.
Tries = 0;
}
if (Program.MainF != null)
{ //2014.11.21.
if (Program.MainF.InvokeRequired) //2014.11.21.
{ //2014.11.21.
Program.MainF.Invoke(new Action<MainForm.StatType, int>(Program.MainF.UpdateStats), //2014.11.21.
MainForm.StatType.MainServer, 1); //2014.11.21.
}
else //2014.11.21.
{ //2014.11.21.
Program.MainF.UpdateStats(MainForm.StatType.MainServer, 1); //2014.11.21.
}
}
Tries++;
return SendRequest(action, data, remnum, loggedin); //Újrapróbálkozik
}
string responseString;
responseString = Uri.UnescapeDataString(new StreamReader(response.GetResponseStream()).ReadToEnd());
if (Program.MainF != null)
{ //2014.11.21.
if (Program.MainF.InvokeRequired) //2014.11.21.
{ //2014.11.21.
Program.MainF.Invoke(new Action<MainForm.StatType, int>(Program.MainF.UpdateStats), //2014.11.21.
MainForm.StatType.MainServer, 2); //2014.11.21.
}
else //2014.11.21.
{ //2014.11.21.
Program.MainF.UpdateStats(MainForm.StatType.MainServer, 2); //2014.11.21.
}
}
return responseString;
}
private static bool IsNetworkAvailable()
{
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface nic in nics)
{
if (
(nic.NetworkInterfaceType != NetworkInterfaceType.Loopback && nic.NetworkInterfaceType != NetworkInterfaceType.Tunnel) &&
nic.OperationalStatus == OperationalStatus.Up)
{
return true;
}
}
return false;
}
}
}

View file

@ -0,0 +1,193 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MSGer.tk
{
partial class Networking
{
public static UdpClient SenderConnection = new UdpClient(); //2014.09.04. - Ezt ne társítsa egy porthoz, hogy működjön az udp hole punching
public static UdpClient ReceiverConnection = new UdpClient(); //2014.09.04. - Társítsa egy porthoz
public static byte[] DataBuffer;
public static IPEndPoint RemoteEP;
public static bool WaitingOnResponse = false; //2014.08.16.
public static byte WaitingOnPacket = 0x00; //2014.08.16. - 0x00: Nincs
public static byte[][] SendUpdate(UpdateType ut, byte[] data, bool response, IPEndPoint onlythisep = null)
{
if (Program.MainF != null && Program.MainF.IsHandleCreated) //IsHandleCreated: 2014.12.31.
{ //2014.11.21.
if (Program.MainF.InvokeRequired) //2014.11.21.
{ //2014.11.21.
Program.MainF.Invoke(new Action<MainForm.StatType, int>(Program.MainF.UpdateStats), //2014.11.21.
MainForm.StatType.Servers, UserInfo.IPs.Count); //2014.11.21.
Program.MainF.Invoke(new Action<MainForm.StatType, int>(Program.MainF.UpdateStats), //2014.11.21.
MainForm.StatType.OnlineServers, UserInfo.IPs.Count - UserInfo.BannedIPs.Count); //2014.11.21.
}
else //2014.11.21.
{ //2014.11.21.
/*Program.MainF.UpdateStats(MainForm.StatType.Servers, UserInfo.IPs.Count); //2014.11.21.
Program.MainF.UpdateStats(MainForm.StatType.OnlineServers, UserInfo.IPs.Count - UserInfo.BannedIPs.Count); //2014.11.21. - 2014.12.05. - Servers --> OnlineServers*/
//2014.12.31.
MessageBox.Show("Internal error: Network call was made in the same thread as the UI. This could lead to freezes.\nNetwork update canceled.");
return null;
}
}
if (UserInfo.IPs.Count == 0
&& !UserInfo.IPs.Any(entry => entry.Address.Equals(RemoteEP.Address))
&& ut != Networking.UpdateType.LoginUser
/*&& ut != Networking.UpdateType.CheckConn
&& ut != Networking.UpdateType.RequestConn
&& ut != Networking.UpdateType.MakeConn
&& ut != Networking.UpdateType.MakeConn2*/) //2014.12.19.
return null;
//Log("Packet sending begins: there are users online and/or it is an update type that does not require that.");
byte[] senddata = CreatePacket(response, (byte)ut, data);
//Log("Packet created successfully (" + ((response) ? "" : "not ") + "response) with update type " + ut.ToString());
if (UserInfo.BanTime < Environment.TickCount - 1000 * 10) //2014.08.30. - 2014.10.09. - 10 percről 1-re csökkentve - 2014.11.22. - 1 percről 10 mp-re csökkentve
//UserInfo.BannedIPs = new List<IPEndPoint>(); //2014.08.30.
UserInfo.BannedIPs = new List<IPEndPoint>(); //2014.11.23.
if (!response)
{ //2014.08.30. - Azelőtt állítsa be, hogy elküldené a lekéréseket, hogy biztosan reagáljon a válaszra
WaitingOnResponse = true; //2014.08.16.
WaitingOnPacket = (byte)ut; //2014.08.16.
}
//Log("Hole punching begins.");
/*if (ut != UpdateType.CheckConn && ut != UpdateType.RequestConn)
CheckNPunchHole(); //2014.11.22.*/
//Log("Hole punching done.");
if (onlythisep == null) //2014.11.22. - != helyett ==: 2014.12.18.
{
//Log("Sending to every known user...");
foreach (var item in UserInfo.IPs)
{ //Elküldi az összes ismert címre
try
{
if (!UserInfo.BannedIPs.Contains(item))
//SenderConnection.Send(Storage.Encrypt(senddata.ToArray(), "sendupdatestringencrypted"), senddata.Count, item);
SenderConnection.Send(senddata, senddata.Length, item);
}
catch (ObjectDisposedException)
{
return null;
}
}
}
else
{ //2014.11.22.
//Log("Sending to single ip: " + onlythisep.Address + ":" + onlythisep.Port);
try
{
//if (UserInfo.IPs.Any(entry=>entry.IP==onlythisep) && !UserInfo.BannedIPs.Any(entry=>entry.IP==onlythisep))
//if (UserInfo.IPs.Any(entry => entry.IP == onlythisep) && !UserInfo.BannedIPs.Any(entry => entry.IP == onlythisep))
SenderConnection.Send(senddata, senddata.Length, onlythisep);
}
catch (ObjectDisposedException)
{
return null;
}
}
if (!response)
{
int lasttick = Environment.TickCount;
List<byte[]> Ret = new List<byte[]>();
List<IPEndPoint> ResponsedIPs = new List<IPEndPoint>();
int count = 1;
//Log("Starting to wait on response...");
while (Environment.TickCount - 1000 * 10 < lasttick && (
(onlythisep == null) ? //2014.11.22.
ResponsedIPs.Count < UserInfo.IPs.Count - UserInfo.BannedIPs.Count :
ResponsedIPs.Count == 0 //2014.11.22.
)) //2014.09.09. - 2014.10.09. - 60 mp --> 10 mp
{ //2014.08.19. - Ret.Count == tmp.Length
if (MainForm.LThread != null) //2014.09.06.
{
//Log("Waiting to get response... Wait time: " + count * 2 + "seconds");
while (DataBuffer == null && Environment.TickCount - 1000 * count * 2 < lasttick) ; //Várakozik, amíg a másik thread át nem adja a választ - 2014.10.09. - 10 mp --> 2 mp
/*foreach (var item in UserInfo.IPs.Except(UserInfo.BannedIPs).Except(ResponsedIPs)) //2014.09.22.
{ //Elküldi az összes ismert címre
try
{
SenderConnection.Send(senddata, senddata.Length, item.IP);
}
catch (ObjectDisposedException)
{
return null;
}
}
count++;*/
}
if (DataBuffer == null) //2014.08.30. - Az idő telt le
{
//Log("No response received. Retrying...");
//UserInfo.BannedIPs = UserInfo.IPs.Except(ResponsedIPs).ToList(); //2014.08.30. - Ideiglenesen kitilt minden IP-t, ahonnan nem érkezett válasz
//UserInfo.BanTime = Environment.TickCount;
foreach (var item in UserInfo.IPs.Except(UserInfo.BannedIPs).Except(ResponsedIPs)) //2014.09.22.
{ //Elküldi az összes ismert címre
try
{
SenderConnection.Send(senddata, senddata.Length, item);
}
catch (ObjectDisposedException)
{
return null;
}
}
count++;
//break;
continue;
}
//Log("A response received.");
//if (UserInfo.IPs.Any(entry=>entry.IP==RemoteEP) && !UserInfo.BannedIPs.Any(entry=>entry.IP==RemoteEP))
if (!(!UserInfo.IPs.Any(entry => entry.Address.Equals(RemoteEP.Address))
&& ut != Networking.UpdateType.LoginUser
/*&& ut != Networking.UpdateType.CheckConn
&& ut != Networking.UpdateType.RequestConn
&& ut != Networking.UpdateType.MakeConn
&& ut != Networking.UpdateType.MakeConn2*/)) //2014.12.22. - Ha az egész feltétel nem teljesül, akkor sikerült
{
//Log("Response is from known ip or it's not required to be that.");
//ResponsedIPs.Add(RemoteEP);
foreach (var item in UserInfo.IPs.Where(entry => entry == RemoteEP))
ResponsedIPs.Add(item);
var pparts = ParsePacket(DataBuffer);
//Log("Packet parsed.");
if (pparts.KeyVersion != CurrentUser.KeyIndex && pparts.UpdateType != UpdateType.SetKey)
{
//Log("Key version mismatch.");
DataBuffer = null; //2014.09.22. - Mindig adja meg a lehetőséget, hogy újra beállítsa
continue;
}
//Log("Complete success!");
int i;
for (i = 0; i < Ret.Count; i++)
{
if (DataBuffer.SequenceEqual(Ret[i]))
break;
}
if (i == Ret.Count)
Ret.Add(DataBuffer);
} //(2014.08.17. -->) Várja meg, amíg az összes online(!) ismerőse válaszol - Vagy letelik az egy perc
DataBuffer = null; //2014.09.22. - Mindig adja meg a lehetőséget, hogy újra beállítsa
}
//Log("Resetting everything.");
DataBuffer = null;
RemoteEP = null;
WaitingOnResponse = false;
WaitingOnPacket = 0x00;
//Log("Returning response if there was any.");
return Ret.ToArray();
}
return null;
}
}
}

View file

@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace MSGer.tk
{
partial class Networking
{
//private const string ConnID = "MSGer.tk connection";
/*public static void WaitForNewConnections()
{
while (true)
{
Ping pingSender = new Ping();
//byte[] id = Encoding.Unicode.GetBytes(ConnID);
//PingReply reply = pingSender.Send("3.3.3.3", 30000, id, new PingOptions(512, true));
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp);
socket.SendTo(ICMPPacket.CreateRequest(), new IPEndPoint(IPAddress.Parse("3.3.3.3"), 8988));
byte[] buffer = new byte[128];
//IPEndPoint ep = new IPEndPoint(IPAddress.Any, 8988);
EndPoint ep = (EndPoint)new IPEndPoint(IPAddress.Any, 8988);
socket.ReceiveFrom(buffer, ref ep);
//if (reply.Status == IPStatus.TimeExceeded)
if(ICMPPacket.IsPacketGood(buffer))
{
Log("A client is trying to connect...");
//MakeConnection(reply.Address);
MakeConnection(((IPEndPoint)ep).Address);
}
else
{
//Log("An error occured during ICMP... - Status: " + reply.Status);
Log("An error occured during ICMP...");
}
Thread.Sleep(28 * 1000);
}
}
public static void ConnectToServer(IPEndPoint server)
{
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp);
socket.SendTo(ICMPPacket.CreateReply(),server);
}
private static void MakeConnection(IPAddress addr)
{
}*/
public static void KeepUpThread()
{ //2014.08.28.
while (true) //while: 2014.12.19.
{
Thread.Sleep(59 * 60 * 1000); //59 percenként frissíti a jelenlétét, így biztosan nem jelenti offline-nak a PHP (elvileg)
Console.WriteLine("KeepUpThread: " + Networking.SendRequest("keepactive", "", 0, true));
}
}
public static void KeepUpUsersThread() //2014.09.26. - Nehogy bezáruljon a kapcsolat
{
while (true) //while: 2014.12.19.
{
Thread.Sleep(20 * 1000);
Networking.SendUpdate(UpdateType.KeepAlive, new byte[] { 0x01 }, false);
}
}
public static void SendUpdateInThread(UpdateType ut, byte[] data, EventHandler<byte[][]> doneevent, IPEndPoint onlythisep = null)
{ //2014.12.31. 0:24 - Válaszadásra van külön thread, itt csak eredeti küldést használhat
threadobject.Clear();
threadobject.Add(ut);
threadobject.Add(data);
threadobject.Add(doneevent);
threadobject.Add(onlythisep);
while (networkthread == null) ;
networkthread.Interrupt();
}
private static List<object> threadobject = new List<object>();
private static Thread networkthread;
public static void NetworkThread() //A MainThread ezen keresztül hívja meg, hogy ne fagyjon le
{ //2014.12.30.
networkthread = Thread.CurrentThread;
while (true)
{
try
{
Thread.Sleep(Timeout.Infinite);
}
catch (ThreadInterruptedException)
{
var resp = SendUpdate((UpdateType)threadobject[0], (byte[])threadobject[1], false, (IPEndPoint)threadobject[3]);
if (threadobject[2] != null)
((EventHandler<byte[][]>)threadobject[2])(null, resp);
}
}
}
}
}

140
MSGer.tk/Networking.cs Normal file
View file

@ -0,0 +1,140 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MSGer.tk
{
static partial class Networking
{
public enum UpdateType : byte
{
ListUpdate = 0x01, //0x01: OK
UpdateMessages, //0x01: OK
GetImage, //(int)0: Hiba, egyébként a kép hossza, majd a kép
LoginUser, //0x00: Hiba - Egyébként minden fontos információ, amiről "lemaradt"
LogoutUser, //0x01: OK
SetKey, //0x01: OK
KeepAlive,
/*CheckConn, //0x01: Csatlakozva
RequestConn, //
MakeConn,
MakeConn2*/
};
private static void Log(string message) //2014.12.31.
{
Logging.Log(message, Logging.LogType.Network);
}
/*public static byte[][] SendUpdate(UpdateType ut, byte[] data, bool response) - Opcionális paraméterre változtatva: 2014.12.22.
{ //2014.11.22.
return SendUpdate(ut, data, response, null);
}*/
/*private static void CheckNPunchHole() //Még előtte tudja meg a belső portot
{ //2014.11.22.
try
{
foreach (var item in UserInfo.IPs.Except(UserInfo.BannedIPs))
{
if (Thread.CurrentThread == MainForm.MainThread)
{
SendUpdateInThread(UpdateType.CheckConn, new byte[] { }, new EventHandler<byte[][]>(
(e, resp) =>
{
if (resp != null && resp.Length != 0 && ParsePacket(resp[0]).Data[0] == 0x01)
return; //Minden rendben, válaszolt
UserInfo.BannedIPs.Remove(item); //2014.12.19.
//if (Storage.Settings["isserver"] == "1") - Ha szerver, ha nem, kérje a többi szervert, hogy csatlakoztassa össze
resp = SendUpdate(UpdateType.RequestConn, Encoding.Unicode.GetBytes(item.ToString()), false); //Mindenkitől kéri, akivel van kapcsolata
if (resp != null && resp.Length != 0 && ParsePacket(resp[0]).Data[0] == 0x01) //2014.11.23. - Ilyenkor már tudnia kellene a portot, és hasonlókat
{
Networking.SendUpdate(UpdateType.MakeConn2, new byte[] { 0x01 }, false); //Elvileg akkor végez ez az utasítás, ha létrejött a kapcsolat, vagy letelt a határidő
}
}
), item);
}
else
{
var resp = SendUpdate(UpdateType.CheckConn, new byte[] { }, false, item);
if (resp != null && resp.Length != 0 && ParsePacket(resp[0]).Data[0] == 0x01)
continue; //Minden rendben, válaszolt
UserInfo.BannedIPs.Remove(item); //2014.12.19.
//if (Storage.Settings["isserver"] == "1") - Ha szerver, ha nem, kérje a többi szervert, hogy csatlakoztassa össze
resp = SendUpdate(UpdateType.RequestConn, Encoding.Unicode.GetBytes(item.ToString()), false); //Mindenkitől kéri, akivel van kapcsolata
if (resp != null && resp.Length != 0 && ParsePacket(resp[0]).Data[0] == 0x01) //2014.11.23. - Ilyenkor már tudnia kellene a portot, és hasonlókat
{
Networking.SendUpdate(UpdateType.MakeConn2, new byte[] { 0x01 }, false); //Elvileg akkor végez ez az utasítás, ha létrejött a kapcsolat, vagy letelt a határidő
}
}
}
}
catch (InvalidOperationException) { }
}*/
public static bool SendChatMessage(ChatPanel chat, string message)
{ //2014.09.22.
List<byte> bytes = new List<byte>();
string sendstr = "";
foreach (var pID in chat.ChatPartners)
{
sendstr += pID + ",";
}
bytes.AddRange(BitConverter.GetBytes(Encoding.Unicode.GetByteCount(sendstr)));
bytes.AddRange(Encoding.Unicode.GetBytes(sendstr));
sendstr = message; //Átállítja a sendstr-t az üzenetre, majd újra belerakja
bytes.AddRange(BitConverter.GetBytes(Encoding.Unicode.GetByteCount(sendstr)));
bytes.AddRange(Encoding.Unicode.GetBytes(sendstr));
sendstr = Program.DateTimeToUnixTime(DateTime.Now);
bytes.AddRange(BitConverter.GetBytes(Encoding.Unicode.GetByteCount(sendstr)));
bytes.AddRange(Encoding.Unicode.GetBytes(sendstr));
byte[][] resp = SendUpdate(UpdateType.UpdateMessages, Encoding.Unicode.GetBytes(sendstr), false);
if (resp == null || resp.Length == 0 || resp.All(bytesb => bytesb[0] != 0x01))
return false;
else //Ha válaszoltak, és senki sem válaszolt nem oké jelzéssel, akkor rendben van
return true;
}
public static object[] ReceiveUpdates() //Thread function
{
IPEndPoint remoteEP;
remoteEP = new IPEndPoint(IPAddress.Any, Int32.Parse(Storage.Settings["port"])); //2014.09.04. - A port beállítása már megtörtént
byte[] buf;
try
{
buf = ReceiverConnection.Receive(ref remoteEP);
}
catch
{
return null;
}
if (buf[0] == 0x01) //0x01: Válasz egy kérelemre
{
if (WaitingOnResponse == false || WaitingOnPacket != buf[1])
return null;
while (DataBuffer != null) ; //Várja meg, amíg feldolgozza a legutóbbi adatot
DataBuffer = buf; //2014.09.19. - Küldön el mindenhova mindent, és egységesen egy funkcióval dolgozza fel
RemoteEP = remoteEP;
return null;
}
else
return new object[] { buf, remoteEP };
}
public struct PacketParts
{
public bool Response;
public UpdateType UpdateType;
public int KeyVersion;
public int Port; //2014.12.19.
public int UserID;
public byte[] Data;
};
}
}

BIN
MSGer.tk/ObjectListView.dll Normal file

Binary file not shown.

View file

@ -0,0 +1,188 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{18FEDA0C-D147-4286-B39A-01204808106A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BrightIdeasSoftware</RootNamespace>
<AssemblyName>ObjectListView</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>olv-keyfile.snk</AssemblyOriginatorKeyFile>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<DocumentationFile>bin\Debug\ObjectListView.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="Accessibility" />
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DataTreeListView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="DragDrop\OLVDataObject.cs" />
<Compile Include="Filtering\DateTimeClusteringStrategy.cs" />
<Compile Include="Filtering\FlagClusteringStrategy.cs" />
<Compile Include="Filtering\TextMatchFilter.cs" />
<Compile Include="Implementation\Delegates.cs" />
<Compile Include="Implementation\Enums.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Implementation\GroupingParameters.cs" />
<Compile Include="Implementation\NullableDictionary.cs" />
<Compile Include="Implementation\OLVListItem.cs" />
<Compile Include="Implementation\OLVListSubItem.cs" />
<Compile Include="Implementation\OlvListViewHitTestInfo.cs" />
<Compile Include="Implementation\TreeDataSourceAdapter.cs" />
<Compile Include="OLVColumn.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Rendering\Adornments.cs" />
<Compile Include="Implementation\Attributes.cs" />
<Compile Include="CellEditing\CellEditors.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CellEditing\EditorRegistry.cs" />
<Compile Include="DataListView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Implementation\DataSourceAdapter.cs" />
<Compile Include="Rendering\Decorations.cs" />
<Compile Include="DragDrop\DragSource.cs" />
<Compile Include="DragDrop\DropSink.cs" />
<Compile Include="Implementation\Events.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="FastDataListView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Filtering\ClusteringStrategy.cs" />
<Compile Include="Filtering\Cluster.cs" />
<Compile Include="Filtering\ClustersFromGroupsStrategy.cs" />
<Compile Include="FastObjectListView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Filtering\FilterMenuBuilder.cs" />
<Compile Include="Filtering\Filters.cs" />
<Compile Include="Filtering\ICluster.cs" />
<Compile Include="Filtering\IClusteringStrategy.cs" />
<Compile Include="Rendering\TreeRenderer.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="SubControls\ToolStripCheckedListBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Utilities\ColumnSelectionForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Utilities\ColumnSelectionForm.Designer.cs">
<DependentUpon>ColumnSelectionForm.cs</DependentUpon>
</Compile>
<Compile Include="Utilities\Generator.cs" />
<Compile Include="SubControls\GlassPanelForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Implementation\Groups.cs" />
<Compile Include="SubControls\HeaderControl.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="CellEditing\CellEditKeyEngine.cs" />
<Compile Include="Implementation\Munger.cs" />
<Compile Include="Implementation\NativeMethods.cs" />
<Compile Include="Implementation\Comparers.cs">
</Compile>
<Compile Include="ObjectListView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ObjectListView.DesignTime.cs" />
<Compile Include="Rendering\Overlays.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Rendering\Renderers.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Rendering\Styles.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="SubControls\ToolTipControl.cs" />
<Compile Include="TreeListView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Utilities\OLVExporter.cs" />
<Compile Include="Utilities\TypedObjectListView.cs" />
<Compile Include="Implementation\VirtualGroups.cs" />
<Compile Include="Implementation\VirtualListDataSource.cs" />
<Compile Include="VirtualObjectListView.cs">
<SubType>Component</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="CustomDictionary.xml" />
<None Include="FullClassDiagram.cd" />
<None Include="Resources\sort-descending.png" />
<None Include="Resources\sort-ascending.png" />
<None Include="Resources\filter.png" />
<None Include="Resources\clear-filter.png" />
<None Include="Resources\filter-icons3.png" />
</ItemGroup>
<ItemGroup>
<None Include="olv-keyfile.snk" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Utilities\ColumnSelectionForm.resx">
<DependentUpon>ColumnSelectionForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\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>

182
MSGer.tk/PartnerInformation.Designer.cs generated Normal file
View file

@ -0,0 +1,182 @@
namespace MSGer.tk
{
partial class PartnerInformation
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.nameTextBox = new Khendys.Controls.ExRichTextBox();
this.messageTextBox = new Khendys.Controls.ExRichTextBox();
this.statusLabel = new System.Windows.Forms.Label();
this.userName1 = new System.Windows.Forms.Label();
this.userName2 = new System.Windows.Forms.Label();
this.userID1 = new System.Windows.Forms.Label();
this.userID2 = new System.Windows.Forms.Label();
this.email2 = new System.Windows.Forms.Label();
this.email1 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(12, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(100, 100);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// nameTextBox
//
this.nameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.nameTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.nameTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.nameTextBox.HiglightColor = Khendys.Controls.RtfColor.White;
this.nameTextBox.Location = new System.Drawing.Point(119, 12);
this.nameTextBox.Multiline = false;
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.ReadOnly = true;
this.nameTextBox.Size = new System.Drawing.Size(445, 30);
this.nameTextBox.TabIndex = 1;
this.nameTextBox.Text = "ShownName";
this.nameTextBox.TextColor = Khendys.Controls.RtfColor.Black;
//
// messageTextBox
//
this.messageTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.messageTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.messageTextBox.HiglightColor = Khendys.Controls.RtfColor.White;
this.messageTextBox.Location = new System.Drawing.Point(119, 57);
this.messageTextBox.Name = "messageTextBox";
this.messageTextBox.ReadOnly = true;
this.messageTextBox.Size = new System.Drawing.Size(445, 55);
this.messageTextBox.TabIndex = 2;
this.messageTextBox.Text = "User Message\nLine";
this.messageTextBox.TextColor = Khendys.Controls.RtfColor.Black;
//
// statusLabel
//
this.statusLabel.AutoSize = true;
this.statusLabel.Location = new System.Drawing.Point(119, 38);
this.statusLabel.Name = "statusLabel";
this.statusLabel.Size = new System.Drawing.Size(63, 13);
this.statusLabel.TabIndex = 3;
this.statusLabel.Text = "StatusLabel";
//
// userName1
//
this.userName1.AutoSize = true;
this.userName1.Location = new System.Drawing.Point(12, 120);
this.userName1.Name = "userName1";
this.userName1.Size = new System.Drawing.Size(63, 13);
this.userName1.TabIndex = 4;
this.userName1.Text = "UserName1";
//
// userName2
//
this.userName2.AutoSize = true;
this.userName2.Location = new System.Drawing.Point(119, 120);
this.userName2.Name = "userName2";
this.userName2.Size = new System.Drawing.Size(63, 13);
this.userName2.TabIndex = 5;
this.userName2.Text = "UserName2";
//
// userID1
//
this.userID1.AutoSize = true;
this.userID1.Location = new System.Drawing.Point(12, 135);
this.userID1.Name = "userID1";
this.userID1.Size = new System.Drawing.Size(46, 13);
this.userID1.TabIndex = 6;
this.userID1.Text = "UserID1";
//
// userID2
//
this.userID2.AutoSize = true;
this.userID2.Location = new System.Drawing.Point(119, 135);
this.userID2.Name = "userID2";
this.userID2.Size = new System.Drawing.Size(46, 13);
this.userID2.TabIndex = 7;
this.userID2.Text = "UserID2";
//
// email2
//
this.email2.AutoSize = true;
this.email2.Location = new System.Drawing.Point(119, 150);
this.email2.Name = "email2";
this.email2.Size = new System.Drawing.Size(38, 13);
this.email2.TabIndex = 9;
this.email2.Text = "Email2";
//
// email1
//
this.email1.AutoSize = true;
this.email1.Location = new System.Drawing.Point(12, 150);
this.email1.Name = "email1";
this.email1.Size = new System.Drawing.Size(38, 13);
this.email1.TabIndex = 8;
this.email1.Text = "Email1";
//
// PartnerInformation
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(576, 273);
this.Controls.Add(this.email2);
this.Controls.Add(this.email1);
this.Controls.Add(this.userID2);
this.Controls.Add(this.userID1);
this.Controls.Add(this.userName2);
this.Controls.Add(this.userName1);
this.Controls.Add(this.statusLabel);
this.Controls.Add(this.messageTextBox);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.pictureBox1);
this.Name = "PartnerInformation";
this.Text = "PartnerInformation";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
private Khendys.Controls.ExRichTextBox nameTextBox;
private Khendys.Controls.ExRichTextBox messageTextBox;
private System.Windows.Forms.Label statusLabel;
private System.Windows.Forms.Label userName1;
private System.Windows.Forms.Label userName2;
private System.Windows.Forms.Label userID1;
private System.Windows.Forms.Label userID2;
private System.Windows.Forms.Label email2;
private System.Windows.Forms.Label email1;
}
}

View file

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MSGer.tk
{
public partial class PartnerInformation : ThemedForms
{
public PartnerInformation(UserInfo uinfo)
{
InitializeComponent();
nameTextBox.BackColor = this.BackColor;
messageTextBox.BackColor = this.BackColor;
string tmp = Path.GetTempPath();
string pictlocation = tmp + "\\MSGer.tk\\pictures\\" + uinfo.UserID + ".png";
if (File.Exists(pictlocation))
pictureBox1.ImageLocation = pictlocation;
else
pictureBox1.ImageLocation = "noimage.png";
nameTextBox.Text = uinfo.Name;
if (uinfo.State == 1)
statusLabel.Text = Language.Translate("menu_file_status_online");
else if (uinfo.State == 2)
statusLabel.Text = Language.Translate("menu_file_status_busy");
else if (uinfo.State == 3)
statusLabel.Text = Language.Translate("menu_file_status_away");
else
statusLabel.Text = "";
messageTextBox.Text = uinfo.Message;
userName1.Text = Language.Translate("reg_username") + ":";
userName2.Text = uinfo.UserName;
userID1.Text = Language.Translate("userid");
userID2.Text = uinfo.UserID.ToString();
email1.Text = "E-mail:";
email2.Text = uinfo.Email;
}
}
}

View file

@ -0,0 +1,120 @@
<?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>
</root>

View file

@ -21,6 +21,7 @@ namespace MSGer.tk
static class Program
{
public static MainForm MainF;
public static SettingsForm SettingsF;
public static string ProcessName = Process.GetCurrentProcess().ProcessName;
/// <summary>
/// The main entry point for the application.
@ -40,8 +41,9 @@ namespace MSGer.tk
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
try
{
MainF = new MainForm();
Application.Run(MainF);
//MainF = new MainForm(); - 2014.11.21. - A létrehozáskor hozzárendeli, így már akkor hozzáférhető ezen a néven
//Application.Run(MainF);
Application.Run(new MainForm()); //2014.11.21.
}
catch (FileNotFoundException e)
{
@ -161,7 +163,7 @@ namespace MSGer.tk
///
/// The object to be cloned must be serializable.
///
public static object Clone(object obj)
public static object Clone(this object obj)
{
using (MemoryStream buffer = new MemoryStream())
{
@ -172,5 +174,16 @@ namespace MSGer.tk
return temp;
}
}
public static IEnumerable<Control> GetAll(this Control control, Type type = null)
{ //2015.02.26.
var controls = control.Controls.Cast<Control>();
/*return controls.SelectMany(ctrl => GetAll(ctrl, type))
.Concat(controls)
.Where(c => c.GetType() == type);*/
var ret = controls.SelectMany(ctrl => GetAll(ctrl, type))
.Concat(controls);
return (type == null) ? ret : ret.Where(c => c.GetType() == type);
}
}
}

View file

@ -0,0 +1,357 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HdSystemLibrary.IO
{
public class ProgressEventArgs : EventArgs
{
public ProgressEventArgs(ProgressStatistic progressStatistic)
{
if (progressStatistic == null)
throw new ArgumentNullException("progressStatistic");
ProgressStatistic = progressStatistic;
}
public ProgressStatistic ProgressStatistic { get; private set; }
}
[Serializable]
public class OperationAlreadyStartedException : Exception
{
public OperationAlreadyStartedException() { }
public OperationAlreadyStartedException(string message) : base(message) { }
public OperationAlreadyStartedException(string message, Exception inner) : base(message, inner) { }
protected OperationAlreadyStartedException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
: base(info, context) { }
}
/// <summary>
/// A class which calculates progress statistics like average bytes per second or estimated finishing time.
/// To use it, call the ProgressChange method in regular intervals with the actual progress.
/// </summary>
public class ProgressStatistic
{
public ProgressStatistic()
{
StartingTime = DateTime.MinValue;
FinishingTime = DateTime.MinValue;
progressChangedArgs = new ProgressEventArgs(this); //Event args can be cached
}
private bool hasStarted = false;
/// <summary>
/// Gets whether the operation has started
/// </summary>
public bool HasStarted { get { return hasStarted; } }
/// <summary>
/// Gets whether the operation has finished
/// </summary>
public bool HasFinished { get { return FinishingTime != DateTime.MinValue; } }
/// <summary>
/// Gets whether the operation is still running
/// </summary>
public bool IsRunning { get { return HasStarted && !HasFinished; } }
#region Time
/// <summary>
/// Gets the date time when the operation has started
/// </summary>
public DateTime StartingTime { get; private set; }
/// <summary>
/// Gets the date time when the operation has finished
/// </summary>
public DateTime FinishingTime { get; private set; }
/// <summary>
/// Gets the duration of the operation.
/// If the operation is still running, the time since starting is returned.
/// If the operation has not started, TimeSpan.Zero is returned.
/// If the operation has finished, the time between starting and finishing is returned.
/// </summary>
public TimeSpan Duration
{
get
{
if (!HasStarted)
return TimeSpan.Zero;
else if (!HasFinished)
return DateTime.Now - StartingTime;
else
return FinishingTime - StartingTime;
}
}
/// <summary>
/// The method which will be used for estimating duration and finishing time
/// </summary>
public enum EstimatingMethod
{
/// <summary>
/// Current bytes per second will be used for estimating.
/// </summary>
CurrentBytesPerSecond,
/// <summary>
/// Average bytes per second will be used for estimating
/// </summary>
AverageBytesPerSecond
}
private EstimatingMethod estimatingMethod = EstimatingMethod.CurrentBytesPerSecond;
/// <summary>
/// Gets or sets which method will be used for estimating.
/// Can only be set before the operation has started, otherwise an OperationAlreadyStartedException will be thrown.
/// </summary>
public EstimatingMethod UsedEstimatingMethod
{
get { return estimatingMethod; }
set
{
if (HasStarted)
throw new OperationAlreadyStartedException();
estimatingMethod = value;
}
}
/// <summary>
/// Gets the estimated duration. Use UsedEstimatingMethod to specify which method will be used for estimating.
/// If the operation will take more than 200 days, TimeSpan.MaxValue is returned.
/// </summary>
public TimeSpan EstimatedDuration
{
get
{
if (HasFinished)
return Duration;
if (TotalBytesToRead == -1)
return TimeSpan.MaxValue;
double bytesPerSecond = 1;
if (UsedEstimatingMethod == EstimatingMethod.AverageBytesPerSecond)
bytesPerSecond = AverageBytesPerSecond;
else if (UsedEstimatingMethod == EstimatingMethod.CurrentBytesPerSecond)
bytesPerSecond = CurrentBytesPerSecond;
double seconds = (TotalBytesToRead - BytesRead) / bytesPerSecond;
if (seconds > 60 * 60 * 24 * 200) //over 200 Days -> infinite
return TimeSpan.MaxValue;
else
return Duration + TimeSpan.FromSeconds(seconds);
}
}
/// <summary>
/// Gets the estimated finishing time based on EstimatedDuration.
/// If the operation will take more than 200 days, DateTime.MaxValue is returned.
/// If the operation has finished, the actual finishing time is returned.
/// </summary>
public DateTime EstimatedFinishingTime
{
get
{
if (EstimatedDuration == TimeSpan.MaxValue)
return DateTime.MaxValue;
return StartingTime + EstimatedDuration;
}
}
#endregion
/// <summary>
/// Gets the amount of bytes already read.
/// </summary>
public long BytesRead { get; private set; }
/// <summary>
/// Gets the amount of total bytes to read. Can be -1 if unknown.
/// </summary>
public long TotalBytesToRead { get; private set; }
/// <summary>
/// Gets the progress in percent between 0 and 1.
/// If the amount of total bytes to read is unknown, -1 is returned.
/// </summary>
public double Progress
{
get
{
if (TotalBytesToRead == -1)
return -1;
else
return (double)BytesRead / (double)TotalBytesToRead;
}
}
/// <summary>
/// Gets the average bytes per second.
/// </summary>
public double AverageBytesPerSecond { get { return (double)BytesRead / Duration.TotalSeconds; } }
#region CurrentBytesPerSecond
/// <summary>
/// Gets the approximated current count of bytes processed per second
/// </summary>
public double CurrentBytesPerSecond { get; private set; }
private TimeSpan currentBytesCalculationInterval = TimeSpan.FromSeconds(0.5);
/// <summary>
/// Gets or sets the interval used for the calculation of the current bytes per second. Default is 500 ms.
/// </summary>
/// <exception cref="OperationAlreadyStartedException">
/// Thrown when trying to set although the operation has already started.</exception>
public TimeSpan CurrentBytesCalculationInterval
{
get { return currentBytesCalculationInterval; }
set
{
if (HasStarted)
throw new InvalidOperationException("Task has already started!");
currentBytesCalculationInterval = value;
}
}
KeyValuePair<DateTime, long>[] currentBytesSamples = new KeyValuePair<DateTime, long>[6];
/// <summary>
/// Gets or sets the number of samples in CurrentBytesPerSecondInterval used for current bytes per second approximation
/// </summary>
/// <exception cref="OperationAlreadyStartedException">
/// Thrown when trying to set although the operation has already started.</exception>
public int CurrentBytesSampleCount
{
get { return currentBytesSamples.Length; }
set
{
if (HasStarted)
throw new InvalidOperationException("Task has already started!");
if (value != currentBytesSamples.Length)
{
currentBytesSamples = new KeyValuePair<DateTime, long>[value];
}
}
}
int currentSample = 0; //current sample index in currentBytesSamples
DateTime lastSample;
private void ProcessSample(long bytes)
{
if ((DateTime.Now - lastSample).Ticks > CurrentBytesCalculationInterval.Ticks / currentBytesSamples.Length)
{
lastSample = DateTime.Now;
KeyValuePair<DateTime, long> current = new KeyValuePair<DateTime, long>(DateTime.Now, bytes);
var old = currentBytesSamples[currentSample];
currentBytesSamples[currentSample] = current;
if (old.Key == DateTime.MinValue)
CurrentBytesPerSecond = AverageBytesPerSecond;
else
CurrentBytesPerSecond = (double)(current.Value - old.Value) / (current.Key - old.Key).TotalSeconds;
currentSample++;
if (currentSample >= currentBytesSamples.Length)
currentSample = 0;
}
}
#endregion
/// <summary>
/// This method can be called to report progress changes.
/// The signature of this method is compliant with the ProgressChange-delegate
/// </summary>
/// <param name="bytesRead">The amount of bytes already read</param>
/// <param name="totalBytesToRead">The amount of total bytes to read. Can be -1 if unknown.</param>
/// <exception cref="ArgumentException">Thrown if bytesRead has not changed or even shrunk.</exception>
/// <exception cref="InvalidOperationException">Thrown if the operation has finished already.</exception>
public virtual void ProgressChange(long bytesRead, long totalBytesToRead)
{
if (bytesRead <= BytesRead)
throw new ArgumentException("Operation cannot go backwards!", "bytesRead");
if (HasFinished)
throw new InvalidOperationException("Operation has finished already!");
if (!hasStarted)
{
StartingTime = DateTime.Now;
hasStarted = true;
OnStarted();
}
BytesRead = bytesRead;
TotalBytesToRead = totalBytesToRead;
ProcessSample(bytesRead);
OnProgressChanged();
if (bytesRead == TotalBytesToRead)
{
FinishingTime = DateTime.Now;
OnFinished();
}
}
/// <summary>
/// This method can be called to finish an aborted operation.
/// If the operation does not reach 100%, "Finished" will be never raised, so this method should be called.
/// </summary>
public virtual void Finish()
{
if (!HasFinished)
{
FinishingTime = DateTime.Now;
OnFinished();
}
}
#region Events
private readonly ProgressEventArgs progressChangedArgs;
protected virtual void OnStarted()
{
if (Started != null)
Started(this, progressChangedArgs);
}
protected virtual void OnProgressChanged()
{
if (ProgressChanged != null)
ProgressChanged(this, progressChangedArgs);
}
protected virtual void OnFinished()
{
if (Finished != null)
Finished(this, progressChangedArgs);
}
/// <summary>
/// Will be raised when the operation has started
/// </summary>
public event EventHandler<ProgressEventArgs> Started;
/// <summary>
/// Will be raised when the progress has changed
/// </summary>
public event EventHandler<ProgressEventArgs> ProgressChanged;
/// <summary>
/// Will be raised when the operation has finished
/// </summary>
public event EventHandler<ProgressEventArgs> Finished;
#endregion
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -11,7 +11,7 @@ using System.Windows.Forms;
namespace MSGer.tk
{
public partial class SelectPartnerForm : Form
public partial class SelectPartnerForm : ThemedForms
{
public SelectPartnerForm(ToolStripMenuItem SelectPartnerSender) //paraméter: 2014.09.06.
{

View file

@ -28,11 +28,23 @@
/// </summary>
private void InitializeComponent()
{
GlacialComponents.Controls.GLColumn glColumn2 = new GlacialComponents.Controls.GLColumn();
GlacialComponents.Controls.GLColumn glColumn1 = new GlacialComponents.Controls.GLColumn();
GlacialComponents.Controls.GLItem glItem1 = new GlacialComponents.Controls.GLItem();
GlacialComponents.Controls.GLSubItem glSubItem1 = new GlacialComponents.Controls.GLSubItem();
GlacialComponents.Controls.GLItem glItem2 = new GlacialComponents.Controls.GLItem();
GlacialComponents.Controls.GLSubItem glSubItem2 = new GlacialComponents.Controls.GLSubItem();
GlacialComponents.Controls.GLItem glItem3 = new GlacialComponents.Controls.GLItem();
GlacialComponents.Controls.GLSubItem glSubItem3 = new GlacialComponents.Controls.GLSubItem();
this.glacialList1 = new GlacialComponents.Controls.GlacialList();
this.panel1 = new System.Windows.Forms.Panel();
this.isserver = new System.Windows.Forms.CheckBox();
this.technical = new System.Windows.Forms.Label();
this.chatwindowTabs = new System.Windows.Forms.CheckBox();
this.chatwindow = new System.Windows.Forms.CheckBox();
this.layout = new System.Windows.Forms.Label();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.label3 = new System.Windows.Forms.Label();
this.messageText = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.nameText = new System.Windows.Forms.TextBox();
@ -40,9 +52,6 @@
this.personal = new System.Windows.Forms.Label();
this.okbtn = new System.Windows.Forms.Button();
this.cancelbtn = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.panel1.SuspendLayout();
this.SuspendLayout();
//
@ -57,16 +66,16 @@
this.glacialList1.AutoHeight = true;
this.glacialList1.BackColor = System.Drawing.Color.White;
this.glacialList1.BackgroundStretchToFit = true;
glColumn2.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None;
glColumn2.CheckBoxes = false;
glColumn2.ImageIndex = -1;
glColumn2.Name = "Column1";
glColumn2.NumericSort = false;
glColumn2.Text = "Column";
glColumn2.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
glColumn2.Width = 115;
glColumn1.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None;
glColumn1.CheckBoxes = false;
glColumn1.ImageIndex = -1;
glColumn1.Name = "Column1";
glColumn1.NumericSort = false;
glColumn1.Text = "Column";
glColumn1.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
glColumn1.Width = 115;
this.glacialList1.Columns.AddRange(new GlacialComponents.Controls.GLColumn[] {
glColumn2});
glColumn1});
this.glacialList1.ControlStyle = GlacialComponents.Controls.GLControlStyles.Normal;
this.glacialList1.ForeColor = System.Drawing.Color.Black;
this.glacialList1.FullRowSelect = true;
@ -84,6 +93,20 @@
this.glacialList1.HoverTime = 1;
this.glacialList1.ImageList = null;
this.glacialList1.ItemHeight = 17;
glItem1.BackColor = System.Drawing.Color.White;
glItem1.ForeColor = System.Drawing.Color.Black;
glItem1.RowBorderColor = System.Drawing.Color.Black;
glItem1.RowBorderSize = 0;
glSubItem1.BackColor = System.Drawing.Color.Empty;
glSubItem1.Checked = false;
glSubItem1.ForceText = false;
glSubItem1.ForeColor = System.Drawing.Color.Black;
glSubItem1.ImageAlignment = System.Windows.Forms.HorizontalAlignment.Left;
glSubItem1.ImageIndex = -1;
glSubItem1.Text = "Személyes";
glItem1.SubItems.AddRange(new GlacialComponents.Controls.GLSubItem[] {
glSubItem1});
glItem1.Text = "Személyes";
glItem2.BackColor = System.Drawing.Color.White;
glItem2.ForeColor = System.Drawing.Color.Black;
glItem2.RowBorderColor = System.Drawing.Color.Black;
@ -94,12 +117,28 @@
glSubItem2.ForeColor = System.Drawing.Color.Black;
glSubItem2.ImageAlignment = System.Windows.Forms.HorizontalAlignment.Left;
glSubItem2.ImageIndex = -1;
glSubItem2.Text = "Személyes";
glSubItem2.Text = "Kinézet";
glItem2.SubItems.AddRange(new GlacialComponents.Controls.GLSubItem[] {
glSubItem2});
glItem2.Text = "Személyes";
glItem2.Text = "Kinézet";
glItem3.BackColor = System.Drawing.Color.White;
glItem3.ForeColor = System.Drawing.Color.Black;
glItem3.RowBorderColor = System.Drawing.Color.Black;
glItem3.RowBorderSize = 0;
glSubItem3.BackColor = System.Drawing.Color.Empty;
glSubItem3.Checked = false;
glSubItem3.ForceText = false;
glSubItem3.ForeColor = System.Drawing.Color.Black;
glSubItem3.ImageAlignment = System.Windows.Forms.HorizontalAlignment.Left;
glSubItem3.ImageIndex = -1;
glSubItem3.Text = "Technikai";
glItem3.SubItems.AddRange(new GlacialComponents.Controls.GLSubItem[] {
glSubItem3});
glItem3.Text = "Technikai";
this.glacialList1.Items.AddRange(new GlacialComponents.Controls.GLItem[] {
glItem2});
glItem1,
glItem2,
glItem3});
this.glacialList1.ItemWordWrap = false;
this.glacialList1.Location = new System.Drawing.Point(12, 12);
this.glacialList1.Name = "glacialList1";
@ -122,6 +161,11 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.panel1.AutoScroll = true;
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel1.Controls.Add(this.isserver);
this.panel1.Controls.Add(this.technical);
this.panel1.Controls.Add(this.chatwindowTabs);
this.panel1.Controls.Add(this.chatwindow);
this.panel1.Controls.Add(this.layout);
this.panel1.Controls.Add(this.listView1);
this.panel1.Controls.Add(this.label3);
this.panel1.Controls.Add(this.messageText);
@ -134,13 +178,85 @@
this.panel1.Size = new System.Drawing.Size(385, 391);
this.panel1.TabIndex = 1;
//
// isserver
//
this.isserver.AutoSize = true;
this.isserver.Location = new System.Drawing.Point(12, 405);
this.isserver.Name = "isserver";
this.isserver.Size = new System.Drawing.Size(217, 17);
this.isserver.TabIndex = 11;
this.isserver.Text = "Szerver mód (port forwarding szükséges)";
this.isserver.UseVisualStyleBackColor = true;
//
// technical
//
this.technical.AutoSize = true;
this.technical.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.technical.Location = new System.Drawing.Point(6, 371);
this.technical.Name = "technical";
this.technical.Size = new System.Drawing.Size(131, 31);
this.technical.TabIndex = 10;
this.technical.Text = "Technikai";
//
// chatwindowTabs
//
this.chatwindowTabs.AutoSize = true;
this.chatwindowTabs.Enabled = false;
this.chatwindowTabs.Location = new System.Drawing.Point(50, 329);
this.chatwindowTabs.Name = "chatwindowTabs";
this.chatwindowTabs.Size = new System.Drawing.Size(194, 17);
this.chatwindowTabs.TabIndex = 9;
this.chatwindowTabs.Text = "A beszélgetések fülekbe rendezése";
this.chatwindowTabs.UseVisualStyleBackColor = true;
//
// chatwindow
//
this.chatwindow.AutoSize = true;
this.chatwindow.Location = new System.Drawing.Point(12, 305);
this.chatwindow.Name = "chatwindow";
this.chatwindow.Size = new System.Drawing.Size(272, 17);
this.chatwindow.TabIndex = 8;
this.chatwindow.Text = "A beszélgetések jelenjenek meg külön ablak(ok)ban";
this.chatwindow.UseVisualStyleBackColor = true;
//
// layout
//
this.layout.AutoSize = true;
this.layout.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.layout.Location = new System.Drawing.Point(6, 270);
this.layout.Name = "layout";
this.layout.Size = new System.Drawing.Size(105, 31);
this.layout.TabIndex = 7;
this.layout.Text = "Kinézet";
//
// listView1
//
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});