C# how to fix this - c#

I have a error that I don't no how to fix. I would perfer the answer in code. This is the error, Error 1 No overload for
'turnToVideoToolStripMenuItem_Click' matches delegate 'System.EventHandler'
C:\Users\kinoa\documents\visual studio 2013\Projects\Armored Animation Studio\Armored Animation Studio\main.Designer.cs 259 56 Armored Animation Studio.
This is the code,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NReco.VideoConverter;
using System.Diagnostics;
using System.IO;
namespace Armored_Animation_Studio
{
public partial class main : Form
{
public Point current = new Point();
public Point old = new Point();
public Graphics g;
public Pen p = new Pen(Color.Black, 5);
public List<Image> Animation = new List<Image>();
public main()
{
InitializeComponent();
g = panel1.CreateGraphics();
p.SetLineCap(System.Drawing.Drawing2D.LineCap.Round,
System.Drawing.Drawing2D.LineCap.Round,
System.Drawing.Drawing2D.DashCap.Round);
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
current = e.Location;
g.DrawLine(p, current, old);
old = current;
}
}
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
old = e.Location;
if(radioButton1.Checked)
{
p.Width = 1;
}
else if(radioButton2.Checked)
{
p.Width = 5;
}
else if (radioButton3.Checked)
{
p.Width = 10;
}
else if (radioButton4.Checked)
{
p.Width = 15;
}
else if (radioButton5.Checked)
{
p.Width = 30;
}
}
private void button1_Click(object sender, EventArgs e)
{
ColorDialog cd = new ColorDialog();
if (cd.ShowDialog() == DialogResult.OK)
p.Color = cd.Color;
}
private void button3_Click(object sender, EventArgs e)
{
panel1.Invalidate();
}
private void radioButton7_CheckedChanged(object sender, EventArgs e)
{
p.Color = System.Drawing.Color.White;
}
private void button2_Click(object sender, EventArgs e)
{
Bitmap bmp = new Bitmap(panel1.Width, panel1.Height);
panel1.DrawToBitmap(bmp, new Rectangle(0, 0, panel1.Width,
panel1.Height));
Animation.Add(bmp);
}
private void turnToVideoToolStripMenuItem_Click(object sender, EventArgs
e, string [] args)
{
Process proc = new Process();
proc.StartInfo.FileName = "ffmpeg";
proc.StartInfo.Arguments = "-i " + args[0] + " " + args[1];
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.UseShellExecute = false;
if (!proc.Start())
{
Console.WriteLine("Error starting");
return;
}
StreamReader reader = proc.StandardError;
string line;
while ((line = reader.ReadLine()) != null)
{
Console.WriteLine("ffmpeg -i <imagefile> -vcodec mpeg4 out_movie");
}
proc.Close();
}
}
}
Thank you!

Change the method signature:
private void turnToVideoToolStripMenuItem_Click(object sender, EventArgs e, string [] args)
to:
private void turnToVideoToolStripMenuItem_Click(object sender, EventArgs e)
Would take care of the compiler error, but you are left with getting to the data that you expected to be in args. What are you expecting to be passed in that last parameter?

Related

Folder Copy Error:System.UnauthorizedAccessException in C#

I want to copy an existing file to another destination, but it gives an access error.
Error Name:
System.UnauthorizedAccessException
I understand that I need to grant access but I don't know how to do this.
My project looks like:
I will put the file on the server and run this program from the web-based program. I will close the button and textbox with the source file. I will only leave the target forms open
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
BackgroundWorker worker = new BackgroundWorker();
public Form1()
{
InitializeComponent();
worker.WorkerReportsProgress = true;
worker.WorkerSupportsCancellation = true;
worker.ProgressChanged += Worker_ProgressChanged;
worker.DoWork += Worker_DoWork;
}
void Copyfile(string source, string des)
{
FileStream fsOut = new FileStream(des, FileMode.Create);
FileStream fsIn = new FileStream(source, FileMode.Open);
byte[] bt = new byte[1048456];
int readByte;
while ((readByte = fsIn.Read(bt, 0, bt.Length)) > 0)
{
fsOut.Write(bt,0,readByte);
worker.ReportProgress((int)(fsIn.Position * 100 / fsIn.Length));
}
fsIn.Close();
fsOut.Close();
}
private void Worker_DoWork(object sender, DoWorkEventArgs e)
{
Copyfile(txtSource.Text, txtTarget.Text);
}
private void Worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
label1.Text = progressBar1.Value.ToString() + "%";
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd1 = new FolderBrowserDialog();
if (fbd1.ShowDialog() == DialogResult.OK)
{
txtSource.Text = Path.Combine(fbd1.SelectedPath, Path.GetFileName(txtTarget.Text));
}
}
private void button2_Click(object sender, EventArgs e)
{
worker.RunWorkerAsync();
}
private void button3_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
{
txtTarget.Text = Path.Combine(fbd.SelectedPath, Path.GetFileName(txtSource.Text));
}
}
}
}
I added and changed some codes
public static void CopyAll(DirectoryInfo source, DirectoryInfo target)
{
Directory.CreateDirectory(target.FullName);
// HER DOSYAYI YENI DIZINE KOPYALAR
foreach (FileInfo fi in source.GetFiles())
{
fi.CopyTo(System.IO.Path.Combine(target.FullName, fi.Name), true);
}
// HER ALT DIZINI KOPYALAR
foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
{
DirectoryInfo nextTargetSubDir =
target.CreateSubdirectory(diSourceSubDir.Name);
CopyAll(diSourceSubDir, nextTargetSubDir);
}
}
void CopyFile(string source, string des)
{
FileStream fsout = new FileStream(des, FileMode.Create);
FileStream fsIn = new FileStream(source, FileMode.Open);
byte[] bt = new byte[1048756];
int readByte;
while ((readByte=fsIn.Read(bt, 0, bt.Length))>0)
{
fsout.Write(bt, 0, readByte);
worker.ReportProgress((int)(fsIn.Position*100/fsIn.Length));
}
fsIn.Close();
fsout.Close();
}
private void Worker_DoWork(object sender, DoWorkEventArgs e)
{
CopyAll(new DirectoryInfo( txtSource.Text), new DirectoryInfo(txtTarget.Text));
}
I add my github repository:https://github.com/yusufcelik1/Copy-Folder.git

Return values from serial data received to another function

I am taking serial data from a distance sensor through Arduino to Visual Studio and I have another machine that is controlled by another controller.
Return values from serial data received to another function.
My question is: how to return the values from the function?
public void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
to a while loop inside the function
private void btnMove_Click(object sender, EventArgs e)
My code is as follows:
using System;
using System.Windows.Forms;
using PokeysLibSR;
using System.Drawing;
using System.Diagnostics;
using System.Threading;
using System.IO.Ports;
using System.Text.RegularExpressions;
namespace Melexis
{
public partial class Form1 : Form
{
PokeysLib pokeys;
public Form1()
{
InitializeComponent();
serialPort1.BaudRate = 9600;
serialPort1.PortName = "COM3";
}
}
private void button1_Click(object sender, EventArgs e)
{
serialPort1.Open();
}
public void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
try
{
string line = serialPort1.ReadLine();
string yourPortStringFormatted = Regex.Replace(line, #"\t|\n|\r", "");
string yourPortStringFormatted1 = yourPortStringFormatted.Trim();
double portNum = Double.Parse(yourPortStringFormatted1);
string line1 = Convert.ToString(portNum / 100);
this.BeginInvoke(new LineReceivedEvent(LineReceived), line1);
}
catch { }
finally
{
GC.Collect();
}
}
private delegate void LineReceivedEvent(string line1);
private void LineReceived(string line1)
{
textBox1.Text = line1;
}
private void btnMove_Click(object sender, EventArgs e)
{
double[] coords = new double[4] { 0, 0, 0, 0 };
byte axisMask = 0;
if (double.TryParse(tbX.Text, out coords[0])) axisMask = (byte)(axisMask + 1);
if (double.TryParse(tbY.Text, out coords[1])) axisMask = (byte)(axisMask + 2);
if (double.TryParse(tbZ.Text, out coords[2])) axisMask = (byte)(axisMask + 4);
while (true)
{
pokeys.StartMove(false, rbAbsolut.Checked, 1, coords);
Thread.Sleep(5000);
coords[0] = -coords[0];
pokeys.StartMove(false, rbAbsolut.Checked, 4, coords);
coords[2] = coords[2] + 10;
Thread.Sleep(5000);
}
}
}

AxWMPLib.AxWindowsMediaPlayer autoplay after end of song [duplicate]

