Author Topic: Hitmen Chat (C# .NET)  (Read 4853 times)

0 Members and 1 Guest are viewing this topic.

Offline Newby

  • Moderator
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Hitmen Chat (C# .NET)
« on: August 26, 2005, 10:37:09 pm »
Yes, I figured I'd release it.

It was something I worked up during the end of 8th grade (May 2004-ish). Yes, it is sloppy (I wasn't very good at C#, though I'm probably worse now!) and I figure it's a nice base to learn off of.

Telnet connection with a pretty interface! Let me browse my old computer for a picture of it.

Criticism is welcome.

frmMain.cs
clsCommands.cs
clsDatabase.cs

(if something doesn't work (ala Commands.Commands) it's something I got started on, but never finished.)

Code: [Select]
using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;



using System.Net;

using System.Text;

using System.IO;

using System.Net.Sockets;

using System.Threading;



namespace Hitmen_Chat

{

/// <summary>

/// Main form for Hitmen Chat :D

/// Open source C# Telnet Client for Battle.net

/// Designed with Hitmen in mind, since he said if I made it he'd use it. :D

/// PLEASE give me credit if you produce this :|

/// </summary>

public class frmMain : System.Windows.Forms.Form

{

private System.Windows.Forms.RichTextBox rtbMain;

private System.Windows.Forms.TextBox txtTalk;

private System.Windows.Forms.Label lblChannel;

private System.Windows.Forms.MainMenu MainMenu;

private System.Windows.Forms.MenuItem mnuMain;

private System.Windows.Forms.MenuItem mnuConnect;

private System.Windows.Forms.MenuItem mnuDisconnect;

private System.Windows.Forms.MenuItem SeperatorOne;

private System.Windows.Forms.MenuItem mnuExit;

private System.Windows.Forms.MenuItem mnuHelpTopics;

private System.Windows.Forms.MenuItem mnuAbout;

private BattleNet BNET = new BattleNet();

private System.Windows.Forms.ImageList ClientImages;

private System.Windows.Forms.ListView lvMain;

private System.Windows.Forms.ColumnHeader chOne;

private System.ComponentModel.IContainer components;



public frmMain()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();



//

// TODO: Add any constructor code after InitializeComponent call

//

}



/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (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.components = new System.ComponentModel.Container();

System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmMain));

this.rtbMain = new System.Windows.Forms.RichTextBox();

this.txtTalk = new System.Windows.Forms.TextBox();

this.lvMain = new System.Windows.Forms.ListView();

this.chOne = new System.Windows.Forms.ColumnHeader();

this.ClientImages = new System.Windows.Forms.ImageList(this.components);

this.lblChannel = new System.Windows.Forms.Label();

this.MainMenu = new System.Windows.Forms.MainMenu();

this.mnuMain = new System.Windows.Forms.MenuItem();

this.mnuConnect = new System.Windows.Forms.MenuItem();

this.mnuDisconnect = new System.Windows.Forms.MenuItem();

this.SeperatorOne = new System.Windows.Forms.MenuItem();

this.mnuExit = new System.Windows.Forms.MenuItem();

this.mnuHelpTopics = new System.Windows.Forms.MenuItem();

this.mnuAbout = new System.Windows.Forms.MenuItem();

this.SuspendLayout();

//

// rtbMain

//

this.rtbMain.BackColor = System.Drawing.Color.Black;

this.rtbMain.Cursor = System.Windows.Forms.Cursors.IBeam;

this.rtbMain.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

this.rtbMain.ForeColor = System.Drawing.Color.White;

this.rtbMain.Name = "rtbMain";

this.rtbMain.ReadOnly = true;

this.rtbMain.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;

this.rtbMain.Size = new System.Drawing.Size(328, 304);

this.rtbMain.TabIndex = 0;

this.rtbMain.Text = "";

this.rtbMain.TextChanged += new System.EventHandler(this.rtbMain_TextChanged);

//

// txtTalk

//

this.txtTalk.BackColor = System.Drawing.Color.Black;

this.txtTalk.Dock = System.Windows.Forms.DockStyle.Bottom;

this.txtTalk.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

this.txtTalk.ForeColor = System.Drawing.Color.White;

this.txtTalk.Location = new System.Drawing.Point(0, 306);

this.txtTalk.Multiline = true;

this.txtTalk.Name = "txtTalk";

this.txtTalk.Size = new System.Drawing.Size(512, 20);

this.txtTalk.TabIndex = 1;

this.txtTalk.Text = "";

this.txtTalk.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtTalk_KeyPress);

//

// lvMain

//

this.lvMain.Anchor = System.Windows.Forms.AnchorStyles.Right;

this.lvMain.BackColor = System.Drawing.Color.Black;

this.lvMain.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {

this.chOne});

