- 프로젝트 만들기
- 개체 및 변수 참조
- 프로젝트 확장
NetLogic을 만들어 이미지에 애니메이션 효과 적용
필수 구성 요소
기본 외부 코드 편집기를 설정합니다. 기본 코드 편집기 설정 항목을 참조하십시오.
- 이미지에 애니메이션 효과를 주는 NetLogic을 만들려면
- 프로젝트 보기에서MainWindow (type)를 마우스 오른쪽 버튼으로 클릭하고 을 선택합니다.
- NetLogic을 두 번 클릭합니다.외부 코드 편집기가 열립니다.
- NetLogic을 다음 코드로 바꿔 편집합니다. NetLogic 편집 항목을 참조하십시오.#region Using directives using FTOptix.NetLogic; using FTOptix.UI; using System.Xml.Linq; using System.Linq; using UAManagedCore; using System.Threading; #endregion public class RuntimeNetLogic1 : BaseNetLogic { public override void Start() { // LogicObject.Owner is the button, so LogicObject.Owner is the MainWindow svgImage = LogicObject.Owner.Get<AdvancedSVGImage>("AdvancedSVGImage1"); // Retrieve the Path to the SVG var imageAbsolutePath = svgImage.Path.Uri; // Load the SVG into an XDocument xDocument = XDocument.Load(imageAbsolutePath); // Find the first path element var pathNode = xDocument.Descendants().Where(x => x.Name.LocalName == "path").FirstOrDefault(); // Find the first polygon element var polyNode = xDocument.Descendants().Where(x => x.Name.LocalName == "polygon").FirstOrDefault(); // Get the polygon transform attribute polyTransformAttribute = polyNode.Attribute("transform"); // Get the polygon transform attribute pathTransformAttribute = pathNode.Attribute("transform"); } public override void Stop() { keepGoing = false; if (myLRT != null) myLRT.Dispose(); } private void doRotate() { int degrees = 3; while (keepGoing) { Thread.Sleep(50); degrees += 3; if (degrees > 360) degrees = 0; string newTransformPoly = new string("rotate(" + degrees + ", 50, 250)"); polyTransformAttribute.SetValue(newTransformPoly); string newTransformPath = new string("rotate(" + degrees + ", 96, 97)"); pathTransformAttribute.SetValue(newTransformPath); //Update the SVG svgImage.SetImageContent(xDocument.ToString()); } } [ExportMethod] public void rotateSVG() { keepGoing = false; if (myLRT != null) myLRT.Dispose(); keepGoing = true; myLRT = new LongRunningTask(doRotate, LogicObject); myLRT.Start(); } private XDocument xDocument; private AdvancedSVGImage svgImage; private XAttribute polyTransformAttribute; private XAttribute pathTransformAttribute; private LongRunningTask myLRT; private bool keepGoing = true; }
- 코드를 저장합니다.
의견을 작성 부탁드립니다.