This question already has an answer here:
Function call only works when MessageBox.Show() is included?
(1 answer)
Closed 8 years ago.
I try to make simple audio player,
then I try it.
After end of song, the player stopped.
I want to set it automatically and select randomized, at the playlist.
I use URL and a ListBox as playlist..
This is the code snippet at autoplay part:
private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if (e.newState == 8)
{
Random rnd = new Random();
int nowPlayIndex = rnd.Next(listURLPlayers.Count);
axWindowsMediaPlayer1.URL = listURLPlayers[nowPlayIndex];
axWindowsMediaPlayer1.Ctlenabled = true;
axWindowsMediaPlayer1.Ctlcontrols.play();
listAudio.SelectedIndex = nowPlayIndex;
}
}
But I try it then the URL changed, but not played automatically.
What is wrong with my code?
https://github.com/mudzakkir/MP3Player.git
Please help.
Ok it is now working..
I should use Timer..
My code is now like this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mp3Player
{
public partial class MediaPlayer : Form
{
string HomeDir;
string[] sPlaylists, sURLs;
List<string> listURLPlayers = new List<string>();
public MediaPlayer()
{
InitializeComponent();
HomeDir = Directory.GetCurrentDirectory();
string[] playlist = File.ReadAllLines("playlist.txt");
foreach (string fileText in playlist)
{
listAudio.Items.Add(fileText);
}
string[] playlistUrl = File.ReadAllLines("playlistURL.txt");
foreach (string fileText in playlistUrl)
{
listURLPlayers.Add(fileText);
}
}
private void btnOpen_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
sPlaylists = openFileDialog1.SafeFileNames;
sURLs = openFileDialog1.FileNames;
for (int i = 0; i < sPlaylists.Length; i++)
{
listAudio.Items.Add(sPlaylists[i]);
}
for (int i = 0; i < sURLs.Length; i++)
{
listURLPlayers.Add(sURLs[i]);
}
System.IO.StreamWriter SaveFile = new System.IO.StreamWriter("playlist.txt");
foreach (var item in listAudio.Items)
{
SaveFile.WriteLine(item);
}
SaveFile.Close();
SaveFile = new System.IO.StreamWriter("playlistURL.txt");
foreach (var item in listURLPlayers)
{
SaveFile.WriteLine(item);
}
SaveFile.Close();
}
}
private void listAudio_MouseDoubleClick(object sender, MouseEventArgs e)
{
axWindowsMediaPlayer1.URL = listURLPlayers[listAudio.SelectedIndex];
}
private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if (e.newState == 8)
{
timer1.Enabled = true;
}
}
private void listAudio_SelectedIndexChanged(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = listURLPlayers[listAudio.SelectedIndex];
}
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;
Random rnd = new Random();
int nowPlayIndex = rnd.Next(listURLPlayers.Count);
axWindowsMediaPlayer1.URL = listURLPlayers[nowPlayIndex];
listAudio.SelectedIndex = nowPlayIndex;
}
}
}
Thank You

C# Sending UDP packages

