public static void FixConnectorTextControl(Shape shape) { if (Common.GetShapeType(shape) == ShapeTypes.Connector) { string pinX = Common.GetCellFormula(shape, "TxtPinX"); // if the current TxtPinX already is updating another cell via setatref, we don't need to // do anything if (!pinX.Contains("SETATREF")) { shape.AddNamedRow((short)VisSectionIndices.visSectionControls, "TextPosition", 0); // get old values and reuse them if we already have text string pinY = Common.GetCellFormula(shape, "TxtPinY"); if (shape.Text.Length > 0) { shape.get_CellsU("Controls.TextPosition.X").Formula = pinX; shape.get_CellsU("Controls.TextPosition.Y").Formula = pinY; } else { shape.get_CellsU("Controls.TextPosition.Y").FormulaU = "Height*0.5"; shape.get_CellsU("Controls.TextPosition.X").FormulaU = "Width*0.5"; } shape.get_CellsU("Controls.TextPosition.XDyn").FormulaU = "Controls.TextPosition.X"; shape.get_CellsU("Controls.TextPosition.YDyn").FormulaU = "Controls.TextPosition.Y"; shape.get_CellsU("Controls.TextPosition.XCon").FormulaU = "IF(OR(STRSAME(SHAPETEXT(TheText),\"\"),HideText),5,0)"; shape.get_CellsU("Controls.TextPosition.CanGlue").FormulaU = "FALSE"; shape.get_CellsU("Controls.TextPosition.Prompt").FormulaU = "\"Reposition Text\""; shape.get_CellsU("TxtPinX").FormulaU = "SETATREF(Controls.TextPosition)"; shape.get_CellsU("TxtPinY").FormulaU = "SETATREF(Controls.TextPosition.Y)"; } } }
internal static void SetCellFormula(Shape shape, string cellName, string value) { string rowName = cellName; string sectionName = ""; if (cellName.Contains(".")) { string[] tmp = cellName.Split('.'); System.Diagnostics.Debug.Assert(tmp.Length == 2); sectionName = tmp[0]; rowName = tmp[1]; } if (shape.get_CellExists(cellName, (short)VisExistsFlags.visExistsAnywhere) == 0) { // we should only be adding rows to the Prop or User sections System.Diagnostics.Debug.Assert(sectionName.ToUpper().Equals("PROP") || sectionName.ToUpper().Equals("USER")); if (sectionName.ToUpper().Equals("USER")) { if (shape.get_SectionExists((short)VisSectionIndices.visSectionUser, (short)VisExistsFlags.visExistsAnywhere) == 0) { shape.AddSection((short)VisSectionIndices.visSectionUser); } shape.AddNamedRow((short)VisSectionIndices.visSectionUser, rowName, (short)VisRowTags.visTagDefault); } else { if (shape.get_SectionExists((short)VisSectionIndices.visSectionProp, (short)VisExistsFlags.visExistsAnywhere) == 0) { shape.AddSection((short)VisSectionIndices.visSectionProp); } shape.AddNamedRow((short)VisSectionIndices.visSectionProp, rowName, (short)VisRowTags.visTagDefault); } } shape.get_Cells(cellName).Formula = value; }
public static void SetCustomProperty(Shape shape, string propertyName, string label, string value) { short rowIndex = shape.AddNamedRow((short)VisSectionIndices.visSectionProp, propertyName, (short)VisRowIndices.visRowProp); shape.CellsSRC[(short)VisSectionIndices.visSectionProp, rowIndex, (short)VisCellIndices.visCustPropsLabel]. FormulaU = StringToFormulaForString(label); shape.CellsSRC[(short)VisSectionIndices.visSectionProp, rowIndex, (short)VisCellIndices.visCustPropsType].FormulaU = StringToFormulaForString( ((short)VisCellVals.visPropTypeString).ToString(System.Globalization.CultureInfo.InvariantCulture)); shape.CellsSRC[(short)VisSectionIndices.visSectionProp, rowIndex, (short)VisCellIndices.visCustPropsValue]. FormulaU = StringToFormulaForString(value); }
internal void AddAction(string actionRowId, string action, string name, bool flyout, bool enabled = true) { if (Shape.CellExists[Format(VisioFormulas.Action_Action, actionRowId), (short)VisExistsFlags.visExistsAnywhere] == Constants.CellExists) { Shape.DeleteRow((short)VisSectionIndices.visSectionAction, Shape.CellsRowIndex[Format(VisioFormulas.Action_Action, actionRowId)]); } Shape.AddNamedRow((short)VisSectionIndices.visSectionAction, actionRowId, (short)VisRowTags.visTagDefault); Shape.CellsU[Format(VisioFormulas.Action_Action, actionRowId)].FormulaU = action; Shape.CellsU[Format(VisioFormulas.Action_MenuName, actionRowId)].FormulaU = Format(VisioFormulas.Formula_EscapedValue, name); Shape.CellsU[Format(VisioFormulas.Action_Disabled, actionRowId)].FormulaU = (!enabled).ToString().ToUpper(); Shape.CellsU[Format(VisioFormulas.Action_IsFlyoutChild, actionRowId)].FormulaU = flyout.ToString().ToUpper(); }
public static void AddNamedRow(this Shape shape, VisSectionIndices section, string rowName, int rowTag) { shape.AddNamedRow((short)section, rowName, 0); }
internal static void SetCellFormula(Shape shape, string cellName, string value) { string rowName = cellName; string sectionName = ""; if (cellName.Contains(".")) { string[] tmp = cellName.Split('.'); System.Diagnostics.Debug.Assert(tmp.Length == 2); sectionName = tmp[0]; rowName = tmp[1]; } if (shape.get_CellExists(cellName, (short)VisExistsFlags.visExistsAnywhere) == 0) { // we should only be adding rows to the Prop or User sections System.Diagnostics.Debug.Assert(sectionName.ToUpper().Equals("PROP") || sectionName.ToUpper().Equals("USER")); if (sectionName.ToUpper().Equals("USER")) { if (shape.get_SectionExists((short)VisSectionIndices.visSectionUser, (short)VisExistsFlags.visExistsAnywhere) == 0) shape.AddSection((short)VisSectionIndices.visSectionUser); shape.AddNamedRow((short)VisSectionIndices.visSectionUser, rowName, (short)VisRowTags.visTagDefault); } else { if (shape.get_SectionExists((short)VisSectionIndices.visSectionProp, (short)VisExistsFlags.visExistsAnywhere) == 0) shape.AddSection((short)VisSectionIndices.visSectionProp); shape.AddNamedRow((short)VisSectionIndices.visSectionProp, rowName, (short)VisRowTags.visTagDefault); } } shape.get_Cells(cellName).Formula = value; }
public void AddUserRow(string fieldName) => Shape.AddNamedRow((short)VisSectionIndices.visSectionUser, fieldName, (short)VisRowTags.visTagDefault);