Beispiel #1
0
        private void ExecuteCommand(object Settings)
        {
            // Cast object parameter as RunCommandSettings object
            RunCommandSettings rcSettings = Settings as RunCommandSettings;

            if (rcSettings == null)
            {
                return;
            }

            // Catch any errors (i.e. bad command, bad filename, bad anything)
            try
            {
                Process Process = new Process();
                // Expand environment variable to support %SYSTEMROOT%, etc.
                Process.StartInfo.FileName        = Environment.ExpandEnvironmentVariables(rcSettings.Command);
                Process.StartInfo.Arguments       = Environment.ExpandEnvironmentVariables(rcSettings.Arguments);
                Process.StartInfo.UseShellExecute = true;
                Process.Start();
            }
            catch
            {
                // Errors are stupid
            }
        }
Beispiel #2
0
        public string Serialize()
        {
            _Settings = _GUI.Settings;

            if (_Settings == null)
            {
                _Settings = new RunCommandSettings();
            }

            // Create json serializer to serialize json file
            DataContractJsonSerializer jSerial = new DataContractJsonSerializer(typeof(RunCommandSettings));

            // Open json file
            MemoryStream mStream = new MemoryStream();
            StreamWriter sWrite  = new StreamWriter(mStream);

            // Serialize actions into json file
            jSerial.WriteObject(mStream, _Settings);

            return(Encoding.Default.GetString(mStream.ToArray()));
        }
Beispiel #3
0
        public void Deserialize(string SerializedData)
        {
            // Clear existing settings if nothing was passed in
            if (String.IsNullOrEmpty(SerializedData))
            {
                _Settings = new RunCommandSettings();
                return;
            }

            // Create memory stream from serialized data string
            MemoryStream memStream = new MemoryStream(Encoding.Default.GetBytes(SerializedData));

            // Create json serializer to deserialize json file
            DataContractJsonSerializer jSerial = new DataContractJsonSerializer(typeof(RunCommandSettings));

            // Deserialize json file into actions list
            _Settings = jSerial.ReadObject(memStream) as RunCommandSettings;

            if (_Settings == null)
                _Settings = new RunCommandSettings();
        }
Beispiel #4
0
        public void Deserialize(string SerializedData)
        {
            // Clear existing settings if nothing was passed in
            if (String.IsNullOrEmpty(SerializedData))
            {
                _Settings = new RunCommandSettings();
                return;
            }

            // Create memory stream from serialized data string
            MemoryStream memStream = new MemoryStream(Encoding.Default.GetBytes(SerializedData));

            // Create json serializer to deserialize json file
            DataContractJsonSerializer jSerial = new DataContractJsonSerializer(typeof(RunCommandSettings));

            // Deserialize json file into actions list
            _Settings = jSerial.ReadObject(memStream) as RunCommandSettings;

            if (_Settings == null)
            {
                _Settings = new RunCommandSettings();
            }
        }
Beispiel #5
0
 public RunCommandUI(RunCommandSettings CommandSettings)
     : this()
 {
     Settings = CommandSettings;
 }
Beispiel #6
0
        public string Serialize()
        {
            _Settings = _GUI.Settings;

            if (_Settings == null)
                _Settings = new RunCommandSettings();

            // Create json serializer to serialize json file
            DataContractJsonSerializer jSerial = new DataContractJsonSerializer(typeof(RunCommandSettings));

            // Open json file
            MemoryStream mStream = new MemoryStream();
            StreamWriter sWrite = new StreamWriter(mStream);

            // Serialize actions into json file
            jSerial.WriteObject(mStream, _Settings);

            return Encoding.Default.GetString(mStream.ToArray());
        }
Beispiel #7
0
 public RunCommandUI(RunCommandSettings CommandSettings) : this()
 {
     Settings = CommandSettings;
 }