this.lvMain.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

this.lvMain.ForeColor = System.Drawing.Color.Gray;

this.lvMain.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;

this.lvMain.Location = new System.Drawing.Point(328, 24);

this.lvMain.Name = "lvMain";

this.lvMain.Size = new System.Drawing.Size(184, 280);

this.lvMain.SmallImageList = this.ClientImages;

this.lvMain.TabIndex = 2;

this.lvMain.View = System.Windows.Forms.View.Details;

//

// chOne

//

this.chOne.Text = "Username";

this.chOne.Width = 155;

//

// ClientImages

//

this.ClientImages.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;

this.ClientImages.ImageSize = new System.Drawing.Size(28, 14);

this.ClientImages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ClientImages.ImageStream")));

this.ClientImages.TransparentColor = System.Drawing.Color.Transparent;

//

// lblChannel

//

this.lblChannel.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);

this.lblChannel.BackColor = System.Drawing.Color.Black;

this.lblChannel.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

this.lblChannel.ForeColor = System.Drawing.Color.Red;

this.lblChannel.Location = new System.Drawing.Point(328, 0);

this.lblChannel.Name = "lblChannel";

this.lblChannel.Size = new System.Drawing.Size(184, 23);

this.lblChannel.TabIndex = 3;

this.lblChannel.Text = "Hitmen Chat! <3";

this.lblChannel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

//

// MainMenu

//

this.MainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {

this.mnuMain,

this.mnuHelpTopics});

//

// mnuMain

//

this.mnuMain.Index = 0;

this.mnuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {

this.mnuConnect,

this.mnuDisconnect,

this.SeperatorOne,

this.mnuExit});

this.mnuMain.Text = "Main";

//

// mnuConnect

//

this.mnuConnect.Index = 0;

this.mnuConnect.Text = "Connect";

this.mnuConnect.Click += new System.EventHandler(this.mnuConnect_Click);

//

// mnuDisconnect

//

this.mnuDisconnect.Index = 1;

this.mnuDisconnect.Text = "Disconnect";

this.mnuDisconnect.Click += new System.EventHandler(this.mnuDisconnect_Click);

//

// SeperatorOne

//

this.SeperatorOne.Index = 2;

this.SeperatorOne.Text = "-";

//

// mnuExit

//

this.mnuExit.Index = 3;

this.mnuExit.Text = "E&xit";

this.mnuExit.Click += new System.EventHandler(this.mnuExit_Click);

//

// mnuHelpTopics

//

this.mnuHelpTopics.Index = 1;

this.mnuHelpTopics.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {

  this.mnuAbout});

this.mnuHelpTopics.Text = "Help";

//

// mnuAbout

//

this.mnuAbout.Index = 0;

this.mnuAbout.Text = "About";

this.mnuAbout.Click += new System.EventHandler(this.mnuAbout_Click);

//

// frmMain

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(512, 326);

this.Controls.AddRange(new System.Windows.Forms.Control[] {

  this.lblChannel,

  this.lvMain,

  this.txtTalk,

  this.rtbMain});

this.Menu = this.MainMenu;

this.Name = "frmMain";

this.Text = "Hitmen Chat";

this.Resize += new System.EventHandler(this.frmMain_Resize);

this.Closing += new System.ComponentModel.CancelEventHandler(this.frmMain_Closing);

this.Load += new System.EventHandler(this.frmMain_Load);

this.ResumeLayout(false);



}

#endregion



/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new frmMain());

}



private void frmMain_Load(object sender, System.EventArgs e)

{

RTB.Notify(rtbMain, true, true, "Welcome to Hitmen Chat!\r\n", Color.Red);



BNET.rtbMain = this.rtbMain; /* Until I find out otherwise */

BNET.lvMain = this.lvMain; /* ^^ */

BNET.lblMain = this.lblChannel; /* ^^ */



BNET.Username = "GG";

BNET.Password = "";

BNET.Server = "useast.battle.net";

}



private void mnuAbout_Click(object sender, System.EventArgs e)

{

RTB.Notify(rtbMain, true, true, "Hitmen Chat -- Open Source C# Telnet Client\r\n", Color.Red);

RTB.Notify(rtbMain, true, true, "Designed with Hitmen in mind", Color.Red, " <3\r\n", Color.Pink);

}



private void mnuDisconnect_Click(object sender, System.EventArgs e)

{

if (BNET.Connected == true)

BNET.EndConnection();

else

RTB.Notify(rtbMain, true, true, "[BNET] Already disconnected!\r\n", Color.Red);

}



private void mnuConnect_Click(object sender, System.EventArgs e)

{

if (BNET.Connected == false)

{

RTB.Notify(rtbMain, true, true, "[BNET] Connecting ..\r\n", Color.Khaki);

BNET.BeginConnection();

}

else

RTB.Notify(rtbMain, true, true, "[BNET] Already connected!\r\n", Color.Red);

}



private void mnuExit_Click(object sender, System.EventArgs e)

{

Close();

}



private void frmMain_Closing(object sender, System.ComponentModel.CancelEventArgs e)

{

if (MessageBox.Show("Are you sure you want to exit Hitmen Chat?", "Query", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)

{

BNET.EndConnection();

e.Cancel = false;

}

else

e.Cancel = true;

}



private void txtTalk_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)

{

if (e.KeyChar == 13)

{

BNET.SendData(txtTalk.Text.ToString());

txtTalk.Text = String.Empty;

}

}



private void frmMain_Resize(object sender, System.EventArgs e)

{

rtbMain.Width = ((this.Width - lvMain.Width) - 7); /* Resizing the rich text box */

rtbMain.Height = ((this.Height - txtTalk.Height) - 55); /* Resizing the rich text box */

lvMain.Top = lblChannel.Height;

lvMain.Height = (txtTalk.Top - lblChannel.Height);

}



private void rtbMain_TextChanged(object sender, System.EventArgs e)

{

rtbMain.SelectionStart = rtbMain.Text.Length;

rtbMain.Focus();

txtTalk.SelectionStart = rtbMain.Text.Length;

txtTalk.Focus();

}

}



public class BattleNet

{

/* Contains:

* 1. Lots of stuff you shouldn't mess with =P */

#region User-specific Variables

private string strUsername = String.Empty;

private string strPassword = String.Empty;

private string strServer = String.Empty;

#endregion

#region Wrappers for user-specific variables

public string Username

{

get { return strUsername; }

set { strUsername = value; }

}

public string Password

{

get { return strPassword; }

set { strPassword = value; }

}

public string Server

{

get { return strServer; }

set { strServer = value; }

}

public System.Windows.Forms.RichTextBox rtbMain

{

get { return this.MainRTB; }

set { MainRTB = value; }

}

public System.Windows.Forms.ListView lvMain

{

get { return this.MainLV; }

set { MainLV = value; }

}

public System.Windows.Forms.Label lblMain

{

get { return this.MainLBL; }

set { MainLBL = value; }

}

public bool Connected

{

get { try { return sckBnet.Connected;}

  catch { return false; } }  

}

#endregion

#region Needed Variables

private Socket sckBnet;

private System.Windows.Forms.RichTextBox MainRTB;

private System.Windows.Forms.ListView MainLV;

private System.Windows.Forms.Label MainLBL;

private byte[] RecvBytes = new byte[1024];

private Thread ReceiveLoopThread;

private int ChannelCount = 0;

private string CurrentChannelName = String.Empty;



private clsDatabase Database = new clsDatabase(); // For database! :)

private clsCommands Commands = new clsCommands();

#endregion

private Socket ConnectSocket(string server, int port)

{

// found this on MSDN :)

Socket s = null;

IPHostEntry hostEntry = null;

       

hostEntry = Dns.Resolve(server);



foreach(IPAddress address in hostEntry.AddressList)

{

IPEndPoint ipe = new IPEndPoint(address, port);

Socket tempSocket =

new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);



tempSocket.Connect(ipe);



if(tempSocket.Connected)

{

s = tempSocket;

break;

}

else

{

continue;

}

}

return s;

}





public void EndConnection()

{

try

{

if (sckBnet.Connected == true) sckBnet.Close();

RTB.Notify(MainRTB, true, true, "[BNET] Disconnected!\r\n", Color.Red);

RTB.Notify(MainRTB, true, true, "Shutting down receive loop thread..\r\n", Color.Yellow);

ReceiveLoopThread.Abort();

}

catch (Exception E)

{

RTB.Notify(MainRTB, true, true, E.Message + "\r\n", Color.Red);

}

}



public void BeginConnection()

{

if (strUsername == String.Empty || strPassword == String.Empty || strServer == String.Empty)

{

RTB.Notify(MainRTB, true, true, "[BNET] Fill out your config!\r\n", Color.Red);

return;

}

sckBnet = ConnectSocket(strServer, 6112);

if (sckBnet.Connected == true) /* Incase it locked up */

{

RTB.Notify(MainRTB, true, true, "[BNET] Connected!\r\n", Color.LightGreen);

RTB.Notify(MainRTB, true, true, "[BNET] Sending login string ..\r\n", Color.Khaki);

string AuthString = String.Format("\x03\x04{0}\r\n{1}\r\n", strUsername, strPassword); /* The authorization string to send to BNET

Could also be: 'string AuthString = "\x03\x04" + Username + "\r\n" + Password + "\r\n"; */

try

{

if ((sckBnet.Send(Encoding.ASCII.GetBytes(AuthString)) > 0)) /* Method 'send' returns number of bytes successfully sent! */

{

RTB.Notify(MainRTB, true, true, "[BNET] Login string sent!\r\n", Color.LightGreen);

ReceiveLoopThread = new Thread(new ThreadStart(ReceiveLoop));

ReceiveLoopThread.Priority = ThreadPriority.Normal;

ReceiveLoopThread.Start();

}

else

RTB.Notify(MainRTB, true, true, "[BNET] Error sending login string!\r\n", Color.Red);

}

catch (Exception E)

{

RTB.Notify(MainRTB, true, true, "[BNET] " + E.Message + "\r\n", Color.Red);

}

// RTB.Notify(MainRTB, true, true, "[BNET DEBUG] AuthString: ", Color.Magenta, AuthString + "\r\n", Color.White);

}

}



public void SendData(string Data)

{

Data = Data.Replace("\r", String.Empty);

Data = Data.Replace("\n", String.Empty);

if (sckBnet.Send(Encoding.Unicode.GetBytes(Data + "\r\n")) == 0)

RTB.Notify(MainRTB, true, true, "[BNET] Message refused!\r\n", Color.Red);

else

if (!Data.StartsWith("/")) RTB.Notify(MainRTB, true, true, "<" + strUsername + "> ", Color.Thistle, Data + "\r\n", Color.GhostWhite);

}



private void ReceiveLoop()

{

while (sckBnet.Connected == true)

{

try

{

byte[] RecvBytes = new byte[1024];

if ((sckBnet.Receive(RecvBytes)) > 0) /* Data incoming! */

ParseTelnet(Encoding.ASCII.GetString(RecvBytes));

}

catch (Exception E)

{

RTB.Notify(MainRTB, true, true, "[BNET] " + E.Message + "!\r\n", Color.Red);

}

}

}



private void ParseTelnet(string IncomingInfo)

