Example #1
0
        //
        // CodecBox_Changed
        //
        // Handler sub for the selection change event of the codec combo box.
        // It is checked, whether the new selected codec has a configuration dialog
        // and is able to export and import configuration data. Depending on these
        // capabilities the appropriate controls of the AVI Dialog will be enabled or
        // disabled.
        //
        private void CodecBox_Changed(object sender, System.EventArgs e)
        {
            AviCompressor Codec = ((AviCompressor)(CodecBox.SelectedItem));

            // Check for the configuration dialog
            if (Codec.PropertyPageAvailable)
            {
                cmdShowPropPage.Enabled = true;
            }
            else
            {
                cmdShowPropPage.Enabled = false;
            }

            // Check, whether the codec exports and imports configuration data
            if (Codec.CompressorDataSize > 0)
            {
                cmdSaveCodecData.Enabled        = true;
                cmdLoadCodecData.Enabled        = true;
                edtConfigFile.Enabled           = true;
                cmdCodecDataFileChooser.Enabled = true;
            }
            else
            {
                cmdSaveCodecData.Enabled        = false;
                cmdLoadCodecData.Enabled        = false;
                edtConfigFile.Enabled           = false;
                cmdCodecDataFileChooser.Enabled = false;
            }
        }
Example #2
0
        //
        // cmdSaveCodecData_Click
        //
        // Save the configuration properties of the current selected codec to a
        // binary file.
        //
        //<<SaveData
        private void cmdSaveCodecData_Click(object sender, System.EventArgs e)
        {
            if (edtConfigFile.Text != "")
            {
                try
                {
                    System.IO.FileStream Filestream = new System.IO.FileStream(edtConfigFile.Text, System.IO.FileMode.Create, System.IO.FileAccess.Write);

                    // Create the writer for data.
                    System.IO.BinaryWriter BinWriter = new System.IO.BinaryWriter(Filestream);

                    // Write data to Test.data.
                    AviCompressor aviComp = null;
                    aviComp = ((AviCompressor)(CodecBox.SelectedItem));

                    BinWriter.Write(aviComp.ToString());
                    BinWriter.Write(aviComp.CompressorDataSize);
                    BinWriter.Write(aviComp.CompressorData);

                    BinWriter.Close();
                    Filestream.Close();
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.Message, "Write error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #3
0
        //>>

        //
        // cmdShowPropPage_Click
        //
        // Event handler sub of the codec property button. If the current
        // seleceted codec has a property dialog, the property button is
        // enabled. A click on this button opens the codec's property dialog.
        //
        private void cmdShowPropPage_Click(object sender, System.EventArgs e)
        {
            AviCompressor Codec = null;

            Codec = ((AviCompressor)(CodecBox.SelectedItem));
            Codec.ShowPropertyPage();
        }
Example #4
0
        //>>

        //
        // cmdLoadCodecData_Click
        //
        // The previously saved codec configuration is loaded from the
        // file specified in edtConfigFile.Text. The codec configuration
        // contains the name of the codec. This name is searched in the
        // codec combobox. If it was found, the codec is selected and the
        // configuration data is assigned to this codec.
        //
        //<<LoadData
        private void cmdLoadCodecData_Click(object sender, System.EventArgs e)
        {
            if (edtConfigFile.Text != "")
            {
                try
                {
                    // Create the reader for data.
                    System.IO.FileStream   Filestrem = new System.IO.FileStream(edtConfigFile.Text, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                    System.IO.BinaryReader BinReader = new System.IO.BinaryReader(Filestrem);

                    string        CodecName  = "";
                    AviCompressor Codec      = null;
                    bool          CodecFound = false;

                    // Retrieve the name of the codec from the codec configuration file
                    CodecName = BinReader.ReadString();

                    // Search this codec in the codec combo box
                    CodecFound = false;
                    foreach (AviCompressor item in CodecBox.Items)
                    {
                        if (item.ToString() == CodecName)
                        {
                            CodecBox.SelectedItem = item;
                            Codec      = item;
                            CodecFound = true;
                        }
                    }

                    if (CodecFound == true)
                    {
                        int codecDataLen = BinReader.ReadInt32();
                        // Assign the configuration data to the codec.
                        Codec.CompressorData = BinReader.ReadBytes(codecDataLen);
                    }
                    else
                    {
                        // If the codec was not found, display an error message.
                        MessageBox.Show("The codec " + CodecName + " was not found!", "Load codec configuration", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    BinReader.Close();
                    Filestrem.Close();
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.Message, "Read error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }