程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> C#進行Visio二次開發之動態仿真實現(3)

C#進行Visio二次開發之動態仿真實現(3)

編輯:關於C語言

線路顏色變化以及動畫展示部分的代碼如下所示 :

/// <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
                    }
                }

            }
        }

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved