using System; using System.IO; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Flyinsono.Client.Test.Log; namespace Flyinsono.Client.Test { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { private MainWindowViewModel _mainWindowViewModel; public MainWindow() { var logEngine = new LogEngineImplement((s) => { AddLog(s); }); Logger.RegisterEngine(logEngine); AppManager.Instance.Initialize(); _mainWindowViewModel = new MainWindowViewModel(RunOnMainDispatcher); InitializeComponent(); DataContext = _mainWindowViewModel; } private void RunOnMainDispatcher(Action action) { App.MainDispatcher.Invoke(action); } private void AddLog(LogItem s) { Dispatcher.BeginInvoke(() => { if (_mainWindowViewModel != null) { _mainWindowViewModel.LogItems.Add(s); } }); } } }