{

string Username = String.Empty;

string Message = String.Empty;

string Product = String.Empty;

int Flags = 0x00;



string[] IncomingData = IncomingInfo.Split("\r\n".ToCharArray());



for (int I = 0; I < IncomingData.Length; I++)

{

IncomingData[I] = IncomingData[I].ToString();

switch (IncomingData[I].ToString().Split(' ')[0])

{

case "2010": /* BNET Unique Username (2010 NAME [Your Unique Name]) */

strUsername = IncomingData[I].Split(' ')[2];

RTB.Notify(MainRTB, true, true, "[BNET] Logged on as " + strUsername + "\r\n", Color.LightGreen);

MainRTB.Focus();

break;

case "2000": /* NULL (2000 NULL) */

break;

case "1005": /* User talks (1005 TALK [User Talking] FLAGS [Message]) */

Username = IncomingData[I].Split(' ')[2];

Message = IncomingData[I].Split(" ".ToCharArray(), 5)[4].Trim();

Message = Message.Substring(1, Message.LastIndexOf('\"') - 1); /* Remove those damn quotes :| */

RTB.Notify(MainRTB, true, true, "<" + Username + "> ", Color.Green, Message + "\r\n", Color.White);

if (Message.Substring(0, 1).CompareTo(Commands.Trigger.ToString()) == 0 || Message.CompareTo("?trigger") == 0)

{

int TempAccess = 0;

if ((TempAccess = Database.GetAccess(Username)) > 0)

Commands.Commands(Username, Message.Substring(1), TempAccess, this, Database);

}

MainRTB.Focus();

break;

case "1023": /* User emotes (1023 EMOTE [Username] FLAGS [Message]) */

Username = IncomingData[I].Split(' ')[2];

Message = IncomingData[I].Split(" ".ToCharArray(), 5)[4].Trim();

Message = Message.Substring(1, Message.LastIndexOf('\"') - 1); /* Remove those damn quotes :| */

RTB.Notify(MainRTB, true, true, Username + " " + Message + "\r\n", Color.Gray);

MainRTB.Focus();

break;

case "1010": /* You whisper to a user (1010 WHISPER [User you are whispering] [Flags of user you're wihspering] [Message]) */

Username = IncomingData[I].Split(' ')[2];

Message = IncomingData[I].Split(" ".ToCharArray(), 5)[4].Trim();

Message = Message.Substring(1, Message.LastIndexOf('\"') - 1); /* Remove those damn quotes :| */

RTB.Notify(MainRTB, true, true, "<", Color.Blue, "To ", Color.Yellow, Username, Color.YellowGreen, "> ", Color.Blue, Message + "\r\n", Color.Silver);

break;

case "1004": /* User whispers you (1004 WHISPER [User whispering you] [Flags of user whispering you] [Message])*/

Username = IncomingData[I].Split(' ')[2];

Message = IncomingData[I].Split(" ".ToCharArray(), 5)[4].Trim();

Message = Message.Substring(1, Message.LastIndexOf('\"') - 1); /* Remove those damn quotes :| */

RTB.Notify(MainRTB, true, true, "<", Color.Blue, "From ", Color.Yellow, Username, Color.YellowGreen, "> ", Color.Blue, Message + "\r\n", Color.Silver);

MainRTB.Focus();

break;

case "1001": /* User in channel (1001 USER [Username] [Flags] [DWORD Product]) */

try

{

ChannelCount++;

MainLBL.Text = CurrentChannelName + " (" + ChannelCount + ")";

Username = IncomingData[I].Split(' ')[2];

Product = IncomingData[I].Split(' ')[4]; /* Leaves us: [PRODUCT] */

Product = Product.Substring(1, Product.LastIndexOf(']') - 1);

Flags = Convert.ToInt32(IncomingData[I].Split(' ')[3], 16);

LV.AddUser(MainLV, Username, Product, Flags);

break;

}

catch { break; }

case "1002": /* User joined the channel (1002 JOIN [Username] [Flags] [DWORD Product]) */

ChannelCount++;

MainLBL.Text = CurrentChannelName + " (" + ChannelCount + ")";

Username = IncomingData[I].Split(' ')[2];

Product = IncomingData[I].Split(' ')[4]; /* Leaves us: [PRODUCT] */

Product = Product.Substring(1, Product.LastIndexOf(']') - 1);

Flags = Convert.ToInt32(IncomingData[I].Split(' ')[3], 16);

RTB.Notify(MainRTB, true, true, Username + " has joined the channel using " + GetFullClientName(Product) + "\r\n", Color.LightSteelBlue);

LV.AddUser(MainLV, Username, Product, Flags);

break;

case "1003": /* User left the channel (1003 LEAVE [Username] FLAGS) */

ChannelCount--;

MainLBL.Text = CurrentChannelName + " (" + ChannelCount + ")";

Username = IncomingData[I].Split(' ')[2];

RTB.Notify(MainRTB, true, true, Username + " has left the channel.\r\n", Color.LightSteelBlue);

for (int L = 0; L < MainLV.Items.Count; L++)

if (MainLV.Items[L].Text.CompareTo(Username) == 0)

LV.RemoveUser(MainLV, L);

break;

case "1007": /* You joined a channel (1007 CHANNEL [Channel Name]) */

string ChannelName = IncomingData[I].Split(" ".ToCharArray(), 3)[2];

ChannelName = ChannelName.Substring(1, ChannelName.LastIndexOf('\"') - 1);

CurrentChannelName = ChannelName;

ChannelCount = 0;

LV.ClearList(MainLV);

RTB.Notify(MainRTB, true, true, "Joined channel: " + ChannelName + "\r\n", Color.LightGreen);

break;

case "1018": /* Server information */

Message = IncomingData[I].Split(" ".ToCharArray(), 3)[2];

if (Message.LastIndexOf('\"') > 1)

Message = Message.Substring(1, Message.LastIndexOf('\"') - 1);

else

Message = Message.Substring(1);

RTB.Notify(MainRTB, true, true, Message + "\r\n", Color.LightBlue);

break;

case "1019": /* Server error */

Message = IncomingData[I].Split(" ".ToCharArray(), 3)[2];

if (Message.LastIndexOf('\"') > 1)

Message = Message.Substring(1, Message.LastIndexOf('\"') - 1);

else

Message = Message.Substring(1);

RTB.Notify(MainRTB, true, true, Message + "\r\n", Color.OrangeRed);

break;

default:

// RTB.Notify(MainRTB, true, true, IncomingData[I].ToString() + "\r\n", Color.White);

break;

}

}

}



