/// <summary> /// 添加时间标签到时间标签列表 /// </summary> /// <param name="label"></param> public void AddTimeLabel(TimeLabel label) { if (_fileOperation == FileOperation.OpenWithReadOnly) { throw new WaveformFileException(ErrorCode.CannotCall); } if (TimeLabels.FindIndex(t => t.Name == label.Name) >= 0) //不允许添加相同名字的标签 { throw new WaveformFileException(ErrorCode.SameLabel); } TimeLabels.Add(label);//添加到时间标签列表 }
/// <summary> /// 添加时间标签到时间标签列表 /// </summary> /// <param name="name"></param> /// <param name="position"></param> /// <param name="time"></param> /// <param name="description"></param> public void AddTimeLabel(string name, long position, DateTime time, string description) { if (_fileOperation == FileOperation.OpenWithReadOnly) { throw new WaveformFileException(ErrorCode.CannotCall); } TimeLabel label = new TimeLabel(name, position, time, description); if (TimeLabels.FindIndex(t => t.Name == name) >= 0) //不允许添加相同名字的标签 { throw new WaveformFileException(ErrorCode.SameLabel); } TimeLabels.Add(label);//添加到时间标签列表 }
/// <summary> /// 获取指定时间标签信息 /// </summary> /// <param name="name"></param> /// <returns></returns> public TimeLabel GetTimeLabel(string name) { TimeLabel label = new TimeLabel(); int idx = -1; if ((idx = TimeLabels.FindIndex(t => t.Name == name)) >= 0) //查找 { label = TimeLabels[idx]; } else//如果指定标签不存在 { throw new WaveformFileException(ErrorCode.LabelNotExit); } return(label); }