Esempio n. 1
0
        public List <List <TCellGroup> > GetCellGroups(Microsoft.Office.Interop.Visio.Page page, IList <int> shapeids)
        {
            this.validate_query();
            var data_for_shapes = query.GetFormulasAndResults(page, shapeids);
            var list            = new List <List <TCellGroup> >(shapeids.Count);
            var objects         = data_for_shapes.Select(d => this.SubQueryRowsToCellGroups(d.Sections[0]));

            list.AddRange(objects);
            return(list);
        }
        /// <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);
                }
            }
        }
Esempio n. 3
0
        public FormErrors(Microsoft.Office.Interop.Visio.Page targetPage, List <Error> errors)
        {
            //InitializeComponent();
            _tarPage = targetPage;
            _errors.AddRange(errors);

            foreach (var err in _errors)
            {
                //dataGridView1.Rows.Add(err.descr, err.Id);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a control from the property definition.
        /// </summary>
        /// <param name="element">Element in the XML definition file.</param>
        /// <param name="data">Data to pass to the control.</param>
        /// <returns>Instance of Control.</returns>
        public static Control CreateProperty(XmlElement element, object data, Microsoft.Office.Interop.Visio.Page page)
        {
            string prefix    = FormsNamespace.NamespaceManager.LookupPrefix(element.NamespaceURI);
            string localName = element.LocalName;

            string type;

            if (prefix != null && prefix != "")
            {
                type = string.Format("{0}:{1}", prefix, localName);
            }
            else
            {
                type = localName;
            }

            Property property = null;

            foreach (Property p in FormConfigs.Properties)
            {
                if (p.Type == type)
                {
                    property = p;
                    break;
                }
            }


            if (property == null)
            {
                throw new Exception("No registered property handler. (" + element.Name + ")");
            }


            Control control;

            try
            {
                if (property.Type.Contains("itemList"))
                {
                    control = (Control)TypeFactory.Create(property.Moniker, new object[] { element, data, page });
                }
                else
                {
                    control = (Control)TypeFactory.Create(property.Moniker, new object[] { element, data });
                }
            }
            catch (InvalidCastException ex)
            {
                throw new Exception("Error creating property handler.", ex);
            }

            return(control);
        }
Esempio n. 5
0
        public CellQueryOutputList <string> GetCells(Microsoft.Office.Interop.Visio.Page page, IList <int> shapeids, CellValueType type)
        {
            var surface = new SurfaceTarget(page);

            if (type == CellValueType.Formula)
            {
                return(this.GetFormulas(surface, shapeids));
            }
            else
            {
                return(this.GetResults <string>(surface, shapeids));
            }
        }
Esempio n. 6
0
        public void ComboBox_Page_SelectedIndexChanged(object sender, EventArgs e)
        {
            LstbxDisplayAndItem lstItem = this.ComboBox_Page.SelectedItem;

            try
            {
                this.F_vsoPage = (Microsoft.Office.Interop.Visio.Page)lstItem.Value;
            }
            catch (Exception)
            {
                //MessageBox.Show(ex.Message, "选择Visio页面出错!", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            }
            this.btnLink.Enabled = false;
        }
Esempio n. 7
0
        public void Render(Microsoft.Office.Interop.Visio.Page page, Drawing drawing, VisioLayoutOptions options)
        {
            // This is Visio-based render - it does NOT use MSAGL
            if (page == null)
            {
                throw new System.ArgumentNullException(nameof(page));
            }

            if (options == null)
            {
                throw new System.ArgumentNullException(nameof(options));
            }

            var    page_node = new DOM.Page();
            double x         = 0;
            double y         = 1;

            foreach (var shape in drawing.Shapes)
            {
                var shape_nodes = page_node.Shapes.Drop(shape.MasterName, shape.StencilName, x, y);
                shape.DOMNode      = shape_nodes;
                shape.DOMNode.Text = new Text.Markup.TextElement(shape.Label);
                x += 1.0;
            }

            foreach (var connector in drawing.Connectors)
            {
                var connector_node = page_node.Shapes.Connect("Dynamic Connector", "connec_u.vss", connector.From.DOMNode, connector.To.DOMNode);
                connector.DOMNode      = connector_node;
                connector.DOMNode.Text = new Text.Markup.TextElement(connector.Label);
            }

            page_node.ResizeToFit       = true;
            page_node.ResizeToFitMargin = new VisioAutomation.Drawing.Size(0.5, 0.5);
            if (options.Layout != null)
            {
                page_node.Layout = options.Layout;
            }
            page_node.Render(page);
        }
Esempio n. 8
0
        //验证
        /// <summary>
        /// 验证页面中是否包含所有位于数据记录集中所记录的形状ID。
        /// </summary>
        /// <param name="page"></param>
        /// <param name="DRS"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        private bool ValidateShapes(Microsoft.Office.Interop.Visio.Page page, Microsoft.Office.Interop.Visio.DataRecordset DRS, int intIndexOfShapeID)
        {
            bool blnValidated = true;

            if (DRS != null)
            {
                int[] lngRowIDs = DRS.GetDataRowIDs("");
                Microsoft.Office.Interop.Visio.Shape shp;
                foreach (int id in lngRowIDs)
                {
                    object[] RowData = DRS.GetRowData(id);
                    object   shapeID = RowData[intIndexOfShapeID];
                    try
                    {
                        shp = page.Shapes.ItemFromID(System.Convert.ToInt32(shapeID));
                    }
                    catch (Exception)
                    {
                        blnValidated = false;
                        var Result = MessageBox.Show("在页面中没有找到与形状ID \"" + System.Convert.ToString(shapeID) + "\" 相匹配的形状。请仔细检查记录的形状ID值。",
                                                     "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                        if (Result == Windows.Forms.DialogResult.OK)
                        {
                        }
                        else if (Result == Windows.Forms.DialogResult.Cancel)
                        {
                            //不再提示这条错误
                            goto endOfForLoop;
                        }
                    }
                }
endOfForLoop:
                1.GetHashCode();                  //VBConversions note: C# requires an executable line here, so a dummy line was added.
            }
            else
            {
                blnValidated = false;
            }
            return(blnValidated);
        }
Esempio n. 9
0
        public void Commit(Microsoft.Office.Interop.Visio.Page page)
        {
            var surface = new ShapeSheetSurface(page);

            this.Commit(surface);
        }
Esempio n. 10
0
        public static List <TextXFormCells> GetCells(Microsoft.Office.Interop.Visio.Page page, IList <int> shapeids, CellValueType type)
        {
            var query = lazy_query.Value;

            return(query.GetCells(page, shapeids, type));
        }
Esempio n. 11
0
 bool _VisioApplication_QueryCancelPageDelete(Microsoft.Office.Interop.Visio.Page Page)
 {
     DisplayInWatchWindow(countQueryCancelPageDelete++, System.Reflection.MethodInfo.GetCurrentMethod().Name);
     return(false);
 }
Esempio n. 12
0
 void _VisioApplication_PageChanged(Microsoft.Office.Interop.Visio.Page Page)
 {
     DisplayInWatchWindow(countPageChanged++, System.Reflection.MethodInfo.GetCurrentMethod().Name);
 }
Esempio n. 13
0
 void _VisioApplication_BeforePageDelete(Microsoft.Office.Interop.Visio.Page Page)
 {
     DisplayInWatchWindow(countBeforePageDelete++, System.Reflection.MethodInfo.GetCurrentMethod().Name);
 }
Esempio n. 14
0
        /// <summary>This method walks the connections of the page passed in and
        /// displays information about the shapes that are connected and the
        /// connectors.</summary>
        /// <param name="pageToWalk">Page for which connections will be walked
        /// </param>
        public void ShowPageConnections(
            Microsoft.Office.Interop.Visio.Page pageToWalk)
        {
            const string DEBUG_MESSAGE =
                "{0} of '{1}' is connected to {2} of '{3}' with Text: '{4}'";

            Microsoft.Office.Interop.Visio.Shape        shapeFrom;
            Microsoft.Office.Interop.Visio.Shape        shapeTo;
            Microsoft.Office.Interop.Visio.Connects     connections;
            Microsoft.Office.Interop.Visio.VisFromParts visioFromData;
            Microsoft.Office.Interop.Visio.VisToParts   visioToData;
            int    fromIntegerData;
            int    toIntegerData;
            string fromStringData;
            string toStringData;


            if (pageToWalk == null)
            {
                return;
            }


            try
            {
                // Get the Connects collection for the page.
                connections = pageToWalk.Connects;

                // Loop through the objects in the Connects collection.
                foreach (Microsoft.Office.Interop.Visio.Connect connection
                         in connections)
                {
                    // Get the From information of the Connect object.
                    shapeFrom       = connection.FromSheet;
                    fromIntegerData = connection.FromPart;

                    // Converts the VisFromParts value to a string.
                    // Use fromIntegerData to determine the type of connection.
                    if (fromIntegerData < (int)Microsoft.Office.Interop.Visio.
                        VisFromParts.visControlPoint)
                    {
                        visioFromData =
                            (Microsoft.Office.Interop.Visio.VisFromParts)
                            fromIntegerData;
                        fromStringData = visioFromData.ToString();
                    }
                    else
                    {
                        // Control points are numbered starting with 1
                        // in the UI but with 0 in the API.
                        fromStringData = "visControlPoint"
                                         + Convert.ToString(fromIntegerData
                                                            - (int)Microsoft.Office.Interop.Visio.
                                                            VisFromParts.visControlPoint + 1,
                                                            System.Globalization.CultureInfo.InvariantCulture);
                    }

                    // Get the To information of the Connect object.
                    shapeTo       = connection.ToSheet;
                    toIntegerData = connection.ToPart;

                    // Converts the VisToParts value to a string.
                    // Use toIntegerData to determine the type of shape to
                    // which the connector is connected.
                    if (toIntegerData < (int)Microsoft.Office.Interop.Visio.
                        VisToParts.visConnectionPoint)
                    {
                        visioToData =
                            (Microsoft.Office.Interop.Visio.VisToParts)
                            toIntegerData;
                        toStringData = visioToData.ToString();
                    }
                    else
                    {
                        // Connection points are numbered starting with 1
                        // in the UI but with 0 in the API
                        toStringData = "visConnectionPoint"
                                       + Convert.ToString(toIntegerData
                                                          - (int)Microsoft.Office.Interop.Visio.
                                                          VisToParts.visConnectionPoint + 1,
                                                          System.Globalization.CultureInfo.InvariantCulture);
                    }

                    // Display the information in the Debug window.
                    System.Diagnostics.Debug.WriteLine(
                        String.Format(System.Globalization.CultureInfo.CurrentCulture,
                                      DEBUG_MESSAGE,
                                      fromStringData, shapeFrom.NameU,
                                      toStringData, shapeTo.NameU, shapeFrom.Text));
                }
            }
            catch (Exception err)
            {
                System.Diagnostics.Debug.WriteLine(err.Message);
                throw;
            }
        }
Esempio n. 15
0
 public ShapeSheetWriter(Client client, Microsoft.Office.Interop.Visio.Page page)
 {
     this.Client  = client;
     this.Surface = new VisioAutomation.ShapeSheet.ShapeSheetSurface(page);
     this.writer  = new SidSrcWriter();
 }
        public static IList <ShapeLayoutCells> GetCells(Microsoft.Office.Interop.Visio.Page page, IList <int> shapeids)
        {
            var query = ShapeLayoutCells.lazy_query.Value;

            return(ShapeSheet.CellGroups.CellGroup._GetCells <ShapeLayoutCells, double>(page, shapeids, query, query.GetCells));
        }
 public ShapeSheetWriter(Client client, Microsoft.Office.Interop.Visio.Page page)
 {
     this.Client         = client;
     this.Surface        = new ShapeSheetSurface(page);
     this.formula_writer = new FormulaWriterSIDSRC();
 }
Esempio n. 18
0
        //链接
        /// <summary>
        /// 将Visio中的外部数据链接到Page中的指定形状。
        /// 此操作的作用:通过Visio的数据图形功能,在对应的形状上显示出它所链接的数据,比如此图形对应的开挖深度。
        /// </summary>
        /// <param name="DataRS">数据链接的源数据记录集</param>
        /// <param name="Page">要进行数据链接的形状所在的Page</param>
        /// <param name="ColumnIndex_PrimaryKey">在数据记录集中,用来记录形状的名称的数据所在的列号。如果是第一列,则为0.</param>
        /// <param name="DeleteDataRecordset">是否要在数据记录集的数据链接到形状后,将此数据记录集删除。</param>
        /// <remarks></remarks>
        private dynamic PassDataRecordsetToShape(Microsoft.Office.Interop.Visio.DataRecordset DataRS, Microsoft.Office.Interop.Visio.Page Page, short ColumnIndex_PrimaryKey = 0, bool DeleteDataRecordset = false)
        {
            bool blnSucceeded = true;

            int[] IDs = null;
            //  ------------------ GetDataRowIDs ---------------------
            //获取数据记录集内所有行的 ID 组成的数组,其中每一行均代表一个数据记录。
            //若要不应用筛选器(即获取所有行),则传递一个空字符串 ("") 即可。
            IDs = DataRS.GetDataRowIDs("");
            //
            Microsoft.Office.Interop.Visio.Shape shp = default(Microsoft.Office.Interop.Visio.Shape);
            try
            {
                foreach (int RowID in IDs)
                {
                    int shapeID = System.Convert.ToInt32(DataRS.GetRowData(RowID)[ColumnIndex_PrimaryKey]);
                    //ItemFromID可以进行页面或者形状集合中的全局索引,即可以索引子形状中的嵌套形状,而Item一般只能索引其下的子形状。
                    shp = Page.Shapes.ItemFromID(shapeID);
                    shp.LinkToData(DataRS.ID, RowID, false);
                }
            }
            catch (Exception)
            {
                blnSucceeded = false;
            }

            //是否要在数据记录集的数据链接到形状后,将此数据记录集删除。
            if (DeleteDataRecordset)
            {
                DataRS.Delete();
                DataRS = null;
            }
            return(blnSucceeded);
        }
Esempio n. 19
0
        public CellQueryOutputList <TResult> GetResults <TResult>(Microsoft.Office.Interop.Visio.Page page, IList <int> shapeids)
        {
            var surface = new SurfaceTarget(page);

            return(this.GetResults <TResult>(surface, shapeids));
        }
Esempio n. 20
0
        public static List <TextXFormCells> GetCells(Microsoft.Office.Interop.Visio.Page page, IList <int> shapeids)
        {
            var query = TextXFormCells.lazy_query.Value;

            return(query.GetCellGroups(page, shapeids));
        }
Esempio n. 21
0
        public CellQueryOutputList <string> GetFormulas(Microsoft.Office.Interop.Visio.Page page, IList <int> shapeids)
        {
            var surface = new SurfaceTarget(page);

            return(this.GetFormulas(surface, shapeids));
        }
Esempio n. 22
0
        public void Commit(Microsoft.Office.Interop.Visio.Page page)
        {
            var surface = new SurfaceTarget(page);

            this.Commit(surface);
        }
        /// <summary>
        /// !进行监测点位的绘制
        /// </summary>
        /// <remarks></remarks>
        private void DrawPoints()
        {
            ClsDrawing_PlanView vso = GlobalApplication.Application.PlanView_VisioWindow;

            if (vso != null)
            {
                Microsoft.Office.Interop.Visio.Page pg = vso.Page;
                try
                {
                    Microsoft.Office.Interop.Visio.Window vsoWindow = pg.Application.ActiveWindow;
                    vsoWindow.Page = pg;
                    vsoWindow.Application.ShowChanges = false;
                    //
                    string[] arrListedPoints  = F_dicListedPoints.Keys.ToArray;
                    string[] arrExistedPoints = F_dicVisioPoints.Keys.ToArray;
                    //
                    object[] arrAddOrRemove = new object[2];
                    arrAddOrRemove = GetPointsToBeProcessed(arrExistedPoints, arrListedPoints);
                    string[] arrToBeAdded   = arrAddOrRemove[0];
                    string[] arrToBeRemoved = arrAddOrRemove[1];


                    // ----- arrPointsToBeAdded ------------- 处理要进行添加的图形
                    PointInVisio[] arrPointsToBeAdded = new PointInVisio[arrToBeAdded.Length - 1 + 1];
                    int            i            = 0;
                    string         strSeparator = TreeViewPoints.PathSeparator;
                    foreach (string tag_Add in arrToBeAdded)
                    {
                        TreeNode     nd           = F_dicListedPoints.Item(tag_Add);
                        PointInVisio struct_Point = new PointInVisio();
                        var          str          = tag_Add;
                        struct_Point.strItem     = str.Substring(0, str.IndexOf(strSeparator));
                        struct_Point.strPoint    = nd.Text;
                        struct_Point.Coordinates = nd.Tag;
                        arrPointsToBeAdded[i]    = struct_Point;
                        i++;
                    }

                    AddMonitorPoints(vsoWindow, arrToBeAdded, arrPointsToBeAdded);

                    // ----- arrToBeRemoved ------------- 处理要进行删除的图形
                    foreach (string strPointTag in arrToBeRemoved)
                    {
                        Microsoft.Office.Interop.Visio.Shape shp = default(Microsoft.Office.Interop.Visio.Shape);
                        shp = pg.Shapes.ItemFromID(System.Convert.ToInt32(F_dicVisioPoints.Item(strPointTag)));
                        shp.Delete();
                        //
                        F_dicVisioPoints.Remove(strPointTag);
                    }

                    // -----------------------
                    this.blnRefreshed = true;
                    vsoWindow.Application.ShowChanges = true;
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message);
                    MessageBox.Show("出错!" + "\r\n" + ex.Message + "\r\n" + "报错位置:" + ex.TargetSite.Name,
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Visio绘图已经关闭,请重新打开。", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }