public override void Execute(ProtocolApplication app, string url)
        {
            url = RewriteUrl(url);

            var newUrl = url.Split('#');

            var urlParts = new List<string> { newUrl[0] };
            
            if (newUrl.Count() > 1)
            {
                NameValueCollection query = HttpUtility.ParseQueryString(newUrl[1]);
                
                var file = query.Get("file");
                if (file != null)
                    urlParts.Add(file);
                else
                    urlParts.Add("");

                var infohash = query.Get("infohash");
                if (infohash != null)
                    urlParts.Add(infohash);
                else
                    urlParts.Add("");
            }
            
            var fileArguments = app.FileArguments;
            for (int i = 1; i <= urlParts.Count(); i++)
                fileArguments = fileArguments.Replace($"\"%{i}\"", $"\"{escapeString(urlParts[i - 1])}\"");

            Debug.WriteLine("Resulting file:{0} arguments:{1}", app.FilePath, fileArguments);
            Process.Start(app.FilePath, fileArguments);

        }
 public virtual void Execute(ProtocolApplication app, string url)
 {
     url = RewriteUrl(url);
     Process.Start(app.FilePath, app.FileArguments.Replace("%1", escapeString(url)));
 }
        public List<ProtocolApplication> GetApplications() // Need to get selected application too, even if it is a selected file
        {
            var apps = new List<ProtocolApplication>();
            var currentExecutable = getSelectedExecutable();

            if (ApplicationExecutables != null)
                ApplicationExecutables.ForEach(ae => apps.Add(new ProtocolApplication(ae)));

            if (Applications != null)
                apps.AddRange(Applications);

            apps = apps.FindAll(app => app.Enabled);
            apps
                .FindAll(app => app.FilePath == currentExecutable)
                .ForEach(app => app.CurrentlySelected = true);
            

            if (!apps.Exists(app => app.CurrentlySelected) && currentExecutable != null && File.Exists(currentExecutable))
            {
                var registry = getRegistry();
                var arguments = (string)registry.GetValue(ExecutableArgumentsKey);
                var app = new ProtocolApplication(currentExecutable, currentExecutable, arguments);
                app.CurrentlySelected = true;
                apps.Add(app);
            }

            return apps;
        }
 public void SetApplication(ProtocolApplication app)
 {
     Debug.WriteLine("Setting application");
     var registry = getRegistry();
     registry.SetValue(ExecutablePathKey, app.FilePath);
     registry.SetValue(ExecutableArgumentsKey, app.FileArguments);
 }
 private void OnHandlerSelect(object sender, EventArgs e, ProtocolHandler handler)
 {
     var executable = OpenHandlerFileDialog();
     if (executable != null && executable.Length > 0)
     {
         var app = new ProtocolApplication(executable.Split('\\').Last(), executable);
         OnSelectApplication(sender, e, handler, app);
     }
 }
 private void OnSelectApplication(object sender, EventArgs e, ProtocolHandler handler, ProtocolApplication app)
 {
     Debug.WriteLine($"Setting handler for {handler.Name} to app {app.Name}");
     handler.SetApplication(app);
     UpdateTrayMenu();
 }