当前位置: 首页>>代码示例>>C#>>正文


C# Engine.MessageModel类代码示例

本文整理汇总了C#中Smuxi.Engine.MessageModel的典型用法代码示例。如果您正苦于以下问题:C# MessageModel类的具体用法?C# MessageModel怎么用?C# MessageModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MessageModel类属于Smuxi.Engine命名空间,在下文中一共展示了MessageModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MessageHookEnvironment

        public MessageHookEnvironment(MessageModel msg, string sender, string receiver)
        {
            if (msg == null) {
                throw new ArgumentNullException("msg");
            }
            if (sender == null) {
                throw new ArgumentNullException("sender");
            }
            if (receiver == null) {
                throw new ArgumentNullException("receiver");
            }

            var nick = msg.GetNick();
            var message = msg.ToString();
            if (String.IsNullOrEmpty(nick)) {
                this["MSG"] = message;
            } else {
                this["MSG"] = message.Substring(nick.Length + 3);
            }
            this["MSG_TYPE"] = msg.MessageType.ToString();

            var timestamp = (Int64) (msg .TimeStamp - UnixEpoch).TotalSeconds;
            this["MSG_TIMESTAMP_UNIX"] = timestamp.ToString();
            this["MSG_TIMESTAMP_ISO_UTC"] = msg.TimeStamp.ToString("u").Replace('Z', ' ').TrimEnd();
            this["MSG_TIMESTAMP_ISO_LOCAL"] = msg.TimeStamp.ToLocalTime().ToString("u").Replace('Z', ' ').TrimEnd();

            this["SENDER"] = sender;
            this["RECEIVER"] = receiver;
        }
开发者ID:pacificIT,项目名称:smuxi,代码行数:29,代码来源:MessageHookEnvironment.cs

示例2: ParseSmileys

        public static void ParseSmileys(MessageModel msg)
        {
            string simleyRegex;
            simleyRegex = @":-?(\(|\))";
            Regex reg = new Regex(simleyRegex);
            // clone MessageParts
            IList<MessagePartModel> parts = new List<MessagePartModel>(msg.MessageParts);
            foreach (MessagePartModel part in parts) {
                if (!(part is TextMessagePartModel)) {
                    continue;
                }

                TextMessagePartModel textPart = (TextMessagePartModel) part;
                Match simleyMatch = reg.Match(textPart.Text);
                // OPT: fast regex scan
                if (!simleyMatch.Success) {
                    // no smileys in this MessagePart, nothing to do
                    continue;
                }

                // found smiley(s)
                // remove current MessagePartModel as we need to split it
                int idx = msg.MessageParts.IndexOf(part);
                msg.MessageParts.RemoveAt(idx);

                string[] textPartParts = textPart.Text.Split(new char[] {' '});
                for (int i = 0; i < textPartParts.Length; i++) {
                    string textPartPart = textPartParts[i];
                    simleyMatch = reg.Match(textPartPart);
                    if (simleyMatch.Success) {
                        string filename = null;
                        if (textPartPart == ":-)") {
                            filename = "smile.png";
                        }
                        ImageMessagePartModel imagePart = new ImageMessagePartModel(
                            filename,
                            textPartPart
                        );
                        msg.MessageParts.Insert(idx++, imagePart);
                        msg.MessageParts.Insert(idx++, new TextMessagePartModel(" "));
                    } else {
                        // FIXME: we put each text part into it's own object, instead of combining them (the smart way)
                        TextMessagePartModel notUrlPart = new TextMessagePartModel(textPartPart + " ");
                        // restore formatting / colors from the original text part
                        notUrlPart.IsHighlight     = textPart.IsHighlight;
                        notUrlPart.ForegroundColor = textPart.ForegroundColor;
                        notUrlPart.BackgroundColor = textPart.BackgroundColor;
                        notUrlPart.Bold            = textPart.Bold;
                        notUrlPart.Italic          = textPart.Italic;
                        notUrlPart.Underline       = textPart.Underline;
                        msg.MessageParts.Insert(idx++, notUrlPart);
                    }
                }
            }
        }
开发者ID:tuukka,项目名称:smuxi,代码行数:55,代码来源:MessageParser.cs

示例3: MessageModel

        public MessageModel(MessageModel msg)
            : this()
        {
            if (msg == null) {
                throw new ArgumentNullException("msg");
            }

            var writer = SerializationWriter.GetWriter();
            msg.GetObjectData(writer);
            var data = writer.GetData();
            var reader = SerializationReader.GetReader(data);
            SetObjectData(reader);
        }
开发者ID:grendello,项目名称:smuxi,代码行数:13,代码来源:MessageModel.cs

