独立Group导入、导出及执行
1. 界面设计
2. 添加引用
Group相当于VM中的模块,因此在调用相关接口函数前,需要引用对应的动态库IMVSGroupCs,同时将复制本地的属性改为False
using IMVSGroupCs;
3. 添加VmSingleModuleSetConfigControl控件
拖入控件后,设置Dock为Fill
4. 选择Group路径
/// <summary>
/// 选择Group路径
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.Filter = "VM Gro File|*.gro*";
DialogResult openFileRes = fileDialog.ShowDialog();
if (openFileRes==DialogResult.OK)
{
textBox1.Text = fileDialog.FileName;
}
}
- 导入Group
/// <summary>
/// 导入Group
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, EventArgs e)
{
string strMsg = null;
try
{
groupTool = IMVSGroupTool.LoadIndependentGroup(textBox1.Text);
vmSingleModuleSetConfigControl1.ModuleSource = groupTool;
}
catch (VmException ex)
{
strMsg = "加载Group失败.异常码:"+Convert.ToString(ex.errorCode,16);
}
strMsg = "加载Group成功.";
listBox1.Items.Add(strMsg);
listBox1.TopIndex = listBox1.Items.Count - 1;
}
6. 导出Group
/// <summary>
/// 导出Group
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
groupTool.Save();
}
7. 执行Group
/// <summary>
/// 执行一次
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button4_Click(object sender, EventArgs e)
{
groupTool.Run();
}
8. 运行
- 选择路径
- 导入Group
- 导出Group
可将Group保存至原路径.
- 执行Group
可将Group执行一次