Пример #1
0
        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;
        }
Пример #2
0
        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++;
        }
Пример #3
0
 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;
 }
Пример #4
0
 private Inline CreateSubject(IMessage message)
 {
     var subj = message.XmppMessage.Subject;
     var span = new Span();
     span.Inlines.Add(subj);
     return new Italic(new Bold(span));
 }
Пример #5
0
        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;
        }
Пример #6
0
        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();
        }
Пример #7
0
 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;
 }
Пример #8
0
        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);
        }
        public static Inline AppendRange(this Inline inline, IEnumerable<Inline> inlines)
        {
            var span = new Span(inline);

            span.Inlines.AddRange(inlines);

            return span;
        }
Пример #10
0
        public static Inline Append(this Inline inline, Inline inlineToAdd)
        {
            var span = new Span(inline);

            span.Inlines.Add(inlineToAdd);

            return span;
        }
Пример #11
0
 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);
 }
Пример #12
0
 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);
 }
Пример #13
0
 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;
 }
Пример #14
0
 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;
 }
Пример #15
0
 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;
 }
Пример #16
0
		/// <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;
		}
Пример #17
0
 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;
     }
 }
Пример #18
0
 // 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);
 }
Пример #19
0
 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;
 }
Пример #20
0
 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;
 }
Пример #21
0
        public static Inline AppendRange(this Inline inline, IEnumerable<Inline> inlines)
        {
            Argument.IsNotNull(() => inline);
            Argument.IsNotNull(() => inlines);

            var span = new Span(inline);

            span.Inlines.AddRange(inlines);

            return span;
        }
Пример #22
0
 protected override Inline BuildElementInternal()
 {
     var element = new Span();
     foreach (var child in Children.Where(o => o.ShouldBuildElement()))
     {
         var buildElement = child.BuildElement();
         AddingChild(element, buildElement);
         AddChild(element, buildElement);
     }
     return element;
 }
Пример #23
0
        public static Inline Append(this Inline inline, Inline inlineToAdd)
        {
            Argument.IsNotNull(() => inline);
            Argument.IsNotNull(() => inlineToAdd);

            var span = new Span(inline);

            span.Inlines.Add(inlineToAdd);

            return span;
        }
Пример #24
0
 private Inline CreateHeader(IMessage message)
 {
     var from = message.XmppMessage.From;
     var date = message.Date;
     var name = GetName(from);
     var span = new Span();
     var format = date >= DateTime.Today
         ? string.Format("{0} {1:t}", name, date)
         : string.Format("{0} {1:g}", name, date);
     span.Inlines.Add(format);
     return new Bold(span);
 }
Пример #25
0
 public MultiPartBit(string[] strings, Brush[] brushes)
 {
     int iC = Math.Min(strings.Length, brushes.Length);
     Span s = new Span();
     for (int i = 0; i < iC; i++)
     {
         Span s2 = new Span(new Run(strings[i]));
         s2.Foreground = brushes[i];
         s.Inlines.Add(s2);
     }
     b = new Paragraph(s);
 }
Пример #26
0
 public Inline DisplayFormula()
 {
     Span form = new Span();
     form.Inlines.Add(Utilities.Num1(Parm[0], CParm[0]));
     form.Inlines.Add(new Italic(new Run("sqr")));
     form.Inlines.Add("(");
     form.Inlines.Add(Utilities.Num1(Parm[1], CParm[1]));
     form.Inlines.Add(", ");
     form.Inlines.Add(Utilities.Num1(Parm[2] / 100D, CParm[2]));
     form.Inlines.Add(")");
     return form;
 }
		/// <summary>
		/// Creates labels by given ticks info.
		/// Is not intended to be called from your code.
		/// </summary>
		/// <param name="ticksInfo">The ticks info.</param>
		/// <returns>
		/// Array of <see cref="UIElement"/>s, which are axis labels for specified axis ticks.
		/// </returns>
		public override UIElement[] CreateLabels(ITicksInfo<double> ticksInfo)
		{
			var ticks = ticksInfo.Ticks;

			Init(ticks);

			UIElement[] res = new UIElement[ticks.Length];

			LabelTickInfo<double> tickInfo = new LabelTickInfo<double> { Info = ticksInfo.Info };

			for (int i = 0; i < res.Length; i++)
			{
				var tick = ticks[i];
				tickInfo.Tick = tick;
				tickInfo.Index = i;

				string labelText = GetString(tickInfo);

				TextBlock label;
				if (labelText.Contains('E'))
				{
					string[] substrs = labelText.Split('E');
					string mantissa = substrs[0];
					string exponenta = substrs[1];
					exponenta = exponenta.TrimStart('+');
					Span span = new Span();
					span.Inlines.Add(String.Format(CultureInfo.CurrentCulture, "{0}·10", mantissa));
					Span exponentaSpan = new Span(new Run(exponenta));
					exponentaSpan.BaselineAlignment = BaselineAlignment.Superscript;
					exponentaSpan.FontSize = 8;
					span.Inlines.Add(exponentaSpan);

					label = new TextBlock(span);
					LabelProviderProperties.SetExponentialIsCommonLabel(label, false);
				}
				else
				{
					label = (TextBlock)GetResourceFromPool();
					if (label == null)
					{
						label = new TextBlock();
					}

					label.Text = labelText;
				}
				res[i] = label;
				label.ToolTip = tick.ToString(CultureInfo.CurrentCulture);

				ApplyCustomView(tickInfo, label);
			}

			return res;
		}
        public FeedItemDetails(Feed feed, FeedItem feedItem)
        {
            InitializeComponent();

            Feed = feed;
            FeedItem = feedItem;

            TextBlock_FeedTitle.Inlines.Add(Feed.Title);

            Hyperlink h = new Hyperlink();
            h.NavigateUri = new Uri(Feed.Link);
            h.RequestNavigate += new RequestNavigateEventHandler(Hyperlink_RequestNavigate);
            h.Inlines.Add(Feed.Link);
            TextBlock_FeedLink.Inlines.Add(h);

            TextBlock_FeedDescription.Inlines.Add(Feed.Description);
            if (Feed.Category.Name != null)
                TextBlock_FeedCategory.Inlines.Add(Feed.Category.Name);

            TextBlock_ItemTitle.Inlines.Add(FeedItem.Title);

            h = new Hyperlink();
            h.NavigateUri = new Uri(FeedItem.Link);
            h.RequestNavigate += new RequestNavigateEventHandler(Hyperlink_RequestNavigate);
            h.Inlines.Add(FeedItem.Link);
            TextBlock_ItemLink.Inlines.Add(h);

            TextBlock_ItemDescription.Inlines.Add(FeedItem.Description);
            TextBlock_ItemPubDate.Inlines.Add(FeedItem.PublicationDate.ToString());

            h = new Hyperlink();
            h.NavigateUri = new Uri(FeedItem.MediaUrl);
            h.RequestNavigate += new RequestNavigateEventHandler(Hyperlink_RequestNavigate);
            h.Click += new RoutedEventHandler(Hyperlink_SetFeedItemHasBeenPlayed);
            h.TextDecorations = null;
            h.Inlines.Add("play item");
            TextBlock_ItemActions.Inlines.Add("[");
            TextBlock_ItemActions.Inlines.Add(h);
            TextBlock_ItemActions.Inlines.Add("] ");

            Span s = new Span();
            if (FeedItem.HasBeenPlayed)
            {
                s.Foreground = Brushes.Green;
                s.Inlines.Add("Played");
            }
            else
            {
                s.Foreground = Brushes.Red;
                s.Inlines.Add("Unplayed");
            }
            TextBlock_ItemActions.Inlines.Add(s);
        }
Пример #29
0
        public void AppendText(Paragraph p, ScrollViewer scroll, ChatMessage message)
        {
            var text = string.Format("[ {0:HH:mm:ss} ]  {1}\n", message.Date, message.Message);
            var color = ServerMonitorModel.GetMessageColor(message);

            var brush = new SolidColorBrush(color);
            var span = new Span() { Foreground = brush };
            span.Inlines.Add(text);
            paragraph.Inlines.Add(span);

            if (Model.AutoScroll)
                scroll.ScrollToEnd();
        }
Пример #30
0
 public Inline DisplayFormula()
 {
     string Pi = Char.ToString((char)0x03C0);
     Span form = new Span();
     form.Inlines.Add(Utilities.Num1(Parm[0], CParm[0]));
     form.Inlines.Add(new Italic(new Run("sin")));
     form.Inlines.Add("(2" + Pi + "(");
     form.Inlines.Add(Utilities.Num1(Parm[1], CParm[1]));
     form.Inlines.Add(new Italic(new Run("t")));
     form.Inlines.Add(Utilities.Num0(Parm[2] / 360D, CParm[2]));
     form.Inlines.Add("))");
     return form;
 }
