123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- using LogoForceTestApp.Modules.MainModule.Models;
- using Prism.Events;
- using System;
- using System.Windows.Controls;
- using System.Windows.Input;
- using System.Windows.Threading;
- namespace LogoForceTestApp.Modules.MainModule.Views
- {
- /// <summary>
- /// MainPage.xaml 的交互逻辑
- /// </summary>
- public partial class MainPage : UserControl
- {
- private readonly IEventAggregator _eventAggregator;
- public MainPage(IEventAggregator eventAggregator)
- {
- _eventAggregator = eventAggregator;
- _eventAggregator.GetEvent<LogEvent>().Subscribe(WriteLog);
- InitializeComponent();
-
- }
- private void WriteLog(Tuple<LogType, string> log)
- {
- ListBoxMessage?.Dispatcher?.BeginInvoke(DispatcherPriority.Render, new Action(() =>
- {
- if (ListBoxMessage.Items.Count > 100)
- {
- ListBoxMessage.Items.RemoveAt(0);
- }
- var (type, info) = log;
- var listBoxItem = new ListBoxItem
- {
- Content = info
- };
- if (log.Item1 == LogType.Error)
- listBoxItem.Foreground = System.Windows.Media.Brushes.Red;
- else if (log.Item1 == LogType.Warning)
- listBoxItem.Foreground = System.Windows.Media.Brushes.Yellow;
- else
- listBoxItem.Foreground = System.Windows.Media.Brushes.DarkOliveGreen;
- ListBoxMessage.Items.Add(listBoxItem);
- ListBoxMessage.ScrollIntoView(listBoxItem);
- }));
- }
- private void TextBox1_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox2?.Focus();
- }
- }
- private void TextBox2_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox3?.Focus();
- }
- }
- private void TextBox3_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox4?.Focus();
- }
- }
- private void TextBox4_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox5?.Focus();
- }
- }
-
- private void TextBox5_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox6?.Focus();
- }
- }
- private void TextBox6_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox7?.Focus();
- }
- }
- private void TextBox7_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox8?.Focus();
- }
- }
- private void TextBox8_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox9?.Focus();
- }
- }
- private void TextBox9_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox10?.Focus();
- }
- }
- private void TextBox10_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox11?.Focus();
- }
- }
- private void TextBox11_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox12?.Focus();
- }
- }
- private void TextBox12_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox13?.Focus();
- }
- }
- private void TextBox13_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox14?.Focus();
- }
- }
- private void TextBox14_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox15?.Focus();
- }
- }
- private void TextBox15_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox16?.Focus();
- }
- }
- private void TextBox16_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox17?.Focus();
- }
- }
- private void TextBox17_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox18?.Focus();
- }
- }
- private void TextBox18_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox19?.Focus();
- }
- }
- private void TextBox19_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox20?.Focus();
- }
- }
- private void TextBoxProCode_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- TextBox1?.Focus();
- }
- }
- }
- }
|