215 lines
5.4 KiB
C#
215 lines
5.4 KiB
C#
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<frameRange.Start)
|
|
{
|
|
MessageBox.Show("End frame must be higher than the start frame");
|
|
return;
|
|
}
|
|
|
|
frameRange.End = currentIndex;
|
|
updateFrameRange();
|
|
}
|
|
|
|
private void btnEncode_Click(object sender, EventArgs e)
|
|
{
|
|
parent.encodeMovie(frameRange.Start, frameRange.End, frameCount);
|
|
}
|
|
|
|
private void textBoxFrameStart_TextChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
frameRange.Start = int.Parse(textBoxFrameStart.Text);
|
|
}
|
|
catch (System.Exception)
|
|
{
|
|
frameRange.Start = 0;
|
|
textBoxFrameStart.Text = "0";
|
|
}
|
|
|
|
}
|
|
|
|
private void textBoxFrameEnd_TextChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
frameRange.End = int.Parse(textBoxFrameEnd.Text);
|
|
}
|
|
catch (System.Exception)
|
|
{
|
|
frameRange.End = frameCount-1;
|
|
textBoxFrameEnd.Text = frameRange.End.ToString();
|
|
}
|
|
|
|
}
|
|
|
|
private void PreviewForm_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void label1_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void startFrame_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
}
|