aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml.cs
blob: de2c728b05fe7ff0b5fde2ca2998ab9f8173dc10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
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.Shapes;

namespace Tango.MachineStudio.UI.Console
{
    /// <summary>
    /// Interaction logic for ConsoleWindow.xaml
    /// </summary>
    public partial class ConsoleWindow : MetroWindow
    {
        private ConsoleWindowVM _vm;

        public ConsoleWindow()
        {
            InitializeComponent();

            this.Loaded += (_, __) =>
            {
                _vm = this.DataContext as ConsoleWindowVM;
                _vm.SetLogTextBox(txtLog);
            };
        }

        //Auto scroll to bottom of response log each time it is changed.
        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            txtLog.SelectionStart = txtLog.Text.Length;
            txtLog.ScrollToEnd();
        }
    }
}
ss="k">set { _job = value; RaisePropertyChangedAuto(); } } /// <summary> /// Gets or sets the dye command. /// </summary> public RelayCommand DyeCommand { get; set; } /// <summary> /// Gets or sets the edit command. /// </summary> public RelayCommand EditCommand { get; set; } /// <summary> /// Initializes a new instance of the <see cref="JobSummeryViewVM"/> class. /// </summary> public JobSummeryViewVM() { RegisterForMessage<JobSelectedMessage>(HandleJobSelectedMessage); DyeCommand = new RelayCommand(StartJob); EditCommand = new RelayCommand(EditJob); } /// <summary> /// Handles the job selected message. /// </summary> /// <param name="message">The message.</param> private void HandleJobSelectedMessage(JobSelectedMessage message) { _context = message.Context; Job = message.Job; } /// <summary> /// Edits the job. /// </summary> private void EditJob() { LogManager.Log("Edit command pressed."); NavigationManager.NavigateTo<JobsModule>(false, nameof(JobView)); } /// <summary> /// Starts the job. /// </summary> private async void StartJob() { try { LogManager.Log("Start job command pressed. Starting job and navigating to job progress view..."); Job = await new JobBuilder(_context).Set(Job.Guid) .WithConfiguration() .WithRML() .WithUser() .WithSegments() .WithBrushStops() .BuildAsync(); PrintingManager.Print(Job, _context); await NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView)); } catch (Exception ex) { LogManager.Log(ex, "Could not start the current job."); await NotificationProvider.ShowError($"Cannot start job.\n{ex.Message}."); } } /// <summary> /// Called when the application has been started. /// </summary> public override void OnApplicationStarted() { } } }