using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace CrashDumpSender { public partial class PreviewForm : Form { public PreviewForm(CrashDumpSenderForm parentForm) { InitializeComponent(); parent = parentForm; } int currentIndex = 0; string screen_directory = ""; int frameCount = 0; CrashDumpSenderForm parent = null; public class FrameRange { public int Start = 0; public int End = 0; }; FrameRange frameRange = new FrameRange(); public string generateName(int index) { string key = String.Format("{0:00000000}", index); string res = screen_directory + @"/screenITF" + key + ".jpg"; return res; } public void init(string fileSrc,string soundFile) { screen_directory = Path.GetDirectoryName(fileSrc); //get all the files in this directory //... DirectoryInfo di = new DirectoryInfo(screen_directory); FileInfo[] rgFiles = di.GetFiles("*.jpg"); frameCount = rgFiles.Length; trackBarFrame.Maximum = frameCount-1; frameRange.Start = 0; frameRange.End = trackBarFrame.Maximum; updateInfos(); updateFrameRange(); previewJpg.ImageLocation = generateName(0); float videoLength = ((1000.0f / 30.0f) * frameCount)/1000.0f; labelVideoLength.Text = "Video Length: " + videoLength.ToString(); if (File.Exists(soundFile)) { WaveFileReader file = new WaveFileReader(soundFile); file.read(); labelSoundLength.Text = "Sound Length: " + file.m_data.dSecLength.ToString(); file = null; } } public void next() { currentIndex++; } private void updateInfos() { previewJpg.ImageLocation = generateName(currentIndex); int frameCountMax = frameCount-1; lblCurrentFrame.Text = currentIndex.ToString() + "/" + frameCountMax.ToString(); } private void updateFrameRange() { textBoxFrameStart.Text = frameRange.Start.ToString(); textBoxFrameEnd.Text = frameRange.End.ToString(); } private void btnNextFrame_Click(object sender, EventArgs e) { next(); updateInfos(); } private void textBoxSelectFrame_TextChanged(object sender, EventArgs e) { int index = 0; try { index = int.Parse(textBoxSelectFrame.Text); } catch (System.Exception ) { } if (index>=0 && index<=frameCount) { currentIndex = index; updateInfos(); } } private void trackBarFrame_Scroll(object sender, EventArgs e) { int index = trackBarFrame.Value; currentIndex = index; updateInfos(); } private void PreviewForm_KeyUp(object sender, KeyEventArgs e) { } private void PreviewForm_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '+') { next(); updateInfos(); trackBarFrame.Value = currentIndex; } } private void btnSaveAsStart_Click(object sender, EventArgs e) { frameRange.Start = currentIndex; updateFrameRange(); } private void btnSaveAsEnd_Click(object sender, EventArgs e) { if (currentIndex