本文整理汇总了C#中System.Windows.Documents.Span类的典型用法代码示例。如果您正苦于以下问题:C# Span类的具体用法?C# Span怎么用?C# Span使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Span类属于System.Windows.Documents命名空间,在下文中一共展示了Span类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MakeFlowDocument
public static FlowDocument MakeFlowDocument(string eugenstr, System.Windows.Media.Brush specialColor)
{
FlowDocument document = new FlowDocument();
int i = 0;
string[] parts = eugenstr.Split(GREEN_TAG, StringSplitOptions.None);
if (parts.Length > 1)
{
Paragraph paragraph = new Paragraph();
while (i < parts.Length)
{
if (i % 2 == 0)
{
Span normalspan = new Span(new Run(parts[i].Replace("#styleGreen", string.Empty)));
paragraph.Inlines.Add(normalspan);
}
else
{
Span coloredSpan = new Span(new Run(parts[i]));
coloredSpan.Foreground = specialColor;
paragraph.Inlines.Add(coloredSpan);
}
i++;
}
document.Blocks.Add(paragraph);
}
else { Paragraph paragraph = new Paragraph(new Run(eugenstr)); document.Blocks.Add(paragraph); }
return document;
}
开发者ID:KennyJLam,项目名称:AoA,代码行数:28,代码来源:EugenStringConverter.cs
示例2: Convert
public object Convert(object[] value, Type targetType, object parameter, CultureInfo cultureInfo)
{
var text = value[0] as string;
var hdata = value[1] as List<int>;
var textBlock = new Span();
if (hdata == null || !hdata.Any())
{
// no highlight data, just return the text
return new Run(text);
}
for (var i = 0; i < text.Length; i++)
{
var ch = text.Substring(i, 1);
// should this character be highlighted?
if (hdata.Contains(i))
{
textBlock.Inlines.Add(new Bold(new Run(ch)));
}
else
{
textBlock.Inlines.Add(new Run(ch));
}
}
return textBlock;
}
开发者ID:JohnTheGr8,项目名称:Wox,代码行数:28,代码来源:HighlightTextConverter.cs
示例3: BuildFont
private static Inline BuildFont(ElementToken token, Hint hint)
{
var span = new Span();
string size;
if (token.Attributes.TryGetValue("size", out size))
{
var fc = new FontSizeConverter();
var sz = (double)fc.ConvertFromString(size);
span.FontSize = sz;
}
string face;
if (token.Attributes.TryGetValue("face", out face))
{
span.FontFamily = new FontFamily(face);
}
string color;
if (token.Attributes.TryGetValue("color", out color))
{
var bc = new BrushConverter();
var br = (Brush)bc.ConvertFromString(color);
span.Foreground = br;
}
return span.Fill(token, hint);
}
开发者ID:vestild,项目名称:nemerle,代码行数:27,代码来源:HintBuilder.cs
示例4: GetTextSpan
private static Span GetTextSpan(HelpOmniboxResult helpResult)
{
var span = new Span();
for (int i = 0; i < helpResult.Text.Length; )
{
var start = helpResult.Text.IndexOf('(', i);
if (start == -1)
{
span.Inlines.Add(helpResult.Text.Substring(i));
break;
}
span.Inlines.Add(helpResult.Text.Substring(i, start - i));
start++;
var end = helpResult.Text.IndexOf(')', start);
if (end == -1)
{
span.Inlines.Add(helpResult.Text.Substring(start));
break;
}
span.Inlines.Add(new Bold(new Run(helpResult.Text.Substring(start, end - start ))));
i = end + 1;
}
return span;
}
开发者ID:mapacheL,项目名称:extensions,代码行数:29,代码来源:OmniboxTemplate.xaml.cs
示例5: AddMsg
public void AddMsg(string message, bool isRecieved)
{
if (currentSize >= logSize)
{
log.Inlines.Remove(log.Inlines.FirstInline); //удалили время
log.Inlines.Remove(log.Inlines.FirstInline); //удалили текст
currentSize--;
}
string time = "[" + System.DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss") + "] ";
Span DateSpan = new Span();
DateSpan.Inlines.Add(time);
DateSpan.Foreground = Brushes.DarkGreen;
DateSpan.FontWeight = FontWeights.Bold;
log.Inlines.Add(DateSpan);
Span Msg = new Span();
Msg.Inlines.Add(message);
if (isRecieved)
Msg.Foreground = Brushes.OrangeRed;
else
Msg.Foreground = Brushes.DodgerBlue;
log.Inlines.Add(Msg);
scrollViewer.UpdateLayout();
scrollViewer.ScrollToEnd();
currentSize++;
}
开发者ID:Retivykh-Serg,项目名称:Dixit,代码行数:27,代码来源:messageViewer.xaml.cs
示例6: WarningView
public WarningView()
{
this.InitializeComponent();
// Init
var warningService = Singleton<ServiceController>.Instance.Get<IWarningService>();
var lightGrayBrush = new SolidColorBrush(Colors.DarkGray);
foreach (var warning in warningService.GetWarnings().OrderByDescending(w => w.Issued))
{
var inline = new Span();
inline.Inlines.Add(new Bold(new Run(warning.Title)));
inline.Inlines.Add(new LineBreak());
inline.Inlines.Add(new Run(warning.Message));
inline.Inlines.Add(new LineBreak());
inline.Inlines.Add(new Run(warning.Issued.ToShortDateString()) {Foreground = lightGrayBrush});
if (warning.Read)
{
foreach (var i in inline.Inlines)
{
i.Foreground = lightGrayBrush;
}
}
this.StackPanel.Children.Add(new TextBlock(inline) {Margin = new Thickness(5), LineHeight = 20});
}
warningService.SetAllWarningsRead();
}
开发者ID:TheRealVira,项目名称:Scrooge,代码行数:28,代码来源:WarningView.xaml.cs
示例7: DisplayFormula
public Inline DisplayFormula()
{
string Pi = Char.ToString((char)0x03C0);
Span form = new Span();
form.Inlines.Add(Utilities.Num1(Parm[0], CParm[0])); //Coef
form.Inlines.Add(new Italic(new Run("sin")));
form.Inlines.Add("(2" + Pi + "(");
form.Inlines.Add(Utilities.Num1(Parm[1], CParm[1])); //FreqC
form.Inlines.Add(new Italic(new Run("t")));
if (Parm[5] != 0D)
{
if (Parm[5] < 0D) form.Inlines.Add("(1 - ");
else form.Inlines.Add("(1 + ");
form.Inlines.Add(Utilities.Num1(Math.Abs(Parm[5] / 100D), CParm[5])); //Mod
form.Inlines.Add(new Italic(new Run("sin")));
form.Inlines.Add("(2" + Pi + "(");
form.Inlines.Add(Utilities.Num1(Parm[3], CParm[3])); //FreqM
form.Inlines.Add(new Italic(new Run("t")));
form.Inlines.Add(Utilities.Num0(Parm[4] / 360D, CParm[4])); //PhaseM
form.Inlines.Add(")))");
}
form.Inlines.Add(Utilities.Num0(Parm[2] / 360D, CParm[2])); //PhaseC
form.Inlines.Add("))");
return form;
}
开发者ID:DOPS-CCI,项目名称:CCI_project,代码行数:25,代码来源:FMTab.xaml.cs
示例8: CreateSubject
private Inline CreateSubject(IMessage message)
{
var subj = message.XmppMessage.Subject;
var span = new Span();
span.Inlines.Add(subj);
return new Italic(new Bold(span));
}
开发者ID:Irdis,项目名称:VSTalk,代码行数:7,代码来源:SubjectBlockBuilder.cs
示例9: AppendRange
public static Inline AppendRange(this Inline inline, IEnumerable<Inline> inlines)
{
var span = new Span(inline);
span.Inlines.AddRange(inlines);
return span;
}
开发者ID:WildGums,项目名称:Orc.NuGetExplorer,代码行数:8,代码来源:InlineExtensions.cs
示例10: Append
public static Inline Append(this Inline inline, Inline inlineToAdd)
{
var span = new Span(inline);
span.Inlines.Add(inlineToAdd);
return span;
}
开发者ID:WildGums,项目名称:Orc.NuGetExplorer,代码行数:8,代码来源:InlineExtensions.cs
示例11: DisplayFormula
public Inline DisplayFormula()
{
Span form = new Span();
form.Inlines.Add(Coef.ToString("G6"));
Span sub = new Span(new Run(Utilities.ConvertFromVType(CCoef)));
sub.Typography.Variants = System.Windows.FontVariants.Subscript;
form.Inlines.Add(sub);
return form;
}
开发者ID:DOPS-CCI,项目名称:CCI_project,代码行数:9,代码来源:NoiseTab.xaml.cs
示例12: CreateStatus
private Inline CreateStatus(IMessage message)
{
var from = message.XmppMessage.From;
var name = GetName(from);
var chatstate = message.XmppMessage.Chatstate.ToString();
var span = new Span();
span.Inlines.Add(string.Format("{0} is {1}...", name, chatstate));
return new Italic(span);
}
开发者ID:Irdis,项目名称:VSTalk,代码行数:9,代码来源:StatusBlockBuilder.cs
示例13: PasteContentData
internal static bool PasteContentData(InputBox inputBox, IDataObject iDataObject)
{
TextData data = TryGetText(iDataObject);
if (!data.ContainsData)
{
if (iDataObject.GetDataPresent(DataFormats.Bitmap, true))
{
inputBox.Paste(iDataObject);
return true;
}
return false;
}
inputBox.TempFlowDocument.Blocks.Clear();
TextRange range = null;
if (data.Format == BamaDataFormat)
{
object obj2 = XamlReader.Parse(data.Data);
if (obj2 is Block)
{
inputBox.TempFlowDocument.Blocks.Add(obj2 as Block);
}
else if (obj2 is Inline)
{
Span span = new Span(inputBox.TempFlowDocument.ContentStart, inputBox.TempFlowDocument.ContentEnd)
{
Inlines = { obj2 as Span }
};
}
range = new TextRange(inputBox.TempFlowDocument.ContentStart, inputBox.TempFlowDocument.ContentEnd);
range.ClearAllProperties();
inputBox.Selection.Text = "";
Span newspan = new Span(inputBox.Selection.Start, inputBox.Selection.End);
ReplaceControls.AddBlocksToSpan(inputBox.TempFlowDocument, newspan);
inputBox.CaretPosition = newspan.ElementEnd.GetInsertionPosition(LogicalDirection.Forward);
}
else
{
range = new TextRange(inputBox.TempFlowDocument.ContentStart, inputBox.TempFlowDocument.ContentEnd);
using (MemoryStream stream = new MemoryStream())
{
using (StreamWriter writer = new StreamWriter(stream))
{
writer.Write(data.Data);
writer.Flush();
stream.Position = 0L;
range.Load(stream, data.Format);
}
}
range.ClearAllProperties();
inputBox.Selection.Text = "";
Span span3 = new Span(inputBox.Selection.Start, inputBox.Selection.End);
ReplaceControls.AddBlocksToSpan(inputBox.TempFlowDocument, span3);
inputBox.CaretPosition = span3.ElementEnd.GetInsertionPosition(LogicalDirection.Forward);
}
inputBox.TempFlowDocument.Blocks.Clear();
return true;
}
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:57,代码来源:ClipboardMgr.cs
示例14: AppendText
public void AppendText(Paragraph p, ScrollViewer scroll, ChatMessage message, string servername)
{
var text = string.Format("[{0}] [ {1:yyyy-MM-dd HH:mm:ss} ] {2}\n", servername, message.Date, message.Message);
var color = ServerMonitorModel.GetMessageColor(message);
var brush = new SolidColorBrush(color);
var span = new Span() { Foreground = brush };
span.Inlines.Add(text);
p.Inlines.Add(span);
}
开发者ID:svargy,项目名称:arma3beclient,代码行数:9,代码来源:ChatHistory.xaml.cs
示例15: DateSpan
private Span DateSpan(DateTime date)
{
Span span = new Span();
span.FontStyle = FontStyles.Normal;
span.FontSize = 10;
span.FontWeight = FontWeights.Bold;
span.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
span.Inlines.Add("[" + date + "] ");
return span;
}
开发者ID:iwikimon,项目名称:diplom,代码行数:10,代码来源:ChatControl.xaml.cs
示例16: MsgSpan
private Span MsgSpan(string message)
{
Span span = new Span();
span.FontStyle = FontStyles.Normal;
span.FontSize = 10;
span.FontWeight = FontWeights.Bold;
span.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
span.Inlines.Add(message);
return span;
}
开发者ID:iwikimon,项目名称:diplom,代码行数:10,代码来源:ChatControl.xaml.cs
示例17: AddBlocksToSpan
// Methods
internal static void AddBlocksToSpan(FlowDocument tempFlowDocument, Span newspan)
{
List<Inline> ic = new List<Inline>();
CollectInlineFromBlocks(tempFlowDocument.Blocks, ic);
if ((ic.Count > 0) && (ic[ic.Count - 1] is LineBreak))
{
ic.RemoveAt(ic.Count - 1);
}
newspan.Inlines.AddRange(ic);
}
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:11,代码来源:ReplaceControls.cs
示例18: LoginSpan
private Span LoginSpan(string login)
{
Span span = new Span();
span.FontStyle = FontStyles.Italic;
span.FontSize = 12;
span.FontWeight = FontWeights.Bold;
span.Foreground = new SolidColorBrush(Color.FromArgb(255, 155, 155, 155));
span.Inlines.Add(login+":");
return span;
}
开发者ID:iwikimon,项目名称:diplom,代码行数:10,代码来源:ChatControl.xaml.cs
示例19: ToTextRun
/// <inheritdoc/>
public override Inline ToTextRun()
{
Span span = new Span();
foreach (SnippetElement e in this.Elements) {
Inline r = e.ToTextRun();
if (r != null)
span.Inlines.Add(r);
}
return span;
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:11,代码来源:SnippetContainerElement.cs
示例20: CreateInline
public static Inline CreateInline(this List<ITextSection> inners)
{
var inlines = CreateInlines(inners);
if (inlines.Count() == 1) return inlines.First();
else {
var span = new Span();
span.Inlines.AddRange(inlines);
return span;
}
}
开发者ID:dirv,项目名称:TemplateWizard,代码行数:10,代码来源:TextSectionExtensions.cs
注:本文中的System.Windows.Documents.Span类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论