Esempio n. 1
0
 private void OutPut(Uri from, object input) => Dispatcher.Invoke(() =>
 {
     Paragraph paragraphFrom = new Paragraph();
     paragraphFrom.Inlines.Add(new Run(DateTime.Now.ToString())
     {
         Foreground = Brushes.Blue
     });
     paragraphFrom.Inlines.Add(new Run("=>")
     {
         Foreground = Brushes.Yellow
     });
     paragraphFrom.Inlines.Add(new Run($"From {from.ToString()}")
     {
         Foreground = Brushes.Green
     });
     OutPutText.Document.Blocks.Add(paragraphFrom);
     Paragraph paragraph = new Paragraph();
     paragraph.Inlines.Add(new PackIcon()
     {
         Kind = PackIconKind.ConsoleLine, Margin = new Thickness(0, -3, 0, -3), Foreground = Brushes.Purple
     });
     paragraph.Inlines.Add(new Run(Regex.Replace(input.ToString(), "\n+$", ""))
     {
         Foreground = Brushes.Gray
     });
     OutPutText.Document.Blocks.Add(paragraph);
     OutPutText.ScrollToEnd();
 });
Esempio n. 2
0
 private void OutPutErr(object input) => Dispatcher.Invoke(() =>
 {
     OutPutText.Document.Blocks.Add(new Paragraph(new Run(DateTime.Now.ToString())
     {
         Foreground = Brushes.Blue
     }));
     Paragraph paragraph = new Paragraph();
     paragraph.Inlines.Add(new PackIcon()
     {
         Kind = PackIconKind.ErrorOutline, Margin = new Thickness(0, -3, 0, -3), Foreground = Brushes.Red
     });
     paragraph.Inlines.Add(new Run(input.ToString())
     {
         Foreground = Brushes.Red
     });
     OutPutText.Document.Blocks.Add(paragraph);
     OutPutText.ScrollToEnd();
 });
        private void ButtonSelectConfigFile_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog
            {
                InitialDirectory = Environment.CurrentDirectory,
                Filter           = "ini 配置文件|*.ini",
                Multiselect      = false,
            };

            if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                ViewModel.ConfigFilePath = fileDialog.FileName;
            }
            ;
            PushMessage("加载配置文件中。\n");
            if (Workbook != null)
            {
                Workbook.Save();
                Workbook.Close();
                SheetName2ExcelSheet.Clear();
                SheetConfigModels.Clear();
                BodyParams.Clear();
                SubjectParams.Clear();
                MailToParams.Clear();
                OutPutText.Clear();
                ParamsDict.Clear();
                buttonStart.Click        -= ButtonStart_Click;
                buttonSendTestMail.Click -= ButtonSendTestMail_Click;
            }
            bool loadSuccess = LoadConfig();

            if (loadSuccess)
            {
                buttonStart.Click        += ButtonStart_Click;
                buttonSendTestMail.Click += ButtonSendTestMail_Click;
            }
        }
 /// <summary>
 /// 将信息输出到textbox中
 /// </summary>
 /// <param name="message"></param>
 private void PushMessage(string message)
 {
     OutPutText.Append(message);
     ViewModel.Text = OutPutText.ToString();
     DoEvents();
 }
Esempio n. 5
0
 private void textChangeMessage(object sender, EventArgs e)
 {
     OutPutText.SelectionStart = OutPutText.TextLength;
     OutPutText.ScrollToCaret();
 }
Esempio n. 6
0
 private void OutPutText_OnTextChanged(object sender, TextChangedEventArgs e)
 {
     OutPutText.ScrollToEnd();
 }
Esempio n. 7
0
 //日志组件自动滚动到底部
 private void outputText_TextChanged(object sender, EventArgs e)
 {
     OutPutText.SelectionStart = OutPutText.Text.Length;
     OutPutText.ScrollToCaret();
 }