示例4: AddMessageToChat

        public void AddMessageToChat(ChatModel chat, MessageModel msg)
        {
            Trace.Call(chat, msg);

            ChatView chatView = _ChatViewManager.GetChat(chat);
            #if LOG4NET
            if (chatView == null) {
                _Logger.Fatal(String.Format("AddMessageToChat(): _ChatViewManager.GetChat(chat) chat.Name: {0} returned null!", chat.Name));
                return;
            }
            #endif
            chatView.AddMessage(msg);
        }
开发者ID:tuukka,项目名称:smuxi,代码行数:13,代码来源:StflUI.cs

示例5: ToMarkup

        public void ToMarkup()
        {
            MessageModel testmodel = new MessageModel();
            testmodel.IsCompactable = false;
            TextMessagePartModel textmodel;
            UrlMessagePartModel urlmodel;

            textmodel = new TextMessagePartModel("normal");
            testmodel.MessageParts.Add(textmodel);

            textmodel = new TextMessagePartModel("blue");
            textmodel.ForegroundColor = TextColor.Parse("0000FF");
            testmodel.MessageParts.Add(textmodel);

            textmodel = new TextMessagePartModel("bold");
            textmodel.Bold = true;
            testmodel.MessageParts.Add(textmodel);

            textmodel = new TextMessagePartModel("bold2");
            textmodel.Bold = true;
            testmodel.MessageParts.Add(textmodel);

            textmodel = new TextMessagePartModel("normal");
            testmodel.MessageParts.Add(textmodel);

            textmodel = new TextMessagePartModel("underline");
            textmodel.Underline = true;
            testmodel.MessageParts.Add(textmodel);

            textmodel = new TextMessagePartModel("combined");
            textmodel.Underline = true;
            textmodel.Bold = true;
            textmodel.Italic = true;
            textmodel.ForegroundColor = TextColor.Parse("00FF00");
            textmodel.BackgroundColor = TextColor.Parse("0000FF");
            testmodel.MessageParts.Add(textmodel);

            urlmodel = new UrlMessagePartModel("http://www.smuxi.org");
            testmodel.MessageParts.Add(urlmodel);

            textmodel = new TextMessagePartModel("normal");
            testmodel.MessageParts.Add(textmodel);

            string expected = "normal<span color='#0000FF'>blue</span>" +
                "<b>bold</b><b>bold2</b>normal<u>underline</u>" +
                "<span color='#00FF00'><u><b><i>combined</i></b></u></span>" +
                "<span color='#00008B'><u>http://www.smuxi.org</u></span>normal";
            string tested = PangoTools.ToMarkup(testmodel);

            Assert.AreEqual(expected, tested);
        }
开发者ID:pacificIT,项目名称:smuxi,代码行数:51,代码来源:PangoToolsTests.cs

示例6: AddMessage

        public override void AddMessage(MessageModel msg)
        {
            base.AddMessage(msg);

            var nick = msg.GetNick();
            if (nick == null) {
                return;
            }

            // update who spoke last
            for (int i = 0; i < Participants.Count; ++i) {
                var speaker = Participants[i];
                if (speaker.IdentityName == nick) {
                    Participants.RemoveAt(i);
                    Participants.Insert(0, speaker);
                    break;
                }
            }
        }
开发者ID:pacificIT,项目名称:smuxi,代码行数:19,代码来源:GroupChatView.cs

示例7: AddMessageToChat

        public void AddMessageToChat(ChatModel chat, MessageModel msg)
        {
            Trace.Call(chat, msg);

            try {
                ChatView chatView = _ChatViewManager.GetChat(chat);
                if (chatView == null) {
            #if LOG4NET
                    _Logger.Fatal(String.Format("AddMessageToChat(): _ChatViewManager.GetChat(chat) chat.Name: {0} returned null!", chat.Name));
            #endif
                    return;
                }

                // FIXME: this must be marshalled into the UI thread!
                chatView.AddMessage(msg);
                _ChatViewManager.UpdateNavigation();
            } catch (Exception ex) {
            #if LOG4NET
                _Logger.Fatal(ex);
            #endif
            }
        }
开发者ID:pacificIT,项目名称:smuxi,代码行数:22,代码来源:StflUI.cs

示例8: AddMessageToChat

        public void AddMessageToChat(ChatModel page, MessageModel msg)
        {
            Trace.Call(page, msg);

            string finalMsg = String.Empty;
            foreach (MessagePartModel msgPart in msg.MessageParts) {
                // TODO: implement other types
                if (msgPart is TextMessagePartModel) {
                    TextMessagePartModel fmsgti = (TextMessagePartModel) msgPart;
                    finalMsg += fmsgti.Text;
                }
            }

            string timestamp;
            try {
                timestamp = msg.TimeStamp.ToLocalTime().ToString((string)Frontend.UserConfig["Interface/Notebook/TimestampFormat"]);
            } catch (FormatException e) {
                timestamp = "Timestamp Format ERROR: " + e.Message;
            }
            finalMsg = timestamp + " " + page.Name + " " + finalMsg;

            Console.WriteLine(finalMsg);
        }
