-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
103 lines (85 loc) · 4.58 KB
/
Program.cs
File metadata and controls
103 lines (85 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using DevExpress.Docs.Presentation;
using DevExpress.Drawing;
using System.Drawing;
namespace DxPresentationGetStarted;
public class Program {
public static void Main(string[] _) {
Presentation presentation = new Presentation();
presentation.Slides.Clear();
SlideMaster slideMaster = presentation.SlideMasters[0];
slideMaster.Background = new CustomSlideBackground(new SolidFill(Color.FromArgb(194, 228, 249)));
Slide slide1 = new Slide(slideMaster.Layouts.Get(SlideLayoutType.Title));
foreach (Shape shape in slide1.Shapes) {
if (shape.PlaceholderSettings.Type is PlaceholderType.CenteredTitle) {
shape.TextArea = new TextArea("Daily Testing Status Report");
}
if (shape.PlaceholderSettings.Type is PlaceholderType.Subtitle) {
shape.TextArea = new TextArea($"{DateTime.Now: dddd, MMMM d, yyyy}");
}
}
presentation.Slides.Add(slide1);
Slide slide2 = new Slide(slideMaster.Layouts.GetOrCreate(SlideLayoutType.Object));
foreach (Shape shape in slide2.Shapes) {
if (shape.PlaceholderSettings.Type is PlaceholderType.Title) {
shape.TextArea = new TextArea("Today’s Highlights");
}
if (shape.PlaceholderSettings.Type is PlaceholderType.Body) {
TextArea textArea = new TextArea();
textArea.Paragraphs.Clear();
textArea.Paragraphs.Add(new TextParagraph("5 successful builds"));
textArea.Paragraphs.Add(new TextParagraph("2 failed builds"));
textArea.Paragraphs.Add(new TextParagraph("12 new bugs reported"));
textArea.Paragraphs.Add(new TextParagraph("3 deployments"));
textArea.Paragraphs.Add(new TextParagraph("1 rollback"));
shape.TextArea = textArea;
}
}
presentation.Slides.Add(slide2);
Slide slide3 = new Slide(slideMaster.Layouts.GetOrCreate(SlideLayoutType.Object));
foreach (Shape shape in slide3.Shapes.ToList()) {
if (shape.PlaceholderSettings.Type is PlaceholderType.Title) {
shape.TextArea = new TextArea("Build Status");
}
if (shape.PlaceholderSettings.Type is PlaceholderType.Body) {
RectangleF rect = presentation.GetActualShapeBounds(slide3, shape);
slide3.Shapes.Remove(shape);
Table table = new Table(5, 5, rect.X, rect.Y, rect.Width, rect.Height);
slide3.Shapes.Add(table);
table[0, 0].TextArea.Text = "Build ID";
table[0, 1].TextArea.Text = "Branch";
table[0, 2].TextArea.Text = "Status";
table[0, 3].TextArea.Text = "Duration";
table[0, 4].TextArea.Text = "Triggered By";
table[1, 0].TextArea.Text = "#5421";
table[1, 1].TextArea.Text = "main";
table[1, 2].TextArea.Text = "✅ Passed";
table[1, 3].TextArea.Text = "4m 30s";
table[1, 4].TextArea.Text = "Auto-schedule";
table[2, 0].TextArea.Text = "#5420";
table[2, 1].TextArea.Text = "ui-fix";
table[2, 2].TextArea.Text = "❌ Failed";
table[2, 3].TextArea.Text = "2m 18s";
table[2, 4].TextArea.Text = "Push by dev1";
table[3, 0].TextArea.Text = "#5419";
table[3, 1].TextArea.Text = "main";
table[3, 2].TextArea.Text = "✅ Passed";
table[3, 3].TextArea.Text = "3m 52s";
table[3, 4].TextArea.Text = "Auto-schedule";
table[4, 0].TextArea.Text = "#5418";
table[4, 1].TextArea.Text = "hotfix";
table[4, 2].TextArea.Text = "❌ Failed";
table[4, 3].TextArea.Text = "5m 1s";
table[4, 4].TextArea.Text = "Manual";
table.Style = new ThemedTableStyle(TableStyleType.LightStyle1);
table.HasBandedRows = false;
}
}
presentation.Slides.Add(slide3);
presentation.HeaderFooterManager.AddSlideNumberPlaceholder(presentation.Slides);
presentation.HeaderFooterManager.AddFooterPlaceholder(presentation.Slides, "ProductXCompany");
FileStream outputStream = new FileStream(@"..\..\..\data\my-presentation.pptx", FileMode.Create);
presentation.SaveDocument(outputStream);
outputStream.Dispose();
presentation.ExportToPdf(new FileStream(@"..\..\..\data\exported-document.pdf", FileMode.Create));
}
}