⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wincom.cs

📁 一个即时通信 Messenger C#代码
💻 CS
字号:
/*

<Aicaca Community Messenger Client>

Copyright (c) Aicaca.com, All rights reserved.

Writer                : Byung-ku, Cho (Aicaca)
E-mail                : aicaca@hanmail.net
Personal Homepage URL : http://www.aicaca.com
Last Updated Date     : Feb. 27th, 2002

Programming Language  : C#
Editor & Compiler     : VisualStudio.NET

*/


using System;

namespace TalkClient
{
	public class WinCom
	{
        public string varStr1 = "C:\\Program Files\\Aicaca\\AicacaClient1.2\\";

        public string lineStr1 = "Can't connect to the other side.";
		public string lineStr2 = "Client is running...";
		public string lineStr3 = "Client is stopped...";
		public string lineStr4 = "Can't connect to the server.";
		public string lineStr5 = "Disconnected to the server.";
		public string lineStr6 = "Password is incorrect.";
		public string lineStr7 = "Please input the password.";
		public string lineStr8 = "One of the fields' value is empty.";
        public string lineStr9 = "Please input all the required data.";
		public string lineStr10 = "Other side has closed the connection.";
		public string lineStr11 = "Can't send this file.";
		public string lineStr12 = "File accepted.";
		public string lineStr13 = "File rejected.";
		public string lineStr14 = "File canceled.";
		public string lineStr15 = "File size is limited to 3MB.";
        public string lineStr16 = "Please select a keyword type.";
		public string lineStr17 = "Please input a keyword.";
		public string lineStr18 = "Can't upload this file.";
		public string lineStr19 = "Upload file size is limited to 3MB.";
		public string lineStr20 = "Please update your client program to ";

		public string RemoveStr(string originStr, string removeStr)
		{
			string rv = "";

			try
			{
				int firstPos = originStr.IndexOf(removeStr);
				int originLen = originStr.Length;
				int removeLen = removeStr.Length;

				if (firstPos >= 0)
				{
					rv = originStr.Substring(0, firstPos) + originStr.Substring(firstPos+removeLen, originLen-firstPos-removeLen);
				}
			}
			catch (Exception e)
			{
				rv = "Error : Aicaca.Com.String.RemoveStr";
			}

			return rv;
		}

		public string ReplaceStr(string originStr, string feedStr, string returnStr)
		{
			string rv = originStr;
			int firstPos = -1;
			int feedLength = feedStr.Length;

			try
			{
				while ((firstPos=rv.IndexOf(feedStr, firstPos+1)) != -1)
				{
					rv = rv.Substring(0, firstPos) + returnStr + rv.Substring(firstPos+feedLength);
				}
			}
			catch (Exception e)
			{
				rv = "Error : Aicaca.Com.String.ReplaceStr";
			}

			return rv;
		}

		public string MakeXML(string tagStr, string valueStr)
		{
			string rv = "";

			rv = "<" + tagStr + ">" + valueStr + "</" + tagStr + ">";

			return rv;
		}

		public string GetXML(string originStr, string tagStr)
		{
			string rv = "";

			try
			{
				int firstPos = originStr.IndexOf("<" + tagStr + ">");
				int secondPos = originStr.IndexOf("</" + tagStr + ">");
				int tagLen = tagStr.Length;

				if (firstPos != -1 && secondPos != -1)
				{
					rv = originStr.Substring(firstPos+tagLen+2, secondPos-firstPos-tagLen-2);
				}
			}

			catch (Exception e)
			{
				rv = "Error : Aicaca.Com.XML.GetXML";
			}

			return rv;
		}

		public string GetXML(string originStr, string tagStr, int pos)
		{
			string rv = "";

			try
			{
				int firstPos = originStr.IndexOf("<" + tagStr + ">", pos);
				int secondPos = originStr.IndexOf("</" + tagStr + ">", pos);
				int tagLen = tagStr.Length;

				if (firstPos != -1 && secondPos != -1)
				{
					rv = originStr.Substring(firstPos+tagLen+2, secondPos-firstPos-tagLen-2);
				}
			}

			catch (Exception e)
			{
				rv = "Error : Aicaca.Com.XML.GetXML";
			}

			return rv;
		}

		public string GetNextXML(string originStr, string tagStr)
		{
			string rv = "";

			try
			{
				int firstPos = originStr.IndexOf("<" + tagStr + ">");
				int originLen = originStr.Length;
				int tagLen = tagStr.Length;

				if (firstPos != -1)
				{
					rv = originStr.Substring(firstPos+tagLen+2, originLen-firstPos-tagLen-2);
				}
			}

			catch (Exception e)
			{
				rv = "Error : Aicaca.Com.XML.GetNextXML";
			}

			return rv;
		}

		public string MakeRootID(string rootSort, string rootName, string rootIP, string rootPort)
		{
			string rv = "";

			rv = "<rid>" + this.MakeXML("rs", rootSort) + this.MakeXML("rn", rootName) + this.MakeXML("ri", rootIP) + this.MakeXML("rp", rootPort) + "</rid>";

			return rv;
		}

		public string MakeLocalID(string localSort, string localName, string localIP, string localPort)
		{
			string rv = "";

			rv = "<lid>" + this.MakeXML("ls", localSort) + this.MakeXML("ln", localName) + this.MakeXML("li", localIP) + this.MakeXML("lp", localPort) + "</lid>";

			return rv;
		}

		public string MakeClientID(string clientSort, string clientName, string clientIP, string clientPort)
		{
			string rv = "";

			rv = "<cid>" + this.MakeXML("cs", clientSort) + this.MakeXML("cn", clientName) + this.MakeXML("ci", clientIP) + this.MakeXML("cp", clientPort) + "</cid>";

			return rv;
		}

		public string MakeThreadID(string threadSort, string threadName, string threadIP, string threadPort)
		{
			string rv = "";

			rv = "<tid>" + this.MakeXML("ts", threadSort) + this.MakeXML("tn", threadName) + this.MakeXML("ti", threadIP) + this.MakeXML("tp", threadPort) + "</tid>";

			return rv;
		}

		public string MakeRemoteID(string remoteSort, string remoteName, string remoteIP, string remotePort)
		{
			string rv = "";

			rv = "<eid>" + this.MakeXML("es", remoteSort) + this.MakeXML("en", remoteName) + this.MakeXML("ei", remoteIP) + this.MakeXML("ep", remotePort) + "</eid>";

			return rv;
		}

		public string LocalToClient(string localID)
		{
			string rv = "";

			string clientSort = this.GetXML(localID, "ls");
			string clientName = this.GetXML(localID, "ln");
			string clientIP = this.GetXML(localID, "li");
			string clientPort = this.GetXML(localID, "lp");

			rv = this.MakeClientID(clientSort, clientName, clientIP, clientPort);

			return rv;
		}

		public string ClientToLocal(string clientID)
		{
			string rv = "";

			string localSort = this.GetXML(clientID, "cs");
			string localName = this.GetXML(clientID, "cn");
			string localIP = this.GetXML(clientID, "ci");
			string localPort = this.GetXML(clientID, "cp");

			rv = this.MakeLocalID(localSort, localName, localIP, localPort);

			return rv;
		}

		public string ThreadToRemote(string threadID)
		{
			string rv = "";

			string remoteSort = this.GetXML(threadID, "ts");
			string remoteName = this.GetXML(threadID, "tn");
			string remoteIP = this.GetXML(threadID, "ti");
			string remotePort = this.GetXML(threadID, "tp");

			rv = this.MakeRemoteID(remoteSort, remoteName, remoteIP, remotePort);

			return rv;
		}

		public string RemoteToThread(string remoteID)
		{
			string rv = "";

			string threadSort = this.GetXML(remoteID, "es");
			string threadName = this.GetXML(remoteID, "en");
			string threadIP = this.GetXML(remoteID, "ei");
			string threadPort = this.GetXML(remoteID, "ep");

			rv = this.MakeThreadID(threadSort, threadName, threadIP, threadPort);

			return rv;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -