Beispiel #1
0
 public static IDisposable StartMisakura()
 {
     return(Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1))
            .Subscribe(_ => {
         var application = GetApplication();
         application.Dispatcher.BeginInvoke((Action)(() => {
             foreach (var window in application.Windows.Cast <Window>().ToArray())
             {
                 window.Title = MisakuraConverter.Convert(window.Title);
                 window
                 .Descendants()
                 .ToList()
                 .ForEach(x => Convert(x));
             }
         }));
     }));
 }
Beispiel #2
0
        public static void Convert(object content)
        {
            if (MisakuraedControls.ContainsKey(content))
            {
                return;
            }

            if (content is TextBlock)
            {
                var textBlock = (TextBlock)content;
                if (textBlock.Inlines.Any())
                {
                    foreach (var inline in textBlock.Inlines.ToArray())
                    {
                        Convert(inline);
                    }
                }
                else
                {
                    textBlock.Text = MisakuraConverter.Convert(textBlock.Text);
                }
            }
            else if (content is Run)
            {
                var run = (Run)content;
                run.Text = MisakuraConverter.Convert(run.Text);
            }
            else if (content is Hyperlink)
            {
                var hyperlink = (Hyperlink)content;
                foreach (var inline in hyperlink.Inlines.ToArray())
                {
                    Convert(inline);
                }
            }
            else
            {
                return;
            }

            MisakuraedControls[content] = true;
        }