示例#1
0
        private async void ReadHTML_Click(object sender, RoutedEventArgs e)
        {
            HtmlTextBox.Text = await Task.Run(() => _scrapper.ReadHtml(_htmlLocalization));

            await Task.Delay(100);

            ConvertButton.IsEnabled = true;
            StatusTextBox.Text     += $"{DateTime.Now:T} Html file read\n";
            StatusTextBox.ScrollToEnd();
        }
示例#2
0
        private void SetStatus(string Message)
        {
            //Check for cross threading
            if (StatusTextBox.Dispatcher.CheckAccess() == false)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action <string>)SetStatus, Message);
                return;
            }

            StatusTextBox.AppendText(Environment.NewLine + Message);
            StatusTextBox.ScrollToEnd();
        }
示例#3
0
        /// <summary>
        /// Displays a work progress message in the status textbox.
        /// Right now this only displays items that have failed validation. Mostly
        /// this is there to show that the application is working and isn't stalled out.
        /// </summary>
        /// <param name="message"></param>
        void AppendStatusMessage(string message)
        {
            if (message == null || message == "")
            {
                return;
            }

            // Add results to the data grid as soon as they are available
            StatusTextBox.Text += Environment.NewLine + Environment.NewLine;
            StatusTextBox.Text += message;
            StatusTextBox.Focus();
            StatusTextBox.CaretIndex = StatusTextBox.Text.Length;
            StatusTextBox.ScrollToEnd();
        }
示例#4
0
        private async void GoogleServices_Click(object sender, RoutedEventArgs e)
        {
            _googleApi.CreateGoogleToken(_credentialsLocalization);
            await Task.Delay(200);

            StatusTextBox.Text += $"{DateTime.Now:T} Generated Google token\n";
            StatusTextBox.ScrollToEnd();
            _googleApi.CreateGoogleCalendarService();
            await Task.Delay(200);

            AddEventsButton.IsEnabled = true;
            StatusTextBox.Text       += $"{DateTime.Now:T} Created Google calendar service\n";
            StatusTextBox.ScrollToEnd();
        }
示例#5
0
        private async void Convert_Click(object sender, RoutedEventArgs e)
        {
            HtmlTextBox.Text = await Task.Run(() => _scrapper.ConvertHtmlToClass(_scrapper.TableElements));

            await Task.Delay(200);

            if (_credentialsLocalization == null)
            {
                ErrorLabel.Content = "Please add credentials.json and press Convert again";
            }
            else
            {
                ErrorLabel.Content             = "";
                GoogleServicesButton.IsEnabled = true;
                StatusTextBox.Text            += $"{DateTime.Now:T} Html file converted\n";
                StatusTextBox.ScrollToEnd();
            }
        }
示例#6
0
 private void ShowStatus(string str, bool newline = true)
 {
     if (App.Current != null)
     {
         if (newline)
         {
             App.Current.Dispatcher.Invoke((Action) delegate {
                 StatusTextBox.AppendText(str + '\n');
                 StatusTextBox.ScrollToEnd();
             });
         }
         else
         {
             App.Current.Dispatcher.Invoke((Action) delegate {
                 StatusTextBox.AppendText(str);
             });
         }
     }
 }
示例#7
0
        private async void LoadCredentials_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "JSON (*.json)|*.json";
                if (ofd.ShowDialog() == true)
                {
                    _credentialsLocalization            = ofd.FileName;
                    CredentialsLocalizationTextBox.Text = ofd.FileName;
                    await Task.Delay(200);

                    StatusTextBox.Text += $"{DateTime.Now:T} Credentials file loaded\n";
                    StatusTextBox.ScrollToEnd();
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                throw;
            }
        }
示例#8
0
        private async void LoadHtml_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();

                ofd.Filter = "Html (*.html)|*.html";
                if (ofd.ShowDialog() == true)
                {
                    _htmlLocalization            = ofd.FileName;
                    HtmlLocalizationTextBox.Text = ofd.FileName;
                    await Task.Delay(200);

                    ReadHtmlButton.IsEnabled = true;
                    StatusTextBox.Text      += $"{DateTime.Now:T} Html file loaded\n";
                    StatusTextBox.ScrollToEnd();
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                throw;
            }
        }
示例#9
0
 private void OnDialerStateChanged(DialerStateChangedMessage message)
 {
     StatusTextBox.AppendText(message.Message + Environment.NewLine);
     StatusTextBox.ScrollToEnd();
 }
示例#10
0
 /// <summary>
 /// Событие по изминению текста, перемещает скрол в конец текстбокса.
 /// </summary>
 private void StatusTextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     StatusTextBox.ScrollToEnd();
 }
示例#11
0
 private void SafeUpdateStatus(string statusText)
 {
     StatusTextBox.AppendText(statusText);
     StatusTextBox.ScrollToEnd();
 }
示例#12
0
 public void ScrollToEnd()
 {
     StatusTextBox.ScrollToEnd();
 }
示例#13
0
 private void AddEvent_Click(object sender, RoutedEventArgs e)
 {
     _googleApi.AddEventToCalendar(_scrapper.Lessons, int.Parse(ReminderTextBox.Text));
     StatusTextBox.Text += $"{DateTime.Now:T} Added {_scrapper.Lessons.Count} lessons to your schedule. Enjoy\n";
     StatusTextBox.ScrollToEnd();
 }