コード例 #1
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;
        }
コード例 #2
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;
        }
コード例 #3
0
ファイル: NickDecorator.cs プロジェクト: eNoise/cyclops-chat
        /// <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;
        }
コード例 #4
0
ファイル: ChatNodeRenderer.cs プロジェクト: Mofsy/jinxbot
        /// <summary>
        /// Renders the specified chat node to the client.
        /// </summary>
        /// <param name="node">The node to append.</param>
        /// <remarks>
        /// <para>The return value of this function is a reference to the outermost <see cref="Inline">Inline</see> constructed
        /// by this function.  It may create additional inner elements as needed.</para>
        /// </remarks>
        /// <returns>
        /// Returns an object instance of <see cref="Inline">Inline</see> that can be appended to the HTML document.
        /// </returns>
        public virtual Inline Render(ChatNode node)
        {
            Inline result;

            if (node == ChatNode.NewLine)
            {
                result = new LineBreak();
            } 
            else if (node.LinkUri == null)
            {
                Run run = new Run();
                if (node.CssClass != null)
                {
                    run.Style = ResourceProvider[node.CssClass] as Style;
                    run.SetResourceReference(FrameworkContentElement.StyleProperty, node.CssClass);
                }
                else if (node.Color != GdiColor.Empty)
                {
                    run.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, node.Color.R, node.Color.G, node.Color.B));
                }
                run.Text = node.Text;

                result = run;
            }
            else // need to make a link.
            {
                Hyperlink link = new Hyperlink();
                link.Inlines.Add(new Run(node.Text));
                link.NavigateUri = node.LinkUri;

                if (node.CssClass != null)
                {
                    link.SetResourceReference(FrameworkContentElement.StyleProperty, node.CssClass);
                }
                else if (node.Color != GdiColor.Empty)
                {
                    link.Foreground = new SolidColorBrush(WpfColor.FromArgb(255, node.Color.R, node.Color.G, node.Color.B));
                }

                link.ToolTip = string.Format(CultureInfo.CurrentUICulture, "Link to {0}", node.LinkUri.ToString());

                result = link;
            }

            return result;
        }
コード例 #5
0
ファイル: TextRender.cs プロジェクト: heartszhang/WeiZhi3
        private static void InsertWriter(ICollection<Inline> textblock, Token t)
        {
            var name = t.text;
            if (string.IsNullOrEmpty(name))
                return;
            var run = new Run(t.text);
            run.SetResourceReference(Control.ForegroundProperty, "MetroColorFeatureBrush");

            textblock.Add(run);
            textblock.Add(new Run(":"));
        }