/// <summary> /// Inits progress bar or reset it. /// </summary> /// <param name="fp"></param> private void InitProgressBar(FileParser fp) { if (progressBar.InvokeRequired) { progressBar.Invoke((MethodInvoker)(() => { progressBar.Maximum = fp.NumberOfFrames; progressBar.Value = 0; })); } else { progressBar.Maximum = fp.NumberOfFrames; progressBar.Value = 0; } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { mrse.Reset(); numericUpDown1.Value = 0; var file = openFileDialog1.OpenFile(); byte[] data = new byte[file.Length]; file.Read(data, 0, (int)file.Length); currentData = new FileParser(data); StartPlay(); mrse.Set(); } }
private void PlayFile(object data) { if (!(data is FileParser)) { throw new Exception("Wrong type"); } FileParser fp = (FileParser)(data as FileParser).Clone(); Bitmap bmp = new Bitmap(fp.FrameLength * pixelWidth, 15); int pb = 0; foreach (var frame in fp) { pb++; UpdateProgressBar(pb); mrse.WaitOne(); FillBitmap(pixelWidth, bmp, frame); DrawBitmapOnPanel(bmp); Pause(); } }
public NewProgramm(FileParser fp) { InitializeComponent(); _fp = fp; }