Exemplo n.º 1
0
        public MainForm()
        {
            InitializeComponent();

            var executingAssembly = Assembly.GetExecutingAssembly();

            Icon  = Icon.ExtractAssociatedIcon(executingAssembly.Location);
            Text += $" - {executingAssembly.GetName().Version}";


            AudioProcessor.Init(); // clear logfile
            SettingsHandler.Load();
            imageHeightTextBox.ReadOnly = SettingsHandler.UseInputHeight;
            barCountTextBox.Text        = SettingsHandler.BarCount.ToString();
            smoothCheckBox.Checked      = SettingsHandler.ShouldCreateSmoothDuplicate;
            chunkSizeTextBox.Text       = SettingsHandler.ChunkSize.ToString();
            fileCountProgress.Visible   = false;

            _sourceFolderDialog.RootFolder = Environment.SpecialFolder.Desktop;
            _targetFolderDialog            = new FolderBrowserDialog();



            if (!string.IsNullOrEmpty(SettingsHandler.SourceDir))
            {
                _targetFolderDialog.SelectedPath = SettingsHandler.SourceDir;
                inputPathTextBox.Text            = SettingsHandler.SourceDir;
            }
            if (!string.IsNullOrEmpty(SettingsHandler.OutputDir))
            {
                _sourceFolderDialog.SelectedPath = SettingsHandler.OutputDir;
                outputPathTextBox.Text           = SettingsHandler.OutputDir;
            }



            #region find python

            if (!string.IsNullOrEmpty(SettingsHandler.PythonExe))
            {
                _locatePythonDialog.FileName = SettingsHandler.PythonExe;
                pythonLocTextBox.Text        = SettingsHandler.PythonExe;
            }
            else
            {
                _locatePythonDialog.FileName = "";
            }

            string pythonPath = Directory.GetDirectories("C:\\", "Python3*").FirstOrDefault();
            if (string.IsNullOrEmpty(pythonPath))
            {
                pythonPath = Directory.GetDirectories("C:\\Program Files\\", "Python3*").FirstOrDefault();
            }
            if (string.IsNullOrEmpty(pythonPath))
            {
                pythonPath = Path.Combine("%AppData%", "Local\\Programs");
            }

            _locatePythonDialog.InitialDirectory = pythonPath;
            #endregion

            _ffmpegWrapper  = new FfmpegWrapper("ffmpeg.exe");
            _imageProcessor = new ImageProcessor();

            useInputHeightForOutputCheckBox.Checked = true;
            generateButton.Text = GenerateButtonText;
        }