線路顏色變化以及動畫展示部分的代碼如下所示 :
/// <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
}
}
}
}