Visio 파일은 다양한 유형의 셰이프와 커넥터로 구성되어 다양한 다이어그램을 만듭니다. 경우에 따라 특정 모양이 변경되지 않도록 보호해야 할 수 있습니다. 이러한 시나리오에 따라 이 문서에서는 C#에서 프로그래밍 방식으로 Visio 다이어그램의 셰이프를 보호하거나 보호 해제하는 방법을 설명합니다.
Visio 셰이프 파일 보호 또는 보호 해제 – .NET API 설치
Aspose.Diagram for .NET API는 순서도, 조직도 등과 같은 다양한 유형의 다이어그램 생성 또는 편집을 지원합니다. Microsoft Visio 애플리케이션을 설치하지 않고도 다양한 파일 형식으로 작업할 수 있습니다. . 다운로드 섹션에서 참조 DLL 파일을 다운로드하거나 아래의 NuGet 설치 명령을 실행하여 API를 쉽게 설치할 수 있습니다.
PM> Install-Package Aspose.Diagram
C#의 변경 사항으로부터 Visio 셰이프 보호
Visio 다이어그램의 셰이프를 변경으로부터 보호하기 위해 다른 속성을 설정할 수 있습니다. 예를 들어, 텍스트 편집, 회전, 높이 등을 잠글 수 있습니다. VSD 또는 VSDX Visio 다이어그램 파일의 모양을 보호하려면 아래 단계를 따르십시오.
- Diagram 클래스를 사용하여 소스 Visio Diagram을 로드합니다.
- 페이지에 액세스한 다음 해당 ID를 사용하여 특정 셰이프에 액세스합니다.
- 다른 모양 속성을 변경으로부터 보호합니다.
- 출력 다이어그램을 저장합니다.
아래 코드 조각은 C#에서 프로그래밍 방식으로 Visio 셰이프를 보호하는 방법을 보여줍니다.
// 로드 입력 다이어그램
Aspose.Diagram.Diagram diagram = new Aspose.Diagram.Diagram("ProtectAndUnprotect.vsd");
// 이름으로 페이지 가져오기
Aspose.Diagram.Page page = diagram.Pages.GetPage("Flow 1");
// ID로 모양 가져오기
Aspose.Diagram.Shape shape = page.Shapes.GetShape(1);
// 보호 설정
shape.Protection.LockAspect.Value = Aspose.Diagram.BOOL.True;
shape.Protection.LockCrop.Value = Aspose.Diagram.BOOL.True;
shape.Protection.LockCustProp.Value = Aspose.Diagram.BOOL.True;
shape.Protection.LockDelete.Value = Aspose.Diagram.BOOL.True;
shape.Protection.LockHeight.Value = Aspose.Diagram.BOOL.True;
shape.Protection.LockMoveX.Value = Aspose.Diagram.BOOL.True;
shape.Protection.LockMoveY.Value = Aspose.Diagram.BOOL.True;
shape.Protection.LockRotate.Value = Aspose.Diagram.BOOL.True;
shape.Protection.LockTextEdit.Value = Aspose.Diagram.BOOL.True;
// 보호된 출력 Visio 다이어그램 저장
diagram.Save("VisioShapeProtection_Out.vdx", Aspose.Diagram.SaveFileFormat.VDX);
C#에서 Visio 셰이프 보호 해제
아래 단계에 따라 Visio 다이어그램에서 셰이프 보호를 해제할 수 있습니다.
- 입력 Visio 다이어그램 파일을 로드합니다.
- 특정 페이지 및 해당 셰이프에 액세스하여 셰이프 보호를 해제합니다.
- 출력 Visio 파일을 내보냅니다.
다음 코드 샘플은 C#에서 프로그래밍 방식으로 Visio 다이어그램의 셰이프 보호를 해제하는 방법을 보여줍니다.
// 로드 입력 다이어그램
Aspose.Diagram.Diagram diagram = new Aspose.Diagram.Diagram(dataDir + "ProtectAndUnprotect.vsd");
// 이름으로 페이지 가져오기
Aspose.Diagram.Page page = diagram.Pages.GetPage("Flow 1");
// ID로 모양 가져오기
Aspose.Diagram.Shape shape = page.Shapes.GetShape(1);
// Visio 셰이프 보호 해제
shape.Protection.LockAspect.Value = Aspose.Diagram.BOOL.False;
shape.Protection.LockCrop.Value = Aspose.Diagram.BOOL.False;
shape.Protection.LockCustProp.Value = Aspose.Diagram.BOOL.False;
shape.Protection.LockDelete.Value = Aspose.Diagram.BOOL.False;
shape.Protection.LockHeight.Value = Aspose.Diagram.BOOL.False;
shape.Protection.LockMoveX.Value = Aspose.Diagram.BOOL.False;
shape.Protection.LockMoveY.Value = Aspose.Diagram.BOOL.False;
shape.Protection.LockRotate.Value = Aspose.Diagram.BOOL.False;
shape.Protection.LockTextEdit.Value = Aspose.Diagram.BOOL.False;
// 보호되지 않은 출력 Visio 다이어그램 저장
diagram.Save("VisioShape_unProtect_Out.vdx", Aspose.Diagram.SaveFileFormat.VDX);
결론
이 문서에서는 C#에서 프로그래밍 방식으로 VSD 또는 VSDX 형식의 Visio 다이어그램 파일에서 셰이프를 보호하거나 보호 해제하는 방법을 배웠습니다. 또한 문서 공간에서 API의 다양한 다른 기능을 배울 수 있습니다. 질문이 있는 경우 포럼으로 문의해 주십시오.