Exemplo n.º 1
0
        private void btnProcess_Click(object sender, EventArgs e)
        {
            try
            {
                Control      _control   = (sender as Control);
                FileTypeBase _processor = null;

                if (ConfirmAction(_control.Tag.ToString()))
                {
                    txtLog.Text += "Processing " + _control.Tag.ToString() + " files:\n\n";
                    txtLog.Refresh();
                    Application.DoEvents();

                    switch (_control.Name)
                    {
                    case "btnProcessEPub":
                        _processor = new EPub();

                        break;

                    case "btnProcessMP3":
                        _processor = new MP3();
                        break;

                    default:
                        return;
                    }
                    _processor.ProcessFolder(txtDirSource.Text, chkSubfolders.Checked, chkTra.Checked, txtLog);
                    txtLog.Text += "\n\n";
                    txtLog.Refresh();
                    Application.DoEvents();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + "=================" + ex.ToString());
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            LoadSettings();

            if (args.Length > 0)
            {
                //Use comand prompt execution
                try
                {
                    string   _folder        = "";
                    bool     _recursive     = false;
                    bool     _renameFiles   = false;
                    string[] _fileTypes     = new string[2];
                    int      _fileTypeIndex = 0;
                    for (int _i = 0; _i < args.Length; _i++)
                    {
                        switch (args[_i].Replace("/", "").Replace("\\", "").Replace("-", "").ToLower())
                        {
                        case "d":     // directory
                            _folder = args[++_i];
                            break;

                        case "s":     // include subfolders
                            _recursive = true;
                            break;

                        case "r":     // rename files
                            _renameFiles = true;
                            break;

                        case "mp3":
                        case "epub":
                            _fileTypes[_fileTypeIndex++] = args[_i];
                            break;

                        case "?":
                            string _helpMessage = "Syntax: ktanc2e.exe -<switch>\n\n";
                            _helpMessage += "-d <folder>\t- source directory/folder\n";
                            _helpMessage += "-mp3\t\t- process MP3 files\n";
                            _helpMessage += "-epub\t\t- process epub files\n";
                            _helpMessage += "-s\t\t- include subdirectories\n";
                            _helpMessage += "-r\t\t- rename files\n";
                            _helpMessage += "-?\t\t- show this message\n\n";
                            _helpMessage += "Example:\t";
                            _helpMessage += "ktanc2e.exe -d c:\\MyDocs -epub -mp3 -s -r\n";
                            MessageBox.Show(_helpMessage);
                            Environment.Exit(0);
                            break;

                        default:
                            break;
                        }
                    }

                    if (String.IsNullOrEmpty(_folder) && (_fileTypes.Length <= 0))
                    {
                        args = new string[0];
                    }
                    else
                    {
                        foreach (string _fileType in _fileTypes)
                        {
                            FileTypeBase _processor = null;
                            switch (_fileType.ToUpper())
                            {
                            case "EPUB":
                                _processor = new EPub();
                                break;

                            case "MP3":
                                _processor = new MP3();
                                break;

                            default:
                                continue;
                            }
                            _processor.ProcessFolder(_folder, _recursive, _renameFiles, Console.Out);
                            MessageBox.Show("Finished Succesufy.");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine("==================================");
                    Console.WriteLine(ex.ToString());
                }
            }

            if (args.Length <= 0)
            {
                // Show GUI
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new frmMain());
            }
        }