source: branches/Obi-OnTheFlyOperations/Obi/ProjectView/Waveform_Recording.cs @ 4675

Revision 4675, 26.7 KB checked in by chhavi-negi, 10 months ago (diff)

added method to ConvertTimeToPixels?
some more improvements in code

Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Text;
7using System.Windows.Forms;
8using urakawa.media.timing;
9using AudioLib;
10
11
12namespace Obi.ProjectView
13{
14    public partial class Waveform_Recording : UserControl
15    {
16        private ContentView m_ContentView = null;
17        private ProjectView m_ProjectView = null;
18        private float m_ZoomFactor;
19        private AudioLib.VuMeter m_VUMeter;
20        private System.Drawing.Graphics g;
21        private Pen pen_ChannelMono;
22        private Pen pen_Channel1;
23        private Pen pen_Channel2;
24        private Pen pen_HighContrastMono;
25        private Pen pen_HighContrastChannel1;
26        private Pen pen_HighContrastChannel2;
27        private Pen pen_WaveformBaseLine;
28        private Font myFont = new Font("Microsoft Sans Serif", 7);
29        private EmptyNode m_ExistingPhrase = null;
30        private int m_Counter = 0;
31        private int m_LocalTime = 0;
32        private ColorSettings m_ColorSettings;
33        private ColorSettings m_ColorSettingsHC;
34        private bool m_IsColorHighContrast = false;
35      //  private Dictionary<int, short> m_PointMMinChannelMap = new Dictionary<int, short>();
36      //  private Dictionary<int, short> m_PointMaxChannelMap = new Dictionary<int, short>();
37        private Pen pen = new Pen(Color.Black);
38        private List<int> listOfCurrentXLocation = new List<int>();
39        private List<int> listOfCurrentMinChannel1 = new List<int>();
40        private List<int> listOfCurrentMaxChannel1 = new List<int>();
41        private List<int> listOfCurrentMinChannel2 = new List<int>();
42        private List<int> listOfCurrentMaxChannel2 = new List<int>();
43        private int m_X = 0;
44        private int m_XCV = 0;
45        private Dictionary<int, string> m_MainDictionary = new Dictionary<int, string>();
46        private double timeOfAssetMilliseconds = 0;
47        private bool m_IsMaximized = false;
48        private bool m_IsToBeRepainted = false;
49        private int m_CounterWaveform = 0;
50        private Dictionary<int, string> m_CurrentDictionary = new Dictionary<int, string>();
51        private int m_OffsetLocation = 400;
52        private int m_StaticRecordingLocation = 0;
53        private int m_TotalPixelCount = 0;
54        private int m_Pass = 0;
55        private double m_InitialStaticTime = 0;
56       
57        public Waveform_Recording()
58        {
59            InitializeComponent();
60            m_ZoomFactor = 1.0f;
61            this.Height = Convert.ToInt32(104 * m_ZoomFactor);
62            g = this.CreateGraphics();
63            if (m_ProjectView != null && m_ProjectView.TransportBar.RecordingPhrase != null)
64                m_ExistingPhrase = m_ProjectView.TransportBar.RecordingPhrase;
65            Location = new Point(-400, Location.Y);
66            Size = new Size(10000, Height);
67            m_StaticRecordingLocation = -1;
68        }
69
70        private RecordingSession m_RecordingSession;
71        public RecordingSession RecordingSession { set { m_RecordingSession = value; } }
72
73        public ContentView contentView
74        {
75            get { return m_ContentView; }
76            set 
77            { 
78                m_ContentView = value;
79           //     if (m_ContentView != null) m_ContentView.SizeChanged += new EventHandler(Waveform_Recording_Resize);
80            }
81        }
82
83        public bool invertColor
84        {
85            get { return m_IsColorHighContrast; }
86            set { m_IsColorHighContrast = value; }
87        }
88
89        public ProjectView projectView
90        {
91            get { return m_ProjectView; }
92            set 
93            { 
94                m_ProjectView = value;
95                if (m_ProjectView != null)
96                {
97                    m_ProjectView.TransportBar.Recorder.PcmDataBufferAvailable += new AudioRecorder.PcmDataBufferAvailableHandler(OnPcmDataBufferAvailable_Recorder);
98                    m_ProjectView.ObiForm.Resize += new EventHandler(ObiForm_Resize);
99                    m_ColorSettings = m_ProjectView.ObiForm.Settings.ColorSettings;
100                    m_ColorSettingsHC = m_ProjectView.ObiForm.Settings.ColorSettingsHC;
101                    this.BackColor = m_ColorSettings.WaveformBackColor;
102                    pen_ChannelMono = m_ColorSettings.WaveformMonoPen;
103                    pen_Channel1 = m_ColorSettings.WaveformChannel1Pen;
104                    pen_Channel2 = m_ColorSettings.WaveformChannel2Pen;
105                    pen_WaveformBaseLine = m_ColorSettings.WaveformBaseLinePen;
106                    m_ProjectView.TransportBar.PhraseCreatedEvent += new EventHandler(Phrase_Created_Event);
107                    if (m_IsColorHighContrast)
108                    {
109                        pen_HighContrastMono = m_ColorSettingsHC.WaveformMonoPen;
110                        pen_HighContrastChannel1 = m_ColorSettingsHC.WaveformChannel1Pen;
111                        pen_HighContrastChannel2 = m_ColorSettingsHC.WaveformChannel2Pen;
112                    }
113                }
114            }
115        }
116
117        public AudioLib.VuMeter VUMeter
118        {
119            get { return m_VUMeter; }
120            set { m_VUMeter = value; }
121        }
122
123        public float zoomFactor
124        {
125            get { return m_ZoomFactor; }
126            set
127            {
128                m_ZoomFactor = value;
129                ZoomWaveform();
130            }
131        }
132
133        public int recordingTimeCursor
134        {
135            get { return m_ContentView.Width / 2 + 50; }
136        }
137
138        public void ZoomWaveform()
139        {
140            if (m_ContentView != null)
141                this.Size = new Size(m_ContentView.Width, Convert.ToInt32(104 * m_ZoomFactor));
142        }       
143
144        private void timer1_Tick(object sender, EventArgs e)
145        {
146            if (m_StaticRecordingLocation == -1)
147            {
148                Location = new Point(-m_OffsetLocation, Location.Y);
149                m_StaticRecordingLocation = recordingTimeCursor + Math.Abs( this.Location.X);
150            }
151               
152            m_XCV = m_X + Location.X;
153            int diff = m_XCV - recordingTimeCursor;
154            int newXLocation = (m_X - recordingTimeCursor) * -1;
155            if (Math.Abs(diff) > 2)
156            {
157                this.Location = new Point(newXLocation, this.Location.Y);
158                m_IsToBeRepainted = false;
159            }
160            if (newXLocation > 0)
161            {               
162                m_IsToBeRepainted = false;
163                Location = new Point(-m_OffsetLocation, Location.Y);               
164            }
165           
166            int difference = 0;
167            difference = this.Width - m_X - m_ContentView.Width;
168            if (difference == 20)
169            {
170                this.Location = new Point(-m_OffsetLocation, Location.Y);
171                //  listOfXLocation.Clear();
172                m_X = recordingTimeCursor + m_OffsetLocation;
173                m_StaticRecordingLocation = m_X;
174                ResetLists();
175                ResetWaveform();
176                m_Pass++;
177            }
178                   
179            if (m_VUMeter == null || m_ContentView == null) return;
180            g = this.CreateGraphics();
181           
182            if (m_ProjectView.TransportBar.Recorder.RecordingPCMFormat.NumberOfChannels == 1)
183            {
184                if(!m_IsColorHighContrast)
185                g.DrawLine(pen_ChannelMono, new Point(m_X, Height - (int)Math.Round(((minChannel1 - short.MinValue) * Height) / (float)ushort.MaxValue)),
186                        new Point(m_X, Height - (int)Math.Round(((maxChannel1 - short.MinValue) * Height) / (float)ushort.MaxValue)));
187                else
188                g.DrawLine(pen_HighContrastMono, new Point(m_X, Height - (int)Math.Round(((minChannel1 - short.MinValue) * Height) / (float)ushort.MaxValue)),
189                    new Point(m_X, Height - (int)Math.Round(((maxChannel1 - short.MinValue) * Height) / (float)ushort.MaxValue)));               
190            }
191            if (m_ProjectView.TransportBar.Recorder.RecordingPCMFormat.NumberOfChannels > 1)
192            {
193                if (!m_IsColorHighContrast)
194                {
195                    g.DrawLine(pen_Channel1, new Point(m_X, Height - (int)Math.Round(((minChannel1 - short.MinValue) * Height) / (float)ushort.MaxValue)),
196                        new Point(m_X, Height - (int)Math.Round(((maxChannel1 - short.MinValue) * Height) / (float)ushort.MaxValue)));
197                    g.DrawLine(pen_Channel2, new Point(m_X, Height - (int)Math.Round(((minChannel2 - short.MinValue) * Height) / (float)ushort.MaxValue)),
198                           new Point(m_X, Height - (int)Math.Round(((maxChannel2 - short.MinValue) * Height) / (float)ushort.MaxValue)));
199                }
200                else
201                {
202                    g.DrawLine(pen_HighContrastChannel1, new Point(m_X, Height - (int)Math.Round(((minChannel1 - short.MinValue) * Height) / (float)ushort.MaxValue)),
203                        new Point(m_X, Height - (int)Math.Round(((maxChannel1 - short.MinValue) * Height) / (float)ushort.MaxValue)));
204                    g.DrawLine(pen_HighContrastChannel2, new Point(m_X, Height - (int)Math.Round(((minChannel2 - short.MinValue) * Height) / (float)ushort.MaxValue)),
205                           new Point(m_X, Height - (int)Math.Round(((maxChannel2 - short.MinValue) * Height) / (float)ushort.MaxValue)));
206                }
207            }
208           
209            g.DrawLine(pen_WaveformBaseLine, 0, Height / 2, m_ContentView.Width, Height / 2);           
210           
211            g.DrawLine(pen_WaveformBaseLine, 0, Height / 2, Width, Height / 2);
212            string text = "";
213            Pen newPen = new Pen(SystemColors.Control);
214           
215            timeOfAssetMilliseconds =
216                   (double)m_ProjectView.TransportBar.Recorder.RecordingPCMFormat.ConvertBytesToTime(Convert.ToInt64 (m_ProjectView.TransportBar.Recorder.CurrentDurationBytePosition)) /
217                   Time.TIME_UNIT;
218            int timeInSeconds = Convert.ToInt32(timeOfAssetMilliseconds / 1000);
219            m_Counter++;
220            if (m_Counter == 10)
221            {
222                g.DrawLine(newPen, m_X, 0, m_X, Height);
223                if (timeInSeconds % 10 == 0 && m_LocalTime != timeInSeconds)
224                {
225                    text = timeInSeconds.ToString();
226                    g.DrawString(text, myFont, Brushes.Gray, m_X, Height - 12);
227                    if (!m_MainDictionary.ContainsKey(m_X))
228                        m_MainDictionary.Add(m_X, text); 
229                    m_LocalTime = timeInSeconds;
230                }
231                else
232                {
233                    if (!m_MainDictionary.ContainsKey(m_X))
234                        m_MainDictionary.Add(m_X, "");
235                }
236           
237                m_Counter = 0;
238                Console.WriteLine("LAT VAL IN DICT " + m_X);
239            }
240
241            if (m_ProjectView.TransportBar.CurrentState != TransportBar.State.Monitoring && m_ExistingPhrase != m_ProjectView.TransportBar.RecordingPhrase)
242                CreatePageorPhrase(m_X);
243            if ((m_ContentView.Width - m_XCV) > 600)
244            {             
245            //    this.Location = new Point(m_ContentView.Location.X, Location.Y);
246                  // m_IsMaximized = false;
247            }
248
249            listOfCurrentXLocation.Add(m_X); 
250             m_X++;
251             listOfCurrentMinChannel1.Add((int)minChannel1);
252             listOfCurrentMaxChannel1.Add((int)maxChannel1);
253             listOfCurrentMinChannel2.Add((int)minChannel2);
254             listOfCurrentMaxChannel2.Add((int)maxChannel2);
255             m_TotalPixelCount++;
256         }
257
258        private void ResetLists()
259        {
260            List<int> listOfMinChannel1Temp = new List<int>();
261            List<int> listOfMinChannel2Temp = new List<int>();
262            List<int> listOfMaxChannel1Temp = new List<int>();
263            List<int> listOfMaxChannel2Temp = new List<int>();
264            Dictionary<int, string> m_TempDictionary = new Dictionary<int, string>();
265            int calculatedKey = 0;
266            int tempXLocation = 0;
267
268            listOfMinChannel1Temp = listOfCurrentMinChannel1;
269            listOfMinChannel2Temp = listOfCurrentMinChannel2;
270            listOfMaxChannel1Temp = listOfCurrentMaxChannel1;
271            listOfMaxChannel2Temp = listOfCurrentMaxChannel2;
272            m_TempDictionary = m_MainDictionary;
273            tempXLocation = listOfCurrentXLocation[listOfCurrentXLocation.Count - 1];
274                       
275            listOfCurrentMinChannel1 = new List<int>();
276            listOfCurrentMinChannel2 = new List<int>();
277            listOfCurrentMaxChannel1 = new List<int>();
278            listOfCurrentMaxChannel2 = new List<int>();
279            m_MainDictionary = new Dictionary<int, string>();
280            m_InitialStaticTime = (m_ProjectView.TransportBar.Recorder.RecordingPCMFormat.ConvertBytesToTime(Convert.ToInt64(m_ProjectView.TransportBar.Recorder.CurrentDurationBytePosition)) /
281                        Time.TIME_UNIT);
282            for (int i = listOfMinChannel1Temp.Count - recordingTimeCursor; i <= listOfMinChannel1Temp.Count - 1; i ++)
283            {
284                if (i >= 0)
285                {
286                    listOfCurrentMinChannel1.Add(listOfMinChannel1Temp[i]);
287                    listOfCurrentMinChannel2.Add(listOfMinChannel2Temp[i]);
288                    listOfCurrentMaxChannel1.Add(listOfMaxChannel1Temp[i]);
289                    listOfCurrentMaxChannel2.Add(listOfMaxChannel2Temp[i]);
290                }
291            }
292
293            foreach (KeyValuePair<int, string> pair in m_TempDictionary)
294            {
295                if (pair.Key > tempXLocation - recordingTimeCursor && pair.Key < tempXLocation - 1)
296                {
297                    calculatedKey = pair.Key - (tempXLocation - recordingTimeCursor);
298                    m_MainDictionary.Add(calculatedKey + m_OffsetLocation, pair.Value);
299                }
300            }
301         
302        }
303
304        private double ConvertPixelsToTime(int pixels)
305        {
306            double timeInMilliseconds = 0;
307            timeInMilliseconds = pixels * 100;
308            return timeInMilliseconds;
309        }
310
311        private int ConvertTimeToPixels(double time)
312        {
313            int pixels = 0;
314            pixels = Convert.ToInt32(time * .01);
315            return pixels;
316        }
317
318        private void Waveform_Recording_VisibleChanged(object sender, EventArgs e)
319        {
320            if (this.Visible == true)
321            {
322                timer1.Start();
323                if(m_ContentView != null)
324                m_X = recordingTimeCursor;
325                Location = new Point(-m_OffsetLocation, Location.Y);
326                m_MainDictionary.Clear();
327            }
328            else
329            {
330                Location = new Point(-m_OffsetLocation, Location.Y);
331                timer1.Stop();
332            }
333            listOfCurrentMaxChannel1.Clear();
334            listOfCurrentMinChannel1.Clear();
335            listOfCurrentMinChannel2.Clear();
336            listOfCurrentMaxChannel2.Clear();
337            m_StaticRecordingLocation = -1;
338        }
339
340        private short[] m_Amp = new short[2];
341        private int m_AmpValue = 0;
342        short minChannel1;
343        short maxChannel1;
344        short minChannel2;
345        short maxChannel2;
346
347        public void OnPcmDataBufferAvailable_Recorder(object sender, AudioRecorder.PcmDataBufferAvailableEventArgs e)
348        {
349            if (e.PcmDataBuffer != null && e.PcmDataBuffer.Length > 1)
350            {
351                m_Amp[0] = e.PcmDataBuffer[0];
352                //m_Amp[1] = e.PcmDataBuffer[1];
353
354                minChannel1 = short.MaxValue;
355                            maxChannel1 = short.MinValue;
356int channels = m_ProjectView.TransportBar.Recorder.RecordingPCMFormat.NumberOfChannels ;
357int channel = 0;
358                int frameSize = m_ProjectView.TransportBar.Recorder.RecordingPCMFormat.BlockAlign ;
359                short [] samples = new short[e.PcmDataBufferLength];
360                Buffer.BlockCopy(e.PcmDataBuffer,0,samples,0,e.PcmDataBufferLength ) ;
361
362            //for (int i = 0 ; i < (int)Math.Ceiling(e.PcmDataBufferLength/ (float)frameSize); i += frameSize)
363                for (int i = channel; i < (int)Math.Ceiling(e.PcmDataBufferLength/ (float)frameSize); i += channels)
364            {
365               
366                                if (samples [i] < minChannel1) minChannel1 = samples [i];
367                                if (samples[i] > maxChannel1) maxChannel1 = samples [i];
368            }
369
370            if (channels > 1)
371            {
372                minChannel2 = short.MaxValue;
373                maxChannel2 = short.MinValue;
374                channel = 1;
375                for (int i = channel; i < (int)Math.Ceiling(e.PcmDataBufferLength / (float)frameSize); i += channels)
376                {
377                    if (samples[i] < minChannel2) minChannel2 = samples[i];
378                    if (samples[i] > maxChannel2) maxChannel2 = samples[i];
379                } 
380            }
381                m_AmpValue =  m_Amp[0] + (int) (m_Amp[1] *  Math.Pow(8, m_Amp.Length));
382               // m_PointMinChannelMap.Add(x_Loc, minChannel1);
383               // m_PointMaxChannelMap.Add(x_Loc, maxChannel1);
384               
385            }
386        }
387
388     /*   private void Waveform_Recording_Resize(object sender, EventArgs e)
389        {
390            System.Media.SystemSounds.Asterisk.Play () ;
391
392            RepaintWaveform();           
393        }*/
394
395        private void ObiForm_Resize(object sender, EventArgs e)
396        {
397         //   if (m_ProjectView.ObiForm.WindowState == FormWindowState.Maximized)
398            m_CounterWaveform = listOfCurrentMinChannel1.Count;
399           // m_OffsetLocation =
400            RepaintWaveform();
401        }
402
403        private void RepaintWaveform()
404        {
405            Font myFont = new Font("Microsoft Sans Serif", 7);
406            Pen newPen = new Pen(SystemColors.Control);
407            int xSize = SystemInformation.PrimaryMonitorSize.Width;
408            int tempm_X = m_X;
409
410            if (m_IsMaximized)
411            {
412                m_IsMaximized = false;
413                return;
414            }
415            m_IsMaximized = true;
416            int counterMin = listOfCurrentMinChannel1.Count;
417            int x = 0;
418            int counterMax = listOfCurrentMaxChannel2.Count;
419            int countToRepaint = 0;
420
421            if (m_ContentView != null)
422                x = recordingTimeCursor;
423            if (counterMin == 0)
424                return;
425            if (counterMin < 5)
426            { }
427            else
428            {
429                timer1.Stop();
430                if (m_CounterWaveform < xSize)
431                    countToRepaint = m_CounterWaveform;
432                else
433                    countToRepaint = xSize;
434               
435                for (int i = listOfCurrentMinChannel1.Count - 1; i >= 0; i--)
436                {
437                    if (m_ProjectView.TransportBar.Recorder.RecordingPCMFormat.NumberOfChannels == 1)
438                    {
439                        g.DrawLine(pen_Channel1, new Point(tempm_X, Height - (int)Math.Round(((listOfCurrentMinChannel1[i] - short.MinValue) * Height) / (float)ushort.MaxValue)),
440                        new Point(tempm_X, Height - (int)Math.Round(((listOfCurrentMaxChannel1[i] - short.MinValue) * Height) / (float)ushort.MaxValue)));
441                    }
442
443                    if (m_ProjectView.TransportBar.Recorder.RecordingPCMFormat.NumberOfChannels > 1)
444                    {
445                        g.DrawLine(pen_Channel1, new Point(tempm_X, Height - (int)Math.Round(((listOfCurrentMinChannel2[i] - short.MinValue) * Height) / (float)ushort.MaxValue)),
446                        new Point(tempm_X, Height - (int)Math.Round(((listOfCurrentMaxChannel2[i] - short.MinValue) * Height) / (float)ushort.MaxValue)));
447                    }                       
448                    tempm_X--;
449                  /*  if (this.Location.X < 0 &&
450                        (this.Location.X * -1) < listOfXLocation[i])
451                    {
452                        Console.WriteLine("Breaking refresh loop at:" + i) ;
453                        break;
454                    }*/
455                }
456               
457                foreach (KeyValuePair<int, string> pair in m_MainDictionary)
458                {
459                    if (!pair.Value.EndsWith("0"))
460                        g.DrawString(pair.Value, myFont, Brushes.Gray, pair.Key, 0);
461                    else
462                    {
463                        g.DrawLine(newPen, pair.Key, 0, pair.Key, Height);
464                        g.DrawString(pair.Value, myFont, Brushes.Gray, pair.Key, Height - 15);
465                    }
466                    g.DrawLine(newPen, pair.Key, 0, pair.Key, Height);                   
467                }
468                m_IsMaximized = false;
469                timer1.Start();
470            }
471        }
472
473        public void ResetWaveform()
474        {
475                Font myFont = new Font("Microsoft Sans Serif", 7);
476                Pen newPen = new Pen(SystemColors.Control);
477                int xSize = SystemInformation.PrimaryMonitorSize.Width;
478                int temp = m_X;
479                if (m_IsMaximized)
480                {
481                    m_IsMaximized = false;
482                    return;
483                }
484                m_IsMaximized = true;
485                int counterMin = listOfCurrentMinChannel1.Count;
486                int x = 0;
487                int counterMax = listOfCurrentMaxChannel2.Count;
488                int countToRepaint = 0;
489             
490                if (m_ContentView != null)
491                    x = recordingTimeCursor;
492                if (counterMin == 0)
493                    return;
494                if (counterMin < 5)
495                { }
496                else
497                {
498                    timer1.Stop();
499                    if (m_CounterWaveform < xSize)
500                        countToRepaint = m_CounterWaveform;
501                    else
502                        countToRepaint = xSize;
503           
504                    for (int i = counterMin - 1; i >= 0; i--)
505                    {
506                        if (m_ProjectView.TransportBar.Recorder.RecordingPCMFormat.NumberOfChannels == 1)
507                        {
508                            g.DrawLine(pen_Channel1, new Point(temp, Height - (int)Math.Round(((listOfCurrentMinChannel1[i] - short.MinValue) * Height) / (float)ushort.MaxValue)),
509                            new Point(temp, Height - (int)Math.Round(((listOfCurrentMaxChannel1[i] - short.MinValue) * Height) / (float)ushort.MaxValue)));
510                        }
511
512                        if (m_ProjectView.TransportBar.Recorder.RecordingPCMFormat.NumberOfChannels > 1)
513                        {
514                            g.DrawLine(pen_Channel1, new Point(temp, Height - (int)Math.Round(((listOfCurrentMinChannel2[i] - short.MinValue) * Height) / (float)ushort.MaxValue)),
515                            new Point(temp, Height - (int)Math.Round(((listOfCurrentMaxChannel2[i] - short.MinValue) * Height) / (float)ushort.MaxValue)));
516                        }
517                       
518                        temp--;
519                        /*  if (this.Location.X < 0 &&
520                              (this.Location.X * -1) < listOfXLocation[i])
521                          {
522                              Console.WriteLine("Breaking refresh loop at:" + i) ;
523                              break;
524                          }*/
525                    }
526
527                    foreach (KeyValuePair<int, string> pair in m_MainDictionary)
528                    {
529                        if (!pair.Value.EndsWith("0"))
530                            g.DrawString(pair.Value, myFont, Brushes.Gray, pair.Key, 0);
531                        else
532                        {
533                            g.DrawLine(newPen, pair.Key, 0, pair.Key, Height);
534                            g.DrawString(pair.Value, myFont, Brushes.Gray, pair.Key, Height - 15);
535                        }
536                        g.DrawLine(newPen, pair.Key, 0, pair.Key, Height);                     
537                    }
538
539                    m_IsMaximized = false;
540                    timer1.Start();
541                }       
542        }
543
544        public void Phrase_Created_Event(object sender, EventArgs e)
545        {
546            int lastItemInList = (int)(m_ProjectView.TransportBar.phDetectorPhraseTimingList[m_ProjectView.TransportBar.phDetectorPhraseTimingList.Count - 1] / 100);
547            int location = lastItemInList + recordingTimeCursor;
548
549            if (m_ProjectView.TransportBar.CurrentState != TransportBar.State.Monitoring)
550            CreatePageorPhrase(location);
551        }
552
553        private void CreatePageorPhrase(int xLocation)
554        {
555            string text = "";
556            if (m_ProjectView.TransportBar.RecordingPhrase.Role_ == EmptyNode.Role.Page)
557                text = "Page" + m_ProjectView.TransportBar.RecordingPhrase.PageNumber.ToString();
558            else if (m_ProjectView.TransportBar.RecordingPhrase.Role_ == EmptyNode.Role.Plain)
559                text = "Phrase";
560            g.DrawLine(pen, xLocation, 0, xLocation, Height);
561            g.DrawString(text, myFont, Brushes.Black, xLocation, 0);
562            m_ExistingPhrase = m_ProjectView.TransportBar.RecordingPhrase;
563
564            if (!m_MainDictionary.ContainsKey(xLocation))
565                m_MainDictionary.Add(xLocation, text);                   
566        }
567
568        protected override void OnPaint(PaintEventArgs e)
569        {
570            if (m_IsToBeRepainted)
571            {
572               // ResetLists();
573                RepaintWaveform();               
574            }
575            m_IsToBeRepainted = true;
576            m_IsMaximized = false;
577        }
578
579        private void Waveform_Recording_MouseClick(object sender, MouseEventArgs e)         
580        {
581            int initialPos = m_StaticRecordingLocation;
582            double time = 0;
583            int pixel = 0;
584            double timeTemp = 0;
585            Pen pen = new Pen(SystemColors.ControlDarkDark);
586
587            if (m_Pass > 0)
588                time = m_InitialStaticTime + ConvertPixelsToTime(e.X - initialPos);
589            else
590                time = ConvertPixelsToTime(e.X - initialPos);
591
592            timeTemp = time - m_InitialStaticTime;
593            if (m_Pass > 0)
594                pixel = ConvertTimeToPixels(timeTemp) + initialPos;
595            else
596                pixel = ConvertTimeToPixels(time) + initialPos;
597           
598            g.DrawLine(pen, pixel, 0, pixel, Height);
599            g.DrawString("Phrase", myFont, Brushes.Gray, pixel, Height - 15);
600        }               
601    }
602}
603
604
605
Note: See TracBrowser for help on using the repository browser.