I was wondering, is their any way of checking if your program is sending UDP packages to the desired IP?I am a beginner socket programmer. So if you do decide to help me, please explain with some amount of detail. I am only 15 and have been learning c# for only 2 months.
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.Net;
using System.Net.Sockets;
namespace Challenger
{
public partial class Form1 : Form
{
int ipWidth;
String x;
String methodValue;
int threadNumber;
IPEndPoint endPoint;
byte[] buffer;
public Form1()
{
InitializeComponent();
urlTextbox.Text ="www.";
this.MessageTextBox.Size = new System.Drawing.Size(231, 40);
MessageTextBox.Text = "When harpoons, air strikes, and nukes fail.";
threadValue();
methodSetter();
ipLabelText();
}
private void Form1_Load(object sender, EventArgs e)
{
this.BackColor = Color.FromArgb(0, 47, 80); //Dark blue background
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
System.Net.IPAddress[] addressess = System.Net.Dns.GetHostAddresses(urlTextbox.Text);
String ipTextLength = Convert.ToString(addressess[0]);
SendUDPPacket(ipTextLength, 80, "Hello!", 100000000);
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
Color pixelColor;//Initialize pixelColor
SolidBrush pixelBrush = new SolidBrush(Color.FromArgb(0, 83, 146)); //RGB Brush
e.Graphics.FillRectangle(pixelBrush, 0, 0, 500, 400); //Light blue rectangle for displaying IP address
}
private void urlTextbox_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
System.Net.IPAddress[] addresses = System.Net.Dns.GetHostAddresses(urlTextbox.Text);
String ipTextLength = Convert.ToString(addresses[0]);
label2.Text = Convert.ToString(addresses[0]); //Puts ip into a string-> Label for Display
label2.Location = new Point(80, 20);
}
public void ipLabelText()
{
label2.Parent = panel1;
label2.BackColor = Color.Transparent;
label2.ForeColor = Color.White;
}
private void label2_Click(object sender, EventArgs e)
{
}
private void TimeoutLabel_Click(object sender, EventArgs e)
{
}
private void portLabel_Click(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
this.MessageTextBox.Size = new System.Drawing.Size(231, 40);
}
private void label4_Click(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void methodClick(object sender, MouseEventArgs e)
{
}
public void methodSetter()
{
comboBox1.SelectedIndex = 0;
if (comboBox1.SelectedIndex == 0)
{
methodValue = "TCP";
}
if (comboBox1.SelectedIndex == 1)
{
methodValue = "UDP";
}
if (comboBox1.SelectedIndex == 2)
{
methodValue = "HTTP";
}
}
private void textBox3_TextChanged_1(object sender, EventArgs e)
{
}
public void threadValue()
{
textBox3.Text = "10";//Default thread value
threadNumber = Convert.ToInt32(threadNumber);
}
private void ipLockOn_Click(object sender, EventArgs e)
{
IPHostEntry hostEntry;
hostEntry = Dns.GetHostEntry(ip1.Text+"."+ip2.Text+"."+ip3.Text+"."+ip4.Text);
String x = Convert.ToString(hostEntry.AddressList);
label2.Text = x; //Puts ip into a string-> Label for Display
label2.Location = new Point(80, 20);
}
public void SendUDPPacket(string hostNameOrAddress, int destinationPort, string data, int count)
{
// Validate the destination port number
if (destinationPort < 1 || destinationPort > 65535)
throw new ArgumentOutOfRangeException("destinationPort", "Parameter destinationPort must be between 1 and 65,535.");
// Resolve the host name to an IP Address
IPAddress[] ipAddresses = Dns.GetHostAddresses(urlTextbox.Text);
if (ipAddresses.Length == 0)
throw new ArgumentException("Host name or address could not be resolved.", "hostNameOrAddress");
// Use the first IP Address in the list
IPAddress destination = ipAddresses[0];
IPEndPoint endPoint = new IPEndPoint(destination, destinationPort);
byte[] buffer = Encoding.ASCII.GetBytes(data);
// Send the packets
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
while (true)
{
socket.SendTo(buffer, endPoint);
}
}
}
}
Porting LOIC Android Application in C#
https://www.wireshark.org/ - this is the best tool ever for network debugging. You can filter by UDP & port, and it'll give you a detailed breakdown of all the packets & headers, including source & destination IP.

How to Record WebCam Video in MPEG or AVI files using C# Desktop Application

