Example #1
0
        /// <summary>
        /// Read a definition
        /// </summary>
        /// <param name="externalCommandConfiguration">IExternalCommandConfiguration</param>
        /// <param name="command">string</param>
        /// <returns>ExternalCommandDefinition</returns>
        public static ExternalCommandDefinition Read(this IExternalCommandConfiguration externalCommandConfiguration,
                                                     string command)
        {
            var definition = new ExternalCommandDefinition
            {
                Name    = command,
                Command = externalCommandConfiguration.Commandline[command]
            };

            if (externalCommandConfiguration.Argument.ContainsKey(command))
            {
                definition.Arguments = externalCommandConfiguration.Argument[command];
            }
            if (externalCommandConfiguration.Behaviors.ContainsKey(command))
            {
                definition.CommandBehavior = externalCommandConfiguration.Behaviors[command];
            }

            // Convert old values
            if (externalCommandConfiguration.RunInbackground.ContainsKey(command))
            {
                var runInBackground = externalCommandConfiguration.RunInbackground[command];
                if (runInBackground)
                {
                    definition.CommandBehavior |= CommandBehaviors.DeleteOnExit | CommandBehaviors.ProcessReturncode;
                }
            }

            return(definition);
        }
 public ExternalCommandMasterViewModel(
     IExternalCommandConfiguration externalCommandConfiguration,
     IExternalCommandLanguage externalCommandLanguage)
 {
     ExternalCommandConfiguration = externalCommandConfiguration;
     ExternalCommandLanguage      = externalCommandLanguage;
 }
Example #3
0
 /// <summary>
 /// Read a definition
 /// </summary>
 /// <param name="externalCommandConfiguration">IExternalCommandConfiguration</param>
 /// <param name="definition">ExternalCommandDefinition</param>
 public static void Write(this IExternalCommandConfiguration externalCommandConfiguration, ExternalCommandDefinition definition)
 {
     externalCommandConfiguration.Delete(definition.Name);
     externalCommandConfiguration.Commands.Add(definition.Name);
     externalCommandConfiguration.Commandline[definition.Name] = definition.Command;
     externalCommandConfiguration.Argument[definition.Name]    = definition.Arguments;
     externalCommandConfiguration.Behaviors[definition.Name]   = definition.CommandBehavior;
 }
 public ExternalCommandDestinationProvider(
     IExternalCommandConfiguration externalCommandConfiguration,
     ICoreConfiguration coreConfiguration,
     IGreenshotLanguage greenshotLanguage)
 {
     _externalCommandConfig = externalCommandConfiguration;
     _coreConfiguration     = coreConfiguration;
     _greenshotLanguage     = greenshotLanguage;
 }
 public ExternalCommandDestination(ExternalCommandDefinition defintion,
                                   IExternalCommandConfiguration externalCommandConfiguration,
                                   ICoreConfiguration coreConfiguration,
                                   IGreenshotLanguage greenshotLanguage
                                   ) : base(coreConfiguration, greenshotLanguage)
 {
     _externalCommandDefinition    = defintion;
     _externalCommandConfiguration = externalCommandConfiguration;
 }
Example #6
0
 public ExternalCommandConfigViewModel(
     IExternalCommandConfiguration externalCommandConfiguration,
     IExternalCommandLanguage externalCommandLanguage,
     IGreenshotLanguage greenshotLanguage,
     FileConfigPartViewModel fileConfigPartViewModel,
     ExternalCommandMasterViewModel externalCommandMasterViewModel)
 {
     ExternalCommandConfiguration   = externalCommandConfiguration;
     ExternalCommandLanguage        = externalCommandLanguage;
     GreenshotLanguage              = greenshotLanguage;
     FileConfigPartViewModel        = fileConfigPartViewModel;
     ExternalCommandMasterViewModel = externalCommandMasterViewModel;
 }
Example #7
0
        /// <summary>
        ///     Delete the configuration for the specified command
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="command">string with command</param>
        public static void Delete(this IExternalCommandConfiguration configuration, string command)
        {
            if (string.IsNullOrEmpty(command))
            {
                return;
            }
            configuration.Commands.Remove(command);
            configuration.Commandline.Remove(command);
            configuration.Argument.Remove(command);
            configuration.RunInbackground.Remove(command);
            if (!MsPaint.Equals(command) && !PaintDotNet.Equals(command))
            {
                return;
            }

            if (!configuration.DeletedBuildInCommands.Contains(command))
            {
                configuration.DeletedBuildInCommands.Add(command);
            }
        }
Example #8
0
        /// <summary>
        /// Fix some settings after loading
        /// </summary>
        /// <param name="configuration"></param>
        public static void AfterLoad(this IExternalCommandConfiguration configuration)
        {
            // Check if we need to add MsPaint
            if (HasPaint && !configuration.Commands.Contains(MsPaint) && !configuration.DeletedBuildInCommands.Contains(MsPaint))
            {
                configuration.Commands.Add(MsPaint);
                configuration.Commandline[MsPaint] = PaintPath;
                configuration.Argument[MsPaint]    = "\"{0}\"";
                configuration.Behaviors[MsPaint]   = CommandBehaviors.Default;
            }

            // Check if we need to add Paint.NET
            if (!HasPaintDotNet || configuration.Commands.Contains(PaintDotNet) ||
                configuration.DeletedBuildInCommands.Contains(PaintDotNet))
            {
                return;
            }

            configuration.Commands.Add(PaintDotNet);
            configuration.Commandline[PaintDotNet] = PaintDotNetPath;
            configuration.Argument[PaintDotNet]    = "\"{0}\"";
            configuration.Behaviors[PaintDotNet]   = CommandBehaviors.Default;
        }
Example #9
0
        /// <summary>
        /// Fix some settings after loading
        /// </summary>
        /// <param name="configuration"></param>
        public static void AfterLoad(this IExternalCommandConfiguration configuration)
        {
            // Check if we need to add MsPaint
            if (HasPaint && !configuration.Commands.Contains(MsPaint) && !configuration.DeletedBuildInCommands.Contains(MsPaint))
            {
                configuration.Commands.Add(MsPaint);
                configuration.Commandline.Add(MsPaint, PaintPath);
                configuration.Argument.Add(MsPaint, "\"{0}\"");
                configuration.RunInbackground.Add(MsPaint, true);
            }

            // Check if we need to add Paint.NET
            if (!HasPaintDotNet || configuration.Commands.Contains(PaintDotNet) ||
                configuration.DeletedBuildInCommands.Contains(PaintDotNet))
            {
                return;
            }

            configuration.Commands.Add(PaintDotNet);
            configuration.Commandline.Add(PaintDotNet, PaintDotNetPath);
            configuration.Argument.Add(PaintDotNet, "\"{0}\"");
            configuration.RunInbackground.Add(PaintDotNet, true);
        }
 public ExternalCommandPlugin(IGreenshotHost greenshotGreenshotHost, IExternalCommandConfiguration externalCommandConfiguration)
 {
     _greenshotHost         = greenshotGreenshotHost;
     _externalCommandConfig = externalCommandConfiguration;
 }