Beispiel #1
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);
        }
 public AssociationDisplayOptions(Shape shape)
 {
     //try
     {
         InitializeComponent();
         if (shape != null)
         {
             m_shape = new VisioClass(shape);
             SetCheckBoxFromShape(DisplayName, shape, "HideText");
             SetCheckBoxFromShape(DisplayEnd1Name, m_shape["end1_name"], "HideText");
             SetCheckBoxFromShape(DisplayEnd2Name, m_shape["end2_name"], "HideText");
             SetCheckBoxFromShape(DisplayEnd1MP, m_shape["end1_mp"], "HideText");
             SetCheckBoxFromShape(DisplayEnd2MP, m_shape["end2_mp"], "HideText");
             if (VisioHelpers.GetShapeType(shape) == Constants.Composition)
             {
                 DisplayArrows.Enabled = false;
             }
             else
             {
                 DisplayArrows.Enabled = true;
                 SetArrowCheckBoxFromShape(DisplayArrows, m_shape.Shape, "BeginArrow");
             }
         }
     }
     //catch (Exception e)
     //{
     //    Debug.WriteLine(e.Message + "Possible cause: Shape or child shape doesn't have user.type cell");
     //}
 }
 private static void SetCheckBoxFromShape(CheckBox checkBox, Shape shape, string cellName)
 {
     if (shape.get_Cells(cellName).FormulaU.Equals("TRUE"))
         checkBox.Checked = false;
     else
         checkBox.Checked = true;
 }
Beispiel #4
0
        public List <TCellGroup> GetCellGroups(Microsoft.Office.Interop.Visio.Shape shape)
        {
            this.validate_query();
            var data_for_shape = query.GetFormulasAndResults(shape);
            var sec            = data_for_shape.Sections[0];
            var cellgroups     = this.SubQueryRowsToCellGroups(sec);

            return(cellgroups);
        }
 private static void SetShapeFromArrowCheckBox(CheckBox checkBox, Shape shape)
 {
     if (checkBox.Checked == true)
     {
         shape.get_Cells("BeginArrow").FormulaU = "1";
         shape.get_Cells("EndArrow").FormulaU = "1";
     }
     else
     {
         shape.get_Cells("BeginArrow").FormulaU = "0";
         shape.get_Cells("EndArrow").FormulaU = "0";
     }
 }
Beispiel #6
0
        public CellQueryOutput <string> GetCells(Microsoft.Office.Interop.Visio.Shape shape, CellValueType type)
        {
            var surface = new SurfaceTarget(shape);

            if (type == CellValueType.Formula)
            {
                return(GetFormulas(surface));
            }
            else
            {
                return(GetResults <string>(surface));
            }
        }
Beispiel #7
0
 public string Generate3DBox(double x, double y, string mensaje)
 {
     try
     {
         Microsoft.Office.Interop.Visio.Master visioOtherMaster = visioStencil.Masters.get_ItemU(@"3-D box");
         Microsoft.Office.Interop.Visio.Shape  visioOtherShape  = visioPage.Drop(visioOtherMaster, x, y);
         visioOtherShape.Text = @mensaje + ".";
         db.InsertFigura("Cuadrado 3D", x, y, mensaje);
     }
     catch (Exception e)
     {
         return("¡ERROR!: " + e.Message);
     }
     return("¡Generación Correcta!");
 }
Beispiel #8
0
 public string GenerateStar(double x, double y, string mensaje)
 {
     try
     {
         Microsoft.Office.Interop.Visio.Master visioStarMaster = visioStencil.Masters.get_ItemU(@"Star 7");
         Microsoft.Office.Interop.Visio.Shape  visioStarShape  = visioPage.Drop(visioStarMaster, x, y);
         visioStarShape.Text = @mensaje + ".";
         db.InsertFigura("Estrella 7 Puntas", x, y, mensaje);
     }
     catch (Exception e)
     {
         return("¡ERROR!: " + e.Message);
     }
     return("¡Generación Correcta!");
 }
