public void SelectAll() { m_Logger.Log("AudioPaneView.SelectAll", Category.Debug, Priority.Medium); m_TimeSelectionLeftX = 0; WaveFormTimeSelectionRect.Visibility = Visibility.Visible; double width = MillisecondsPerPixelToPixelWidthConverter.calc(ZoomSlider.Value, m_ViewModel); #if DEBUG double widthReal = getWaveFormWidth(); DebugFix.Assert((long)Math.Round(width * 100) == (long)Math.Round(widthReal * 100)); #endif //DEBUG WaveFormTimeSelectionRect.Width = width; WaveFormTimeSelectionRect.SetValue(Canvas.LeftProperty, m_TimeSelectionLeftX); }
public void ZoomSelection() { m_Logger.Log("AudioPaneView.OnZoomSelection", Category.Debug, Priority.Medium); if (m_TimeSelectionLeftX < 0) { return; } double widthToUse = WaveFormScroll.ViewportWidth; //widthToUse -= 20; if (!m_ViewModel.State.Audio.HasContent) { // resets to MillisecondsPerPixelToPixelWidthConverter.defaultWidth //m_ForceCanvasWidthUpdate = false; ZoomSlider.Value += 1; return; } double width = MillisecondsPerPixelToPixelWidthConverter.calc(ZoomSlider.Value, m_ViewModel); #if DEBUG double widthReal = getWaveFormWidth(); DebugFix.Assert((long)Math.Round(width * 100) == (long)Math.Round(widthReal * 100)); #endif //DEBUG double newWidth = width * (widthToUse / WaveFormTimeSelectionRect.Width); //if (newWidth > 8000) //{ // newWidth = 8000; //safeguard...image too large //} long bytesPerPixel = m_ViewModel.State.Audio.DataLength / (long)Math.Round(newWidth); bytesPerPixel = m_ViewModel.State.Audio.GetCurrentPcmFormat().Data.AdjustByteToBlockAlignFrameSize(bytesPerPixel); double millisecondsPerPixel = m_ViewModel.State.Audio.GetCurrentPcmFormat().Data.ConvertBytesToTime(bytesPerPixel) / (double)AudioLibPCMFormat.TIME_UNIT; if (millisecondsPerPixel < ZoomSlider.Minimum) { ZoomSlider.Minimum = millisecondsPerPixel; } if (millisecondsPerPixel > ZoomSlider.Maximum) { ZoomSlider.Maximum = millisecondsPerPixel; } if (m_ViewModel.State.Audio.HasContent) { long selectionByteLeft = m_ViewModel.State.Audio.GetCurrentPcmFormat().Data.AdjustByteToBlockAlignFrameSize((long)Math.Round(m_TimeSelectionLeftX * BytesPerPixel)); long selectionByteRight = m_ViewModel.State.Audio.GetCurrentPcmFormat().Data.AdjustByteToBlockAlignFrameSize((long)Math.Round((m_TimeSelectionLeftX + WaveFormTimeSelectionRect.Width) * BytesPerPixel)); if (m_ViewModel.PlayBytePosition < selectionByteLeft || m_ViewModel.PlayBytePosition > selectionByteRight) { m_ViewModel.SetPlayHeadTimeBypassAutoPlay(selectionByteLeft); } } //m_ForceCanvasWidthUpdate = false; ZoomSlider.Value = millisecondsPerPixel; }