aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.FileSystem/Network/PerformDiskSpaceOptimizationRequest.cs
blob: bd69bf9d8ab2c3c4962a6038963eadafcd0ad545 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.FileSystem.Network
{
    public class PerformDiskSpaceOptimizationRequest
    {
    }
}
ackground-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core;
using Tango.Core.Commands;
using Tango.Core.DI;
using Tango.Integration.Operation;
using Tango.PPC.Common.Connection;
using Tango.PPC.Common.Notifications;

namespace Tango.PPC.Maintenance
{
    public abstract class MaintenanceCommand<T> : ExtendedObject
    {
        private IMachineProvider _machineProvider;
        [TangoInject(Mode = TangoInjectMode.WhenAvailable)]
        protected IMachineProvider MachineProvider
        {
            get { return _machineProvider; }
            set
            {
                _machineProvider = value; RaisePropertyChangedAuto();
                _machineProvider.MachineOperator.StatusChanged += MachineOperator_StatusChanged;
            }
        }

        [TangoInject(Mode = TangoInjectMode.WhenAvailable)]
        protected INotificationProvider NotificationProvider { get; set; }

        private RelayCommand _command;
        public RelayCommand Command
        {
            get { return _command; }
            set { _command = value; RaisePropertyChangedAuto(); }
        }

        private bool _isEnabled;
        public bool IsEnabled
        {
            get { return _isEnabled; }
            set { _isEnabled = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
        }

        private T _state;
        public T State
        {
            get { return _state; }
            set { _state = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
        }

        private void MachineOperator_StatusChanged(object sender, MachineStatuses e)
        {
            InvalidateRelayCommands();
        }

        public MaintenanceCommand()
        {
            TangoIOC.Default.Inject(this);
            IsEnabled = true;
            Command = new RelayCommand(Execute, CanExecute);
        }

        protected virtual bool CanExecute()
        {
            if (!IsEnabled) return false;
            if (MachineProvider == null) return false;
            if (!MachineProvider.MachineOperator.CanPrint) return false;

            return true;
        }

        private void Execute()
        {
            OnExecute();
        }

        protected abstract void OnExecute();
    }
}