Visio files comprise various types of shapes and connectors to create different diagrams. In some cases, you may want to protect specific shapes from changes. Following such scenarios, this article explains how to protect or unprotect shapes in a Visio diagram programmatically in C#.
- Protect or Unprotect Shapes in Visio Diagram – C# API Installation
- Protect Visio Shapes from Changes Programmatically in C#
- Unprotect Visio Shapes in C#
Protect or Unprotect Visio Shapes Files – .NET API Installation
Aspose.Diagram for .NET API supports creating or editing different types of diagrams like flowcharts, organizational charts, etc. You can work with a variety of file formats without needing to install the Microsoft Visio application. You can easily install the API by downloading the reference DLL file from the Downloads section, or running the NuGet installation command below:
PM> Install-Package Aspose.Diagram
Protect Visio Shapes from Changes in C#
You can set different properties to protect shapes in Visio diagrams against changes. For instance, you can lock text edit, rotation, height, etc. Please follow the steps below to protect shapes in a VSD or VSDX Visio diagram file:
- Load the source Visio Diagram with the Diagram class.
- Access a page and then a specific shape using its ID.
- Protect different shape properties from changes.
- Save the output diagram.
The code snippet below demonstrates how to protect Visio shapes programmatically in C#:
Unprotect Visio Shapes in C#
You can unprotect shapes in a Visio diagram by following the steps below:
- Load the input Visio diagram file.
- Unprotect the shapes by accessing a specific page and its shapes.
- Export the output Visio file.
The following code sample shows how to unprotect shapes in a Visio diagram programmatically in C#:
In this article, you have learned how to protect or unprotect shapes in a Visio diagram file in VSD or VSDX format programmatically in C#. Furthermore, you may take a look at the documentation space to learn various other features of the API. In case you have any questions, please feel free to reach out to us at forum.