private void AviConvert_Click(object sender, RoutedEventArgs e)
        {
            /* AForge video writer */

            /* //
            // create AviWriter class object
            AVIWriter writer = new AVIWriter("wmv3");
            //int numVal = Convert.ToInt32(textBox1.Text);
            //writer.FrameRate = 1;
            writer.Open("new_movie.avi", width, height);

            
            // populate avi frames with bitmap list
            for(int i = 0; i < proj.working.Count; i++)
            {
                writer.AddFrame(bitmaps[i]); 
            }

            writer.AddFrame(bitmaps[0]);
            //writer.FrameRate = 25;

            writer.AddFrame(bitmaps[1]);
            writer.AddFrame(bitmaps[2]);

            writer.Close();
             // */
            Image previous = new Image
            {
                Source = Big.Source,
            };
            Big.Source = new BitmapImage(new Uri("pack://application:,,,/Simplimation;component/graphics/produce.png"));

            Microsoft.Win32.SaveFileDialog fileload = new Microsoft.Win32.SaveFileDialog();
            fileload.FileName = ""; // Default file name
            fileload.DefaultExt = ""; // Default file extension
            fileload.Filter = "AVI Video File (.avi)|*.avi"; // Filter files by extension
            Nullable<bool> result = fileload.ShowDialog();

            if (result == true)
            {
                string filename = fileload.FileName;
                
                try
                {
                    
                     
                    AviWriter aviwriter = new AviWriter(proj.working, filename, expwidth, expheight);
                    Big.Source = previous.Source;
                    string messageBoxText = "AVI file has been successfully created!\n\nWould you like to open it?";
                    string caption = "Play video?";
                    MessageBoxButton button = MessageBoxButton.YesNo;
                    MessageBoxResult resultm = MessageBox.Show(messageBoxText,caption,button);
                    switch(resultm)
                    {
                        case MessageBoxResult.Yes: {

                            Process.Start(filename);
                            break; 
                        }
                        case MessageBoxResult.No: { break; }
                    }
                }
                catch
                {
                    MessageBox.Show("Error: AVI file could not be created/updated.\n\nPlease make sure that:\n-Images on storyboard are not missing.\n-Destination file is not in use.");
                }
               
            }
            else
            {
                Big.Source = previous.Source;
            }

             
        }
        private void AviConvert_Click(object sender, RoutedEventArgs e)
        {
            /* AForge video writer */

            /* //
            // create AviWriter class object
            AVIWriter writer = new AVIWriter("wmv3");
            //int numVal = Convert.ToInt32(textBox1.Text);
            //writer.FrameRate = 1;
            writer.Open("new_movie.avi", width, height);

            
            // populate avi frames with bitmap list
            for(int i = 0; i < proj.working.Count; i++)
            {
                writer.AddFrame(bitmaps[i]); 
            }

            writer.AddFrame(bitmaps[0]);
            //writer.FrameRate = 25;

            writer.AddFrame(bitmaps[1]);
            writer.AddFrame(bitmaps[2]);

            writer.Close();
             // */

            AviWriter aviwriter = new AviWriter(proj.working, "test.avi");

             
        }