private string GetFullClientName(string DWORDClient)

{

switch (DWORDClient.ToUpper())

{

case "STAR":

return "Starcraft";

case "SEXP":

return "Starcraft: Brood War";

case "SSHR":

return "Starcraft: Shareware";

case "JSTR":

return "Starcraft: Japanese";



case "W2BN":

return "Warcraft II: Battle.net Edition";

case "WAR3":

return "Warcraft III: Reign of Chaos";

case "W3XP":

return "Warcraft III: The Frozen Throne";



case "DSHR":

return "Diablo: Shareware";

case "DRTL":

return "Diablo Retail";

case "D2DV":

return "Diablo II";

case "D2XP":

return "Diablo II: Lord of Destruction";



case "CHAT":

return "a telnet connection";

default:

return "unknown!";

}

}

}



public class RTB

{

/* Contains:

* 1. Notify(); */

public static void Notify(System.Windows.Forms.RichTextBox RTB, bool UseTimestamp, bool UseAMPM, params object[] Content)

{

if ((Content.Length % 2) != 0)

return;

 

if (UseTimestamp == true)

{

RTB.SelectionColor = Color.White;

RTB.AppendText("[" + (UseAMPM ? DateTime.Now.ToString("hh:mm:ss tt") : DateTime.Now.ToString("HH:mm:ss")) + "] " );

}



for (int I = 0; I < Content.Length; I += 2)

{

RTB.SelectionColor = (Color)Content[I + 1];

RTB.AppendText((string)Content[I]);

}



if (RTB.Text.Length >= 12500)

{

RTB.ReadOnly = false;

RTB.SelectionStart = 0;

RTB.SelectionLength = RTB.Text.IndexOf('\n') + 1;

RTB.SelectedText = String.Empty;

RTB.SelectionStart = RTB.Text.Length;

RTB.ReadOnly = true;

}

return;

}

}



public class LV

{

public static void AddUser(System.Windows.Forms.ListView LV, string Username, string Product, int Flags)

{

LV.Items.Add(Username, GetImageNumber(Product, Flags));

}



public static void RemoveUser(System.Windows.Forms.ListView LV, int Index)

{

LV.Items.RemoveAt(Index);

}



public static void ClearList(System.Windows.Forms.ListView LV)

{

LV.Items.Clear();

}



private static int GetImageNumber(string DWORDProduct, int Flags)

{

if ((Flags & 0x01) == 0x01) return 1;

// There is NO way you can get an ops in this, so gfg. -_-

if ((Flags & 0x20) == 0x20) return 2;



switch (DWORDProduct)

{

case "CHAT": return 4;

case "D2DV": return 5;

case "D2XP": return 6;

case "DRTL": return 7;

case "DSHR": return 8;

case "JSTR": return 9;

case "SEXP": return 10;

case "SSHR": return 11;

case "STAR": return 12;

case "W2BN": return 13;

case "W3XP": return 14;

case "WAR3": return 15;

default: return 3; /* Should NEVER occur! Mythix[xL]: unless its teh techbot~ */

}

}

}

}

« Last Edit: August 26, 2005, 10:41:23 pm by Newby »
- Newby
http://www.x86labs.org

Quote
[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

trust

  • Guest
Re: Hitmen Chat (C# .NET)
« Reply #1 on: August 26, 2005, 10:46:15 pm »
I used it. ;D




For like an hour.

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: Hitmen Chat (C# .NET)
« Reply #2 on: August 27, 2005, 05:54:27 am »
Newby, you just screwed over Firefox's parsing engine. =p
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Hitmen Chat (C# .NET)
« Reply #3 on: August 27, 2005, 11:13:18 am »
Nice Newby! :)