本文整理汇总了C#中Run.PrependChild方法的典型用法代码示例。如果您正苦于以下问题:C# Run.PrependChild方法的具体用法?C# Run.PrependChild怎么用?C# Run.PrependChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Run
的用法示例。
在下文中一共展示了Run.PrependChild方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Print
private static void Print(Reservering r)
{
Festival f = FestivalRepository.GetFestival();
string filename = r.ID + "_" + r.Naam + "_" + r.Voornaam + ".docx";
File.Copy("Template.docx", filename, true);
WordprocessingDocument newdoc = WordprocessingDocument.Open(filename, true);
IDictionary<String, BookmarkStart> bookmarks = new Dictionary<String, BookmarkStart>();
foreach (BookmarkStart bms in newdoc.MainDocumentPart.RootElement.Descendants<BookmarkStart>())
{
bookmarks[bms.Name] = bms;
}
bookmarks["Naam"].Parent.InsertAfter<Run>(new Run(new Text(r.Naam)), bookmarks["Naam"]);
bookmarks["Voornaam"].Parent.InsertAfter<Run>(new Run(new Text(r.Voornaam)), bookmarks["Voornaam"]);
bookmarks["Email"].Parent.InsertAfter<Run>(new Run(new Text(r.Email)), bookmarks["Email"]);
bookmarks["Type"].Parent.InsertAfter<Run>(new Run(new Text(r.Ticket.Type)), bookmarks["Type"]);
bookmarks["ID"].Parent.InsertAfter<Run>(new Run(new Text(r.ID.ToString())), bookmarks["ID"]);
bookmarks["FestivalNaam"].Parent.InsertAfter<Run>(new Run(new Text(f.Naam)), bookmarks["FestivalNaam"]);
bookmarks["TitelType"].Parent.InsertAfter<Run>(new Run(new Text(r.Ticket.Type)), bookmarks["TitelType"]);
bookmarks["TitelNaam"].Parent.InsertAfter<Run>(new Run(new Text(r.Naam)), bookmarks["TitelNaam"]);
bookmarks["TitelVoornaam"].Parent.InsertAfter<Run>(new Run(new Text(r.Voornaam)), bookmarks["TitelVoornaam"]);
Run run = new Run(new Text(r.ID.ToString()));
RunProperties prop = new RunProperties();
RunFonts font = new RunFonts() { Ascii = "Code39", HighAnsi = "Code39" };
FontSize size = new FontSize() { Val = "96" };
prop.Append(font);
prop.Append(size);
run.PrependChild<RunProperties>(prop);
bookmarks["Barcode"].Parent.InsertAfter<Run>(run, bookmarks["Barcode"]);
newdoc.Close();
}
示例2: Print
public static void Print(Ticket SelectedTicket, string path)
{
string fileName = SelectedTicket.TicketHolder.Trim() + SelectedTicket.TicketType.Name.Trim() + ".docx";
string finalPath = path + "\\" + fileName;
string code = SelectedTicket.TicketHolder + SelectedTicket.ID;
try
{
File.Copy("template.docx", finalPath, true);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
WordprocessingDocument doc = WordprocessingDocument.Open(finalPath, true);
IDictionary<string, BookmarkStart> bookmarks = new Dictionary<string, BookmarkStart>();
foreach (BookmarkStart bms in doc.MainDocumentPart.RootElement.Descendants<BookmarkStart>())
{
bookmarks[bms.Name] = bms;
}
string TicketCode = SelectedTicket.ID + SelectedTicket.TicketHolder[0] + SelectedTicket.TicketHolder[1] + SelectedTicket.TicketHolder[2];
bookmarks["TicketName"].Parent.InsertAfter<Run>(new Run(new Text("Electronic Rampage")), bookmarks["TicketName"]);
bookmarks["Name"].Parent.InsertAfter<Run>(new Run(new Text(SelectedTicket.TicketHolder)), bookmarks["Name"]);
bookmarks["Code"].Parent.InsertAfter<Run>(new Run(new Text(TicketCode)), bookmarks["Code"]);
bookmarks["TicketType"].Parent.InsertAfter<Run>(new Run(new Text(SelectedTicket.TicketType.Name)), bookmarks["TicketType"]);
Run run = new Run(new Text(code));
RunProperties prop = new RunProperties();
RunFonts font = new RunFonts() { Ascii = "Free 3 of 9 Extended", HighAnsi = "Free 3 of 9 Extended" };
FontSize size = new FontSize() { Val = SelectedTicket.ID.ToString() };
prop.Append(font);
prop.Append(size);
run.PrependChild<RunProperties>(prop);
bookmarks["Barcode"].Parent.InsertAfter<Run>(run, bookmarks["Barcode"]);
doc.Close();
System.Windows.MessageBox.Show("Ticket is aangemaakt");
}
示例3: ApplyFontProperties
private static void ApplyFontProperties(TableStyle tableStyle, RowIdentification rowIdentification, Run run)
{
int fontSize = 0;
switch (rowIdentification) {
case RowIdentification.Title:
fontSize = tableStyle.TitleFontSize;
break;
case RowIdentification.Header:
fontSize = tableStyle.HeaderFontSize;
break;
case RowIdentification.Row:
default:
fontSize = tableStyle.RowFontSize;
break;
}
RunProperties runProp = new RunProperties();
FontSize size = new FontSize();
size.Val = new StringValue((fontSize * 2).ToString());
runProp.Append(size);
run.PrependChild<RunProperties>(runProp);
}
示例4: PrintTickets
//Method om te printen
private void PrintTickets()
{
Ticket test = Ticket.GetLastTicketHolder();
if (TicketHolder.TicketHolder == test.TicketHolder && TicketHolder.TicketHolderEmail == test.TicketHolderEmail && TicketHolder.TicketType.Name == test.TicketType.Name && TicketHolder.Amount == test.Amount)
{
//export naar word
//Eerst een savefile dialog openen zodat gebruiker kan kiezen waar en hoe het document zal worden opgeslaan
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Word Doc|*.docx";
sfd.FileName = "FestivalTicket_" + TicketHolder.TicketHolder + ".docx";
if (sfd.ShowDialog() == true)
{
if (File.Exists("template.docx") == true)
{
//Kopieer de template met een eigen naam
File.Copy("template.docx", sfd.FileName, true);
}
WordprocessingDocument newdoc = WordprocessingDocument.Open(sfd.FileName, true);
IDictionary<String, BookmarkStart> bookmarks = new Dictionary<String, BookmarkStart>();
foreach (BookmarkStart bms in newdoc.MainDocumentPart.RootElement.Descendants<BookmarkStart>())
{
bookmarks[bms.Name] = bms;
}
//Properties voor font en zo instellen voor iedere append die nodig is
Run run1 = new Run(new Text(TicketHolder.TicketHolder));
RunProperties prop1 = new RunProperties();
RunFonts font1 = new RunFonts() { Ascii = "Source Sans Pro", HighAnsi = "Source Sans Pro" };
FontSize size1 = new FontSize() { Val = "20pt" };
prop1.Append(font1);
prop1.Append(size1);
run1.PrependChild<RunProperties>(prop1);
bookmarks["TicketHolder"].Parent.InsertAfter<Run>(run1, bookmarks["TicketHolder"]);
Run run2 = new Run(new Text(TicketHolder.TicketType.Name));
RunProperties prop2 = new RunProperties();
RunFonts font2 = new RunFonts() { Ascii = "Source Sans Pro", HighAnsi = "Source Sans Pro" };
FontSize size2 = new FontSize() { Val = "20pt" };
prop2.Append(font2);
prop2.Append(size2);
run2.PrependChild<RunProperties>(prop2);
bookmarks["Day"].Parent.InsertAfter<Run>(run2, bookmarks["Day"]);
Run run3 = new Run(new Text(TicketHolder.TicketType.Price.ToString()));
RunProperties prop3 = new RunProperties();
RunFonts font3 = new RunFonts() { Ascii = "Source Sans Pro", HighAnsi = "Source Sans Pro" };
FontSize size3 = new FontSize() { Val = "20pt" };
prop3.Append(font3);
prop3.Append(size3);
run3.PrependChild<RunProperties>(prop3);
bookmarks["Price"].Parent.InsertAfter<Run>(run3, bookmarks["Price"]);
Run run4 = new Run(new Text(TicketHolder.Amount.ToString()));
RunProperties prop4 = new RunProperties();
RunFonts font4 = new RunFonts() { Ascii = "Source Sans Pro", HighAnsi = "Source Sans Pro" };
FontSize size4 = new FontSize() { Val = "20pt" };
prop4.Append(font4);
prop4.Append(size4);
run4.PrependChild<RunProperties>(prop4);
bookmarks["Amount"].Parent.InsertAfter<Run>(run4, bookmarks["Amount"]);
String code = TicketHolder.TicketHolder.Substring(0, 2);
code += TicketHolder.TicketHolderEmail.Substring(0, 1);
code += TicketHolder.TicketType.Name.Substring(0, 3);
code += TicketHolder.TicketType.Id.Substring(0, 1);
Run run = new Run(new Text(code));
RunProperties prop = new RunProperties();
RunFonts font = new RunFonts() { Ascii = "Free 3 of 9 Extended", HighAnsi = "Free 3 of 9 Extended" };
FontSize size = new FontSize() { Val = "36pt" };
prop.Append(font);
prop.Append(size);
run.PrependChild<RunProperties>(prop);
bookmarks["Barcode"].Parent.InsertAfter<Run>(run, bookmarks["Barcode"]);
newdoc.Close();
ModernDialog.ShowMessage("Uw ticket werd opgeslagen om te printen.", "Printen", MessageBoxButton.OK);
}
}
else
{
ModernDialog.ShowMessage("Gelieve eerst uw ticket te bestellen.", "Bestellen", MessageBoxButton.OK);
}
}
示例5: PrintTicket
public void PrintTicket()
{
Ticket t = _geselecteerdTicket;
for (int i = 0; i < t.Amount; i++)
{
string filename = i + "_" + t.Ticketholder + ".docx";
File.Copy("Template.docx", filename, true);
WordprocessingDocument newdoc = WordprocessingDocument.Open(filename, true);
IDictionary<String, BookmarkStart> bookmarks = new Dictionary<String, BookmarkStart>();
foreach (BookmarkStart bms in newdoc.MainDocumentPart.RootElement.Descendants<BookmarkStart>())
{
bookmarks[bms.Name] = bms;
}
bookmarks["Naam"].Parent.InsertAfter<Run>(new Run(new Text(t.Ticketholder.Replace(" ", string.Empty))), bookmarks["Naam"]);
bookmarks["Email"].Parent.InsertAfter<Run>(new Run(new Text(t.TicketholderEmail)), bookmarks["Email"]);
bookmarks["Aantal"].Parent.InsertAfter<Run>(new Run(new Text(t.Amount.ToString())), bookmarks["Aantal"]);
Run run = new Run(new Text(i + t.Ticketholder));
RunProperties prop = new RunProperties();
RunFonts font = new RunFonts()
{
Ascii = "Free 3 of 9 Extended", HighAnsi = "Free 3 of 9 Extended"
};
FontSize size = new FontSize() { Val = "50" };
prop.Append(font); prop.Append(size);
run.PrependChild<RunProperties>(prop);
bookmarks["Barcode"].Parent.InsertAfter<Run>(run, bookmarks["Barcode"]);
newdoc.Close();
}
MessageBox.Show("De tickets van "+_geselecteerdTicket.Ticketholder+" werden afgedrukt.");
}
示例6: PrintWord
public static void PrintWord(Ticket ticket, Festival festival, string sPad)
{
string sFileNaam = ticket.ID + "_" + ticket.Ticketholder + ".docx";
string sFullPad = sPad + "\\" + sFileNaam;
try
{
File.Copy("C:\\Users\\jerry_000\\Dropbox\\2NMCT4\\S1\\Business applications\\Project\\FestivalApp\\word\\template.docx", sFullPad, true);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
WordprocessingDocument newDoc = WordprocessingDocument.Open(sFullPad, true);
IDictionary<string, BookmarkStart> bookmarks = new Dictionary<string, BookmarkStart>();
foreach (BookmarkStart bms in newDoc.MainDocumentPart.RootElement.Descendants<BookmarkStart>())
{
bookmarks[bms.Name] = bms;
}
//Festival name moet iets anders qua opmaak zijn
Run runTitle = new Run(new Text(festival.Naam));
RunProperties propTitle = new RunProperties();
RunFonts fontTitle = new RunFonts() { Ascii = "Segoe UI", HighAnsi = "Segoe UI" };
FontSize sizeTitle = new FontSize() { Val = "36" };
propTitle.Append(fontTitle);
propTitle.Append(sizeTitle);
runTitle.PrependChild<RunProperties>(propTitle);
bookmarks["FestivalTitle"].Parent.InsertAfter<Run>(runTitle, bookmarks["FestivalTitle"]);
bookmarks["Name"].Parent.InsertAfter<Run>(new Run(new Text(ticket.Ticketholder)), bookmarks["Name"]);
bookmarks["Email"].Parent.InsertAfter<Run>(new Run(new Text(ticket.TicketholderEmail)), bookmarks["Email"]);
bookmarks["Day"].Parent.InsertAfter<Run>(new Run(new Text(ticket.tickettype.Name)), bookmarks["Day"]);
bookmarks["Type"].Parent.InsertAfter<Run>(new Run(new Text(ticket.tickettype.Name)), bookmarks["Type"]);
bookmarks["Amount"].Parent.InsertAfter<Run>(new Run(new Text(ticket.Amount.ToString())), bookmarks["Amount"]);
bookmarks["Price"].Parent.InsertAfter<Run>(new Run(new Text(ticket.tickettype.Price.ToString())), bookmarks["Price"]);
double iTotalPrice = ticket.Amount * ticket.tickettype.Price;
bookmarks["Totalprice"].Parent.InsertAfter<Run>(new Run(new Text(iTotalPrice.ToString())), bookmarks["Totalprice"]);
//BARCODE TOEVOEGEN
//string code = Guid.NewGuid().ToString();
string code = GenerateUnique(ticket.TicketholderEmail);
Run run = new Run(new Text(code));
RunProperties prop = new RunProperties();
RunFonts font = new RunFonts() { Ascii = "Free 3 of 9 Extended", HighAnsi = "Free 3 of 9 Extended" };
FontSize size = new FontSize() { Val = "96" };
prop.Append(font);
prop.Append(size);
run.PrependChild<RunProperties>(prop);
bookmarks["Barcode"].Parent.InsertAfter<Run>(run, bookmarks["Barcode"]);
newDoc.Close();
MessageBox.Show(sFullPad + " is opgeslaan");
}
示例7: CreateTableCell
private TableCell CreateTableCell(string contents, string cell_color = "ffffff", int width = 0)
{
// Create the TableCell object
TableCell tc = new TableCell();
TableCellProperties tcp;
if (width == 0)
{
// Create the TableCellProperties object
tcp = new TableCellProperties(
new TableCellWidth { Type = TableWidthUnitValues.Auto }
);
}
else
{
tcp = new TableCellProperties(
new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = width.ToString() }
);
}
// Create the Shading object
DocumentFormat.OpenXml.Wordprocessing.Shading shading =
new DocumentFormat.OpenXml.Wordprocessing.Shading()
{
Color = "auto",
Fill = cell_color,
Val = ShadingPatternValues.Clear
};
// Add the Shading object to the TableCellProperties object
tcp.Append(shading);
// Add the TableCellProperties object to the TableCell object
tc.PrependChild<TableCellProperties>(tcp);
// also need to ensure you include the text, otherwise it causes an error (it did for me!)
Text text = new Text(contents);
// Specify the table cell content.
Run run = new Run();
RunProperties runProp = new RunProperties(); // Create run properties.
RunFonts runFont = new RunFonts(); // Create font
runFont.Ascii = "Arial"; // Specify font family
FontSize size = new FontSize();
size.Val = new StringValue("22"); // 48 half-point font size
runProp.Append(runFont);
runProp.Append(size);
run.PrependChild<RunProperties>(runProp);
run.Append(text);
ParagraphProperties pProperties = new ParagraphProperties();
ContextualSpacing cs = new ContextualSpacing();
pProperties.Append(cs);
Paragraph paragraph = new Paragraph(run);
paragraph.PrependChild<ParagraphProperties>(pProperties);
tc.Append(paragraph);
return tc;
}