Пример #1
0
 public static string[] GetNamesU(Microsoft.Office.Interop.Visio.Masters masters)
 {
     System.Array names_sa;
     masters.GetNamesU(out names_sa);
     string[] names = (string[])names_sa;
     return(names);
 }
        /// <summary>
        /// 根据指定的监测点在visio图形中绘出对应的测点图形
        /// </summary>
        /// <param name="vsoWindow">进行绘图的visio图形</param>
        /// <param name="strTags">要绘制的所有监测点的在列表中对应的文本</param>
        /// <param name="PointsToBeAdded">要绘制的所有监测点的集合</param>
        /// <remarks></remarks>
        public void AddMonitorPoints(Microsoft.Office.Interop.Visio.Window vsoWindow, string[] strTags, PointInVisio[] PointsToBeAdded)
        {
            int n = PointsToBeAdded.Count();

            if (n > 0)
            {
                //
                object[] arrMaster     = new object[n - 1 + 1];
                double[] arrCoordinate = new double[2 * n - 1 + 1];
                short[]  arrIDOut      = new short[n - 1 + 1];
                string[] arrPointTag   = new string[n - 1 + 1];
                //

                Microsoft.Office.Interop.Visio.Masters DocumentMasters = vsoWindow.Document.Masters;

                int i = 0;
                foreach (var pt in PointsToBeAdded)
                {
                    try
                    {
                        arrMaster[i] = DocumentMasters[pt.strItem];
                    }
                    catch (Exception)
                    {
                        Debug.Print("测点类型: {0} 在Visio模板文件中并不存在,此时用\"OtherTypes\"来表示。", pt.strItem);
                        arrMaster[i] = DocumentMasters["OtherTypes"];
                    }
                    arrPointTag[i]           = System.Convert.ToString(pt.strPoint);
                    arrCoordinate[2 * i]     = System.Convert.ToDouble(pt.Coordinates(0));
                    arrCoordinate[2 * i + 1] = System.Convert.ToDouble(pt.Coordinates(1));
                    i++;
                }

                Microsoft.Office.Interop.Visio.Page pg = vsoWindow.Page;
                int ProcessedCount = pg.DropMany(ref arrMaster, ref arrCoordinate, ref arrIDOut);

                //设置每一个测点形状上显示的文字
                pg.Application.ShowChanges = true;
                string tag = F_MonitorPointsInfo.ShapeName_MonitorPointTag;
                try
                {
                    for (int i_p = 0; i_p <= n - 1; i_p++)
                    {
                        int id = arrIDOut[i_p];
                        //设置主控形状的实例对象中,“某形状”的文本,“某形状”的索引等规范化。
                        pg.Shapes.ItemFromID(id).Shapes.Item(tag).Text = arrPointTag[i_p];
                        F_dicVisioPoints.Add(strTags[i_p], arrIDOut[i_p]);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("主控形状中没有找到子形状:" + "tag" + "\r\n" + ex.Message + "\r\n" + "报错位置:" + ex.TargetSite.Name, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #3
0
        public static IEnumerable <Microsoft.Office.Interop.Visio.Master> ToEnumerable(Microsoft.Office.Interop.Visio.Masters masters)
        {
            short count = masters.Count;

            for (int i = 0; i < count; i++)
            {
                yield return(masters[i + 1]);
            }
        }