Beispiel #9
0
 public string GenerateTriangle(double x, double y, string mensaje)
 {
     try
     {
         Microsoft.Office.Interop.Visio.Master visioTriangleMaster = visioStencil.Masters.get_ItemU(@"Triangle");
         Microsoft.Office.Interop.Visio.Shape  visioTriangleShape  = visioPage.Drop(visioTriangleMaster, x, y);
         visioTriangleShape.Text = @mensaje + ".";
         db.InsertFigura("Triángulo", x, y, mensaje);
     }
     catch (Exception e)
     {
         return("¡ERROR!: " + e.Message);
     }
     return("¡Generación Correcta!");
 }
        /// <summary>
        /// 窗口加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>先提取坐标变换的斜率及截距;再从监测点编号与其对应的坐标创建树形列表</remarks>
        public void FrmTreeView_Load(object sender, EventArgs e)
        {
            //blnHasLoaded是为了解决showdialog在每次加载窗口时都触发一次load事件的问题。
            if (!blnHasLoaded)
            {
                try
                {
                    // ------------------ 提取坐标变换的斜率及截距
                    Microsoft.Office.Interop.Visio.Shape CP1 = default(Microsoft.Office.Interop.Visio.Shape);
                    Microsoft.Office.Interop.Visio.Shape CP2 = default(Microsoft.Office.Interop.Visio.Shape);
                    CP1 = this.F_PaintingPage.Page.Shapes.ItemFromID(F_MonitorPointsInfo.pt_Visio_BottomLeft_ShapeID);
                    CP2 = this.F_PaintingPage.Page.Shapes.ItemFromID(F_MonitorPointsInfo.pt_Visio_UpRight_ShapeID);
                    //visio中的坐标以inch为单位
                    double xp1 = 0;
                    double yp1 = 0;
                    double xp2 = 0;
                    double yp2 = 0;
                    //x,y,xp,yp都是以inch为单位的
                    double x = 0;
                    double y = 0;
                    x = System.Convert.ToDouble(CP1.Cells("LocPinX").Result(Microsoft.Office.Interop.Visio.VisUnitCodes.visInches));
                    y = System.Convert.ToDouble(CP1.Cells("LocPinY").Result(Microsoft.Office.Interop.Visio.VisUnitCodes.visInches));
                    CP1.XYToPage(x, y, ref xp1, ref yp1);
                    x = System.Convert.ToDouble(CP2.Cells("LocPinX").Result(Microsoft.Office.Interop.Visio.VisUnitCodes.visInches));
                    y = System.Convert.ToDouble(CP2.Cells("LocPinY").Result(Microsoft.Office.Interop.Visio.VisUnitCodes.visInches));
                    CP2.XYToPage(x, y, ref xp2, ref yp2);
                    ConversionParameter = GeneralMethods.Coordinate_Conversion(this.F_MonitorPointsInfo.pt_CAD_BottomLeft.X, this.F_MonitorPointsInfo.pt_CAD_BottomLeft.Y,
                                                                               this.F_MonitorPointsInfo.pt_CAD_UpRight.X, this.F_MonitorPointsInfo.pt_CAD_UpRight.Y,
                                                                               xp1, yp1, xp2, yp2);

                    //从监测点编号与其对应的坐标创建树形列表
                    constructTreeView(F_wkshtPoints, TreeViewPoints);
                    //标记:此窗口已经在主程序中加载过,后面就不用再加载了。因为不会对其进行close,只会将其隐藏
                    blnHasLoaded = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("不能正确地提取监测点位信息。" + "\r\n" + ex.Message + "\r\n" + "报错位置:" + ex.TargetSite.Name,
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //Exit Sub
                    //Me.Close()
                    this.Dispose();
                }
            }
        }
Beispiel #11
0
 public static void changeColor(Microsoft.Office.Interop.Visio.Shape shape, String formula)
 {
     try
     {
         shape.Cells["LineColor"].FormulaU = formula;
     }
     catch
     {
     }
     foreach (Microsoft.Office.Interop.Visio.Shape subShape in shape.Shapes)
     {
         try
         {
             subShape.Cells["LineColor"].FormulaForceU = formula;
         }
         catch
         {
         }
     }
 }
Beispiel #12
0
 public ClassProperties(Shape shape)
 {
     InitializeComponent();
     //try
     {
         m_shape = new VisioClass(shape);
         colorBox.BackColor = m_shape.Color;
         ClassNameTextBox.Text = m_shape["class_name"].Text;
         ClassDSLNameTextBox.Text = m_shape.Name;
         m_attributes = m_shape["attr_section"].Text.Split(new Char[] { '\n' });
         AttrListBox.Items.Clear();
         foreach (string attribute in m_attributes)
         {
             if (!attribute.Equals(string.Empty))
                 AttrListBox.Items.Add(attribute);
         }
         DSLRootClass.Checked = m_shape.IsRootClass;
     }
     //catch (Exception e)
     //{
     //    Debug.WriteLine(e.Message + "Possible cause: Shape or child shape doesn't have user.type cell");
     //}
 }
Beispiel #13
0
        public static string ReadANamedCustomProperty(Microsoft.Office.Interop.Visio.Shape customPropertyShape, string cellName, bool isLocalName)
        {
            Microsoft.Office.Interop.Visio.Cell customPropertyCell = null;
            if (customPropertyShape != null || cellName != null)
            {
                const string CUST_PROP_PREFIX = "Prop.";
                string       propName;
                try
                {
                    if (cellName.Length == 0)
                    {
                        throw new System.ArgumentNullException("cellName", "Zero length string input.");
                    }

                    propName = CUST_PROP_PREFIX + cellName;

                    if (isLocalName)
                    {
                        if (customPropertyShape.get_CellExists(propName, (short)Microsoft.Office.Interop.Visio.VisExistsFlags.visExistsAnywhere) != 0)
                        {
                            customPropertyCell = customPropertyShape.get_Cells(propName);
                        }
                    }
                    else if (customPropertyShape.get_CellExistsU(propName, (short)Microsoft.Office.Interop.Visio.VisExistsFlags.visExistsAnywhere) != 0)
                    {
                        customPropertyCell = customPropertyShape.get_CellsU(propName);
                    }
                }
                catch (Exception err)
                {
                    System.Windows.Forms.MessageBox.Show(err.Message);
                    throw;
                }
            }
            return((customPropertyCell != null) ? customPropertyCell.get_ResultStr(Microsoft.Office.Interop.Visio.VisUnitCodes.visNoCast) : "");
        }
        public static TextXFormCells GetCells(Microsoft.Office.Interop.Visio.Shape shape)
        {
            var query = TextXFormCells.lazy_query.Value;

            return(query.GetCellGroup(shape));
        }
Beispiel #15
0
        public static PageRulerAndGridCells GetCells(Microsoft.Office.Interop.Visio.Shape shape, CellValueType type)
        {
            var query = lazy_query.Value;

            return(query.GetCells(shape, type));
        }
Beispiel #16
0
 void _VisioApplication_ShapeLinkAdded(Microsoft.Office.Interop.Visio.Shape Shape, int DataRecordsetID, int DataRowID)
 {
     DisplayInWatchWindow(countShapeLinkAdded++, System.Reflection.MethodInfo.GetCurrentMethod().Name);
 }
Beispiel #17
0
 void _VisioApplication_ShapeChanged(Microsoft.Office.Interop.Visio.Shape Shape)
 {
     DisplayInWatchWindow(countShapeChanged++, System.Reflection.MethodInfo.GetCurrentMethod().Name);
 }
Beispiel #18
0
 /// <summary>
 /// Initializes a new instance of the NodeIdValidator class.
 /// </summary>
 /// <param name="shape">Shape being validated.</param>
 public NodeIdValidator(VisShape shape) : base()
 {
     _shape = shape;
 }
Beispiel #19
0
        /// <summary>
        /// Sets the shape text on a Tab shape.
        /// </summary>
        /// <param name="text">Text to show.</param>
        protected override void SetShapeText(string text)
        {
            try
            {
                XmlNode labelSpanNode  = null;
                string  labelSpanValue = labelSpanDefault;
                int     labelSpan;
                if (base.GetProperties() != null)
                {
                    labelSpanNode = base.GetProperties().SelectSingleNode("//labelSpan");
                    if (labelSpanNode != null)
                    {
                        labelSpanValue = labelSpanNode.InnerText;
                    }
                    try
                    {
                        labelSpan = int.Parse(labelSpanValue);
                        if (labelSpan < 1)
                        {
                            labelSpanValue = labelSpanDefault;
                        }
                    } catch (Exception)
                    {
                        labelSpanValue = labelSpanDefault;
                    }
                }

                bool writeText = false;

                // BEGIN_HAMMER
                Control c = (Control)Form["columns"];
                if (c == null)
                {
                    c = (Control)Form["items"];
                    if (c != null)
                    {
                        writeText = true;
                    }
                }
                if (c == null)
                {
                    c = (Control)Form["tabs"];
                }
                // END_HAMMER

                ListBox lb = (ListBox)c.Controls[5];
                int     count = lb.Items.Count;
                int     index, min, max;

                // Mostra por defeito 3 elementos (para o caso de ser populado por uma lov)
                int cnt = lb.Items.Count;
                if (cnt == 0)
                {
                    cnt = 3;
                }

                VisioUtils.SetProperty(VisioShape, "Prop", "ValidItems", lb.Items.Count.ToString());
                min = count + 1;
                max = columnsXMax + 1;
                for (index = min; index < max; index++)
                {
                    VisShape center = VisioShape.Shapes[index];
                    center.get_Cells("LockTextEdit").ResultIU = 0;
                    center.Text = string.Empty;
                    center.get_Cells("LockTextEdit").ResultIU = 1;
                }

                for (index = 1; index < min; index++)
                {
                    VisShape center = VisioShape.Shapes[index];
                    center.get_Cells("LockTextEdit").ResultIU = 0;
                    Object obj = lb.Items[index - 1];
                    center.Text = obj.ToString();
                    center.get_Cells("LockTextEdit").ResultIU = 1;
                }

                if (writeText)
                {
                    for (int i = 1; i <= VisioShape.Shapes.Count; i++)
                    {
                        VisShape center  = VisioShape.Shapes[i];
                        int      isInput = VisioUtils.GetPropertyInt(center, "Prop", "Label");
                        if (isInput > 0)
                        {
                            if (labelSpanValue != null)
                            {
                                VisioUtils.SetProperty(center, "User", "LabelLen", labelSpanValue);
                            }

                            center.get_Cells("LockTextEdit").ResultIU = 0;
                            center.Text = text;
                            center.get_Cells("LockTextEdit").ResultIU = 1;
                            i = VisioShape.Shapes.Count + 1;
                        }
                    }
                }
            } catch (FormatException)
            {
                ESIMessageBox.ShowError(Resources.GetString(ResourceTokens.ShapeTableColumns));
            }
        }
Beispiel #20
0
 /// <summary>
 /// Initializes a new instance of the NodeIdValidator class.
 /// </summary>
 /// <param name="shape">Shape being validated.</param>
 public NodeIdValidator( VisShape shape )
     : base()
 {
     _shape = shape;
 }
        public static ShapeLayoutCells GetCells(Microsoft.Office.Interop.Visio.Shape shape)
        {
            var query = ShapeLayoutCells.lazy_query.Value;

            return(ShapeSheet.CellGroups.CellGroup._GetCells <ShapeLayoutCells, double>(shape, query, query.GetCells));
        }
 private static void SetShapeFromCheckBox(CheckBox checkBox, Shape shape, string cellName)
 {
     if (checkBox.Checked == true)
         shape.get_Cells("HideText").FormulaU = "FALSE";
     else
         shape.get_Cells("HideText").FormulaU = "TRUE";
 }
        /// <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);
            }
        }
