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


C# Run.SetResourceReference方法代码示例

本文整理汇总了C#中System.Windows.Documents.Run.SetResourceReference方法的典型用法代码示例。如果您正苦于以下问题:C# Run.SetResourceReference方法的具体用法?C# Run.SetResourceReference怎么用?C# Run.SetResourceReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Documents.Run的用法示例。


在下文中一共展示了Run.SetResourceReference方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Decorate

        /// <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;
        }
开发者ID:eNoise,项目名称:cyclops-chat,代码行数:12,代码来源:TimestampDecorator.cs

示例2: Decorate

        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;
        }
开发者ID:eNoise,项目名称:cyclops-chat,代码行数:12,代码来源:CommonMessageDecorator.cs

示例3: Decorate

        /// <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;
        }
开发者ID:eNoise,项目名称:cyclops-chat,代码行数:19,代码来源:NickDecorator.cs

示例4: Render

        /// <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;
        }
开发者ID:Mofsy,项目名称:jinxbot,代码行数:57,代码来源:ChatNodeRenderer.cs

示例5: InsertWriter

        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(":"));
        }
开发者ID:heartszhang,项目名称:WeiZhi3,代码行数:11,代码来源:TextRender.cs


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