Пример #31
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.viewModel = ((tscui.Pages.Control.ControlViewModel)(target));
                return;

            case 2:
                this.textBlock1 = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 3:
                this.spnEastOther = ((System.Windows.Documents.Span)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #32
0
        private static void AddChildren(Span s, HtmlNode node)
        {
            bool added = false;

            foreach (HtmlNode child in node.ChildNodes)
            {
                Inline i = GenerateBlockForNode(child);
                if (i != null)
                {
                    s.Inlines.Add(i);
                    added = true;
                }
            }
            if (!added)
            {
                s.Inlines.Add(new Run()
                {
                    Text = CleanText(node.InnerText)
                });
            }
        }
Пример #33
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 8 "..\..\FlowDoc1.xaml"
                ((ToolTracker.FlowDoc1)(target)).Loaded += new System.Windows.RoutedEventHandler(this.FlowDoc1_OnLoaded);

            #line default
            #line hidden
                return;

            case 2:
                this.FlowDocTest = ((System.Windows.Documents.FlowDocument)(target));
                return;

            case 3:
                this.rank = ((System.Windows.Documents.Span)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #34
0
        private void closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if ((recieved == false) && (!(Directory.Exists(Pass.pindir))))
            {
                var dlg = new emanual.Wpf.Utility.MessageBoxEx();
                // 単なるテキストを設定する場合は Message プロパティを設定する
                dlg.Message          = "Brith";
                dlg.Width            = 350;
                dlg.Height           = 165;
                dlg.TextBlock.Height = 65;
                // Inlines プロパティを設定する場合
                dlg.TextBlock.Inlines.Add(new System.Windows.Documents.Bold(new System.Windows.Documents.Run(Properties.Resources.pincode_check_1)));//Run("Birth認証を終了しますか?\n\n")));
                var span = new System.Windows.Documents.Span(new System.Windows.Documents.Run(Properties.Resources.pincode_check_2));
                span.Foreground = new SolidColorBrush(Colors.Red);
                dlg.TextBlock.Inlines.Add(span);
                dlg.TextBlock.Inlines.Add(Properties.Resources.pincode_check_3);

                dlg.Owner = this;
                dlg.Left  = this.Left + 50;
                dlg.Top   = this.Top + 50;

                // デフォルトでは薄い水色のグラデーションですが、好みの色に指定可能
                //dlg.Background = Brushes.Wheat;
                dlg.Button = MessageBoxButton.YesNo;
                dlg.Image  = MessageBoxImage.Warning;

                // ダイアログを開いたときにフォーカスをあてるボタン
                dlg.Result = MessageBoxResult.No;
                dlg.ShowDialog();

                MessageBoxResult result = dlg.Result;
                if (result == MessageBoxResult.No)
                {
                    e.Cancel = true;
                }
            }
        }
Пример #35
0
        // only supports the small subset of markdown that we actually care about for the purposes of this application
        private IEnumerable <WPF.Inline> GetInlineCollectionFor(Block document)
        {
            var firstParagraph = true;
            var inlines        = new Stack <List <WPF.Inline> >();

            inlines.Push(new List <WPF.Inline>());

            foreach (var node in document.AsEnumerable())
            {
                if (node.Block != null)
                {
                    var block = node.Block;

                    switch (block.Tag)
                    {
                    case BlockTag.Paragraph:
                        if (node.IsOpening)
                        {
                            if (firstParagraph)
                            {
                                firstParagraph = false;
                            }
                            else
                            {
                                // HACK: see http://stackoverflow.com/a/38866716/5380 for details
                                inlines.Peek().Add(new WPF.LineBreak());
                                var span = new WPF.Span();
                                span.FontSize = 6;
                                span.Inlines.Add(new WPF.Run("\t"));
                                span.Inlines.Add(new WPF.LineBreak());
                                inlines.Peek().Add(span);
                            }
                        }
                        break;
                    }
                }
                else if (node.Inline != null)
                {
                    var inline = node.Inline;

                    switch (inline.Tag)
                    {
                    case InlineTag.String:
                        inlines.Peek().Add(new WPF.Run(inline.LiteralContent));
                        break;

                    case InlineTag.Code:
                        inlines.Peek().Add(new WPF.Run(inline.LiteralContent)
                        {
                            Style = (Style)this.FindResource("CodeRunStyle")
                        });
                        break;

                    case InlineTag.Emphasis:
                        if (node.IsOpening)
                        {
                            inlines.Push(new List <WPF.Inline>());
                        }
                        else
                        {
                            var emphasised = inlines.Pop();
                            var span       = new WPF.Span
                            {
                                Style = (Style)this.FindResource("EmphasisSpanStyle")
                            };
                            span.Inlines.AddRange(emphasised);
                            inlines.Peek().Add(span);
                        }
                        break;

                    case InlineTag.Strong:
                        if (node.IsOpening)
                        {
                            inlines.Push(new List <WPF.Inline>());
                        }
                        else
                        {
                            var emphasised = inlines.Pop();
                            var span       = new WPF.Span
                            {
                                Style = (Style)this.FindResource("StrongSpanStyle")
                            };
                            span.Inlines.AddRange(emphasised);
                            inlines.Peek().Add(span);
                        }
                        break;

                    case InlineTag.Link:
                        if (node.IsOpening)
                        {
                            inlines.Push(new List <WPF.Inline>());
                        }
                        else
                        {
                            WPF.Hyperlink hyperlink;

                            if (Uri.TryCreate(inline.TargetUrl, UriKind.Absolute, out var uri))
                            {
                                hyperlink = new WPF.Hyperlink
                                {
                                    NavigateUri = new Uri(inline.TargetUrl, UriKind.Absolute)
                                };
                            }
                            else
                            {
                                hyperlink = new WPF.Hyperlink
                                {
                                    Command = ReactiveCommand.Create(() => this.ViewModel.SelectSample(inline.TargetUrl))
                                };
                            }

                            hyperlink.Inlines.AddRange(inlines.Pop());
                            inlines.Peek().Add(hyperlink);
                        }
                        break;
                    }
                }
            }

            if (inlines.Count != 1)
            {
                throw new InvalidOperationException("Ended up with more than the single root inlines list.");
            }

            return(inlines.Pop());
        }
Пример #36
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 5 "..\..\MainWindow.xaml"
                ((Microsoft.Samples.Kinect.SpeechBasics.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.WindowLoaded);

            #line default
            #line hidden

            #line 5 "..\..\MainWindow.xaml"
                ((Microsoft.Samples.Kinect.SpeechBasics.MainWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.WindowClosing);

            #line default
            #line hidden
                return;

            case 2:
                this.___No_Name_ = ((System.Windows.Controls.Viewbox)(target));
                return;

            case 3:
                this.playArea = ((System.Windows.Controls.Canvas)(target));
                return;

            case 4:
                this.label1 = ((System.Windows.Controls.Label)(target));
                return;

            case 5:
                this.forwardSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 6:
                this.backSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 7:
                this.stopSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 8:
                this.leftSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 9:
                this.rightSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 10:
                this.statusBar = ((System.Windows.Controls.Primitives.StatusBar)(target));
                return;

            case 11:
                this.statusBarText = ((System.Windows.Controls.TextBlock)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #37
0
        private void UpdateWatermark()
        {
            string watermarkText1 = @"Type in the search box to search. Press Ctrl+F to focus the search box. Results (up to 1000) will display here.

Search for multiple words separated by space (space means AND). Enclose multiple words in double-quotes """" to search for the exact phrase.

Use syntax like '$property Prop' to narrow results down by item kind. Supported kinds: ";

            string watermarkText2 = @"Use the under(FILTER) clause to filter results to only the nodes where any of the parent nodes in the parent chain matches the FILTER. Examples:
 • $task csc under($project Core)
 • Copying file under(Parent)

Examples:
";

            Inline MakeLink(string query, string before = " • ", string after = "\r\n")
            {
                var hyperlink = new Hyperlink(new Run(query));

                hyperlink.Click += (s, e) => searchLogControl.SearchText = query;

                var span = new System.Windows.Documents.Span();

                if (before != null)
                {
                    span.Inlines.Add(new Run(before));
                }

                span.Inlines.Add(hyperlink);

                if (after != null)
                {
                    if (after == "\r\n")
                    {
                        span.Inlines.Add(new LineBreak());
                    }
                    else
                    {
                        span.Inlines.Add(new Run(after));
                    }
                }

                return(span);
            }

            var watermark = new TextBlock();

            watermark.Inlines.Add(watermarkText1);

            bool isFirst = true;

            foreach (var nodeKind in nodeKinds)
            {
                if (!isFirst)
                {
                    watermark.Inlines.Add(", ");
                }

                isFirst = false;
                watermark.Inlines.Add(MakeLink(nodeKind, before: null, after: null));
            }

            watermark.Inlines.Add(new LineBreak());
            watermark.Inlines.Add(new LineBreak());

            watermark.Inlines.Add(watermarkText2);

            foreach (var example in searchExamples)
            {
                watermark.Inlines.Add(MakeLink(example));
            }

            var recentSearches = SettingsService.GetRecentSearchStrings();

            if (recentSearches.Any())
            {
                watermark.Inlines.Add(@"
Recent:
");

                foreach (var recentSearch in recentSearches.Where(s => !searchExamples.Contains(s) && !nodeKinds.Contains(s)))
                {
                    watermark.Inlines.Add(MakeLink(recentSearch));
                }
            }

            searchLogControl.WatermarkContent = watermark;
        }
Пример #38
0
        /// <summary>
        /// Renders DOM text elements recursively, i.e. including their childs.
        /// </summary>
        /// <param name="e">The root DOM text element.</param>
        /// <returns>The corresponding Wpf element.</returns>
        /// <exception cref="System.InvalidOperationException">
        /// </exception>
        /// <exception cref="System.NotImplementedException"></exception>
        public object RenderRecursively(TextElement e)
        {
            object wpf = null;

            switch (e)
            {
            case BlockUIContainer buc:
            {
                wpf = new swd.BlockUIContainer();
            }
            break;

            case FlowDocument flowDocument:
            {
                // make sure the standard colors were set
                flowDocument.Foreground = ExCSS.Color.Black;
                flowDocument.Background = ExCSS.Color.White;

                var flowDocumente = new swd.FlowDocument()
                {
                    Name = NameOfFlowDocument
                };
                if (TemplateBindingViewportWidth is null)
                {
                    TemplateBindingViewportWidth = new Binding("ColumnWidth")
                    {
                        Source = flowDocumente
                    }
                }
                ;
                if (TemplateBindingViewportHeight is null)
                {
                    TemplateBindingViewportHeight = new Binding("ColumnWidth")
                    {
                        Source = flowDocumente
                    }
                }
                ;                                                                                    // Binding to ColumnWidth is not optimal, but better than nothing!

                if (flowDocument.Background.HasValue)
                {
                    flowDocumente.Background = GetBrushFromColor(flowDocument.Background.Value);
                }
                if (flowDocument.Foreground.HasValue)
                {
                    flowDocumente.Foreground = GetBrushFromColor(flowDocument.Foreground.Value);
                }

                wpf = flowDocumente;
            }
            break;

            case Hyperlink hl:
            {
                var hle = new swd.Hyperlink();
                if (!string.IsNullOrEmpty(hl.NavigateUri))
                {
                    if (System.Uri.TryCreate(hl.NavigateUri, UriKind.RelativeOrAbsolute, out var uri))
                    {
                        hle.NavigateUri = uri;
                    }
                }
                if (!string.IsNullOrEmpty(hl.TargetName))
                {
                    hle.TargetName = hl.TargetName;
                }
                wpf = hle;
            }
            break;

            case Image image:
            {
                var imagee = new System.Windows.Controls.Image();
                if (!string.IsNullOrEmpty(image.Source))
                {
                    imagee.SetBinding(System.Windows.Controls.Image.SourceProperty, $"ImageProvider[{image.Source}]");
                }

                if (image.Width == null && image.Height == null)
                {
                    imagee.Stretch = System.Windows.Media.Stretch.Uniform;

                    var binding = new Binding()
                    {
                        RelativeSource = RelativeSource.Self, Path = new System.Windows.PropertyPath("Source")
                    };
                    binding.Converter = ImageToImageWidthConverter.Instance;
                    imagee.SetBinding(System.Windows.Controls.Image.WidthProperty, binding);
                }
                else
                {
                    imagee.Stretch = System.Windows.Media.Stretch.Uniform;
                }

                if (image.Width != null)
                {
                    if (image.Width.IsPurelyAbsolute(out var widthPx))
                    {
                        imagee.Width = widthPx;
                    }
                    else
                    {
                        var multibinding = new MultiBinding();
                        multibinding.Bindings.Add(new Binding()
                            {
                                Source = TemplateBindingViewportWidth.Source, Path = TemplateBindingViewportWidth.Path
                            });
                        multibinding.Bindings.Add(new Binding()
                            {
                                Source = TemplateBindingViewportHeight.Source, Path = TemplateBindingViewportHeight.Path
                            });
                        multibinding.Converter          = CompoundLengthConverter.Instance;
                        multibinding.ConverterParameter = GetCompoundLengthConverterParameters(image.Width);
                        imagee.SetBinding(System.Windows.Controls.Image.WidthProperty, multibinding);
                    }
                }

                if (image.Height != null)
                {
                    if (image.Height.IsPurelyAbsolute(out var heightPx))
                    {
                        imagee.Height = heightPx;
                    }
                    else
                    {
                        var multibinding = new MultiBinding();
                        multibinding.Bindings.Add(new Binding()
                            {
                                Source = TemplateBindingViewportWidth.Source, Path = TemplateBindingViewportWidth.Path
                            });
                        multibinding.Bindings.Add(new Binding()
                            {
                                Source = TemplateBindingViewportHeight.Source, Path = TemplateBindingViewportHeight.Path
                            });
                        multibinding.Converter          = CompoundLengthConverter.Instance;
                        multibinding.ConverterParameter = GetCompoundLengthConverterParameters(image.Height);
                        imagee.SetBinding(System.Windows.Controls.Image.HeightProperty, multibinding);
                    }
                }

                // set max-width and max-height
                if (image.MaxWidth != null && image.MaxWidth.Value.IsAbsolute)
                {
                    imagee.MaxWidth = image.MaxWidth.Value.ToPixel();
                }
                else if (image.MaxWidth == null || image.MaxWidth.Value.Type == ExCSS.Length.Unit.Vw)
                {
                    double vwValue = image.MaxWidth.HasValue ? image.MaxWidth.Value.Value : 100;

                    var binding = new Binding()
                    {
                        Source = TemplateBindingViewportWidth.Source, Path = TemplateBindingViewportWidth.Path
                    };
                    binding.Converter          = RelativeSizeConverter.Instance;
                    binding.ConverterParameter = vwValue;
                    imagee.SetBinding(System.Windows.Controls.Image.MaxWidthProperty, binding);
                }
                else
                {
                    throw new InvalidProgramException();
                }


                if (image.MaxHeight != null && image.MaxHeight.Value.IsAbsolute)
                {
                    imagee.MaxHeight = image.MaxHeight.Value.ToPixel();
                }
                else if (image.MaxHeight == null || image.MaxHeight.Value.Type == ExCSS.Length.Unit.Vh)
                {
                    double vhValue = image.MaxHeight.HasValue ? image.MaxHeight.Value.Value : 100;
                    var    binding = new Binding()
                    {
                        Source = TemplateBindingViewportWidth.Source, Path = TemplateBindingViewportWidth.Path
                    };
                    binding.Converter          = RelativeSizeConverter.Instance;
                    binding.ConverterParameter = vhValue;
                    imagee.SetBinding(System.Windows.Controls.Image.MaxHeightProperty, binding);
                }
                else
                {
                    throw new InvalidProgramException();
                }

                wpf = imagee;
            }
            break;

            case InlineUIContainer iuc:
            {
                var inlineuiContainere = new swd.InlineUIContainer();
                wpf = inlineuiContainere;
            }
            break;

            case LineBreak lb:
            {
                wpf = new swd.LineBreak();
            }
            break;

            case List list:
            {
                var liste = new swd.List();
                if (list.MarkerStyle.HasValue)
                {
                    liste.MarkerStyle = ToMarkerStyle(list.MarkerStyle.Value);
                }
                wpf = liste;
            }
            break;

            case ListItem li:
            {
                wpf = new swd.ListItem();
            }
            break;

            case Paragraph p:
            {
                var pe = new swd.Paragraph();
                if (p.TextDecorations.HasValue)
                {
                    pe.TextDecorations = ToTextDecorations(p.TextDecorations.Value);
                }
                if (p.TextIndent.HasValue)
                {
                    pe.TextIndent = p.TextIndent.Value.IsAbsolute ? p.TextIndent.Value.ToPixel() : 0;
                }
                wpf = pe;
            }
            break;

            case Run run:
            {
                if (SplitIntoWords)
                {
                    wpf = CreateTextElement_SeparateWords(run.Text);
                }
                else if (SplitIntoSentences)
                {
                    wpf = CreateTextElement_SeparateSentences(run.Text);
                }
                else
                {
                    wpf = new swd.Run(run.Text);
                }
            }
            break;

            case Section s:
            {
                wpf = new swd.Section();
            }
            break;

            case Span span:
            {
                wpf = new swd.Span();
            }
            break;

            case Table tb:
            {
                var tbe = new swd.Table();
                foreach (var c in tb.Columns)
                {
                    if (c.Width.HasValue)
                    {
                        tbe.Columns.Add(new swd.TableColumn()
                            {
                                Width = new System.Windows.GridLength(c.Width.Value)
                            });
                    }
                    else
                    {
                        tbe.Columns.Add(new swd.TableColumn());
                    }
                }
                wpf = tbe;
            }
            break;

            case TableCell tc:
            {
                var tce = new swd.TableCell();
                if (1 != tc.ColumnSpan)
                {
                    tce.ColumnSpan = tc.ColumnSpan;
                }

                if (1 != tc.RowSpan)
                {
                    tce.RowSpan = tc.RowSpan;
                }
                if (tc.BorderBrush.HasValue)
                {
                    tce.BorderBrush = new System.Windows.Media.SolidColorBrush(ToColor(tc.BorderBrush.Value));
                }
                if (tc.BorderThickness.HasValue)
                {
                    tce.BorderThickness = ToThickness(tc.BorderThickness.Value);
                }
                wpf = tce;
            }
            break;

            case TableRow trow:
            {
                wpf = new swd.TableRow();
            }
            break;

            case TableRowGroup trg:
            {
                wpf = new swd.TableRowGroup();
            }
            break;

            default:
            {
                wpf = null;
            }
            break;
            }

            // Render TextElement properties

            if (wpf is swd.TextElement te)
            {
                if (!string.IsNullOrEmpty(e.FontFamily))
                {
                    te.FontFamily = GetFontFamily(e.FontFamily);
                }

                if (e.FontSize.HasValue)
                {
                    var fs = e.FontSize.Value;
                    fs          = Math.Max(0.004, fs);
                    te.FontSize = fs;
                }

                if (e.FontStyle.HasValue)
                {
                    te.FontStyle = ToFontStyle(e.FontStyle.Value);
                }

                if (e.FontWeight.HasValue)
                {
                    te.FontWeight = ToFontWeight(e.FontWeight.Value);
                }

                if (e.Foreground.HasValue && e.Foreground != e.ForegroundInheritedOnly)
                {
                    te.Foreground = GetBrushFromColor(e.Foreground.Value);
                }

                if (e.Background.HasValue && e.Background != e.BackgroundInheritedOnly)
                {
                    te.Background = GetBrushFromColor(e.Background.Value);
                }
            }

            // now special properties

            if (e is Block b && wpf is swd.Block be)
            {
                if (b.Margin.HasValue)
                {
                    be.Margin = ToThickness(b.Margin.Value);
                }

                if (b.Padding.HasValue)
                {
                    be.Padding = ToThickness(b.Padding.Value);
                }

                if (b.BorderBrush.HasValue)
                {
                    be.BorderBrush = new System.Windows.Media.SolidColorBrush(ToColor(b.BorderBrush.Value));
                }

                if (b.BorderThickness.HasValue)
                {
                    be.BorderThickness = ToThickness(b.BorderThickness.Value);
                }

                if (b.TextAlignment.HasValue)
                {
                    be.TextAlignment = ToTextAlignment(b.TextAlignment.Value);
                }

                if (b.LineHeight.HasValue)
                {
                    be.LineHeight = b.LineHeight.Value;
                }
            }
            if (e is Inline i && wpf is swd.Inline ie)
            {
                if (i.VerticalAlignment.HasValue)
                {
                    ie.BaselineAlignment = ToBaselineAlignment(i.VerticalAlignment.Value);
                }
            }
            //  finished rendering the attributes


            // now, render all children
            foreach (var child in e.Childs)
            {
                var childe = RenderRecursively(child);

                switch (wpf)
                {
                case swd.Figure figure:
                    figure.Blocks.Add((swd.Block)childe);
                    break;

                case swd.Floater floater:
                    floater.Blocks.Add((swd.Block)childe);
                    break;

                case swd.FlowDocument flowDocument:
                    flowDocument.Blocks.Add((swd.Block)childe);
                    break;

                case swd.List list:
                    list.ListItems.Add((swd.ListItem)childe);
                    break;

                case swd.ListItem listItem:
                    listItem.Blocks.Add((swd.Block)childe);
                    break;

                case swd.Section section:
                    section.Blocks.Add((swd.Block)childe);
                    break;

                case swd.Table table:
                    table.RowGroups.Add((swd.TableRowGroup)childe);
                    break;

                case swd.TableCell tableCell:
                    tableCell.Blocks.Add((swd.Block)childe);
                    break;

                case swd.TableRow tableRow:
                    tableRow.Cells.Add((swd.TableCell)childe);
                    break;

                case swd.TableRowGroup tableRowGroup:
                    tableRowGroup.Rows.Add((swd.TableRow)childe);
                    break;

                // now elements that can contain inlines
                case swd.Paragraph paragraph:
                    paragraph.Inlines.Add((swd.Inline)childe);
                    break;

                case swd.Span span:
                    span.Inlines.Add((swd.Inline)childe);
                    break;

                // now some specialties
                case swd.InlineUIContainer inlineUIContainer:
                    if (inlineUIContainer.Child != null)
                    {
                        throw new InvalidOperationException($"{nameof(swd.InlineUIContainer)} can not contain more than one child");
                    }
                    inlineUIContainer.Child = (System.Windows.UIElement)childe;
                    break;

                case swd.BlockUIContainer blockUIContainer:
                    if (blockUIContainer.Child != null)
                    {
                        throw new InvalidOperationException($"{nameof(swd.BlockUIContainer)} can not contain more than one child");
                    }
                    blockUIContainer.Child = (System.Windows.UIElement)childe;
                    break;

                default:
                    throw new NotImplementedException();
                }
            }

            if (AttachDomAsTags)
            {
                if (wpf is System.Windows.FrameworkContentElement conEle)
                {
                    conEle.Tag = e;
                }
                else if (wpf is System.Windows.FrameworkElement uiEle)
                {
                    uiEle.Tag = e;
                }
            }

            return(wpf);
        }
Пример #39
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 5 "..\..\MainWindow.xaml"
                ((ReconnaissanceVocale.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.WindowLoaded);

            #line default
            #line hidden

            #line 5 "..\..\MainWindow.xaml"
                ((ReconnaissanceVocale.MainWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.WindowClosing);

            #line default
            #line hidden
                return;

            case 2:
                this.playArea = ((System.Windows.Controls.Canvas)(target));
                return;

            case 3:
                this.SpeechBlock = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 4:
                this.BrosseSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 5:
                this.PinceauSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 6:
                this.CrayonSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 7:
                this.SphereSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 8:
                this.PyramideSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 9:
                this.CubeSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 10:
                this.ManuelSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 11:
                this.AutoSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 12:
                this.NordSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 13:
                this.SudSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 14:
                this.EstSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 15:
                this.OuestSpan = ((System.Windows.Documents.Span)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #40
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 4 "..\..\MainWindow.xaml"
                ((KinectChris.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden
                return;

            case 2:
                this.mostrarVideo = ((System.Windows.Controls.Image)(target));
                return;

            case 3:
                this.UP = ((System.Windows.Controls.Button)(target));

            #line 7 "..\..\MainWindow.xaml"
                this.UP.Click += new System.Windows.RoutedEventHandler(this.UP_Click);

            #line default
            #line hidden
                return;

            case 4:
                this.DOWN = ((System.Windows.Controls.Button)(target));

            #line 8 "..\..\MainWindow.xaml"
                this.DOWN.Click += new System.Windows.RoutedEventHandler(this.DOWN_Click);

            #line default
            #line hidden
                return;

            case 5:
                this.REST = ((System.Windows.Controls.Button)(target));

            #line 9 "..\..\MainWindow.xaml"
                this.REST.Click += new System.Windows.RoutedEventHandler(this.REST_Click);

            #line default
            #line hidden
                return;

            case 6:
                this.FOTO = ((System.Windows.Controls.Button)(target));

            #line 10 "..\..\MainWindow.xaml"
                this.FOTO.Click += new System.Windows.RoutedEventHandler(this.FOTO_Click);

            #line default
            #line hidden
                return;

            case 7:
                this.sliderAzul = ((System.Windows.Controls.Slider)(target));

            #line 11 "..\..\MainWindow.xaml"
                this.sliderAzul.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.sliderAzul_ValueChanged);

            #line default
            #line hidden
                return;

            case 8:
                this.sliderVerde = ((System.Windows.Controls.Slider)(target));

            #line 12 "..\..\MainWindow.xaml"
                this.sliderVerde.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.sliderVerde_ValueChanged);

            #line default
            #line hidden
                return;

            case 9:
                this.sliderRojo = ((System.Windows.Controls.Slider)(target));

            #line 13 "..\..\MainWindow.xaml"
                this.sliderRojo.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.sliderRojo_ValueChanged);

            #line default
            #line hidden
                return;

            case 10:
                this.photoSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 11:
                this.upSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 12:
                this.downSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 13:
                this.restoreSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 14:
                this.faceSpan = ((System.Windows.Documents.Span)(target));
                return;

            case 15:
                this.statusBar = ((System.Windows.Controls.Primitives.StatusBar)(target));
                return;

            case 16:
                this.statusBarText = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 17:
                this.angule = ((System.Windows.Controls.Label)(target));
                return;

            case 18:
                this.canvasEsqueleto = ((System.Windows.Controls.Canvas)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #41
0
        private object CreateTextElement_SeparateSentences(string text)
        {
            if (SplitIntoSentences)
            {
                int        prevIdx = 0;
                List <int> list    = null;

                int  numberOfWords = 0;
                bool inWord        = false;

                for (int i = 0; i < text.Length; ++i)
                {
                    char c = text[i];
                    if (char.IsWhiteSpace(text[i]))
                    {
                        inWord = false;
                    }
                    else
                    {
                        if (!inWord)
                        {
                            ++numberOfWords;
                        }
                        inWord = true;
                    }

                    if (c == '.' || c == '!' || c == '?')
                    {
                        if (numberOfWords > 2 || (i - prevIdx) >= 4)
                        {
                            if (null == list)
                            {
                                list = new List <int>(text.Length / 5);
                                list.Add(0);
                            }
                            list.Add(i + 1);
                            prevIdx = i + 1;
                        }
                    }
                }
                if (null != list)
                {
                    list.Add(text.Length);

                    var span = new swd.Span();
                    for (int i = 1; i < list.Count; ++i)
                    {
                        span.Inlines.Add(new swd.Run(text.Substring(list[i - 1], list[i] - list[i - 1])));
                    }
                    return(span);
                }
                else
                {
                    return(new swd.Run(text));
                }
            }
            else
            {
                return(new swd.Run(text));
            }
        }
Пример #42
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 6 "..\..\MainWindow.xaml"
                ((KinectCoordinateMapping.MainWindow)(target)).KeyDown += new System.Windows.Input.KeyEventHandler(this.Window_KeyDown);

            #line default
            #line hidden

            #line 7 "..\..\MainWindow.xaml"
                ((KinectCoordinateMapping.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden

            #line 7 "..\..\MainWindow.xaml"
                ((KinectCoordinateMapping.MainWindow)(target)).Closed += new System.EventHandler(this.Window_Closed);

            #line default
            #line hidden
                return;

            case 2:
                this.testWindow = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 3:
                this.camera = ((System.Windows.Controls.Image)(target));
                return;

            case 4:
                this.canvas = ((System.Windows.Controls.Canvas)(target));
                return;

            case 5:
                this.cameraDepth = ((System.Windows.Controls.Image)(target));
                return;

            case 6:
                this.canvasDepth = ((System.Windows.Controls.Canvas)(target));
                return;

            case 7:
                this.twoJoints = ((System.Windows.Controls.RadioButton)(target));

            #line 21 "..\..\MainWindow.xaml"
                this.twoJoints.Click += new System.Windows.RoutedEventHandler(this.NumberOfJointPoints);

            #line default
            #line hidden
                return;

            case 8:
                this.sixJoints = ((System.Windows.Controls.RadioButton)(target));

            #line 22 "..\..\MainWindow.xaml"
                this.sixJoints.Click += new System.Windows.RoutedEventHandler(this.NumberOfJointPoints);

            #line default
            #line hidden
                return;

            case 9:
                this.depthMode = ((System.Windows.Controls.RadioButton)(target));

            #line 26 "..\..\MainWindow.xaml"
                this.depthMode.Click += new System.Windows.RoutedEventHandler(this.SelectMode);

            #line default
            #line hidden
                return;

            case 10:
                this.colorMode = ((System.Windows.Controls.RadioButton)(target));

            #line 27 "..\..\MainWindow.xaml"
                this.colorMode.Click += new System.Windows.RoutedEventHandler(this.SelectMode);

            #line default
            #line hidden
                return;

            case 11:
                this.start = ((System.Windows.Documents.Span)(target));
                return;

            case 12:
                this.stop = ((System.Windows.Documents.Span)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #43
0
        void GenerateBlocks(SWD.InlineCollection col, string text, ref int i, int spanEnd, List <Drawing.TextAttribute> attributes, ref int attrIndex)
        {
            while (attrIndex < attributes.Count)
            {
                var at = attributes[attrIndex];
                if (at.StartIndex > spanEnd)
                {
                    FlushText(col, text, ref i, spanEnd);
                    return;
                }

                FlushText(col, text, ref i, at.StartIndex);

                var s = new SWD.Span();

                if (at is Drawing.BackgroundTextAttribute)
                {
                    s.Background = new SWM.SolidColorBrush(((Drawing.BackgroundTextAttribute)at).Color.ToWpfColor());
                }
                else if (at is Drawing.FontWeightTextAttribute)
                {
                    s.FontWeight = ((Drawing.FontWeightTextAttribute)at).Weight.ToWpfFontWeight();
                }
                else if (at is Drawing.FontStyleTextAttribute)
                {
                    s.FontStyle = ((Drawing.FontStyleTextAttribute)at).Style.ToWpfFontStyle();
                }
                else if (at is Drawing.UnderlineTextAttribute)
                {
                    var xa  = (Drawing.UnderlineTextAttribute)at;
                    var dec = new TextDecoration(TextDecorationLocation.Underline, null, 0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended);
                    s.TextDecorations.Add(dec);
                }
                else if (at is Drawing.StrikethroughTextAttribute)
                {
                    var xa  = (Drawing.StrikethroughTextAttribute)at;
                    var dec = new TextDecoration(TextDecorationLocation.Strikethrough, null, 0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended);
                    s.TextDecorations.Add(dec);
                }
                else if (at is Drawing.FontTextAttribute)
                {
                    var xa = (Drawing.FontTextAttribute)at;
                    s.FontFamily  = new SWM.FontFamily(xa.Font.Family);
                    s.FontSize    = WpfFontBackendHandler.GetPointsFromDeviceUnits(xa.Font.Size);
                    s.FontStretch = xa.Font.Stretch.ToWpfFontStretch();
                    s.FontStyle   = xa.Font.Style.ToWpfFontStyle();
                    s.FontWeight  = xa.Font.Weight.ToWpfFontWeight();
                }
                else if (at is Drawing.ColorTextAttribute)
                {
                    s.Foreground = new SWM.SolidColorBrush(((Drawing.ColorTextAttribute)at).Color.ToWpfColor());
                }
                else if (at is Drawing.LinkTextAttribute)
                {
                    var link = new SWD.Hyperlink()
                    {
                        NavigateUri = ((Drawing.LinkTextAttribute)at).Target
                    };
                    link.RequestNavigate += new System.Windows.Navigation.RequestNavigateEventHandler(link_RequestNavigate);
                    s = link;
                }

                col.Add(s);

                var max = i + at.Count;
                if (max > spanEnd)
                {
                    max = spanEnd;
                }

                attrIndex++;
                GenerateBlocks(s.Inlines, text, ref i, i + at.Count, attributes, ref attrIndex);
            }
            FlushText(col, text, ref i, spanEnd);
        }