private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            LogsText.Clear();
            LanguageList.Items.Clear();

            LogsText.Text = "Downloading language list...\n";
            Task.Run(() => siteResponse = loadSite.DownloadString(url))
            .ContinueWith(c =>
            {
                foreach (Match line in lang.Matches(siteResponse))
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate
                    {
                        LanguageList.Items.Add(line.Groups[1].Value);
                    });
                }
                DispatcherInvoke(() => LogsText.Text += "Downloading language list Finished!" + Environment.NewLine);
            });
        }
        private void DownloadBtn_Click(object sender, RoutedEventArgs e)
        {
            LogsText.Clear();
            progressBar.Value = 0;

            int i = 0;

            LogsText.Text += "Downloading tessdata files..." + Environment.NewLine;

            var items = DownloadList.Items;

            try { taskDl?.Dispose(); } catch { }
            taskDl = Task.Run(async() =>
            {
                foreach (string item in items)
                {
                    if (!Directory.Exists(@".\tessdata"))
                    {
                        Directory.CreateDirectory(@".\tessdata");
                    }
                    i++;
                    if (File.Exists($@".\tessdata\{item}.traineddata"))
                    {
                        DispatcherInvoke(() => LogsText.Text += $"\n{item}.traineddata is exists!\n" + Environment.NewLine);
                        continue;
                    }
                    DispatcherInvoke(() => LogsText.Text += String.Format("{0}/{1} | Downloading: {2}..", i, DownloadList.Items.Count, item));
                    try
                    {
                        await DownloadLanguage(i, item.ToString());
                    }
                    catch (Exception ex)
                    {
                        //System.Windows.Forms.MessageBox.Show("Please create a folder named 'tessdata' in your Openbullet directory", "FOLDER MISSING", MessageBoxButtons.OK);
                        DispatcherInvoke(() => LogsText.Text += $"\n[{nameof(Exception).ToUpper()}] {ex}");
                    }
                }
            }).ContinueWith(_ =>
            {
                DispatcherInvoke(() => LogsText.Text += "Your chosen languages have been downloaded ");
            });
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            LogsText.Clear();
            LanguageList.Items.Clear();

            LogsText.Text = "Downloading language list...\n";
            Task.Run(() => siteResponse = loadSite.DownloadString(url))
            .ContinueWith(c =>
            {
                foreach (Match line in lang.Matches(siteResponse))
                {
                    var val = line.Groups[1].Value.Split('"').First();
                    Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate
                    {
                        LanguageList.Items.Add($"{Path.GetFileNameWithoutExtension(val)} ({Path.GetExtension(val).Split('.')[1]})");
                    });
                }
                DispatcherInvoke(() => LogsText.Text += "Downloading language list Finished!" + Environment.NewLine);
            });
        }
Example #4
0
        private void Debug_MessageWritten(object sender, MessageWrittenEventArgs e)
        {
            this.Dispatcher.Invoke(() =>
            {
                switch (e.Type)
                {
                case DebugMessageType.Error:
                    LogsText.AppendText($"[{DateTime.Now.ToString()}] ERROR : {e.Message}" + Environment.NewLine);
                    break;

                case DebugMessageType.General:
                    LogsText.AppendText($"[{DateTime.Now.ToString()}] GENERAL : {e.Message}" + Environment.NewLine);
                    break;
                }

                if (LogsText.LineCount == int.MaxValue - 1)
                {
                    LogsText.Clear();
                }

                LogsText.ScrollToEnd();
            });
        }