C#进行Visio二次开发之动态仿真实现
2010-09-30 22:45:37 来源:WEB开发网其中我们注意到了,活塞运动时一个独立的线程进行处理的,如下所示
Thread thread = new Thread(new ParameterizedThreadStart(HuoSaiMoving));
thread.Start(param);
活塞运动是在线路联通后,继续循环进行动画的展示的,因为它是独立一个线程进行处理操作,通过判断标识来实现动画的停止控制的,具体处理活塞动画的效果实现代码如下所示:
private void HuoSaiMoving(object obj)
{
ThreadParameterInfo objParam = obj as ThreadParameterInfo;
Visio.Cell scratchCell = objParam.ScratchCell;
Visio.Cell typeCell = objParam.Cell;
int intValue = Convert.ToInt32(VisioUtility.FormulaStringToString(scratchCell.Formula));
while (intValue == 1 && isMovie)
{
string minValue = "Width*0.25";
string maxValue = "Width*0.75";
//Visio.Cell typeCell = objCell as Visio.Cell;
if (typeCell != null)
{
string currentValue = "";
//增加
for (int k = 1; k <= 10; k++)
{
currentValue = string.Format("Width*0.25 + Width*{0}", 0.05 * k);
typeCell.Formula = VisioUtility.StringToFormulaForString(currentValue);
System.Windows.Forms.Application.DoEvents();
Thread.Sleep(50);
}
//减少
for (int k = 1; k <= 10; k++)
{
currentValue = string.Format("Width*0.75 - Width*{0}", 0.05 * k);
typeCell.Formula = VisioUtility.StringToFormulaForString(currentValue);
System.Windows.Forms.Application.DoEvents();
Thread.Sleep(50);
}
}
intValue = Convert.ToInt32(VisioUtility.FormulaStringToString(scratchCell.Formula));
}
}
Visio应用曲高和寡,代码贴图众口难调;不求一鸣惊人,但求潜移默化。
主要研究技术:代码生成工具、Visio二次开发、送水管理软件等共享软件开发
出处:http://www.iqidi.com
更多精彩
赞助商链接