Beispiel #1
0
        /// <summary>
        /// Owner draw the list items
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listBox21_DrawItem(object sender, OpenNETCF.Windows.Forms.DrawItemEventArgs e)
        {
            ////Draw the background
            //e.DrawBackground();
            ////Draw the focus rectangle
            //e.DrawFocusRectangle();

            e.Graphics.Clip = new Region(e.Bounds);
            //Draw the data
            if (e.Index <= this.listBox21.Items.Count - 1)
            {
                VoiceNote.VoiceNoteRow row = ((VoiceListItem)this.listBox21.Items[e.Index]).VoiceRow;
                if (row != null)
                {
                    using (Brush b = new SolidBrush(e.State == DrawItemState.Selected ? SystemColors.ActiveCaptionText : e.ForeColor))
                    {
                        //get the length of the data
                        string length = this.GetVoiceNoteLength(row.Data);
                        SizeF  size   = e.Graphics.MeasureString(length, e.Font);
                        int    y      = (e.Bounds.Height / 2 - (int)size.Height / 2) + e.Bounds.Top;

                        //Draw the date
                        e.Graphics.DrawString(this.GetDate(row.Date), e.Font, b, 2, y);

                        //Draw the length
                        e.Graphics.DrawString(length, e.Font, b, e.Bounds.Right - (int)size.Width - 2, y);
                    }
                }
            }
            e.Graphics.ResetClip();
        }
Beispiel #2
0
        /// <summary>
        /// Event handler when recording has stopped
        /// </summary>
        private void rec_DoneRecording()
        {
            using (new Cursor2())
            {
                //Unregister from the doneRecording event
                recorder.DoneRecording -= new WaveFinishedHandler(rec_DoneRecording);
                this.btnRecord.Text     = "Record";

                //Make sure the temp file exists
                if (File.Exists(this.tempVoicePath))
                {
                    //Save the data to the database
                    VoiceNote.VoiceNoteRow row = this.voiceNote1._VoiceNote.NewVoiceNoteRow();
                    row.Date = DateTime.Now;

                    //Get the memory stream buffer to save the voice note
                    this.recordingStream = new FileStream(this.tempVoicePath, FileMode.Open, FileAccess.Read);
                    byte[] buffer = new byte[this.recordingStream.Length];
                    this.recordingStream.Read(buffer, 0, (int)this.recordingStream.Length);
                    this.recordingStream.Close();
                    this.recordingStream = null;
                    row.Data             = buffer;

                    //Create a new key
                    row.Key = Guid.NewGuid();

                    //Save to the table
                    this.voiceNote1._VoiceNote.AddVoiceNoteRow(row);
                    this.voiceNoteTableAdapter1.Update(row);
                    this.UpdateList();
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Playes a voicenote
        /// </summary>
        private void PlayVoiceNote()
        {
            if (this.player.Playing)
            {
                this.player.Restart();
            }
            else
            {
                //Get the voice row
                VoiceNote.VoiceNoteRow row = ((VoiceListItem)this.listBox21.Items[this.listBox21.SelectedIndex]).VoiceRow;

                //Get the voice data stream
                FileStream fs = new FileStream(this.tempVoicePath, FileMode.Create, FileAccess.ReadWrite);
                fs.Write(row.Data, 0, row.Data.Length);
                fs.Close();
                Stream s = File.Open(this.tempVoicePath, FileMode.Open, FileAccess.Read);

                //Wire up to the events
                this.player.DonePlaying += new WaveDoneHandler(player_DonePlaying);
                this.player.Play((Stream)s);
            }
        }
Beispiel #4
0
 public VoiceListItem(VoiceNote.VoiceNoteRow row)
 {
     this.VoiceRow = row;
 }