public static bool Contains(IVisio.Shape shape, string name) { if (shape == null) { throw new ArgumentNullException(nameof(shape)); } if (name == null) { throw new ArgumentNullException(nameof(name)); } CustomPropertyHelper.CheckValidCustomPropertyName(name); string full_prop_name = CustomPropertyHelper.GetRowName(name); var exists = (short)IVisio.VisExistsFlags.visExistsAnywhere; return(0 != (shape.CellExistsU[full_prop_name, exists])); }
public static void Delete(IVisio.Shape shape, string name) { if (shape == null) { throw new ArgumentNullException(nameof(shape)); } if (name == null) { throw new ArgumentNullException(nameof(name)); } CustomPropertyHelper.CheckValidCustomPropertyName(name); string full_prop_name = CustomPropertyHelper.GetRowName(name); short row = shape.CellsU[full_prop_name].Row; shape.DeleteRow((short)IVisio.VisSectionIndices.visSectionProp, row); }
public static void Set( IVisio.Shape shape, string name, CustomPropertyCells cp) { if (shape == null) { throw new ArgumentNullException(nameof(shape)); } CustomPropertyHelper.CheckValidCustomPropertyName(name); if (CustomPropertyHelper.Contains(shape, name)) { string full_prop_name = CustomPropertyHelper.GetRowName(name); var cell_propname = shape.CellsU[full_prop_name]; if (cell_propname == null) { string msg = string.Format("Could not retrieve cell for custom property \"{0}\"", full_prop_name); throw new InternalAssertionException(msg); } var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter(); cp.SetFormulas(writer, cell_propname.Row); writer.Commit(shape); return; } short row = shape.AddNamedRow( (short)IVisio.VisSectionIndices.visSectionProp, name, (short)IVisio.VisRowIndices.visRowProp); CustomPropertyHelper.Set(shape, row, cp); }