Skip to content

Instantly share code, notes, and snippets.

View bonus630's full-sized avatar
🖐️

Reginaldo Santos bonus630

🖐️
View GitHub Profile
@bonus630
bonus630 / DrawLines.cs
Created April 15, 2024 03:07
Código final do tutorial 0008
[CgsAddInMacro]
public string[] ReadLines(string filePath)
{
filePath = filePath.Trim('\"');
string[] lines = File.ReadAllLines(filePath);
return lines;
}
//== igualdade
//= atribuição
@bonus630
bonus630 / CenterSelectionInPage.cs
Created November 1, 2023 16:26
Center selecteds shapes in the page center
[CgsAddInMacro]
public void CenterSelectionInPage()
{
ShapeRange sr = corelApp.ActiveSelectionRange;
sr.CenterX = corelApp.ActivePage.CenterX;
sr.CenterY = corelApp.ActivePage.CenterY;
@bonus630
bonus630 / ApplyBitmapEffect.cs
Created November 1, 2023 15:44
ApplyBitmapEffect Gaussian Blur- Coreldraw
Shape shape = corelApp.ActiveShape;
if (shape.Type == cdrShapeType.cdrBitmapShape)
{
string effectCommand = "GaussianBlurEffect GaussianBlurRadius=2500,GaussianBlurResampled=0";
shape.Bitmap.ApplyBitmapEffect("effect", effectCommand);
}
@bonus630
bonus630 / invertSelection.cs
Created October 17, 2023 03:02
InvertSelection CorelDraw C#
[CgsAddInMacro]
public void InvertSelection()
{
ShapeRange selectedRange, allRange;
selectedRange = corelApp.ActiveSelectionRange;
allRange = corelApp?.ActivePage.Shapes.All();
allRange.RemoveRange(selectedRange);
selectedRange.RemoveFromSelection();
@bonus630
bonus630 / ConnectorDimension.cs
Last active October 4, 2023 18:20
Create Connector and Dimension in CorelDraw C#.cs
[CgsAddInMacro]
public void CreateConnector()
{
Layer l = corelApp.ActiveDocument.ActiveLayer;
corelApp.ActiveDocument.BeginCommandGroup();
Shape el = l.CreateEllipse2(0, 0, 5);
Shape text = l.CreateArtisticText(20, 10, "Ellipse");
SnapPoint elP = el.SnapPoints.FindClosest(cdrPointType.cdrSnapPointObject, el.RightX, el.CenterY);
SnapPoint textP = text.SnapPoints.FindClosest(cdrPointType.cdrSnapPointObject, text.LeftX, text.CenterY);
@bonus630
bonus630 / EAN8.cs
Last active February 17, 2023 04:05
Coreldraw BarCode EAN8 code using rectangles
public class EAN8
{
private Corel.Interop.VGCore.Application app;
private const int EAN8BRASIL = 789;
// 0 1 2 3 4 5 6 7 8 9
private List<bool[]> CodDigL = new List<bool[]>() { new bool[7] { false, false, false, true, true, false, true }, new bool[7] { false, false, true, true, false, false, true }, new bool[7] { false, false, true, false, false, true, true }, new bool[7] { false, true, true, true, true, false, true }, new
@bonus630
bonus630 / CreateTable.cs
Created January 8, 2023 06:28
Coreldraw table creation exemple
public void CreateTable()
{
try
{
Layer l = corelApp.ActiveLayer;
l.Shapes.All().Delete();
double width = l.Page.SizeWidth;
double cellHeight = 9;
int columns = 2;
int rows = 50;
@bonus630
bonus630 / FastGrid.cs
Last active January 8, 2023 05:02
Coreldraw fast rectangles grid creation in C#
private void FastGrid(Shape firstShape,int cols, int rows)
{
try
{
int mShapes = cols * rows;
ShapeRange gridShapeRange = corelApp.CreateShapeRange();
@bonus630
bonus630 / FitContentToPage.cs
Last active December 2, 2022 03:17
Fit content to page in CorelDraw
public void FitContentToPage(Page p,bool proportion = true, double margin = 0)
{
try
{
corelApp.Optimization = true;
ShapeRange sr = p.Shapes.All();
ShapeRange guides = p.FindShapes(Type: cdrShapeType.cdrGuidelineShape);
sr.RemoveRange(guides);
Rect bBox = p.BoundingBox;