public void InvalidateVisualz() { if (m_AudioPaneViewModel.State.Audio.PlayStreamMarkers != null) { #if USE_NORMAL_LIST foreach (TreeNodeAndStreamDataLength marker in m_AudioPaneViewModel.State.Audio.PlayStreamMarkers) { #else LightLinkedList <TreeNodeAndStreamDataLength> .Item current = m_AudioPaneViewModel.State.Audio.PlayStreamMarkers.m_First; while (current != null) { TreeNodeAndStreamDataLength marker = current.m_data; #endif //USE_NORMAL_LIST marker.m_Tag1 = null; marker.m_Tag2 = null; #if USE_NORMAL_LIST } #else current = current.m_nextItem; } #endif //USE_NORMAL_LIST } InvalidateVisual(); }
public void FindInPlayStreamMarkersAndDo(long byteOffset, Func <long, long, TreeNode, int, long> matchFunc, Func <long, long, long, TreeNode, long> nonMatchFunc) { if (PlayStreamMarkers == null) { return; } TreeNode treeNode = null; long bytesRight = 0; long bytesLeft = 0; int index = -1; #if USE_NORMAL_LIST foreach (TreeNodeAndStreamDataLength marker in PlayStreamMarkers) { #else LightLinkedList <TreeNodeAndStreamDataLength> .Item current = PlayStreamMarkers.m_First; while (current != null) { TreeNodeAndStreamDataLength marker = current.m_data; #endif //USE_NORMAL_LIST treeNode = marker.m_TreeNode; index++; bytesRight += marker.m_LocalStreamDataLength; if (byteOffset < bytesRight || index == (PlayStreamMarkers.Count - 1) && byteOffset >= bytesRight) { long newMatch = matchFunc(bytesLeft, bytesRight, treeNode, index); if (newMatch == -1) { break; } byteOffset = newMatch; } else { long newMatch = nonMatchFunc(byteOffset, bytesLeft, bytesRight, treeNode); if (newMatch == -1) { break; } byteOffset = newMatch; } bytesLeft = bytesRight; #if USE_NORMAL_LIST } #else current = current.m_nextItem; } #endif //USE_NORMAL_LIST }
public bool FindInPlayStreamMarkers(long byteOffset, out TreeNode treeNode, out int index, out long bytesLeft, out long bytesRight) { treeNode = null; bytesRight = 0; bytesLeft = 0; index = -1; if (PlayStreamMarkers == null) { return(false); } #if USE_NORMAL_LIST foreach (TreeNodeAndStreamDataLength marker in PlayStreamMarkers) { #else LightLinkedList <TreeNodeAndStreamDataLength> .Item current = PlayStreamMarkers.m_First; while (current != null) { TreeNodeAndStreamDataLength marker = current.m_data; #endif //USE_NORMAL_LIST index++; bytesRight += marker.m_LocalStreamDataLength; if (byteOffset < bytesRight || index == (PlayStreamMarkers.Count - 1) && byteOffset >= bytesRight) { treeNode = marker.m_TreeNode; return(true); } bytesLeft = bytesRight; #if USE_NORMAL_LIST } #else current = current.m_nextItem; } #endif //USE_NORMAL_LIST return(false); }
public bool FindInPlayStreamMarkers(TreeNode treeNode, out int index, out long bytesLeft, out long bytesRight) { bytesRight = 0; bytesLeft = 0; index = -1; if (PlayStreamMarkers == null) { return(false); } #if USE_NORMAL_LIST foreach (TreeNodeAndStreamDataLength marker in PlayStreamMarkers) { #else LightLinkedList <TreeNodeAndStreamDataLength> .Item current = PlayStreamMarkers.m_First; while (current != null) { TreeNodeAndStreamDataLength marker = current.m_data; #endif //USE_NORMAL_LIST index++; bytesRight += marker.m_LocalStreamDataLength; if (treeNode == marker.m_TreeNode || treeNode.IsDescendantOf(marker.m_TreeNode)) { return(true); } bytesLeft = bytesRight; #if USE_NORMAL_LIST } #else current = current.m_nextItem; } #endif //USE_NORMAL_LIST return(false); }
public void ResetAll() { m_SecondaryAudioStream = null; PlayStream = null; // must be first because NotifyPropertyChange chain-reacts for DataLength (TimeString data binding) EndOffsetOfPlayStream = -1; PcmFormat = null; if (!Settings.Default.Audio_DisableSingleWavFileRecord) { //DebugFix.Assert(m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.EnforceSinglePCMFormat); if (m_viewModel != null && m_viewModel.m_RecordAndContinue && m_viewModel.m_UrakawaSession != null && m_viewModel.m_UrakawaSession.DocumentProject != null) { PcmFormatRecordingMonitoring = m_viewModel.m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.DefaultPCMFormat; } else { PcmFormatRecordingMonitoring = null; } } else { PcmFormatRecordingMonitoring = null; } PlayStreamMarkers = null; DataLength = -1; m_notifier.RaisePropertyChanged(() => m_viewModel.CanManipulateWaveForm); }
public void drawChunkInfos(DrawingContext drawingContext, double hoffset, double heightAvailable, double widthAvailable, double bytesPerPixel , ScaleTransform trans) { //double xZoomed = imageAndDraw == null ? -1 : imageAndDraw.m_originalX * zoom; //double wZoomed = imageAndDraw == null ? -1 : imageAndDraw.m_originalW * zoom; Tuple <TreeNode, TreeNode> treeNodeSelection = m_AudioPaneViewModel.m_UrakawaSession.GetTreeNodeSelection(); if (treeNodeSelection.Item1 != null && m_AudioPaneViewModel.State.Audio.PlayStreamMarkers != null) { //drawingContext.Pop(); //PushOpacity long sumData = 0; double pixelsLeft = 0; double pixelsRight = 0; double widthChunk = 0; m_marker_MouseOver_Left = null; m_marker_MouseOver_Right = null; #if USE_NORMAL_LIST foreach (TreeNodeAndStreamDataLength marker in m_AudioPaneViewModel.State.Audio.PlayStreamMarkers) { #else LightLinkedList <TreeNodeAndStreamDataLength> .Item current = m_AudioPaneViewModel.State.Audio.PlayStreamMarkers.m_First; while (current != null) { TreeNodeAndStreamDataLength marker = current.m_data; #endif //USE_NORMAL_LIST if (pixelsLeft > (hoffset + widthAvailable)) { break; } //if (m_MousePosX >= 0) //{ // //long timeInLocalUnits = m_AudioPaneViewModel.State.Audio.GetCurrentPcmFormat().Data. // // ConvertBytesToTime( // // m_AudioPaneViewModel.State.Audio.GetCurrentPcmFormat().Data. // // AdjustByteToBlockAlignFrameSize( // // (long) Math.Round(m_AudioPaneView.BytesPerPixel*(hoffset + m_MousePosX)))); // m_point1.X = m_MousePosX; // m_point1.Y = 0; // m_point2.X = m_MousePosX; // m_point2.Y = heightAvailable; // drawingContext.DrawLine(m_penTick, m_point1, m_point2); //} if (pixelsLeft > hoffset) { m_point1.X = pixelsLeft - hoffset; m_point2.X = m_point1.X; m_point1.Y = 0; m_point2.Y = heightAvailable; drawingContext.DrawLine(m_penPhrases, m_point1, m_point2); if (marker == m_marker_MouseGrab_Left) { m_marker_MouseGrab_Left_X = m_point1.X; } bool mouseMatch = m_MousePosX > 0 && m_MousePosX > m_point1.X - MOUSE_GRAB_OFFSET && m_MousePosX < m_point1.X + MOUSE_GRAB_OFFSET; bool highlightMark = mouseMatch || marker == m_marker_MouseGrab_Left; if (highlightMark) { if (mouseMatch) { m_marker_MouseOver_Left = marker; } double pt1x = m_point1.X; highlightMark_1: double p1X = highlightMark ? pt1x : m_MousePosX; m_point1.X = p1X - MOUSE_GRAB_OFFSET; m_point2.X = m_point1.X; drawingContext.DrawLine(!highlightMark ? m_penPhrases : m_penTick, m_point1, m_point2); m_point1.X = p1X + MOUSE_GRAB_OFFSET; m_point2.X = m_point1.X; drawingContext.DrawLine(!highlightMark ? m_penPhrases : m_penTick, m_point1, m_point2); if (highlightMark && marker == m_marker_MouseGrab_Left) { highlightMark = false; goto highlightMark_1; } } } pixelsRight = (sumData + marker.m_LocalStreamDataLength) / bytesPerPixel; if (pixelsRight > hoffset && pixelsRight < (hoffset + widthAvailable)) { m_point1.X = pixelsRight - hoffset; m_point2.X = m_point1.X; m_point1.Y = 0; m_point2.Y = heightAvailable; drawingContext.DrawLine(m_penPhrases, m_point1, m_point2); if (marker == m_marker_MouseGrab_Right) { m_marker_MouseGrab_Right_X = m_point1.X; } bool mouseMatch = m_MousePosX > 0 && m_MousePosX > m_point1.X - MOUSE_GRAB_OFFSET && m_MousePosX < m_point1.X + MOUSE_GRAB_OFFSET; bool highlightMark = mouseMatch || marker == m_marker_MouseGrab_Right; if (highlightMark) { if (mouseMatch) { m_marker_MouseOver_Right = marker; } double pt1x = m_point1.X; highlightMark_2: double p1X = highlightMark ? pt1x : m_MousePosX; m_point1.X = p1X - MOUSE_GRAB_OFFSET; m_point2.X = m_point1.X; drawingContext.DrawLine(!highlightMark ? m_penPhrases : m_penTick, m_point1, m_point2); m_point1.X = p1X + MOUSE_GRAB_OFFSET; m_point2.X = m_point1.X; drawingContext.DrawLine(!highlightMark ? m_penPhrases : m_penTick, m_point1, m_point2); if (highlightMark && marker == m_marker_MouseGrab_Right) { highlightMark = false; goto highlightMark_2; } } } widthChunk = pixelsRight - pixelsLeft; if (pixelsRight > hoffset && pixelsLeft < (hoffset + widthAvailable)) { if (widthChunk < 20) { sumData += marker.m_LocalStreamDataLength; pixelsLeft = pixelsRight; #if !USE_NORMAL_LIST current = current.m_nextItem; #endif //USE_NORMAL_LIST continue; } if (trans != null) { drawingContext.PushTransform(trans); } long timeInLocalUnits = m_AudioPaneViewModel.State.Audio.GetCurrentPcmFormat().Data.ConvertBytesToTime( m_AudioPaneViewModel.State.Audio.GetCurrentPcmFormat().Data.AdjustByteToBlockAlignFrameSize( (long)Math.Round(bytesPerPixel * (pixelsRight - pixelsLeft)))); double tickHeight = m_tickHeight; double chunkWidthForText = widthChunk - tickHeight - tickHeight - 1; // if (m_standardTextHeight <= 0) // { // var txt = new FormattedText("Test Height", // m_culture, // FlowDirection.LeftToRight, // m_typeFace, // 12, // m_phraseBrush //#if NET40 //, null, TextFormattingMode.Display //#endif //NET40 //); // m_standardTextHeight = txt.Height; // } string strTime = null; if (marker.m_Tag1 == null || !(marker.m_Tag1 is string)) { strTime = AudioPaneViewModel.FormatTimeSpan_Units(timeInLocalUnits); marker.m_Tag1 = strTime; } else { strTime = (string)marker.m_Tag1; } var formattedTextDuration = new FormattedText( strTime, m_culture, FlowDirection.LeftToRight, m_typeFace, 12 * (trans != null ? m_zoom : 1), m_timeTextBrush #if NET40 , null, TextFormattingMode.Display #endif //NET40 ); double formattedTextDurationWidth = formattedTextDuration.Width; double formattedTextDurationHeight = formattedTextDuration.Height; if (trans != null) { formattedTextDurationWidth *= (1 / m_zoom); formattedTextDurationHeight *= (1 / m_zoom); } formattedTextDuration.Trimming = TextTrimming.CharacterEllipsis; formattedTextDuration.MaxTextWidth = chunkWidthForText * (trans != null ? m_zoom : 1); formattedTextDuration.MaxTextHeight = (formattedTextDurationHeight + tickHeight) * (trans != null ? m_zoom : 1); double horizontalMargin = m_horizontalMargin; m_point3.X = pixelsLeft - hoffset + horizontalMargin + tickHeight; if (m_point3.X < tickHeight) { widthChunk += m_point3.X; m_point3.X = tickHeight; } m_point3.Y = heightAvailable - (formattedTextDurationHeight * 2) - tickHeight - tickHeight - tickHeight; double diff = (pixelsRight - hoffset) - widthAvailable; if (diff > 0) { widthChunk -= diff; } double minW = Math.Min(formattedTextDurationWidth + horizontalMargin + horizontalMargin, widthChunk - tickHeight - tickHeight - 1); if (minW > 0) { m_rectRect.X = m_point3.X - horizontalMargin; m_rectRect.Y = m_point3.Y; m_rectRect.Width = minW; m_rectRect.Height = formattedTextDurationHeight; //if (drawingGroup != null) //{ // if (imageAndDraw == null // || // ( // m_rectRect.Left >= xZoomed // && m_rectRect.Left < xZoomed + wZoomed // || // m_rectRect.Right > xZoomed // && m_rectRect.Right <= xZoomed + wZoomed // ) // ) // { // m_rectRect.X -= xZoomed; // if (m_rectRect.X <0) // { // m_rectRect.Width -= -m_rectRect.X; // m_rectRect.X = 0; // } // var rectGeo = new RectangleGeometry(m_rectRect); // rectGeo.Freeze(); // var rectGeoDraw = new GeometryDrawing(m_renderBrush, null, rectGeo); // rectGeoDraw.Freeze(); // drawingGroup.Children.Add(rectGeoDraw); // m_point4.X = m_point3.X; // m_point4.Y = m_point3.Y; // m_point4.X -= xZoomed; // if (m_point4.X >= 0) // { // var textGeo = formattedTextDuration.BuildGeometry(m_point4); // textGeo.Freeze(); // var textGeoDraw = new GeometryDrawing(m_timeTextBrush, null, textGeo); // textGeoDraw.Freeze(); // drawingGroup.Children.Add(textGeoDraw); // } // } //} //else //{ if (trans != null) { m_point3.X *= m_zoom; m_point3.Y *= m_zoom; m_rectRect.X *= m_zoom; m_rectRect.Y *= m_zoom; m_rectRect.Width *= m_zoom; m_rectRect.Height *= m_zoom; } drawingContext.DrawRectangle(m_renderBrush, null, m_rectRect); var clipGeo = new RectangleGeometry(m_rectRect); clipGeo.Freeze(); drawingContext.PushClip(clipGeo); drawingContext.DrawText(formattedTextDuration, m_point3); drawingContext.Pop(); //PushClip //} } if (chunkWidthForText <= 10) { sumData += marker.m_LocalStreamDataLength; pixelsLeft = pixelsRight; #if !USE_NORMAL_LIST current = current.m_nextItem; #endif //USE_NORMAL_LIST if (trans != null) { drawingContext.Pop(); } continue; } //QualifiedName qName = marker.m_TreeNode.GetXmlElementQName(); //string imgAlt = null; //if (qName != null && qName.LocalName.ToLower() == "img") //{ // XmlAttribute xmlAttr = marker.m_TreeNode.GetXmlProperty().GetAttribute("alt"); // if (xmlAttr != null) // { // imgAlt = xmlAttr.Value; // } //} //string nodeTxt = !String.IsNullOrEmpty(imgAlt) ? imgAlt : marker.m_TreeNode.GetTextMediaFlattened(false); string strText = null; FlowDirection flowDirection = FlowDirection.LeftToRight; if (marker.m_Tag2 == null || !(marker.m_Tag2 is string)) { TreeNode.StringChunkRange range = marker.m_TreeNode.GetTextFlattened_(); if (range != null && range.First != null && !String.IsNullOrEmpty(range.First.Str)) { if (range.First.Direction == TreeNode.TextDirection.RTL) { flowDirection = FlowDirection.RightToLeft; } StringBuilder strBuilder = new StringBuilder(range.GetLength()); TreeNode.ConcatStringChunks(range, -1, strBuilder); strBuilder.Replace("\r\n", ""); strBuilder.Replace("\n", ""); strBuilder.Replace(Environment.NewLine, ""); strText = strBuilder.ToString().Trim(); marker.m_Tag2 = strText; } } else { strText = (string)marker.m_Tag2; } if (!string.IsNullOrEmpty(strText)) { var formattedText = new FormattedText(strText, m_culture, flowDirection, m_typeFace, 12 * (trans != null ? m_zoom : 1), m_phraseBrush #if NET40 , null, TextFormattingMode.Display #endif //NET40 ); formattedText.Trimming = TextTrimming.CharacterEllipsis; formattedText.MaxTextWidth = chunkWidthForText * (trans != null ? m_zoom : 1); formattedText.MaxTextHeight = (formattedTextDurationHeight + tickHeight) * (trans != null ? m_zoom : 1); double formattedTextWidth = formattedText.Width; double formattedTextHeight = formattedText.Height; if (trans != null) { formattedTextWidth *= (1 / m_zoom); formattedTextHeight *= (1 / m_zoom); } //FormattedText formattedTextDots = null; m_point3.Y = heightAvailable - formattedTextDurationHeight - tickHeight - tickHeight; minW = Math.Min(formattedTextWidth + horizontalMargin + horizontalMargin, widthChunk - tickHeight - tickHeight - 1); //chunkWidthForText if (minW > 0) { m_rectRect.X = m_point3.X / m_zoom - horizontalMargin; m_rectRect.Y = m_point3.Y; m_rectRect.Width = minW; m_rectRect.Height = formattedTextDurationHeight; //if (drawingGroup != null) //{ // if (imageAndDraw == null // || // ( // m_rectRect.Left >= xZoomed // && m_rectRect.Left < xZoomed + wZoomed // || // m_rectRect.Right > xZoomed // && m_rectRect.Right <= xZoomed + wZoomed // ) // ) // { // m_rectRect.X -= xZoomed; // if (m_rectRect.X < 0) // { // m_rectRect.Width -= -m_rectRect.X; // m_rectRect.X = 0; // } // var rectGeo = new RectangleGeometry(m_rectRect); // rectGeo.Freeze(); // var rectGeoDraw = new GeometryDrawing(m_renderBrush, null, rectGeo); // rectGeoDraw.Freeze(); // drawingGroup.Children.Add(rectGeoDraw); // m_point3.X -= xZoomed; // if (m_point3.X >= 0) // { // var textGeo = formattedText.BuildGeometry(m_point3); // textGeo.Freeze(); // var textGeoDraw = new GeometryDrawing(m_phraseBrush, null, textGeo); // textGeoDraw.Freeze(); // drawingGroup.Children.Add(textGeoDraw); // } // } //} //else //{ //drawingContext.PushOpacity(0.6); if (trans != null) { //m_point3.X *= m_zoom; ==> X is "borrowed" from previous text render, already zoomed m_point3.Y *= m_zoom; m_rectRect.X *= m_zoom; m_rectRect.Y *= m_zoom; m_rectRect.Width *= m_zoom; m_rectRect.Height *= m_zoom; } drawingContext.DrawRectangle(m_renderBrush, null, m_rectRect); //Boolean mouseIn = m_MousePosX >= (pixelsLeft - hoffset) && // m_MousePosX < (pixelsRight - hoffset); //if (mouseIn) //{ // //drawingContext.Pop(); //PushOpacity //} var clipGeo = new RectangleGeometry(m_rectRect); clipGeo.Freeze(); drawingContext.PushClip(clipGeo); drawingContext.DrawText(formattedText, m_point3); drawingContext.Pop(); //PushClip //if (!mouseIn) //{ // //drawingContext.Pop(); //PushOpacity //} //if (false && formattedText.Width >= minW) //{ // formattedTextDots = new FormattedText(" ...", // m_culture, // FlowDirection.LeftToRight, // m_typeFace, // 12, // m_timeTextBrush // ); //} //if (formattedTextDots != null && formattedTextDots.Width < minW) //{ // m_point3.X = m_rectRect.X + m_rectRect.Width - formattedTextDots.Width; // m_rectRect.X = m_point3.X; // m_rectRect.Width = formattedTextDots.Width; // drawingContext.DrawRectangle(m_renderBrush, null, m_rectRect); // drawingContext.DrawText(formattedTextDots, m_point3); //} //} } } if (trans != null) { drawingContext.Pop(); } } sumData += marker.m_LocalStreamDataLength; pixelsLeft = pixelsRight; #if USE_NORMAL_LIST } #else current = current.m_nextItem; } #endif //USE_NORMAL_LIST //drawingContext.PushOpacity(0.6); } }
OpenPcmInputStreamOfManagedAudioMediaFlattened(DelegateAudioPcmStreamFound del, bool openSecondaryStream) { #if USE_NORMAL_LIST StreamWithMarkers? #else StreamWithMarkers #endif //USE_NORMAL_LIST val = OpenPcmInputStreamOfManagedAudioMedia(openSecondaryStream); if (val != null) { if (del != null) { del.Invoke( val. #if USE_NORMAL_LIST GetValueOrDefault(). #endif //USE_NORMAL_LIST m_Stream.Length ); } return(val); } #if USE_NORMAL_LIST List #else LightLinkedList #endif //USE_NORMAL_LIST <StreamWithMarkers> listStreamsWithMarkers = new #if USE_NORMAL_LIST List #else LightLinkedList #endif //USE_NORMAL_LIST <StreamWithMarkers>(); for (int index = 0; index < mChildren.Count; index++) { TreeNode node = mChildren.Get(index); #if USE_NORMAL_LIST StreamWithMarkers? #else StreamWithMarkers #endif //USE_NORMAL_LIST childVal = node.OpenPcmInputStreamOfManagedAudioMediaFlattened(del, openSecondaryStream); if (childVal != null) { listStreamsWithMarkers.Add( childVal #if USE_NORMAL_LIST .GetValueOrDefault() #endif //USE_NORMAL_LIST ); } } if (listStreamsWithMarkers.Count == 0) { return(null); } StreamWithMarkers returnVal = new StreamWithMarkers(); returnVal.m_SubStreamMarkers = new #if USE_NORMAL_LIST List #else LightLinkedList #endif //USE_NORMAL_LIST <TreeNodeAndStreamDataLength>(); #if USE_NORMAL_LIST List #else LightLinkedList #endif //USE_NORMAL_LIST <Stream> listStreams = new #if USE_NORMAL_LIST List #else LightLinkedList #endif //USE_NORMAL_LIST <Stream>(); #if USE_NORMAL_LIST List #else LightLinkedList #endif //USE_NORMAL_LIST <Stream> listSecondaryStreams = openSecondaryStream ? new #if USE_NORMAL_LIST List #else LightLinkedList #endif //USE_NORMAL_LIST <Stream>() : null; #if USE_NORMAL_LIST foreach (StreamWithMarkers strct in listStreamsWithMarkers) { listStreams.Add(strct.m_Stream); if (openSecondaryStream) { listSecondaryStreams.Add(strct.m_SecondaryStream); } returnVal.m_SubStreamMarkers.AddRange(strct.m_SubStreamMarkers); strct.m_SubStreamMarkers.Clear(); } #else LightLinkedList <StreamWithMarkers> .Item current = listStreamsWithMarkers.m_First; while (current != null) { StreamWithMarkers swm = current.m_data; listStreams.Add(swm.m_Stream); if (openSecondaryStream) { listSecondaryStreams.Add(swm.m_SecondaryStream); } returnVal.m_SubStreamMarkers.AddRange(swm.m_SubStreamMarkers); swm.m_SubStreamMarkers.Clear(); current = current.m_nextItem; } #endif //USE_NORMAL_LIST returnVal.m_Stream = new SequenceStream(listStreams); if (openSecondaryStream) { returnVal.m_SecondaryStream = new SequenceStream(listSecondaryStreams); } listStreamsWithMarkers.Clear(); listStreamsWithMarkers = null; return(returnVal); }