private string GetMovString(Movdata movdata, float timer) { string resd = ""; switch (movdata.Model) { case 0: resd = "(" + timer + "s" + ")" + "\t偏航" + "--起始角度:" + movdata.StartAngle + "--目标角度:" + movdata.TargetAngle + "--时间:" + movdata.NeedTime; break; case 1: resd = "(" + timer + "s" + ")" + "\t滚转" + "--起始角度:" + movdata.StartAngle + "--目标角度:" + movdata.TargetAngle + "--时间:" + movdata.NeedTime; break; case 2: resd = "(" + timer + "s" + ")" + "\t俯仰" + "--起始角度:" + movdata.StartAngle + "--目标角度:" + movdata.TargetAngle + "--时间:" + movdata.NeedTime; break; case 3: resd = "(" + timer + "s" + ")" + "\t延迟" + "--时间:" + movdata.NeedTime; break; default: resd = "错误指令"; break; } return(resd); }
/// 带参数创建,修改命令 public AddActionCommand(Movdata _data) { InitializeComponent(); commandBox.SelectedIndex = _data.Model; commandAngle.Text = _data.TargetAngle.ToString(); commandTime.Text = _data.NeedTime.ToString(); }
private void OK_Click(object sender, RoutedEventArgs e) { try { int mod = commandBox.SelectedIndex; float Targetangle = float.Parse(commandAngle.Text); float Needtime = float.Parse(commandTime.Text); if (Needtime <= 0) { MessageBox.Show("时间必须是大于0的数"); return; } movdata = new Movdata(); movdata.Model = mod; movdata.TargetAngle = Clamp_Angle(Targetangle); movdata.NeedTime = Needtime; this.DialogResult = true; this.Close(); } catch { //MessageBox.Show("输入格式有误"); } }