async void CreateParagraphTextAsync(VGCore.Layer layer, ParagraphText paragraphText, CMYKAssign cmykAssign, CancellationTokenSource cts) { VGCore.Shape shape = null; VGCore.Outline outline = null; VGCore.Fill fill = null; VGCore.Color color = null; VGCore.Text text = null; VGCore.TextRange story = null; try { shape = layer.CreateParagraphText( paragraphText.Left, paragraphText.Top, paragraphText.Right, paragraphText.Bottom, paragraphText.Text ); fill = shape.Fill; color = fill.UniformColor; color.CMYKAssign( cmykAssign.C, cmykAssign.M, cmykAssign.Y, cmykAssign.K ); text = shape.Text; story = text.Story; story.Style = VGCore.cdrFontStyle.cdrBoldFontStyle; story.Size = paragraphText.Size; story.Alignment = (VGCore.cdrAlignment)paragraphText.Alignment;//VGCore.cdrAlignment.cdrLeftAlignment; outline = shape.Outline; outline.SetNoOutline(); shape.Name = paragraphText.Name; } catch (OperationCanceledException) { await mainWindow.OutputText.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate() { mainWindow.OutputText.Text += "Операция была отменена пользователем!\n"; })); } catch (Exception ex) { await mainWindow.OutputText.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate() { mainWindow.OutputText.Text += $"Work is failed.\n{ex.Message}\n"; })); } finally { Marshal.ReleaseComObject(story); Marshal.ReleaseComObject(text); Marshal.ReleaseComObject(color); Marshal.ReleaseComObject(fill); Marshal.ReleaseComObject(outline); Marshal.ReleaseComObject(shape); } }
async void CreateRectangleRectAsync(VGCore.Rect rect, VGCore.Layer layer, RectanglePosition rectanglePosition, RGBAssign rgbAssign, CancellationTokenSource cts) { VGCore.Shape shape = null; VGCore.Outline outline = null; VGCore.Fill fill = null; VGCore.Color color = null; try { shape = layer.CreateRectangleRect(rect); shape.PositionX = rectanglePosition.PositionX; shape.PositionY = rectanglePosition.PositionY; outline = shape.Outline; outline.Type = VGCore.cdrOutlineType.cdrNoOutline; fill = shape.Fill; color = fill.UniformColor; color.RGBAssign( rgbAssign.R, rgbAssign.G, rgbAssign.B ); } catch (OperationCanceledException) { await mainWindow.OutputText.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate() { mainWindow.OutputText.Text += "Операция была отменена пользователем!\n"; })); } catch (Exception ex) { await mainWindow.OutputText.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate() { mainWindow.OutputText.Text += $"Work is failed.\n{ex.Message}\n"; })); } finally { Marshal.ReleaseComObject(color); Marshal.ReleaseComObject(fill); Marshal.ReleaseComObject(outline); Marshal.ReleaseComObject(shape); } }