我想制作4D椅子的视频编辑器,我需要通过带有“编辑”窗口的时间轴来进行控制。因此,对于控制板,我如何制作时间轴和参数,因此可以通过它给出控制指令。我想像我给的快照一样。我已经制作了图像的上半部分,即播放器。需要知道如何制作图像的下半部分,即时间范围和参数以指示基于指令轴还是基于参数。需要构思和C#它的代码。需要使给定的图片像编辑窗口一样,并附加视频控件。总而言之,如何使用C#代码创建一个编辑窗口,将其放在代码中的位置以及如何链接它?
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.Timers;
using System.Windows.Forms;
using System.IO;
using System.IO.Ports;
namespace _4D_chair
{
public partial class Form1 : Form
{
//public int OnTimeEventl { get; private set; }
//SerialPort port = new SerialPort();
public Form1()
{
InitializeComponent();
timer1.Interval = 100;
timer2.Interval = 1000;
//serialPort1.Open();
get_port();
// init();
}
void get_port()
{
String[] ports = SerialPort.GetPortNames();
com.Items.AddRange(ports);
}
/* void init()
{
port.PortName = com.Text;
port.BaudRate = 9600;
try
{
port.Open();
}
catch { }
}*/
private void Form1_Load(object sender, EventArgs e)
{
}
private void blockEditModeToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
}
//Open menu to load video File
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "Video File(*.mp4)|*.mp4|All Files(*.*)|*.*";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
this.textBox_path.Text = openFileDialog1.FileName;
axWindowsMediaPlayer1.URL = textBox_path.Text;
axWindowsMediaPlayer1.Ctlcontrols.play();
timer2.Start();
}
}
//Play Button
private void Play_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.Ctlcontrols.play();
timer2.Start();
}
//Pause Button
private void Pause_Click(object sender, EventArgs e)
{
timer1.Stop();
timer2.Stop();
axWindowsMediaPlayer1.Ctlcontrols.pause();
}
//Stop Button
private void Stop_Click(object sender, EventArgs e)
{
timer1.Stop();
timer2.Stop();
axWindowsMediaPlayer1.Ctlcontrols.stop();
}
//Exit
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
//Chair
private void pictureBox5_Click(object sender, EventArgs e)
{
}
//Move the chair
private void timer1_Tick(object sender, EventArgs e)
{
Chair.Location = new Point(Chair.Location.X, Chair.Location.Y);
Chair.Location = new Point(Chair.Location.Y, Chair.Location.X);
}
//Add media
private void Plus_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Mp4 files(*.mp4)|*.mp4|All Files(*.*)|*.* ";
if(open.ShowDialog() == DialogResult.OK)
{
this.textBox_path.Text = open.FileName;
axWindowsMediaPlayer1.URL = textBox_path.Text;
axWindowsMediaPlayer1.Ctlcontrols.play();
timer2.Start();
}
}
//form exiting message
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to close the application?",
"Exit", MessageBoxButtons.YesNoCancel);
if(dialog == DialogResult.Yes)
{
if(serialPort1.IsOpen)
{
serialPort1.WriteLine("ve");
serialPort1.Close();
}
Application.ExitThread();
}
else if(dialog == DialogResult.No)
{
e.Cancel = true;
}
else if(dialog == DialogResult.Cancel)
{
e.Cancel = true;
}
}
//serialport error message
private void serialPort1_ErrorReceived(object sender, System.IO.Ports.SerialErrorReceivedEventArgs e)
{
}
//serialport received message
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
// MessageBox.Show(serialPort1.ReadLine());
}
//opening serial port
private void button1_Click(object sender, EventArgs e)
{
if (com.Text == "")
{
MessageBox.Show("Select com port.");
}
else
{
serialPort1.PortName = com.Text;
serialPort1.BaudRate = 9600;
serialPort1.Open();
if (serialPort1.IsOpen)
{
progressBar1.Value = 100;
}
}
}
private void timer_start_txt_TextChanged(object sender, EventArgs e)
{
}
private void stop1_Click(object sender, EventArgs e)
{
}
private void start1_Click(object sender, EventArgs e)
{
}
//Move the chair//Move the chair
int i = 0;
int start, stop, strt1, stp1, j_servo = 0, j_servo1 = 0;
private void arrow_Click(object sender, EventArgs e)
{
com.Items.Clear();
get_port();
}
private void com_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void timer3_Tick(object sender, EventArgs e)
{
}
char[] command = { 'l', 'c', 'r', };
private void timer2_Tick(object sender, EventArgs e)
{
i++;
//for one time movement
if (timer_start_txt.Text != "" && timer_stop_txt.Text != "" && start1_txt.Text == "" && stop1_txt.Text == "")
{
start = int.Parse(timer_start_txt.Text);
stop = int.Parse(timer_stop_txt.Text);
if (i >= start && i <= stop)
{
timer1.Start();
if (serialPort1.IsOpen)
{
serialPort1.WriteLine("vb");
if(j_servo==command.Length)
{
j_servo = 0;
}
if (j_servo != command.Length)
{
serialPort1.WriteLine(command[j_servo].ToString());
}
j_servo++;
}
// timer1.Start();
}
else if (i > stop)
{
if (serialPort1.IsOpen)
{
serialPort1.WriteLine("ve");
}
timer1.Stop();
j_servo = 0;
// serialPort1.Close();
// progressBar1.Value = 0;
}
}
//for two time movement
if(timer_start_txt.Text != "" && timer_stop_txt.Text != "" && start1_txt.Text != "" && stop1_txt.Text != "" )
{
start = int.Parse(timer_start_txt.Text);
stop = int.Parse(timer_stop_txt.Text);
strt1 = int.Parse(start1_txt.Text);
stp1 = int.Parse(stop1_txt.Text);
if (i >= start && i <= stop)
{
timer1.Start();
if (serialPort1.IsOpen)
{
serialPort1.WriteLine("vb");
if (j_servo == command.Length)
{
j_servo = 0;
}
if (j_servo != command.Length)
{
serialPort1.WriteLine(command[j_servo].ToString());
}
j_servo++;
}
// timer1.Start();
}
else if (i > stop)
{
if (serialPort1.IsOpen)
{
serialPort1.WriteLine("ve");
j_servo = 0;
}
timer1.Stop();
// progressBar1.Value = 0;
}
if(i>=strt1 && i<=stp1)
{
timer1.Start();
if (j_servo1 == command.Length)
{
j_servo1 = 0;
}
if (serialPort1.IsOpen)
{
serialPort1.WriteLine("vb");
if (j_servo1 != command.Length)
{
serialPort1.WriteLine(command[j_servo1].ToString());
}
j_servo1++;
}
}
else if (i > stp1)
{
if (serialPort1.IsOpen)
{
serialPort1.WriteLine("ve");
j_servo = 0;
j_servo1 = 0;
}
timer1.Stop();
timer2.Stop();
// serialPort1.Close();
// progressBar1.Value = 0;
}
}
} // end of chair movement
}
}