aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs
blob: 93cea9485109161950563f8e6194bf5e28c
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Entities;
using Tango.Core.Commands;
using Tango.PPC.Common;
using Tango.PPC.Jobs.Messages;
using Tango.PPC.Jobs.Views;

namespace Tango.PPC.Jobs.ViewModels
{
    public class JobSummeryViewVM : PPCViewModel
    {
        private Job _job;
        /// <summary>
        /// Gets or sets the job.
        /// </summary>
        public Job Job
        {
            get { return _job; }
            set { _job = value; RaisePropertyChangedAuto(); }
        }

        public RelayCommand DyeCommand { get; set; }

        public RelayCommand EditCommand { get; set; }

        public JobSummeryViewVM()
        {
            RegisterForMessage<JobSelectedMessage>(HandleJobSelectedMessage);

            DyeCommand = new RelayCommand(StartJob);
            EditCommand = new RelayCommand(EditJob);
        }

        private void HandleJobSelectedMessage(JobSelectedMessage message)
        {
            Job = message.Job;
        }

        private void EditJob()
        {
            NavigationManager.NavigateTo<JobsModule>(false, nameof(JobView));
        }

        private void StartJob()
        {
            MachineProvider.MachineOperator.Print(Job);
            NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView));
        }

        public override void OnApplicationStarted()
        {

        }
    }
}