async void CreateArtisticTextAsync(VGCore.Layer layer, ArtisticText artisticText, RGBAssign rgbAssign, CancellationTokenSource cts) { VGCore.Shape shape = null; VGCore.Fill fill = null; VGCore.Color color = null; try { shape = layer.CreateArtisticText( artisticText.Left, artisticText.Bottom, artisticText.Text, VGCore.cdrTextLanguage.cdrLanguageNone, VGCore.cdrTextCharSet.cdrCharSetMixed, artisticText.Font, artisticText.Size, VGCore.cdrTriState.cdrFalse, VGCore.cdrTriState.cdrFalse, VGCore.cdrFontLine.cdrMixedFontLine, (VGCore.cdrAlignment)artisticText.Alignment ); fill = shape.Fill; color = fill.UniformColor; color.RGBAssign( rgbAssign.R, rgbAssign.G, rgbAssign.B ); shape.Name = artisticText.Name; shape.SizeWidth = artisticText.SizeWidth; } 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(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); } }