开发者ID:RoninBG,项目名称:smuxi,代码行数:23,代码来源:TestUI.cs

示例9: InsertTimeStamp

        protected override void InsertTimeStamp(Gtk.TextBuffer buffer, ref Gtk.TextIter iter,
                                                string timestamp, MessageModel msg)
        {
            if (String.IsNullOrWhiteSpace(msg.ID)) {
                buffer.Insert(ref iter, timestamp);
            } else {
                var uri = new Uri(String.Format("https://twitter.com/{0}/status/{1}", msg.GetNick(), msg.ID));

                var tags = new List<Gtk.TextTag>();
                // link URI tag
                var linkTag = new LinkTag(uri);
                linkTag.TextEvent += OnLinkTagTextEvent;
                _MessageTextTagTable.Add(linkTag);
                tags.Add(linkTag);

                // link style tag
                tags.Add(LinkTag);

                buffer.InsertWithTags(ref iter, timestamp, tags.ToArray());
            }

            buffer.Insert(ref iter, " ");
        }
开发者ID:meebey,项目名称:smuxi,代码行数:23,代码来源:TwitterMessageTextView.cs

示例10: Insert

 public override void Insert(int index, MessageModel item)
 {
     throw new NotSupportedException();
 }
开发者ID:grendello,项目名称:smuxi,代码行数:4,代码来源:Db4oMessageBuffer.cs

示例11: CopyTo

        public override void CopyTo(MessageModel[] array, int arrayIndex)
        {
            if (array == null) {
                throw new ArgumentNullException("array");
            }

            int i = arrayIndex;
            foreach (var msg in this) {
                array[i++] = msg;
            }
        }
开发者ID:grendello,项目名称:smuxi,代码行数:11,代码来源:Db4oMessageBuffer.cs

示例12: IndexOf

        public override int IndexOf(MessageModel item)
        {
            if (item == null) {
                throw new ArgumentNullException("item");
            }

            var res = Database.QueryByExample(item);
            // return -1 if not found
            if (res.Count == 0) {
                return -1;
            }
            var dbMsg = (MessageModel) res[0];
            var dbId = Database.Ext().GetID(dbMsg);
            return Index.IndexOf(dbId);
        }
开发者ID:grendello,项目名称:smuxi,代码行数:15,代码来源:Db4oMessageBuffer.cs

示例13: Add

        public override void Add(MessageModel item)
        {
            if (item == null) {
                throw new ArgumentNullException("item");
            }

            // make sure the index is initialized at this point else we will
            // load the 1st added item of db4o and end up with a duplicate here
            InitIndex();

            if (MaxCapacity > 0 && Index.Count >= MaxCapacity) {
                RemoveAt(0);
            }

            // TODO: auto-flush every 60 seconds
            var dbMsg = new MessageModel(item);
            Database.Store(dbMsg);
            Database.Deactivate(dbMsg, 5);
            var dbId = Database.Ext().GetID(dbMsg);
            Index.Add(dbId);
            FlushCounter++;
            if (FlushCounter >= FlushInterval) {
                Flush();
            }
        }
开发者ID:grendello,项目名称:smuxi,代码行数:25,代码来源:Db4oMessageBuffer.cs

示例14: Contains

        public override bool Contains(MessageModel item)
        {
            if (item == null) {
                throw new ArgumentNullException("item");
            }

            // TODO: benchmark me!
            //return Database.Query<MessageModel>().Contains(item);
            return IndexOf(item) != -1;
        }
开发者ID:grendello,项目名称:smuxi,代码行数:10,代码来源:Db4oMessageBuffer.cs

示例15: AddMessage

 public virtual void AddMessage(MessageModel msg)
 {
     switch (msg.MessageType) {
         case MessageType.ChatNameChanged:
             ThreadPool.QueueUserWorkItem(delegate {
                 try {
                     // REMOTING CALL
                     var newname = ChatModel.Name;
                     Gtk.Application.Invoke(delegate {
                         Name = newname;
                     });
                 } catch (Exception ex) {
                     Frontend.ShowException(ex);
                 }
             });
             return;
     }
     _OutputMessageTextView.AddMessage(msg);
 }
开发者ID:Jaykul,项目名称:smuxi,代码行数:19,代码来源:ChatView.cs


注:本文中的Smuxi.Engine.MessageModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。