Ejemplo n.º 1
0
        static int Main(params string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool   allowOption = !(new string[] { "unpack", "repack", "pack", }).Contains(Path.GetFileNameWithoutExtension(Application.ExecutablePath).ToLower());
            string filename    = null;
            int    value       = CmdLine(allowOption, ref filename, args);

            if (value == -1)
            {
                return(-1);
            }
            if (!allowOption && value >= 0) // option specified
            {
                CopyableMessageBox.Show("Invalid command line: '" + Environment.CommandLine + "'.", "s3su", CopyableMessageBoxButtons.OK, CopyableMessageBoxIcon.Error);
                return(-1);
            }
            if (!allowOption)
            {
                switch (Path.GetFileNameWithoutExtension(Application.ExecutablePath).ToLower())
                {
                case "unpack": value = 0; break;

                case "repack": value = 1; break;

                case "pack": value = 2; break;

                default:
                    CopyableMessageBox.Show("Invalid command line: '" + Environment.CommandLine + "'.", "s3su", CopyableMessageBoxButtons.OK, CopyableMessageBoxIcon.Error);
                    return(-1);
                }
            }
            else if (value < 0)
            {
                ChooseMode cm = new ChooseMode();
                cm.ShowDialog();
                if (cm.Mode == -1)
                {
                    return(0);
                }
                value = cm.Mode;
            }

            switch (value)
            {
            case 0: Application.Run(filename == null ? new Unpack() : new Unpack(filename)); break;

            case 1: Application.Run(filename == null ? new Repack() : new Repack(filename)); break;

            case 2: Application.Run(filename == null ? new Pack() : new Pack(filename)); break;
            }
            return(0);
        }
Ejemplo n.º 2
0
        static int Main(params string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool allowOption = !(new string[] { "unpack", "repack", "pack", }).Contains(Path.GetFileNameWithoutExtension(Application.ExecutablePath).ToLower());
            string filename = null;
            int value = CmdLine(allowOption, ref filename, args);
            if (value == -1)
                return -1;
            if (!allowOption && value >= 0) // option specified
            {
                CopyableMessageBox.Show("Invalid command line: '" + Environment.CommandLine + "'.", "s3su", CopyableMessageBoxButtons.OK, CopyableMessageBoxIcon.Error);
                return -1;
            }
            if (!allowOption) switch (Path.GetFileNameWithoutExtension(Application.ExecutablePath).ToLower())
                {
                    case "unpack": value = 0; break;
                    case "repack": value = 1; break;
                    case "pack": value = 2; break;
                    default:
                        CopyableMessageBox.Show("Invalid command line: '" + Environment.CommandLine + "'.", "s3su", CopyableMessageBoxButtons.OK, CopyableMessageBoxIcon.Error);
                        return -1;
                }
            else if (value < 0)
            {
                ChooseMode cm = new ChooseMode();
                cm.ShowDialog();
                if (cm.Mode == -1)
                    return 0;
                value = cm.Mode;
            }

            switch (value)
            {
                case 0: Application.Run(filename == null ? new Unpack() : new Unpack(filename)); break;
                case 1: Application.Run(filename == null ? new Repack() : new Repack(filename)); break;
                case 2: Application.Run(filename == null ? new Pack() : new Pack(filename)); break;
            }
            return 0;
        }