using LogoForceTestApp.Modules.MainModule.Models;
using Prism.Events;
using System;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Threading;
namespace LogoForceTestApp.Modules.MainModule.Views
{
///
/// MainPage.xaml 的交互逻辑
///
public partial class MainPage : System.Windows.Controls.UserControl
{
private readonly IEventAggregator _eventAggregator;
public MainPage(IEventAggregator eventAggregator)
{
_eventAggregator = eventAggregator;
_eventAggregator.GetEvent().Subscribe(WriteLog);
InitializeComponent();
}
private void WriteLog(Tuple 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, System.Windows.Input.KeyEventArgs e)
//{
// if (e.Key == Key.Enter)
// {
// TextBox3?.Focus();
// }
//}
//private void TextBox3_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
//{
// if (e.Key == Key.Enter)
// {
// TextBox4?.Focus();
// }
//}
//private void TextBox4_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
//{
// if (e.Key == Key.Enter)
// {
// TextBox5?.Focus();
// }
//}
//private void TextBox5_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
//{
// if (e.Key == Key.Enter)
// {
// TextBox6?.Focus();
// }
//}
//private void TextBox6_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
//{
// if (e.Key == Key.Enter)
// {
// TextBox7?.Focus();
// }
//}
//private void TextBox7_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
//{
// if (e.Key == Key.Enter)
// {
// TextBox8?.Focus();
// }
//}
//private void TextBox8_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
//{
// if (e.Key == Key.Enter)
// {
// TextBox9?.Focus();
// }
//}
//private void TextBox9_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
//{
// if (e.Key == Key.Enter)
// {
// TextBox10?.Focus();
// }
//}
}
}