public static Int32 FromShutdownOption(ShutdownOption value)
        {
            Int32 rval;

            if (FromShutdownOption(value, out rval) == -1)
            {
                ThrowArgumentException(value);
            }
            return(rval);
        }
Example #2
0
        private bool TryCreateOption(out ShutdownOption option)
        {
            option = default;
            if (!TimeValue.HasValue)
            {
                return(false);
            }

            if (SelectActionUnit == null)
            {
                return(false);
            }

            if (SelectTimeUnit == null)
            {
                return(false);
            }

            var message = MessageModule.createNone();

            if (Msg != null)
            {
                var result = MessageModule.createMsg(Msg);
                if (result.IsError)
                {
                    return(false);
                }

                message = result.ResultValue;
            }

            var time = SelectTimeUnit.AsTimeSpan(TimeValue.Value);

            option = new ShutdownOption(
                SelectActionUnit.Action,
                TimeInSecond.NewTime(time),
                IsForceCloseWithoutSave ? CloseType.CloseWindowsWithoutSave : CloseType.SoftWindowsClose,
                message
                );

            return(true);
        }
		public static bool TryToShutdownOption (Int32 value, out ShutdownOption rval)
		{
			return ToShutdownOption (value, out rval) == 0;
		}
		private static extern int ToShutdownOption (Int32 value, out ShutdownOption rval);
		public static Int32 FromShutdownOption (ShutdownOption value)
		{
			Int32 rval;
			if (FromShutdownOption (value, out rval) == -1)
				ThrowArgumentException (value);
			return rval;
		}
		public static bool TryFromShutdownOption (ShutdownOption value, out Int32 rval)
		{
			return FromShutdownOption (value, out rval) == 0;
		}
		private static extern int FromShutdownOption (ShutdownOption value, out Int32 rval);
Example #8
0
 /// <summary>
 /// Shutdown Computer
 /// </summary>
 /// <param name="option">The option.</param>
 public static void Shutdown(ShutdownOption option)
 {
     NativeMethods.ShutdownWindows((int)option);
 }
 public static bool TryToShutdownOption(Int32 value, out ShutdownOption rval)
 {
     return(ToShutdownOption(value, out rval) == 0);
 }
 private static extern int ToShutdownOption(Int32 value, out ShutdownOption rval);
 public static bool TryFromShutdownOption(ShutdownOption value, out Int32 rval)
 {
     return(FromShutdownOption(value, out rval) == 0);
 }
 private static extern int FromShutdownOption(ShutdownOption value, out Int32 rval);