本文整理匯總了C#中ChatSourceType.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# ChatSourceType.ToString方法的具體用法?C# ChatSourceType.ToString怎麽用?C# ChatSourceType.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ChatSourceType
的用法示例。
在下文中一共展示了ChatSourceType.ToString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Add
public void Add(string _message, ChatAudibleLevel _audible, ChatType _type, ChatSourceType _sourcetype, string _fromName, UUID _id, UUID _ownerid, Vector3 _position)
{
Reference.Log.Debug(_message + " ChatAudibleLevel:" + _audible.ToString() + " ChatType:" + _type.ToString() + " ChatSourceType:" + _sourcetype.ToString() + " FromName:" + _fromName);
// name.
string fromName = _fromName + ":";
lock (messageHistory)
{
messageHistory.Add(fromName);
Reference.Viewer.GuiManager.ChatAddMessage(fromName);
}
// message.
string msg = _message;
if (_message.Length > maxMessageLength)
{
string tail = "・・・";
msg = _message.Substring(0, maxMessageLength - tail.Length);
msg += tail;
}
// wide-char space -> 2 char space.
msg = msg.Replace(" ", " ");
// trim space.
msg = msg.Trim();
List<int> colLen = new List<int>();
int colMaxLen = 16 * 2;
int lenCounter = 0;
for (int i = 0; i < msg.Length; i++)
{
char c = msg[i];
if (c < '!' || '~' < c)
{
lenCounter += 2;
}
else
{
lenCounter += 1;
}
if ((lenCounter >= colMaxLen) || ((i + 1) == msg.Length))
{
colLen.Add(i + 1);
lenCounter = 0;
}
}
List<string> msgList = new List<string>();
for (int i = 0; i < colLen.Count; i++)
{
int start = (i > 0 ? colLen[i - 1] : 0);
int length = (i > 0 ? colLen[i] - colLen[i - 1] : colLen[i]);
string text = msg.Substring(start, length);
msgList.Add(text);
}
for (int i = 0; i < msgList.Count; i++)
{
// message.
string addMessage = " " + msgList[i];
lock (messageHistory)
{
messageHistory.Add(addMessage);
Reference.Viewer.GuiManager.ChatAddMessage(addMessage);
}
}
Reference.Viewer.Adapter.CallReceiveMessaged(_id.ToString(), _fromName, _message);
}
示例2: Self_OnChat
void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, UUID id, UUID ownerid, Vector3 position)
{
if (type == ChatType.StartTyping || type == ChatType.StopTyping || audible != ChatAudibleLevel.Fully) return;
if (!Session.Settings.DisplayChat) return;
char[] splitChar = { ' ' };
string[] msg = message.Split(splitChar);
bool action;
if (msg[0].ToLower() == "/me")
{
action = true;
message = String.Join(" ", msg, 1, msg.Length - 1);
}
else action = false;
Display.Chat(Session.SessionNumber, fromName, message, action, type, sourceType);
if (id == Session.Client.Self.AgentID) return;
Dictionary<string, string> identifiers = new Dictionary<string, string>();
identifiers.Add("$name", fromName);
identifiers.Add("$message", message);
identifiers.Add("$id", id.ToString());
identifiers.Add("$ownerid", ownerid.ToString());
identifiers.Add("$ctype", type.ToString());
identifiers.Add("$stype", sourceType.ToString());
identifiers.Add("$pos", position.ToString());
for (int i = 0; i < msg.Length; i++)
identifiers.Add("$" + (i + 1), msg[i]);
ScriptSystem.TriggerEvents(Session.SessionNumber, ScriptSystem.EventTypes.Chat, identifiers);
}