private void btnSave_Click(object sender, EventArgs e)
 {
     SaveFileDialog dlg = new SaveFileDialog();
     dlg.Filter = "Videos (*.avi)|*.avi;";
     if (dlg.ShowDialog() == DialogResult.OK) {
         AviManager.MakeFileFromStream(dlg.FileName, editableStream);
         editableStream.Close();
         editableStream = null;
         panelEditor.Enabled = false;
     }
 }
 private void btnClose_Click(object sender, EventArgs e)
 {
     editableStream.Close();
     editableStream = null;
     panelEditor.Enabled = false;
 }
        private void btnOpen_Click(object sender, EventArgs e)
        {
            if (editableStream != null) {
                editableStream.Close();
            }

            AviManager file = new AviManager(txtAviFileName.Text, true);
            VideoStream stream = file.GetVideoStream();
            editableStream = new EditableVideoStream(stream);
            file.Close();

            numFirst.Maximum = editableStream.CountFrames - 1;
            numFirst.Value = 0;

            numPastePositionStream.Maximum = editableStream.CountFrames - 1;
            numPastePositionStream.Value = 0;

            numLast.Maximum = editableStream.CountFrames - 1;
            numLast.Value = editableStream.CountFrames - 1;

            if (numFrameRate.Maximum < (decimal)editableStream.FrameRate) {
                numFrameRate.Maximum = (decimal)editableStream.FrameRate;
            }
            numFrameRate.Value = (decimal)editableStream.FrameRate;

            panelEditor.Enabled = true;
        }