示例#1
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();
                }
            });
        }
示例#2
0
        //switch from daily basis to minutely.
        public static void Start(MainWindowLogic mainWindow)
        {
            var browsers = new Browser[instanceCount];

            Translate.mainWindow  = mainWindow;
            Language              = MainWindowLogic.Language;
            translateFromBrowsers = new Stack <Browser>(4);
            translateToDLBrowser  = new Browser();
            translateToDLBrowser.AsyncOpenUrl("https://www.deepl.com/translator");
            for (var i = 0; i < instanceCount; i++)
            {
                browsers[i] = new Browser();
                translateFromBrowsers.Push(browsers[i]);
                browsers[i].AsyncOpenUrl("https://www.deepl.com/translator");
            }
            thread              = new Thread(new ThreadStart(_CloseWatch));
            browserThread       = new Thread(new ThreadStart(BrowserThread));
            thread.IsBackground = true;
            thread.Start();
            browserThread.IsBackground = true;
            browserThread.Start();
        }
示例#3
0
 public DelayHandler(MainWindowLogic window) : this(window, MainWindowLogic.TextColor)
 {
 }