I am developing a Desktop Application which requires me to connect to webcam(s) and record(save) the video in MPEG, AVI, MP4 and WMV formats and Burn into the CD/DVD. The application is in Win Forms. I am only Looking for free or open source solutions or controls.
I had done saving as AVI using Aforge.Net but its taking more size to save(like 60-100MB for 15sce 320x240 Video ). I am expecting 1MB for 10sec.
Here is the Code :
using System;
using System.Drawing;
using System.Windows.Forms;
using AForge.Video;
using AForge.Video.DirectShow;
using AForge.Video.VFW;
namespace Aforge_Web_Cam
{
public partial class VideoForm : Form
{
private FilterInfoCollection VideoCaptureDevices;
private VideoCaptureDevice FinalVideo = null;
private VideoCaptureDeviceForm captureDevice;
private Bitmap video;
private AVIWriter AVIwriter = new AVIWriter();
private SaveFileDialog saveAvi;
public VideoForm()
{
InitializeComponent();
}
private void VideoForm_Load(object sender, EventArgs e)
{
VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
captureDevice = new VideoCaptureDeviceForm();
}
private void butStart_Click(object sender, EventArgs e)
{
if (captureDevice.ShowDialog(this) == DialogResult.OK)
{
VideoCaptureDevice videoSource = captureDevice.VideoDevice;
FinalVideo = captureDevice.VideoDevice;
FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
FinalVideo.Start();
}
}
void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
if (butStop.Text == "Stop Record")
{
video = (Bitmap)eventArgs.Frame.Clone();
pbVideo.Image = (Bitmap)eventArgs.Frame.Clone();
AVIwriter.Quality = 0;
AVIwriter.AddFrame(video);
}
else
{
video = (Bitmap)eventArgs.Frame.Clone();
pbVideo.Image = (Bitmap)eventArgs.Frame.Clone();
}
}
private void butRecord_Click(object sender, EventArgs e)
{
saveAvi = new SaveFileDialog();
saveAvi.Filter = "Avi Files (*.avi)|*.avi";
if (saveAvi.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
int h = captureDevice.VideoDevice.VideoResolution.FrameSize.Height;
int w = captureDevice.VideoDevice.VideoResolution.FrameSize.Width;
AVIwriter.Open(saveAvi.FileName, w, h);
butStop.Text = "Stop Record";
//FinalVideo = captureDevice.VideoDevice;
//FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
//FinalVideo.Start();
}
}
private void butStop_Click(object sender, EventArgs e)
{
if (butStop.Text == "Stop Record")
{
butStop.Text = "Stop";
if (FinalVideo == null)
{ return; }
if (FinalVideo.IsRunning)
{
//this.FinalVideo.Stop();
this.AVIwriter.Close();
pbVideo.Image = null;
}
}
else
{
this.FinalVideo.Stop();
this.AVIwriter.Close();
pbVideo.Image = null;
}
}
private void butCapture_Click(object sender, EventArgs e)
{
pbVideo.Image.Save("IMG" + DateTime.Now.ToString("hhmmss") + ".jpg");
}
private void butCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void VideoForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (FinalVideo == null)
{ return; }
if (FinalVideo.IsRunning)
{
this.FinalVideo.Stop();
this.AVIwriter.Close();
}
}
}
}
AVIWriter doesn't provide videocompression, use FileWriter from AForge.Video.FFMPEG. There you can choose everything: Size, Framerate, Codec and Bitrate and if your video was 600MB in 20 sec it now will be 6 MB in 20 sec.
Here you go:
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 AForge.Video;
using AForge.Video.DirectShow;
using AForge.Video.FFMPEG;
using AForge.Video.VFW;
namespace WindowsFormsApplication12
{
public partial class Form1 : Form
{
private FilterInfoCollection VideoCaptureDevices;
private VideoCaptureDevice FinalVideo = null;
private VideoCaptureDeviceForm captureDevice;
private Bitmap video;
//private AVIWriter AVIwriter = new AVIWriter();
private VideoFileWriter FileWriter = new VideoFileWriter();
private SaveFileDialog saveAvi;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
captureDevice = new VideoCaptureDeviceForm();
}
private void button1_Click(object sender, EventArgs e)
{
if (captureDevice.ShowDialog(this) == DialogResult.OK)
{
VideoCaptureDevice videoSource = captureDevice.VideoDevice;
FinalVideo = captureDevice.VideoDevice;
FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
FinalVideo.Start();
}
}
void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
if (butStop.Text == "Stop Record")
{
video = (Bitmap)eventArgs.Frame.Clone();
pictureBox1.Image = (Bitmap)eventArgs.Frame.Clone();
//AVIwriter.Quality = 0;
FileWriter.WriteVideoFrame(video);
//AVIwriter.AddFrame(video);
}
else
{
video = (Bitmap)eventArgs.Frame.Clone();
pictureBox1.Image = (Bitmap)eventArgs.Frame.Clone();
}
}
private void button2_Click(object sender, EventArgs e)
{
saveAvi = new SaveFileDialog();
saveAvi.Filter = "Avi Files (*.avi)|*.avi";
if (saveAvi.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
int h = captureDevice.VideoDevice.VideoResolution.FrameSize.Height;
int w = captureDevice.VideoDevice.VideoResolution.FrameSize.Width;
FileWriter.Open(saveAvi.FileName, w, h,25,VideoCodec.Default,5000000);
FileWriter.WriteVideoFrame(video);
//AVIwriter.Open(saveAvi.FileName, w, h);
butStop.Text = "Stop Record";
//FinalVideo = captureDevice.VideoDevice;
//FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
//FinalVideo.Start();
}
}
private void butStop_Click(object sender, EventArgs e)
{
if (butStop.Text == "Stop Record")
{
butStop.Text = "Stop";
if (FinalVideo == null)
{ return; }
if (FinalVideo.IsRunning)
{
//this.FinalVideo.Stop();
FileWriter.Close();
//this.AVIwriter.Close();
pictureBox1.Image = null;
}
}
else
{
this.FinalVideo.Stop();
FileWriter.Close();
//this.AVIwriter.Close();
pictureBox1.Image = null;
}
}
private void button3_Click(object sender, EventArgs e)
{
pictureBox1.Image.Save("IMG" + DateTime.Now.ToString("hhmmss") + ".jpg");
}
private void button4_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (FinalVideo == null)
{ return; }
if (FinalVideo.IsRunning)
{
this.FinalVideo.Stop();
FileWriter.Close();
//this.AVIwriter.Close();
}
}
}
}

Categories

Resources