private RenderObject CreateButton(string caption) { RenderArea ra = new RenderArea(); RenderInputButton rb = new RenderInputButton(caption); rb.Style.Font = new Font("Tahoma", 14); rb.X = LengthExp.Predefined.HorzCenterAlign; rb.Y = LengthExp.Predefined.VertCenterAlign; rb.Width = "35mm"; rb.Height = "20mm"; ra.Children.Add(rb); return(ra); }
/*private RenderObject CreateItem(string caption, Style style) * { * RenderArea result = new RenderArea(); * result.Style.Padding.All = "1mm"; * * RenderText rt = new RenderText(); * rt.Text = caption; * rt.Style.AmbientParent = style; * result.Children.Add(rt); * * RenderInputText rit = new RenderInputText(); * rit.Style.AmbientParent = style; * rit.Width = "parent.width"; * result.Children.Add(rit); * * return result; * }*/ private void GenerateDoc(C1PrintDocument doc) { doc.Clear(); RenderTable ph = new RenderTable(doc); RenderInputButton rbPrior = new RenderInputButton(doc, "<<"); rbPrior.InputActions.Add( UserActionEnum.Click, new ActionHandlerLink(new C1LinkTargetPage(PageJumpTypeEnum.Previous))); RenderInputButton rbNext = new RenderInputButton(doc, ">>"); rbNext.X = "parent.Width - width"; rbNext.InputActions.Add( UserActionEnum.Click, new ActionHandlerLink(new C1LinkTargetPage(PageJumpTypeEnum.Next))); ph.Cells[0, 0].Area.Children.Add(rbPrior); ph.Cells[0, 1].Area.Children.Add(rbNext); ph.Style.Borders.Bottom = new LineDef("1pt", Color.Black); ph.Style.Spacing.Bottom = "5mm"; doc.PageLayout.PageHeader = ph; doc.PageLayout.PageFooter = new RenderText(doc, "Page [PageNo] of [PageCount]", AlignHorzEnum.Right); // create styles _captionStyle = doc.Style.Children.Add(); _captionStyle.Font = new Font("Tahoma", 16, FontStyle.Bold); _captionStyle.BackColor = Color.FromArgb(208, 237, 253); _captionStyle.Spacing.Bottom = "5mm"; _fieldCaptionStyle = doc.Style.Children.Add(); _fieldCaptionStyle.Font = new Font("Tahoma", 13); _requiredCharStyle = doc.Style.Children.Add(); _requiredCharStyle.Parents = _fieldCaptionStyle; _requiredCharStyle.TextColor = Color.Red; _passwordInfoStyle = doc.Style.Children.Add(); _passwordInfoStyle.Parents = _fieldCaptionStyle; _passwordInfoStyle.TextPosition = TextPositionEnum.Subscript; _textFieldStyle = doc.Style.Children.Add(); _textFieldStyle.Font = new Font("Tahoma", 12, FontStyle.Bold); // Personal information doc.Body.Children.Add(new RenderText(doc, "Personal information", _captionStyle, _captionStyle)); // create RenderTable containing the form's fields RenderTable rt = new RenderTable(doc); rt.CellStyle.Padding.All = "0.5mm"; rt.Cells[0, 0].RenderObject = CreateFieldCaption(doc, "First name:", true, false); rt.Cells[1, 0].RenderObject = CreateTextField(doc, "FirstName", Color.Black, false); rt.Cells[0, 1].RenderObject = CreateFieldCaption(doc, "Last name:", true, false); rt.Cells[1, 1].RenderObject = CreateTextField(doc, "LastName", Color.Black, false); rt.Cells[2, 0].RenderObject = CreateFieldCaption(doc, "Email Address:", true, false); rt.Cells[3, 0].RenderObject = CreateTextField(doc, "EmailAddress", Color.Blue, false); rt.Cells[2, 1].RenderObject = CreateFieldCaption(doc, "Retype Email Address:", true, false); rt.Cells[3, 1].RenderObject = CreateTextField(doc, "RetypeEmailAddress", Color.Blue, false); rt.Cells[4, 0].RenderObject = CreateFieldCaption(doc, "Password:"******"Password", Color.Black, true); rt.Cells[4, 1].RenderObject = CreateFieldCaption(doc, "Retype Password:"******"RetypePassword", Color.Black, true); rt.Cells[6, 0].RenderObject = CreateFieldCaption(doc, "City:", false, false); rt.Cells[7, 0].RenderObject = CreateTextField(doc, "City", Color.Black, false); rt.Cells[6, 1].RenderObject = CreateFieldCaption(doc, "State:", false, false); rt.Cells[7, 1].RenderObject = CreateTextField(doc, "State", Color.Black, false); // add the "Select" button RenderArea ra = new RenderArea(doc); RenderInputButton rb = new RenderInputButton(doc, "Select..."); rb.Name = "Select"; rb.X = "parent.Width - width"; ra.Children.Add(rb); rt.Cells[8, 1].RenderObject = ra; // Work status field rt.Cells[9, 0].RenderObject = CreateFieldCaption(doc, "Work status:", true, false); rt.Cells[9, 0].SpanCols = 2; rt.Cells[10, 0].RenderObject = new RenderInputRadioButton(doc, "StatusCitizen", "I am a citizen"); ((RenderInputRadioButton)rt.Cells[10, 0].RenderObject).Checked = true; rt.Cells[10, 1].RenderObject = new RenderInputRadioButton(doc, "StatusAny", "I am authorized to work for any employer"); rt.Cells[11, 0].RenderObject = new RenderInputRadioButton(doc, "StatusCurrent", "I am authorized to work for my current employer"); rt.Cells[11, 1].RenderObject = new RenderInputRadioButton(doc, "StatusSeeking", "I am seeking authorization"); rt.Style.Spacing.Bottom = "5mm"; doc.Body.Children.Add(rt); // doc.Body.Children.Add(new RenderText(doc, "Interests", _captionStyle, _captionStyle)); rt = new RenderTable(doc); rt.Cells[0, 0].RenderObject = new RenderInputCheckBox(doc, "Accounting"); rt.Cells[0, 1].RenderObject = new RenderInputCheckBox(doc, "General Business"); rt.Cells[0, 2].RenderObject = new RenderInputCheckBox(doc, "Pharmaceutical"); rt.Cells[1, 0].RenderObject = new RenderInputCheckBox(doc, "Admin & Clerical"); rt.Cells[1, 1].RenderObject = new RenderInputCheckBox(doc, "General Labor"); rt.Cells[1, 2].RenderObject = new RenderInputCheckBox(doc, "Professional Services"); rt.Cells[2, 0].RenderObject = new RenderInputCheckBox(doc, "Automotive"); rt.Cells[2, 1].RenderObject = new RenderInputCheckBox(doc, "Government"); rt.Cells[2, 2].RenderObject = new RenderInputCheckBox(doc, "QA - Quality Control"); rt.Cells[2, 0].RenderObject = new RenderInputCheckBox(doc, "Biotech"); rt.Cells[2, 1].RenderObject = new RenderInputCheckBox(doc, "Information Technology"); rt.Cells[2, 2].RenderObject = new RenderInputCheckBox(doc, "Warehouse"); rt.BreakAfter = BreakEnum.Page; doc.Body.Children.Add(rt); doc.Body.Children.Add(new RenderText(doc, "Desired Position", _captionStyle, _captionStyle)); doc.Body.Children.Add(new RenderText(doc, "Describe your desired position by completing as many of the following questions as possible.\n\nPlease indicate the wage you are seeking.")); rt = new RenderTable(doc); rt.Cells[0, 0].RenderObject = new RenderInputCheckBox(doc, "Full-time"); rt.Cells[0, 1].RenderObject = new RenderInputCheckBox(doc, "Part-time"); rt.Cells[0, 2].RenderObject = new RenderInputCheckBox(doc, "Intern"); rt.Cells[1, 0].RenderObject = new RenderInputCheckBox(doc, "Seasonal"); rt.Cells[1, 1].RenderObject = new RenderInputCheckBox(doc, "Temporary"); rt.Style.Spacing.Bottom = "5mm"; doc.Body.Children.Add(rt); doc.Body.Children.Add(new RenderText(doc, "How many miles are you willing to commute to work?")); RenderInputComboBox rc = new RenderInputComboBox( doc, "-- Select Distance --", "1 mile", "5 miles", "10 miles", "25 miles", "50 miles", "100 miles"); rc.Text = rc.Items[0].Text; rc.Style.Parents = _textFieldStyle; rc.Style.Spacing.Bottom = "5mm"; doc.Body.Children.Add(rc); doc.Body.Children.Add(new RenderText(doc, "How often are you willing to travel for work?")); rc = new RenderInputComboBox( doc, "Negligible", "Up to 25%", "Up to 50%", "Road Warrior"); rc.DropDownStyle = ComboBoxStyle.DropDownList; rc.Text = rc.Items[0].Text; doc.Body.Children.Add(rc); // Save button rb = new RenderInputButton(doc, "Save..."); rb.AcceptButton = true; rb.InputActions.Add( UserActionEnum.Click, new ActionHandlerFileSave()); doc.Body.Children.Add(rb); rb = new RenderInputButton(doc, "Save as PDF..."); rb.InputActions.Add( UserActionEnum.Click, new ActionHandlerFileSave(null, ExportProviders.PdfExportProvider)); doc.Body.Children.Add(rb); doc.Generate(); }
private void MakeDoc1(C1PrintDocument doc) { // setup a page header with links to first|prev|next|last pages: RenderTable rtnav = new RenderTable(); // suppress different display of visited hyperlinks for page navigator: rtnav.Style.VisitedHyperlinkAttrs = rtnav.Style.HyperlinkAttrs; // space things out rtnav.Style.Spacing.Bottom = "5mm"; // add navigator links rtnav.Cells[0, 0].Text = "First page"; rtnav.Cells[0, 0].RenderObject.Hyperlink = new C1Hyperlink( new C1LinkTargetPage(PageJumpTypeEnum.First), "Go to first page"); rtnav.Cells[0, 1].Text = "Previous page"; rtnav.Cells[0, 1].RenderObject.Hyperlink = new C1Hyperlink( new C1LinkTargetPage(PageJumpTypeEnum.Previous), "Go to previous page"); rtnav.Cells[0, 2].Text = "Next page"; rtnav.Cells[0, 2].RenderObject.Hyperlink = new C1Hyperlink( new C1LinkTargetPage(PageJumpTypeEnum.Next), "Go to next page"); rtnav.Cells[0, 3].Text = "Last page"; rtnav.Cells[0, 3].RenderObject.Hyperlink = new C1Hyperlink( new C1LinkTargetPage(PageJumpTypeEnum.Last), "Go to last page"); doc.PageLayout.PageHeader = rtnav; // make the body of the document // make an anchor RenderText rt1 = new RenderText("This is text with anchor1."); // the name ("anchor1") will be used to jump to this link: rt1.Anchors.Add(new C1Anchor("anchor1")); rt1.Hyperlink = new C1Hyperlink(new C1LinkTargetPage(PageJumpTypeEnum.Last), "Go to the last page of the document"); doc.Body.Children.Add(rt1); //-------------------------------------------------------------------- // make an external document to jump to: C1PrintDocument doc2 = new C1PrintDocument(); RenderText doc2rt = new RenderText("This is Document 2."); doc2rt.Style.Spacing.All = "3mm"; doc2rt.Style.Font = new Font("Arial", 14); // anchor names must be unique within the document but not across documents doc2rt.Anchors.Add(new C1Anchor("anchor1")); doc2.Body.Children.Add(doc2rt); // make a button in the new document to go back RenderInputButton doc2btn = new RenderInputButton("Go back..."); doc2btn.Width = "3cm"; doc2btn.Height = "1cm"; doc2btn.InputActions.Add(UserActionEnum.Click, new ActionHandlerHistoryPrev()); doc2.Body.Children.Add(doc2btn); doc2.Generate(); // save the document in our run dir: string doc2path = Application.StartupPath + @"\doc2.c1d"; doc2.Save(doc2path); //-------------------------------------------------------------------- // add a link to open doc2: RenderText rt2 = new RenderText("Click here to open Document 2."); rt2.Hyperlink = new C1Hyperlink( new C1LinkTargetExternalAnchor(doc2path, "anchor1")); doc.Body.Children.Add(rt2); // add filler for (int i = 0; i < 500; ++i) { doc.Body.Children.Add(new RenderText(string.Format("... filler {0} ...", i))); } // add hyperlink to anchor1 RenderText rt3 = new RenderText("Click here to go to anchor1."); rt3.Hyperlink = new C1Hyperlink(new C1LinkTargetAnchor("anchor1"), "This is status text when the mouse hovers over link to anchor1"); doc.Body.Children.Add(rt3); // to jump to a render object, an anchor is really not needed: RenderText rt4 = new RenderText("Click here to go to the middle of document."); rt4.Hyperlink = new C1Hyperlink(doc.Body.Children[doc.Body.Children.Count / 2]); rt4.Hyperlink.StatusText = "Go to the approximate middle of the document"; doc.Body.Children.Add(rt4); // add image with hyperlink to a URL RenderImage ri1 = new RenderImage(global::Hyperlinks.Properties.Resources.google); ri1.Hyperlink = new C1Hyperlink(new C1LinkTargetFile("http://www.google.com"), "Go googling..."); doc.Body.Children.Add(ri1); }