Ejemplo n.º 1
0
        /// <summary>
        /// Transform collection of inlines
        /// </summary>
        public List<Inline> Decorate(IConferenceMessage msg, List<Inline> inlines)
        {
            const string pattern = @"((https?|ftp|dchub|magnet|mailto|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)";

            for (int i = 0; i < inlines.Count; i++)
            {
                // splite one Inline element (text (Run)) into several inlines (Runs and Hyperlinks)
                var inline = inlines[i] as Run;
                if (inline == null)
                    continue;

                var matches = Regex.Matches(inline.Text, pattern).OfType<Match>().Select(item => item.Value).ToArray();
                if (matches.Length < 1)
                    continue;

                inlines.RemoveAt(i);

                var parts = inline.Text.SplitAndIncludeDelimiters(matches).ToArray();
                for (int j = i; j < parts.Length + i; j++)
                {
                    var part = parts[j];
                    if (matches.Contains(part))
                        inlines.Insert(j, DecorateAsHyperlink(part));
                    else
                        inlines.Insert(j, CommonMessageDecorator.Decorate(msg, part));
                }
            }
            return inlines;
        }
Ejemplo n.º 2
0
 public void SendConferenceMessage(IConferenceMessage message)
 {
     using (var ctx = new DataContext())
     {
         ctx.Conferences.Single(x=>x.Id == message.ConferenceId).Messages.Add(new ConferenceMessage(message));
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Transform collection of inlines
        /// </summary>
        public List<Inline> Decorate(IConferenceMessage msg, List<Inline> inlines)
        {
            string style = "timestampStyle";
            var timestampInline = new Run(msg.Timestamp.ToString("[hh:mm:ss] "));
            timestampInline.SetResourceReference(FrameworkContentElement.StyleProperty, style);

            inlines.Insert(0, timestampInline);
            return inlines;
        }
Ejemplo n.º 4
0
        public static Inline Decorate(IConferenceMessage msg, string message)
        {
            string style = "commonMessageStyle";
            if (msg is SystemConferenceMessage)
                style = "systemMessageStyle";
            if (msg is SystemConferenceMessage && ((SystemConferenceMessage)msg).IsErrorMessage)
                style = "errorMessageStyle";

            Run messageInline = new Run(message);
            messageInline.SetResourceReference(FrameworkContentElement.StyleProperty, style);
            return messageInline;
        }
Ejemplo n.º 5
0
        public static Paragraph Present(IConferenceMessage message)
        {
            Paragraph paragraph = new Paragraph();
            paragraph.SetResourceReference(Paragraph.StyleProperty, "parentRowStyle");

            // at first, textInlines will contains only one inline - raw text
            List<Inline> textInlines = new List<Inline>();

            // applying custom decorators
            DecoratorsRegistry.GetDecorators().ForEach(i => textInlines = i.Decorate(message, textInlines));

            paragraph.Inlines.AddRange(textInlines);

            return paragraph;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Transform collection of inlines
        /// </summary>
        public List<Inline> Decorate(IConferenceMessage msg, List<Inline> inlines)
        {
            string style = "nickStyle";
            string nick = msg.Author;
            if (string.IsNullOrEmpty(msg.Author))
            {
                style = "systemNickStyle";
                nick = "System";
            }

            Run nickInline = new Run(string.Format("{0}: ", nick));
            nickInline.SetResourceReference(FrameworkContentElement.StyleProperty, style);

            inlines.Insert(0, nickInline);
            return inlines;
        }
Ejemplo n.º 7
0
 public ConferenceMessage(IConferenceMessage source)
     : base(source)
 {
     ConferenceId = source.ConferenceId;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Transform collection of inlines
 /// </summary>
 public List<Inline> Decorate(IConferenceMessage msg, List<Inline> inlines)
 {
     //TODO:
     return inlines;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Transform collection of inlines
 /// </summary>
 public List<Inline> Decorate(IConferenceMessage msg, List<Inline> inlines)
 {
     inlines.Add(Decorate(msg, msg.Text));
     return inlines;
 }
Ejemplo n.º 10
0
 public MessageViewModel(IConferenceMessage msg)
 {
     RawMessage = msg;
     Paragraph = MessagePresenter.Present(msg);
 }