Ejemplo n.º 1
0
        public static void SetTaskbarOverlayIcon(this Form form, Icon icon, string description)
        {
            HResult result = TaskbarList.SetOverlayIcon(
                form.Handle, icon == null ? IntPtr.Zero : icon.Handle, description);

            result.ThrowIf();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Sets the progress value of the specified window's
 /// taskbar button.
 /// </summary>
 /// <param name="hwnd">The window handle.</param>
 /// <param name="current">The current value.</param>
 /// <param name="maximum">The maximum value.</param>
 public static void SetProgressValue(IntPtr hwnd, int current, int maximum)
 {
     if (Windows7OrGreater)
     {
         TaskbarList.SetProgressValue(hwnd, (ulong)current, (ulong)maximum);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Sets the progress value of the specified window's
 /// taskbar button.
 /// </summary>
 /// <param name="current">The current value.</param>
 /// <param name="maximum">The maximum value.</param>
 public static void SetProgressValue(long current, long maximum)
 {
     if (Windows7OrGreater)
     {
         TaskbarList.SetProgressValue(Application.OpenForms[0].Handle, (ulong)current, (ulong)maximum);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Draws the specified overlay icon on the specified window's
        /// taskbar button.
        /// </summary>
        /// <param name="icon">The overlay icon.</param>
        /// <param name="description">The overlay icon description.</param>
        public static void SetTaskbarOverlayIcon(Icon icon, string description)
        {
            HResult result = TaskbarList.SetOverlayIcon(
                Program.HackerWindowHandle, icon == null ? IntPtr.Zero : icon.Handle, description);

            result.ThrowIf();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Sets the progress state of the specified window's
 /// taskbar button.
 /// </summary>
 /// <param name="hwnd">The window handle.</param>
 /// <param name="state">The progress state.</param>
 public static void SetProgressState(IntPtr hwnd, ThumbnailProgressState state)
 {
     if (Windows7OrGreater)
     {
         TaskbarList.SetProgressState(hwnd, state);
     }
 }
Ejemplo n.º 6
0
 private static void SetProgressState(IntPtr hwnd, TaskbarProgressBarStatus state)
 {
     if (Enabled && IsPlatformSupported && hwnd != IntPtr.Zero)
     {
         TaskbarList.SetProgressState(hwnd, state);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Sets the progress value of the specified window's
 /// taskbar button.
 /// </summary>
 /// <param name="hwnd">The window handle.</param>
 /// <param name="current">The current value.</param>
 /// <param name="maximum">The maximum value.</param>
 public static void SetProgressValue(IntPtr hwnd, ulong current, ulong maximum)
 {
     if (Windows7OrGreater)
     {
         TaskbarList.SetProgressValue(hwnd, current, maximum);
     }
 }
        public List <ResultText> TranscribeViaVosk(string waveFileName, string modelFileName)
        {
            Directory.SetCurrentDirectory(_voskFolder);
            Vosk.Vosk.SetLogLevel(0);
            if (_model == null)
            {
                labelProgress.Text = LanguageSettings.Current.AudioToText.LoadingVoskModel;
                labelProgress.Refresh();
                Application.DoEvents();
                _model = new Model(modelFileName);
            }
            var rec = new VoskRecognizer(_model, 16000.0f);

            rec.SetMaxAlternatives(0);
            rec.SetWords(true);
            var list = new List <ResultText>();

            labelProgress.Text = LanguageSettings.Current.AudioToText.Transcribing;
            labelProgress.Text = string.Format(LanguageSettings.Current.AudioToText.TranscribingXOfY, _batchFileNumber, listViewInputFiles.Items.Count);
            labelProgress.Refresh();
            Application.DoEvents();
            var buffer = new byte[4096];

            _bytesWavTotal = new FileInfo(waveFileName).Length;
            _bytesWavRead  = 0;
            _startTicks    = DateTime.UtcNow.Ticks;
            timer1.Start();
            using (var source = File.OpenRead(waveFileName))
            {
                int bytesRead;
                while ((bytesRead = source.Read(buffer, 0, buffer.Length)) > 0)
                {
                    _bytesWavRead += bytesRead;
                    if (rec.AcceptWaveform(buffer, bytesRead))
                    {
                        var res     = rec.Result();
                        var results = ParseJsonToResult(res);
                        list.AddRange(results);
                    }
                    else
                    {
                        var res = rec.PartialResult();
                        textBoxLog.AppendText(res.RemoveChar('\r', '\n'));
                    }

                    if (_cancel)
                    {
                        TaskbarList.SetProgressState(_parentForm.Handle, TaskbarButtonProgressFlags.NoProgress);
                        return(null);
                    }
                }
            }

            var finalResult  = rec.FinalResult();
            var finalResults = ParseJsonToResult(finalResult);

            list.AddRange(finalResults);
            timer1.Stop();
            return(list);
        }
Ejemplo n.º 9
0
 public static void SetThumbnailTooltip(IntPtr hWnd, string tooltip)
 {
     if (!isWindowsVistaOrGreater || hWnd != IntPtr.Zero)
     {
         TaskbarList.SetThumbnailTooltip(hWnd, tooltip);
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Sets the progress state of the specified window's
 /// taskbar button.
 /// </summary>
 /// <param name="state">The progress state.</param>
 public static void SetProgressState(TaskbarState state)
 {
     if (Windows7OrGreater)
     {
         TaskbarList.SetProgressState(Application.OpenForms[0].Handle, state);
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Specifies that only a portion of the window's client area
        /// should be used in the window's thumbnail.
        /// </summary>
        /// <param name="hwnd">The window.</param>
        /// <param name="clipRect">The rectangle that specifies the clipped region.</param>
        private static void SetThumbnailClip(this Form form, Rectangle clipRect)
        {
            //Example: SetThumbnailClip(this, new Rectangle(button.Location, button.Size));
            Rect    rect = new Rect(clipRect.Left, clipRect.Top, clipRect.Right, clipRect.Bottom);
            HResult setThumbnailClipResult = TaskbarList.SetThumbnailClip(form.Handle, ref rect);

            setThumbnailClipResult.ThrowIf();
        }
Ejemplo n.º 12
0
 private static void SetProgressValue(IntPtr hwnd, int currentValue, int maximumValue = 100)
 {
     if (Enabled && IsPlatformSupported && hwnd != IntPtr.Zero)
     {
         currentValue = currentValue.Between(0, maximumValue);
         TaskbarList.SetProgressValue(hwnd, Convert.ToUInt32(currentValue), Convert.ToUInt32(maximumValue));
     }
 }
        private void VobSubOcrCharacter_Shown(object sender, EventArgs e)
        {
            textBoxCharacters.Focus();

            if (ActiveForm == null)
            {
                TaskbarList.StartBlink(_vobSubForm);
            }
        }
Ejemplo n.º 14
0
 private void IncrementAndShowProgress()
 {
     if (progressBar1.Value < progressBar1.Maximum)
     {
         progressBar1.Value++;
     }
     TaskbarList.SetProgressValue(Handle, progressBar1.Value, progressBar1.Maximum);
     labelProgress.Text = progressBar1.Value + " / " + progressBar1.Maximum;
 }
Ejemplo n.º 15
0
        public void EndLogging()
        {
            if ((m_fOwner != null) && (m_fOwner is MainForm))
            {
                TaskbarList.SetProgressState(m_fOwner, TbpFlag.NoProgress);
            }

            m_bCanClose = true;
        }
Ejemplo n.º 16
0
        public void StartLogging(string strOperation, bool bWriteOperationToLog)
        {
            SetProgressGlobal(strOperation, -1);
            m_bCanClose = false;

            if ((m_fOwner != null) && (m_fOwner is MainForm))
            {
                TaskbarList.SetProgressState(m_fOwner, TbpFlag.Indeterminate);
            }
        }
Ejemplo n.º 17
0
        private void GenerateBatch()
        {
            groupBoxInputFiles.Enabled = false;
            _batchFileNumber           = 0;
            textBoxLog.AppendText("Batch mode" + Environment.NewLine);
            foreach (ListViewItem lvi in listViewInputFiles.Items)
            {
                _batchFileNumber++;
                var videoFileName = lvi.Text;
                listViewInputFiles.SelectedIndices.Clear();
                lvi.Selected         = true;
                progressBar1.Maximum = 100;
                progressBar1.Value   = 0;
                progressBar1.Visible = true;
                var modelFileName = Path.Combine(_voskFolder, comboBoxModels.Text);
                buttonGenerate.Enabled  = false;
                buttonDownload.Enabled  = false;
                buttonBatchMode.Enabled = false;
                var waveFileName = GenerateWavFile(videoFileName, 0);
                textBoxLog.AppendText("Wav file name: " + waveFileName + Environment.NewLine);
                progressBar1.Style = ProgressBarStyle.Blocks;
                var transcript = TranscribeViaVosk(waveFileName, modelFileName);
                if (_cancel)
                {
                    TaskbarList.SetProgressState(_parentForm.Handle, TaskbarButtonProgressFlags.NoProgress);
                    if (!_batchMode)
                    {
                        DialogResult = DialogResult.Cancel;
                    }

                    groupBoxInputFiles.Enabled = true;
                    return;
                }

                var postProcessor = new AudioToTextPostProcessor(GetLanguage(comboBoxModels.Text))
                {
                    ParagraphMaxChars = Configuration.Settings.General.SubtitleLineMaximumLength * 2,
                };
                TranscribedSubtitle = postProcessor.Generate(transcript, checkBoxUsePostProcessing.Checked, true, true, true, true);

                SaveToSourceFolder(videoFileName);
                TaskbarList.SetProgressValue(_parentForm.Handle, _batchFileNumber, listViewInputFiles.Items.Count);
            }

            progressBar1.Visible = false;
            labelTime.Text       = string.Empty;

            TaskbarList.StartBlink(_parentForm, 10, 1, 2);
            MessageBox.Show(string.Format(LanguageSettings.Current.AudioToText.XFilesSavedToVideoSourceFolder, listViewInputFiles.Items.Count));
            groupBoxInputFiles.Enabled = true;
            buttonGenerate.Enabled     = true;
            buttonDownload.Enabled     = true;
            buttonBatchMode.Enabled    = true;
            DialogResult = DialogResult.Cancel;
        }
Ejemplo n.º 18
0
 private void SetProgressValue()
 {
     // must be Windows7orGreater
     switch (m_State)
     {
     case ThumbnailProgressState.Normal:
     case ThumbnailProgressState.Error:
     case ThumbnailProgressState.Paused:
         TaskbarList.SetProgressValue(Handle, (ulong)m_Value, (ulong)m_Maximum);
         break;
     }
 }
Ejemplo n.º 19
0
        private void VobSubOcrCharacter_Shown(object sender, EventArgs e)
        {
            textBoxCharacters.Focus();

            if (ActiveForm == null)
            {
                TaskbarList.StartBlink(
                    _vobSubForm,
                    Configuration.Settings.VobSubOcr.UnfocusedAttentionBlinkCount,
                    Configuration.Settings.VobSubOcr.UnfocusedAttentionPlaySoundCount,
                    2);
            }
        }
Ejemplo n.º 20
0
        public static void HideTaskbarProgress()
        {
            if (disableTaskbarProgress || !isWindowsVistaOrGreater)
            {
                return;
            }

            if (LastHwnd != IntPtr.Zero)
            {
                TaskbarList.SetProgressState(LastHwnd, TBPFLAG.TBPF_NOPROGRESS);
                LastHwnd = IntPtr.Zero;
            }
        }
Ejemplo n.º 21
0
 private static void SetProgressState(IntPtr hwnd, TaskbarProgressBarStatus state)
 {
     if (Enabled && IsPlatformSupported && hwnd != IntPtr.Zero)
     {
         try
         {
             TaskbarList.SetProgressState(hwnd, state);
         }
         catch (FileNotFoundException)
         {
             Enabled = false;
         }
     }
 }
Ejemplo n.º 22
0
        private void ButtonGenerate_Click(object sender, EventArgs e)
        {
            if (comboBoxModels.Items.Count == 0)
            {
                buttonDownload_Click(null, null);
                return;
            }

            if (_batchMode)
            {
                if (listViewInputFiles.Items.Count == 0)
                {
                    buttonAddFile_Click(null, null);
                    return;
                }

                GenerateBatch();
                TaskbarList.SetProgressState(_parentForm.Handle, TaskbarButtonProgressFlags.NoProgress);
                return;
            }

            progressBar1.Maximum = 100;
            progressBar1.Value   = 0;
            progressBar1.Visible = true;
            var modelFileName = Path.Combine(_voskFolder, comboBoxModels.Text);

            buttonGenerate.Enabled  = false;
            buttonDownload.Enabled  = false;
            buttonBatchMode.Enabled = false;
            var waveFileName = GenerateWavFile(_videoFileName, 0);

            textBoxLog.AppendText("Wav file name: " + waveFileName);
            textBoxLog.AppendText(Environment.NewLine);
            progressBar1.Style = ProgressBarStyle.Blocks;
            var transcript = TranscribeViaVosk(waveFileName, modelFileName);

            if (_cancel)
            {
                DialogResult = DialogResult.Cancel;
                return;
            }

            var postProcessor = new AudioToTextPostProcessor(GetLanguage(comboBoxModels.Text))
            {
                ParagraphMaxChars = Configuration.Settings.General.SubtitleLineMaximumLength * 2,
            };

            TranscribedSubtitle = postProcessor.Generate(transcript, checkBoxUsePostProcessing.Checked, true, true, true, true);
            DialogResult        = DialogResult.OK;
        }
Ejemplo n.º 23
0
        private static void SetProgressValue(IntPtr hwnd, int currentValue, int maximumValue = 100)
        {
            if (Enabled && IsPlatformSupported && hwnd != IntPtr.Zero)
            {
                currentValue = currentValue.Between(0, maximumValue);

                try
                {
                    TaskbarList.SetProgressValue(hwnd, Convert.ToUInt32(currentValue), Convert.ToUInt32(maximumValue));
                }
                catch (FileNotFoundException)
                {
                    Enabled = false;
                }
            }
        }
        private void ButtonGenerate_Click(object sender, EventArgs e)
        {
            if (comboBoxModels.Items.Count == 0)
            {
                buttonDownload_Click(null, null);
                return;
            }

            if (listViewInputFiles.Items.Count == 0)
            {
                return;
            }

            GenerateBatch();
            TaskbarList.SetProgressState(_parentForm.Handle, TaskbarButtonProgressFlags.NoProgress);
        }
        private void GenerateBatch()
        {
            groupBoxInputFiles.Enabled = false;
            _batchFileNumber           = 0;
            textBoxLog.AppendText("Batch mode" + Environment.NewLine);
            var postProcessor = new AudioToTextPostProcessor(GetLanguage(comboBoxModels.Text))
            {
                ParagraphMaxChars = Configuration.Settings.General.SubtitleLineMaximumLength * 2,
            };

            progressBar1.Visible = true;
            foreach (ListViewItem lvi in listViewInputFiles.Items)
            {
                _batchFileNumber++;
                var videoFileName = lvi.Text;
                listViewInputFiles.SelectedIndices.Clear();
                lvi.Selected = true;
                var modelFileName = Path.Combine(_voskFolder, comboBoxModels.Text);
                buttonGenerate.Enabled = false;
                buttonDownload.Enabled = false;
                var waveFileName = videoFileName;
                textBoxLog.AppendText("Wav file name: " + waveFileName + Environment.NewLine);
                var transcript = TranscribeViaVosk(waveFileName, modelFileName);
                if (_cancel)
                {
                    TaskbarList.SetProgressState(_parentForm.Handle, TaskbarButtonProgressFlags.NoProgress);
                    DialogResult = DialogResult.Cancel;
                    return;
                }

                TranscribedSubtitle = postProcessor.Generate(transcript, checkBoxUsePostProcessing.Checked, false, true, false, false);

                progressBar1.Value = (int)Math.Round(_batchFileNumber * 100.0 / _audioClips.Count, MidpointRounding.AwayFromZero);
                progressBar1.Refresh();
                Application.DoEvents();

                SaveToAudioClip(_batchFileNumber - 1);

                TaskbarList.SetProgressValue(_parentForm.Handle, _batchFileNumber, listViewInputFiles.Items.Count);
            }

            progressBar1.Value = 100;
            labelTime.Text     = string.Empty;
            PostFix(postProcessor);

            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 26
0
        public static void ShowTaskbarProgress(IntPtr hwnd, ThumbnailProgressState state)
        {
            if (disableTaskbarProgress || !isWindowsVistaOrGreater)
            {
                return;
            }

            HideTaskbarProgress();

            if (hwnd == IntPtr.Zero)
            {
                hwnd = GetHandleOfTheMainWindow();
            }

            if (hwnd != IntPtr.Zero)
            {
                LastHwnd = hwnd;
                TaskbarList.SetProgressState(LastHwnd, (TBPFLAG)state);
            }
        }
Ejemplo n.º 27
0
        private void RipSubtitles(string vobFileName, MemoryStream stream, int vobNumber)
        {
            long firstNavStartPts = 0;

            using (var fs = RetryOpenRead(vobFileName))
            {
                var  buffer   = new byte[0x800];
                long position = 0;
                progressBarRip.Maximum = 100;
                progressBarRip.Value   = 0;
                int  lba    = 0;
                long length = fs.Length;
                while (position < length && !_abort)
                {
                    int bytesRead = 0;

                    // Reading and test for IO errors... and allow abort/retry/ignore
                    var tryAgain = true;
                    while (tryAgain && position < length)
                    {
                        tryAgain = false;
                        try
                        {
                            fs.Seek(position, SeekOrigin.Begin);
                            bytesRead = fs.Read(buffer, 0, 0x800);
                        }
                        catch (IOException exception)
                        {
                            var result = MessageBox.Show(string.Format("An error occured while reading file: {0}", exception.Message), "", MessageBoxButtons.AbortRetryIgnore);
                            if (result == DialogResult.Abort)
                            {
                                return;
                            }

                            if (result == DialogResult.Retry)
                            {
                                tryAgain = true;
                            }

                            if (result == DialogResult.Ignore)
                            {
                                position += 0x800;
                                tryAgain  = true;
                            }
                        }
                    }

                    if (VobSubParser.IsMpeg2PackHeader(buffer))
                    {
                        var vsp = new VobSubPack(buffer, null);
                        if (IsSubtitlePack(buffer))
                        {
                            if (vsp.PacketizedElementaryStream.PresentationTimestamp.HasValue && _accumulatedPresentationTimestamp != 0)
                            {
                                UpdatePresentationTimestamp(buffer, _accumulatedPresentationTimestamp, vsp);
                            }

                            stream.Write(buffer, 0, 0x800);
                            if (bytesRead < 0x800)
                            {
                                stream.Write(Encoding.ASCII.GetBytes(new string(' ', 0x800 - bytesRead)), 0, 0x800 - bytesRead);
                            }
                        }
                        else if (IsPrivateStream2(buffer, 0x26))
                        {
                            if (Helper.GetEndian(buffer, 0x0026, 4) == 0x1bf && Helper.GetEndian(buffer, 0x0400, 4) == 0x1bf)
                            {
                                uint vobuSPtm = Helper.GetEndian(buffer, 0x0039, 4);
                                uint vobuEPtm = Helper.GetEndian(buffer, 0x003d, 4);

                                _lastPresentationTimestamp = vobuEPtm;

                                if (firstNavStartPts == 0)
                                {
                                    firstNavStartPts = vobuSPtm;
                                    if (vobNumber == 0)
                                    {
                                        _accumulatedPresentationTimestamp = -vobuSPtm;
                                    }
                                }
                                if (vobuSPtm + firstNavStartPts + _accumulatedPresentationTimestamp < _lastVobPresentationTimestamp)
                                {
                                    _accumulatedPresentationTimestamp += _lastNavEndPts - vobuSPtm;
                                }
                                else if (_lastNavEndPts > vobuEPtm)
                                {
                                    _accumulatedPresentationTimestamp += _lastNavEndPts - vobuSPtm;
                                }
                                _lastNavEndPts = vobuEPtm;
                            }
                        }
                    }
                    position += 0x800;

                    var progress = (int)((position * 100) / length);
                    if (progress != progressBarRip.Value)
                    {
                        progressBarRip.Value = progress;
                        TaskbarList.SetProgressValue(_taskbarFormHandle, (vobNumber * 100) + progressBarRip.Value, progressBarRip.Maximum * listBoxVobFiles.Items.Count);
                        Application.DoEvents();
                    }
                    lba++;
                }
            }
            _lastVobPresentationTimestamp = _lastPresentationTimestamp;
        }
Ejemplo n.º 28
0
        private void ButtonStartRippingClick(object sender, EventArgs e)
        {
            if (buttonStartRipping.Text == _language.Abort)
            {
                _abort = true;
                buttonStartRipping.Text = _language.StartRipping;
                return;
            }
            _abort = false;
            buttonStartRipping.Text       = _language.Abort;
            _lastPresentationTimestamp    = 0;
            _lastVobPresentationTimestamp = 0;
            _lastNavEndPts = 0;
            _accumulatedPresentationTimestamp = 0;

            progressBarRip.Visible = true;
            var ms = new MemoryStream();
            int i  = 0;

            foreach (string vobFileName in listBoxVobFiles.Items)
            {
                i++;
                labelStatus.Text = string.Format(_language.RippingVobFileXofYZ, Path.GetFileName(vobFileName), i, listBoxVobFiles.Items.Count);
                Refresh();
                Application.DoEvents();

                if (!_abort)
                {
                    RipSubtitles(vobFileName, ms, i - 1); // Rip/demux subtitle vob packs
                }
            }
            progressBarRip.Visible = false;
            TaskbarList.SetProgressState(_taskbarFormHandle, TaskbarButtonProgressFlags.NoProgress);
            buttonStartRipping.Enabled = false;
            if (_abort)
            {
                labelStatus.Text           = _language.AbortedByUser;
                buttonStartRipping.Text    = _language.StartRipping;
                buttonStartRipping.Enabled = true;
                return;
            }

            labelStatus.Text = string.Format(_language.ReadingSubtitleData);
            Refresh();
            Application.DoEvents();
            var vobSub = new VobSubParser(radioButtonPal.Checked);

            vobSub.Open(ms);
            ms.Close();
            labelStatus.Text = string.Empty;

            MergedVobSubPacks = vobSub.MergeVobSubPacks(); // Merge splitted-packs to whole-packs
            if (MergedVobSubPacks.Count == 0)
            {
                MessageBox.Show(Configuration.Settings.Language.Main.NoSubtitlesFound);
                buttonStartRipping.Text    = _language.StartRipping;
                buttonStartRipping.Enabled = true;
                return;
            }
            Languages = new List <string>();
            for (int k = 0; k < comboBoxLanguages.Items.Count; k++)
            {
                Languages.Add(comboBoxLanguages.Items[k].ToString());
            }

            buttonStartRipping.Text    = _language.StartRipping;
            buttonStartRipping.Enabled = true;
            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 29
0
        private void buttonRipWave_Click(object sender, EventArgs e)
        {
            if (listViewInputFiles.Items.Count == 0)
            {
                MessageBox.Show(Configuration.Settings.Language.BatchConvert.NothingToConvert);
                return;
            }
            _converting                = true;
            buttonRipWave.Enabled      = false;
            progressBar1.Style         = ProgressBarStyle.Blocks;
            progressBar1.Maximum       = listViewInputFiles.Items.Count;
            progressBar1.Value         = 0;
            progressBar1.Visible       = progressBar1.Maximum > 2;
            buttonInputBrowse.Enabled  = false;
            buttonSearchFolder.Enabled = false;
            _abort = false;
            listViewInputFiles.BeginUpdate();
            foreach (ListViewItem item in listViewInputFiles.Items)
            {
                item.SubItems[3].Text = "-";
            }
            listViewInputFiles.EndUpdate();
            Refresh();
            int index = 0;

            while (index < listViewInputFiles.Items.Count && _abort == false)
            {
                var item = listViewInputFiles.Items[index];
                item.SubItems[3].Text = Configuration.Settings.Language.AddWaveformBatch.ExtractingAudio;
                string fileName = item.Text;
                try
                {
                    string  targetFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".wav");
                    Process process;
                    try
                    {
                        string encoderName;
                        process        = AddWaveform.GetCommandLineProcess(fileName, -1, targetFile, Configuration.Settings.General.VlcWaveTranscodeSettings, out encoderName);
                        labelInfo.Text = encoderName;
                    }
                    catch (DllNotFoundException)
                    {
                        if (MessageBox.Show(Configuration.Settings.Language.AddWaveform.VlcMediaPlayerNotFound + Environment.NewLine +
                                            Environment.NewLine +
                                            Configuration.Settings.Language.AddWaveform.GoToVlcMediaPlayerHomePage,
                                            Configuration.Settings.Language.AddWaveform.VlcMediaPlayerNotFoundTitle, MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            Process.Start("http://www.videolan.org/");
                        }
                        buttonRipWave.Enabled = true;
                        return;
                    }

                    process.Start();
                    while (!process.HasExited && !_abort)
                    {
                        Application.DoEvents();
                    }


                    // check for delay in matroska files
                    var audioTrackNames      = new List <string>();
                    var mkvAudioTrackNumbers = new Dictionary <int, int>();
                    if (fileName.ToLower().EndsWith(".mkv", StringComparison.OrdinalIgnoreCase))
                    {
                        MatroskaFile matroska = null;
                        try
                        {
                            matroska = new MatroskaFile(fileName);

                            if (matroska.IsValid)
                            {
                                foreach (var track in matroska.GetTracks())
                                {
                                    if (track.IsAudio)
                                    {
                                        if (track.CodecId != null && track.Language != null)
                                        {
                                            audioTrackNames.Add("#" + track.TrackNumber + ": " + track.CodecId.Replace("\0", string.Empty) + " - " + track.Language.Replace("\0", string.Empty));
                                        }
                                        else
                                        {
                                            audioTrackNames.Add("#" + track.TrackNumber);
                                        }
                                        mkvAudioTrackNumbers.Add(mkvAudioTrackNumbers.Count, track.TrackNumber);
                                    }
                                }
                                if (mkvAudioTrackNumbers.Count > 0)
                                {
                                    _delayInMilliseconds = (int)matroska.GetTrackStartTime(mkvAudioTrackNumbers[0]);
                                }
                            }
                        }
                        catch
                        {
                            _delayInMilliseconds = 0;
                        }
                        finally
                        {
                            if (matroska != null)
                            {
                                matroska.Dispose();
                            }
                        }
                    }

                    item.SubItems[3].Text = Configuration.Settings.Language.AddWaveformBatch.Calculating;
                    MakeWaveformAndSpectrogram(fileName, targetFile, _delayInMilliseconds);

                    // cleanup
                    try
                    {
                        File.Delete(targetFile);
                    }
                    catch
                    {
                        // don't show error about unsuccessful delete
                    }

                    IncrementAndShowProgress();

                    item.SubItems[3].Text = Configuration.Settings.Language.AddWaveformBatch.Done;
                }
                catch
                {
                    IncrementAndShowProgress();
                    item.SubItems[3].Text = "ERROR";
                }
                index++;
            }
            _converting          = false;
            labelProgress.Text   = string.Empty;
            labelInfo.Text       = string.Empty;
            progressBar1.Visible = false;
            TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress);
            buttonRipWave.Enabled      = true;
            buttonInputBrowse.Enabled  = true;
            buttonSearchFolder.Enabled = true;
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Sets the specified window's thumbnail tooltip.
        /// </summary>
        /// <param name="hwnd">The window.</param>
        /// <param name="tooltip">The tooltip text.</param>
        private static void SetThumbnailTooltip(this Form form, string tooltip)
        {
            HResult setThumbnailTooltipResult = TaskbarList.SetThumbnailTooltip(form.Handle, tooltip);

            setThumbnailTooltipResult.ThrowIf();
        }