Beispiel #24
0
        public static PageRulerAndGridCells GetCells(Microsoft.Office.Interop.Visio.Shape shape)
        {
            var query = PageRulerAndGridCells.lazy_query.Value;

            return(query.GetCellGroup(shape));
        }
Beispiel #25
0
        public CellQueryOutput <TResult> GetResults <TResult>(Microsoft.Office.Interop.Visio.Shape shape)
        {
            var surface = new SurfaceTarget(shape);

            return(GetResults <TResult>(surface));
        }
Beispiel #26
0
        public static TextXFormCells GetCells(Microsoft.Office.Interop.Visio.Shape shape, CellValueType type)
        {
            var query = lazy_query.Value;

            return(query.GetCells(shape, type));
        }
Beispiel #27
0
 void _VisioApplication_BeforeShapeDelete(Microsoft.Office.Interop.Visio.Shape Shape)
 {
     DisplayInWatchWindow(countBeforeShapeDelete++, System.Reflection.MethodInfo.GetCurrentMethod().Name);
 }
Beispiel #28
0
        public void Commit(Microsoft.Office.Interop.Visio.Shape shape)
        {
            var surface = new SurfaceTarget(shape);

            this.Commit(surface);
        }
Beispiel #29
0
        public CellQueryOutput <string> GetFormulas(Microsoft.Office.Interop.Visio.Shape shape)
        {
            var surface = new SurfaceTarget(shape);

            return(GetFormulas(surface));
        }