Esempio n. 1
0
        public MainForm(string[] args)
        {
#if DEBUG
#else
            if (args.Length == 0)
            {
                Environment.Exit(1);
            }
#endif
            Log.Output = Log.Mode.Quiet;

#if DEBUG
            _transport                     = new JObject();
            _transport.options             = Power.ShutdownOptions.Abort.ToString();
            _transport.aggregatedDelayTime = 0;
            _transport.period              = 6000;
#else
            _transport = JObject.Parse(Transform.DecodeBase64(args[0]));
#endif
            // Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("nl-BE");
            InitializeComponent();

            // Retrieve what configuration the prompt should use
            _options = Enum.Parse(typeof(Power.ShutdownOptions), _transport.options.ToString());

            btnAbort.Text = (_options == Power.ShutdownOptions.Abort)
                ? Strings.CANCEL
                : Strings.HIDE;

            _aggregatedDelayTime = _transport.aggregatedDelayTime;

            if (_transport.period == null)
            {
                return;
            }
            _gracePeriod = _transport.period;

            Log.Entry(LogName, _gracePeriod.ToString());
            if (_gracePeriod == 0)
            {
                return;
            }

            textBox1.Text = GenerateMessage();
            textBox1.Select(0, 0);

            progressBar1.Maximum = _gracePeriod - 1;
            label1.Text          = Time.FormatSeconds(_gracePeriod);

            SetColors();
            Localize();
            SwapBanner();
            GenerateDelays();
            PositionForm();
            this.ActiveControl = labelPostpone;

            Bus.SetMode(Bus.Mode.Client);
            Bus.Subscribe(Bus.Channel.Power, onPower);
        }
Esempio n. 2
0
        public MainForm(string[] args)
        {
            if (args.Length == 0)
                Environment.Exit(1);
            Log.Output = Log.Mode.Quiet;

            //_transport = new JObject();
            //_transport.options = Power.ShutdownOptions.Abort.ToString();
            //_transport.aggregatedDelayTime = 0;
            //_transport.period = 30;

            _transport = JObject.Parse(Transform.DecodeBase64(args[0]));
            InitializeComponent();

            // Retrieve what configuration the prompt should use
            _options = Enum.Parse(typeof(Power.ShutdownOptions), _transport.options.ToString());

            btnAbort.Text = (_options == Power.ShutdownOptions.Abort)
                ? "Cancel"
                : "Hide";

            _aggregatedDelayTime = _transport.aggregatedDelayTime;

            if (_transport.period == null)
                return;
            _gracePeriod = _transport.period;

            Log.Entry(LogName, _gracePeriod.ToString());
            if (_gracePeriod == 0)
                return;

            textBox1.Text = GenerateMessage();
            textBox1.Select(0, 0);

            progressBar1.Maximum = _gracePeriod - 1;
            label1.Text = Time.FormatSeconds(_gracePeriod);

            SetColors();
            SwapBanner();
            GenerateDelays();
            PositionForm();

            Bus.SetMode(Bus.Mode.Client);
            Bus.Subscribe(Bus.Channel.Power, onPower);
        }
Esempio n. 3
0
 public void Restart(string comment, Power.ShutdownOptions options = Power.ShutdownOptions.Abort, string message = null)
 {
     Power.QueueShutdown($"-r +0 \"{comment}\"", options, message);
 }
Esempio n. 4
0
 public void Shutdown(string comment, Power.ShutdownOptions options = Power.ShutdownOptions.Abort, string message = null)
 {
     Power.QueueShutdown($"/s /c \"{comment}\" /t 0", options, message);
 }