Beispiel #1
0
        public static void ProcessTranslatedInput(DataPackage package)
        {
            var text   = package.Text;
            var action = new Action(() => System.Windows.Clipboard.SetText(text));

            mainWindow.Invoke(action);
            package.DelayHandler.Resolve(string.Format(Language["SuccessfulInputTranslation"], text));
            package.Clear();
        }
Beispiel #2
0
        public DelayHandler(MainWindowLogic window, System.Windows.Media.Color color)
        {
            window.Invoke(() =>
            {
                this.window          = window;
                textColor            = color;
                image                = new System.Windows.Controls.Image();
                imageContainer       = new InlineUIContainer();
                paragraph            = window.Output.Document.Blocks.LastBlock as Paragraph;
                image.Source         = ImageResources.Loading[0].ImageSource;
                image.MaxHeight      = 22;
                image.MaxWidth       = 22;
                imageContainer.Child = image;
                paragraph.Inlines.Add(imageContainer);
                frameDelay = 0.1;
                imageIndex = 1;
                window.Output.AppendText("\r\n");

                var timer = new Timer(window.MainWindow, 50, (e, args) =>
                {
                    frameDelay -= args.SecondsPassed;

                    if (frameDelay <= 0)
                    {
                        frameDelay   = 0.1;
                        image.Source = ImageResources.Loading[imageIndex++].ImageSource;
                        if (imageIndex > 7)
                        {
                            imageIndex = 0;
                        }
                    }
                });
                this.timer = timer;
                timer.Start();
                if (MainWindowLogic.AutoScrollEnabled)
                {
                    window.Output.ScrollToEnd();
                }
            });
        }