コード例 #1
0
ファイル: GUIWindow.xaml.cs プロジェクト: JTinkers/InfyniaBot
        public GUIWindow()
        {
            DataContext = ViewModel;

            InitializeComponent();

            var consoleWriter = new ConsoleRedirector();

            consoleWriter.TextWritten += (o, e) =>
            {
                ConsoleGUI.Dispatcher.Invoke(() =>
                {
                    ConsoleGUI.AppendText(e.Text);

                    if (!ConsoleGUI.IsFocused)
                    {
                        ConsoleGUI.ScrollToEnd();
                    }
                });
            };

            Console.SetOut(consoleWriter);

            var refreshTimer = new Timer();

            refreshTimer.Interval = 500;
            refreshTimer.Enabled  = true;
            refreshTimer.Elapsed += (t, args) =>
            {
                ViewModel.OnPropertyChanged("Level");
                ViewModel.OnPropertyChanged("Health");
                ViewModel.OnPropertyChanged("Mana");
                ViewModel.OnPropertyChanged("Position");
                ViewModel.OnPropertyChanged("IsPaused");
                ViewModel.OnPropertyChanged("Target");
                ViewModel.OnPropertyChanged("TargetDistance");
            };
        }