C#进行Visio二次开发之动态仿真实现
2010-09-30 22:45:37 来源:WEB开发网线路颜色变化以及动画展示部分的代码如下所示 :
/// <summary>
/// 根据分析后的设备ID,把设备变色动画展示
/// </summary>
/// <param name="visApp"></param>
private void RunColorChanging(Visio.Application visApp)
{
Visio.Cell cell = visApp.ActiveDocument.Pages[1].PageSheet.get_Cells("Scratch.A1");
int intValue = Convert.ToInt32(VisioUtility.FormulaStringToString(cell.Formula));
if (intValue == 1)
{
cell.Formula = "0";
}
else
{
cell.Formula = "1";
isMovie = !isMovie;
}
...................
int sequence = 1;
foreach (int shapeId in AnalyzeShapeIdList)
{
Visio.Shape shape = VisDocument.Pages[1].Shapes.get_ItemFromID(shapeId);
if (shape != null)
{
if (intValue == 0)
{
shape.Text = sequence++.ToString("D2");//string.Format("{0}({1})", sequence++, shape.ID);//
VisioUtility.SetShapeLineColor(shape, VisDefaultColors.visDarkGreen);//有电(绿色)
System.Windows.Forms.Application.DoEvents();
Thread.Sleep(500 * minFlowValue);
}
else
{
shape.Text = "";
VisioUtility.SetShapeLineColor(shape, VisDefaultColors.visBlack);//无电(黑色)
System.Windows.Forms.Application.DoEvents();
}
string equipType = VisioUtility.GetShapeCellValue(shape, "设备类型");
if (!string.IsNullOrEmpty(equipType))
{
#region 单作用、双作用
if (equipType == "单作用" || equipType == "双作用")
{
string minValue = "Width*0.25";
string maxValue = "Width*0.75";
string cellName = "Controls.Row_1.X";
try
{
if (shape.get_CellExistsU(cellName, (short)VisExistsFlags.visExistsAnywhere) != 0)
{
short i = shape.get_CellsRowIndex(cellName);
Visio.Cell typeCell = shape.get_CellsSRC((short)VisSectionIndices.visSectionControls, i, (short)VisCellIndices.visCtlX);
if (intValue == 0)
{
ThreadParameterInfo param = new ThreadParameterInfo();
param.Cell = typeCell;
param.ScratchCell = cell;
Thread thread = new Thread(new ParameterizedThreadStart(HuoSaiMoving));
thread.Start(param);
}
else
{
typeCell.Formula = VisioUtility.StringToFormulaForString(minValue);
System.Windows.Forms.Application.DoEvents();
//Thread.Sleep(500 * minFlowValue);
}
}
}
catch (Exception ex)
{
LogHelper.Error(ex);
}
}
#endregion
}
}
}
}
更多精彩
赞助商链接