Exemplo n.º 1
0
        private void mWishlist_Click(object sender, EventArgs e)
        {
            frmPoolWishlist wl = new frmPoolWishlist();

            wl.ShowDialog();
            wl.Dispose();
        }
Exemplo n.º 2
0
        static bool HasArgumentsThatSkipMainForm()
        {
            Log(LogAction.WriteToLog, "Checking arguments");
            string CurrentArg;

            switch (Environment.GetCommandLineArgs().Length < 1)
            {
            case true:
                return(false);
            }

            for (int ArgIndex = 1; ArgIndex < Environment.GetCommandLineArgs().Length; ArgIndex++)
            {
                CurrentArg = Environment.GetCommandLineArgs()[ArgIndex];

                #region "-installprotocol"
                if (CurrentArg.ToLower().StartsWith("-installprotocol"))   // if the argument is installProtocol
                {
                    Config.Settings.Load(ConfigType.All);
                    frmSettings Settings = new frmSettings();
                    Settings.InstallProtocol = true;
                    Settings.ShowDialog();
                    Settings.Dispose();
                    return(true);
                }
                #endregion

                #region "-updateprotocol"
                else if (CurrentArg.ToLower().StartsWith("-updateprotocol"))
                {
                    if (CurrentArg.ToLower().StartsWith("-updateprotocol:tags"))
                    {
                        string NewPath = CurrentArg.Split('|')[1];
                    }
                    else if (CurrentArg.ToLower().StartsWith("-updateprotocol:pools"))
                    {
                        string NewPath = CurrentArg.Split('|')[1];
                    }
                    else if (CurrentArg.ToLower().StartsWith("-updateprotocol:images"))
                    {
                        string NewPath = CurrentArg.Split('|')[1];
                    }
                    else
                    {
                        return(false);
                    }
                    return(true);
                }
                #endregion

                #region "-settings", "*:configuresettings", "protocol", "-portable", "-schema", "configuresettings"
                else if (CurrentArg.ToLower().StartsWith("-settings") || CurrentArg.StartsWith("tags:configuresettings") || CurrentArg.StartsWith("pools:configuresettings") || CurrentArg.StartsWith("images:configuresettings") || CurrentArg.StartsWith("-protocol") || CurrentArg.StartsWith("-portable") || CurrentArg.StartsWith("-schema") || CurrentArg.StartsWith("configuresettings"))
                {
                    Config.Settings.Load(ConfigType.All);

                    frmSettings Settings = new frmSettings();
                    Settings.SwitchTab = true;

                    switch (CurrentArg.ToLower())
                    {
                    case "-settings":
                        Settings.Tab = 0;
                        break;

                    case "tags:configuresettings":
                        Settings.Tab = 1;
                        break;

                    case "pools:configuresettings":
                        Settings.Tab = 2;
                        break;

                    case "images:configuresettings":
                        Settings.Tab = 3;
                        break;

                    case "-protocol":
                        Settings.Tab = 4;
                        break;

                    case "-portable":
                        Settings.Tab = 5;
                        break;

                    case "-schema":
                        Settings.Tab = 6;
                        break;
                    }

                    Settings.ShowDialog();
                    Settings.Dispose();

                    return(true);
                }
                #endregion

                #region "tags:*" (only for pages)
                else if (CurrentArg.StartsWith("tags:"))
                {
                    CurrentArg = CurrentArg.Substring(5).Replace("|", " ");
                    if (CurrentArg == "start")
                    {
                        Log(LogAction.WriteToLog, "Using tags: protocol to start aphrodite");
                        PushedType = DownloadType.Tags;
                        return(false);
                    }
                    else
                    {
                        Log(LogAction.WriteToLog, "Some tags were passed to the program");
                        bool IsPage = false;
                        if (apiTools.IsValidPageLink(CurrentArg))
                        {
                            IsPage = true;
                        }

                        if (Config.Settings.Initialization.AutoDownloadWithArguments)
                        {
                            if (!Config.Settings.Initialization.SkipArgumentCheck)
                            {
                                using (frmArgumentDialog ArgumentDialog = new frmArgumentDialog(CurrentArg, DownloadType.Tags)) {
                                    switch (ArgumentDialog.ShowDialog())
                                    {
                                    case DialogResult.Yes:
                                        CurrentArg = ArgumentDialog.AppendedArgument;
                                        Config.Settings.Load(ConfigType.General);
                                        Config.Settings.Load(ConfigType.Tags);

                                        if (IsPage)
                                        {
                                            Downloader.Arguments.DownloadPage(CurrentArg);
                                        }
                                        else
                                        {
                                            Downloader.Arguments.DownloadTags(CurrentArg.Replace("%20", " "));
                                        }
                                        return(true);

                                    case DialogResult.No:
                                        CurrentArg = ArgumentDialog.AppendedArgument;
                                        Log(LogAction.WriteToLog, "Pushing the arguments to the main form");
                                        PushedArgument = CurrentArg;
                                        PushedType     = DownloadType.Tags;
                                        return(false);

                                    case DialogResult.Cancel:
                                        return(true);
                                    }
                                }
                            }

                            Config.Settings.Load(ConfigType.General);
                            Config.Settings.Load(ConfigType.Tags);

                            if (IsPage)
                            {
                                Downloader.Arguments.DownloadPage(CurrentArg);
                            }
                            else
                            {
                                Downloader.Arguments.DownloadTags(CurrentArg.Replace("%20", " "));
                            }
                        }
                        else
                        {
                            Log(LogAction.WriteToLog, "Pushing the arguments to the main form");
                            PushedArgument = CurrentArg;
                            PushedType     = DownloadType.Tags;
                            return(false);
                        }
                    }
                }
                #endregion

                #region "pools:"
                else if (CurrentArg.StartsWith("pools:"))
                {
                    CurrentArg = CurrentArg.Substring(6);

                    if (CurrentArg == "start")
                    {
                        Log(LogAction.WriteToLog, "Using pools: protocol to start aphrodite");
                        PushedType = DownloadType.Pools;
                        return(false);
                    }
                    else
                    {
                        Log(LogAction.WriteToLog, "A pool was passed to the program");
                        if (apiTools.IsValidPoolLink(CurrentArg))
                        {
                            Log(LogAction.WriteToLog, "It seems like it was a valid pool link.");
                            CurrentArg = apiTools.GetPoolOrPostId(CurrentArg);
                        }

                        if (Config.Settings.Initialization.AutoDownloadWithArguments)
                        {
                            if (!Config.Settings.Initialization.SkipArgumentCheck)
                            {
                                using (frmArgumentDialog ArgumentDialog = new frmArgumentDialog(CurrentArg, DownloadType.Pools)) {
                                    switch (ArgumentDialog.ShowDialog())
                                    {
                                    case DialogResult.Yes:
                                        CurrentArg = ArgumentDialog.AppendedArgument;
                                        Config.Settings.Load(ConfigType.General);
                                        Config.Settings.Load(ConfigType.Pools);
                                        Downloader.Arguments.DownloadPool(CurrentArg);
                                        return(true);

                                    case DialogResult.No:
                                        CurrentArg = ArgumentDialog.AppendedArgument;
                                        Log(LogAction.WriteToLog, "Pushing the arguments to the main form");
                                        PushedArgument = CurrentArg;
                                        PushedType     = DownloadType.Pools;
                                        return(false);

                                    case DialogResult.Cancel:
                                        return(true);
                                    }
                                }
                            }
                        }
                        else
                        {
                            Log(LogAction.WriteToLog, "Pushing the arguments to the main form");
                            PushedArgument = CurrentArg;
                            PushedType     = DownloadType.Pools;
                            return(false);
                        }
                    }
                }
                #endregion

                #region "images:"
                else if (CurrentArg.StartsWith("images:"))
                {
                    CurrentArg = CurrentArg.Substring(7);
                    if (CurrentArg == "start")
                    {
                        Log(LogAction.WriteToLog, "Using images: protocol to start aphrodite");
                        PushedType = DownloadType.Images;
                        return(false);
                    }
                    else
                    {
                        Log(LogAction.WriteToLog, "An image was passed to the program");
                        if (apiTools.IsValidImageLink(CurrentArg))
                        {
                            Log(LogAction.WriteToLog, "It seems like it was a valid image link.");
                            CurrentArg = apiTools.GetPoolOrPostId(CurrentArg);
                        }

                        if (Config.Settings.Initialization.AutoDownloadWithArguments)
                        {
                            if (!Config.Settings.Initialization.SkipArgumentCheck)
                            {
                                using (frmArgumentDialog ArgumentDialog = new frmArgumentDialog(CurrentArg, DownloadType.Images)) {
                                    switch (ArgumentDialog.ShowDialog())
                                    {
                                    case DialogResult.Yes:
                                        CurrentArg = ArgumentDialog.AppendedArgument;
                                        Config.Settings.Load(ConfigType.General);
                                        Config.Settings.Load(ConfigType.Images);
                                        Downloader.Arguments.DownloadImage(CurrentArg);
                                        return(true);

                                    case DialogResult.No:
                                        CurrentArg = ArgumentDialog.AppendedArgument;
                                        Log(LogAction.WriteToLog, "Pushing the arguments to the main form");
                                        PushedArgument = CurrentArg;
                                        PushedType     = DownloadType.Images;
                                        return(false);

                                    case DialogResult.Cancel:
                                        return(true);
                                    }
                                }
                            }

                            Config.Settings.Load(ConfigType.General);
                            Config.Settings.Load(ConfigType.Images);
                            Downloader.Arguments.DownloadImage(CurrentArg);
                            return(true);
                        }
                        else
                        {
                            Log(LogAction.WriteToLog, "Pushing the arguments to the main form");
                            PushedArgument = CurrentArg;
                            PushedType     = DownloadType.Images;
                            return(false);
                        }
                    }
                }
                #endregion

                #region "poolwl:*"
                else if (CurrentArg.StartsWith("poolwl:"))
                {
                    Config.Settings.Load(ConfigType.Pools);
                    if (CurrentArg == "poolwl:showwl")
                    {
                        frmPoolWishlist WishList = new frmPoolWishlist();
                        WishList.ShowDialog();
                    }
                    else if (CurrentArg == "start")
                    {
                        Log(LogAction.WriteToLog, "Using poolwl: protocol to start aphrodite");
                        return(false);
                    }
                    else
                    {
                        CurrentArg = CurrentArg.Substring(7).Replace("%$|%", " ");
                        string[] ArgumentSplit = CurrentArg.Split('|');
                        if (ArgumentSplit.Length == 2)
                        {
                            string url   = ArgumentSplit[0];
                            string title = title = ArgumentSplit[1];

                            if (apiTools.IsValidPoolLink(ArgumentSplit[0]))
                            {
                                title = title
                                        .Replace("%20", " ")
                                        .Replace("%22", "\"")
                                        .Trim(' ');

                                Config.Config_Pools.AppendToWishlist(title, url);
                            }
                            else
                            {
                                System.Media.SystemSounds.Hand.Play();
                            }
                        }
                    }
                    return(true);
                }
                #endregion

                #region "-redownloader"
                else if (CurrentArg.ToLower().StartsWith("-redownloader"))
                {
                    Config.Settings.Load(ConfigType.All);
                    frmRedownloader rDownloader = new frmRedownloader();
                    rDownloader.ShowDialog();
                    return(true);
                }
                #endregion

                #region "-blacklist"
                else if (CurrentArg.ToLower().StartsWith("-blacklist"))
                {
                    Config.Settings.Load(ConfigType.General);
                    frmBlacklist bList = new frmBlacklist();
                    bList.ShowDialog();
                    return(true);
                }
                #endregion
            }

            return(false);
        }