/// <summary> /// Draws a sample box. /// </summary> public void BeginBox(XGraphics gfx, int number) { //obracene XY gfx.RotateAtTransform(90.0, new XPoint(height / 4, width / 4)); gfx.TranslateTransform(+62, +63); //const int dEllipse = 15; XRect rect = new XRect(0, 0, height /2 -2, width/2 -2); if (number % 2 == 0) rect.X += height/2 +2; rect.Y = ((number - 1) / 2) * (-width/2 - 3); //rect.Inflate(-10, -10); //XRect rect2 = rect; XPen pen = new XPen(XColors.Black, 1); gfx.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height); //rect2.Offset(this.borderWidth, this.borderWidth); //gfx.DrawRoundedRectangle(new XSolidBrush(this.shadowColor), rect2, new XSize(dEllipse + 8, dEllipse + 8)); //XLinearGradientBrush brush = new XLinearGradientBrush(rect, this.backColor, this.backColor2, XLinearGradientMode.Vertical); //gfx.DrawRoundedRectangle(this.borderPen, brush, rect, new XSize(dEllipse, dEllipse)); //rect.Inflate(-5, -5); //rect.Inflate(-10, -5); //rect.Y += 20; //rect.Height -= 20; ////gfx.DrawRectangle(XPens.Red, rect); // gfx.TranslateTransform(rect.X, rect.Y); this.state = gfx.Save(); }
public InternalGraphicsState(XGraphics gfx, XGraphicsState state) { this.gfx = gfx; this.state = state; state.InternalState = this; //#if GDI // //GdiGraphicsState = state.GdiState; // this.gfx = gfx; // this.state = state; // state.InternalState = this; //#endif //#if WPF // this.gfx = gfx; // this.state = state; // state.InternalState = this; //#endif }
public InternalGraphicsState(XGraphics gfx, XGraphicsState state) { this.gfx = gfx; this.state = state; state.InternalState = this; //#if GDI // //GdiGraphicsState = state.GdiState; // this.gfx = gfx; // this.state = state; // state.InternalState = this; //#endif //#if WPF // this.gfx = gfx; // this.state = state; // state.InternalState = this; //#endif }
public void Dispose() { if (g != null && gs != null) { g.Restore(gs); g = null; gs = null; } }
public SaveGraphicsState(XGraphics graphics) { g = graphics; gs = graphics.Save(); }
public InternalGraphicsState(XGraphics gfx, XGraphicsState state) { _gfx = gfx; State = state; State.InternalState = this; }
public SaveGraphicsState(XGraphics g) { this.g = g; this.gs = g.Save(); }
public InternalGraphicsState(XGraphics gfx, XGraphicsState state) { _gfx = gfx; State = state; State.InternalState = this; }
/// <summary> /// Restores the state of this XGraphics object to the state represented by the specified /// XGraphicsState object. /// </summary> public void Restore(XGraphicsState state) { if (state == null) throw new ArgumentNullException("state"); #if GDI if (this.targetContext == XGraphicTargetContext.GDI) { this.gsStack.Restore(state.InternalState); this.gfx.Restore(state.GdiState); this.transform = state.InternalState.Transform; } #endif #if WPF if (this.targetContext == XGraphicTargetContext.WPF) { this.gsStack.Restore(state.InternalState); this.transform = state.InternalState.Transform; } #endif if (this.renderer != null) this.renderer.Restore(state); }
// ----- DrawGrit ----------------------------------------------------------------------------- //[Conditional("DEBUG")] //public void DrawGridlines(XPoint origin, XPen majorpen, double majordelta, XPen minorpen, double minordelta) //{ // RectangleF box = new RectangleF(0, 0, 600, 850); // DrawGridline(origin, minorpen, minordelta, box); // DrawGridline(origin, majorpen, majordelta, box); // /* // float xmin = -10000f, ymin = -10000f, xmax = 10000f, ymax = 10000f; // float x, y; // x = origin.X; // while (x < xmax) // { // DrawLine(majorpen, x, ymin, x, ymax); // x += majordelta; // } // x = origin.X - majordelta; // while (x > xmin) // { // DrawLine(majorpen, x, ymin, x, ymax); // x -= majordelta; // } // y = origin.Y; // while (y < ymax) // { // DrawLine(majorpen, xmin, y, xmax, y); // y += majordelta; // } // y = origin.Y - majordelta; // while (y > ymin) // { // DrawLine(majorpen, xmin, y, xmax, y); // y -= majordelta; // } // */ //} //[Conditional("DEBUG")] //void DrawGridline(XPoint origin, XPen pen, double delta, XRect box) //{ // double xmin = box.X, ymin = box.Y, xmax = box.X + box.Width, ymax = box.Y + box.Height; // double x, y; // y = origin.Y; // while (y < ymax) // { // DrawLine(pen, xmin, y, xmax, y); // y += delta; // } // y = origin.Y - delta; // while (y > ymin) // { // DrawLine(pen, xmin, y, xmax, y); // y -= delta; // } // x = origin.X; // while (x < xmax) // { // DrawLine(pen, x, ymin, x, ymax); // x += delta; // } // x = origin.X - delta; // while (x > xmin) // { // DrawLine(pen, x, ymin, x, ymax); // x -= delta; // } //} #endregion // -------------------------------------------------------------------------------------------- #region Save and Restore /// <summary> /// Saves the current state of this XGraphics object and identifies the saved state with the /// returned XGraphicsState object. /// </summary> public XGraphicsState Save() { XGraphicsState xState = new XGraphicsState(this.gfx.Save()); InternalGraphicsState iState = new InternalGraphicsState(xState); iState.Transform = this.transform; this.gsStack.Push(iState); if (this.renderer != null) this.renderer.Save(xState); return xState; }
/// <summary> /// Resets the clipping. /// </summary> private void RestoreInitialClip() { //Get back to the initial state graphics.Restore(initialState); initialState = graphics.Save(); //Restore transform graphics.MultiplyTransform(transform); clippingRegion = new Region(); }
/// <summary> /// Restores the state to the initial state. /// </summary> private void RestoreInitialTransform() { //Go to the initial state graphics.Restore(initialState); initialState = graphics.Save(); //We've just restored the initial state so the there are no transformations active. transform = new Matrix(); //Restore the last clipping ApplyClip(clippingRegion); }
// ======================================================================== // IGraphics implementation #region === IGraphics implementation #region --- Transform /// <summary> /// Takes the inital state. /// </summary> public void TakeInitialTransform() { initialState = graphics.Save(); //Initial state token, so reset the transform matrix. transform = new Matrix(); }
public void Dispose() { if (this.g != null && this.gs != null) { this.g.Restore(this.gs); this.g = null; this.gs = null; } }
/// <summary> /// Restores the state of this XGraphics object to the state represented by the specified /// XGraphicsState object. /// </summary> public void Restore(XGraphicsState state) { if (state == null) throw new ArgumentNullException("state"); this.gsStack.Restore(state.InternalState); this.gfx.Restore(state.GdipState); this.transform = state.InternalState.Transform; if (this.renderer != null) this.renderer.Restore(state); }
// ----- DrawGrit ----------------------------------------------------------------------------- //[Conditional("DEBUG")] //public void DrawGridlines(XPoint origin, XPen majorpen, double majordelta, XPen minorpen, double minordelta) //{ // RectangleF box = new RectangleF(0, 0, 600, 850); // DrawGridline(origin, minorpen, minordelta, box); // DrawGridline(origin, majorpen, majordelta, box); // /* // float xmin = -10000f, ymin = -10000f, xmax = 10000f, ymax = 10000f; // float x, y; // x = origin.X; // while (x < xmax) // { // DrawLine(majorpen, x, ymin, x, ymax); // x += majordelta; // } // x = origin.X - majordelta; // while (x > xmin) // { // DrawLine(majorpen, x, ymin, x, ymax); // x -= majordelta; // } // y = origin.Y; // while (y < ymax) // { // DrawLine(majorpen, xmin, y, xmax, y); // y += majordelta; // } // y = origin.Y - majordelta; // while (y > ymin) // { // DrawLine(majorpen, xmin, y, xmax, y); // y -= majordelta; // } // */ //} //[Conditional("DEBUG")] //void DrawGridline(XPoint origin, XPen pen, double delta, XRect box) //{ // double xmin = box.X, ymin = box.Y, xmax = box.X + box.Width, ymax = box.Y + box.Height; // double x, y; // y = origin.Y; // while (y < ymax) // { // DrawLine(pen, xmin, y, xmax, y); // y += delta; // } // y = origin.Y - delta; // while (y > ymin) // { // DrawLine(pen, xmin, y, xmax, y); // y -= delta; // } // x = origin.X; // while (x < xmax) // { // DrawLine(pen, x, ymin, x, ymax); // x += delta; // } // x = origin.X - delta; // while (x > xmin) // { // DrawLine(pen, x, ymin, x, ymax); // x -= delta; // } //} #endregion // -------------------------------------------------------------------------------------------- #region Save and Restore /// <summary> /// Saves the current state of this XGraphics object and identifies the saved state with the /// returned XGraphicsState object. /// </summary> public XGraphicsState Save() { XGraphicsState xState = null; #if GDI if (this.targetContext == XGraphicTargetContext.GDI) { xState = new XGraphicsState(this.gfx.Save()); InternalGraphicsState iState = new InternalGraphicsState(this, xState); iState.Transform = this.transform; this.gsStack.Push(iState); } #endif #if WPF if (this.targetContext == XGraphicTargetContext.WPF) { xState = new XGraphicsState(); InternalGraphicsState iState = new InternalGraphicsState(this, xState); iState.Transform = this.transform; this.gsStack.Push(iState); } #endif if (this.renderer != null) this.renderer.Save(xState); return xState; }
void ResetTransform(XGraphicsState state) { if (state != null) this.gfx.Restore(state); }
private static void PrepareInvoiceTop(XGraphics formGfx, XGraphicsState state, string InvoiceNumber) { string Headline = "Service Invoice " + InvoiceNumber + ""; string MyName = TimeConnector.Data.Variables.SelectedContractor["CmpName"]; string Phone = TimeConnector.Data.Variables.SelectedContractorContact["ConPhone"]; string MyPhone = "Phone (" + Phone.Substring(0, 3) + ") " + Phone.Substring(4, 3) + "-" + Phone.Substring(7, 4) + ""; string MyEmail = "Email: " + TimeConnector.Data.Variables.SelectedContractorContact["ConEmail"] + ""; string MyAddress = TimeConnector.Data.Variables.SelectedContractor["CmpAddress"]; string MyCityStateZip = "" + TimeConnector.Data.Variables.SelectedContractor["CmpCity"] + ", " + TimeConnector.Data.Variables.SelectedContractor["CmpState"] + " " + TimeConnector.Data.Variables.SelectedContractor["CmpZip"] + ""; string WeekEnding = TimeConnector.Data.Variables.SelectedPaydate["WeekEnd"]; string PayDate = TimeConnector.Data.Variables.SelectedPaydate["PayDate"]; string CompanyName = TimeConnector.Data.Variables.SelectedCompany["CmpName"]; string CompanyContact = "c/o " + TimeConnector.Data.Variables.SelectedContact["ConName"] + ""; string CompanyContactPhone = "" + TimeConnector.Data.Variables.SelectedContact["ConPhone"] + ""; string CompanyContactEmail = "" + TimeConnector.Data.Variables.SelectedContact["ConEmail"] + ""; string CompanyAddress = TimeConnector.Data.Variables.SelectedCompany["CmpAddress"]; string CompanyCityStateZip = "" + TimeConnector.Data.Variables.SelectedCompany["CmpCity"] + ", " + TimeConnector.Data.Variables.SelectedCompany["CmpState"] + " " + TimeConnector.Data.Variables.SelectedCompany["CmpZip"] + ""; //----- Invoice Header XFont HeaderFont = new XFont("Imprint MT Shadow", 30, XFontStyle.Bold); string HeaderText = "I N V O I C E"; XStringFormat format = new XStringFormat(); format.Alignment = XStringAlignment.Near; format.LineAlignment = XLineAlignment.Near; XColor color = default(XColor); color = XColor.FromName("SteelBlue"); color.A = 0.5; XBrush brush = default(XBrush); brush = new XSolidBrush(color); XPoint point = new XPoint(410, 20); formGfx.DrawString(HeaderText, HeaderFont, brush, point, format); //..... My Company Icon state = formGfx.Save(); formGfx.DrawImage(XImage.FromFile("Images\\logo.png"), 20, 20, 65, 65); formGfx.Restore(state); //..... My Company Information DrawText(MyName, formGfx, new XFont(PdfFontMyInfo, 15, XFontStyle.Bold), XBrushes.SteelBlue, 95, 20); DrawText(MyAddress, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 45); DrawText(MyCityStateZip, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 55); DrawText(MyPhone, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 65); DrawText(MyEmail, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 75); XPen pen1 = new XPen(XColors.Maroon); pen1.Width = 1; //Dim pen2 As New XPen(XColors.Maroon) XPen pen2 = new XPen(XColors.SteelBlue); pen2.Width = 2; //Dim pen3 As New XPen(XColors.SteelBlue) XPen pen3 = new XPen(XColors.Maroon); pen3.Width = 1; formGfx.DrawBeziers(pen1, XPoint.ParsePoints("20,95 80,140 190,70 250,110")); DrawSignature(formGfx, 531, 696, "LightGray", 1); DrawSignature(formGfx, 530, 695, "Black", 1.5); DrawSignature(formGfx, 530, 695, "SteelBlue", 1); //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("300,100 310,110 340,90 350,100")) 'Top //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("312,108 322,118 332,99 342,110")) 'Top Center //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("314,118 324,128 334,109 344,120")) 'Bottom Center //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("310,130 315,140 330,120 335,130")) 'Bottom //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("325,100 335,110 325,120 335,130")) 'Center //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("300,100 310,110 340,90 350,100")) 'Top //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("312,108 322,118 332,99 342,110")) 'Top Center //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("314,118 324,128 334,109 344,120")) 'Bottom Center //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("310,130 315,140 330,120 335,130")) 'Bottom //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("325,100 335,110 325,120 335,130")) 'Center //..... ACS Company Icon DrawText("B I L L T O :", formGfx, new XFont(PdfFont, 9, XFontStyle.Bold), XBrushes.Black, 60, 95); state = formGfx.Save(); formGfx.DrawImage(XImage.FromFile("Images\\ACSIcon.jpg"), 20, 115, 65, 65); formGfx.Restore(state); //..... ACS Company Information DrawText(CompanyName, formGfx, new XFont(PdfFontMyInfo, 15, XFontStyle.Bold), XBrushes.Green, 95, 115); DrawText(CompanyContact, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 135); DrawText(CompanyAddress, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 145); DrawText(CompanyCityStateZip, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 155); DrawText(CompanyContactPhone, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 165); DrawText(CompanyContactEmail, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 175); //..... Invoice Information DrawLine(formGfx, 450, 590, 80, "SteelBlue", 0.5); DrawText("Invoice #:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 71); DrawText(InvoiceNumber, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Maroon, 530, 71); DrawLine(formGfx, 450, 590, 90, "SteelBlue", 0.5); DrawText("Week Ending:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 81); DrawText(WeekEnding, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 530, 81); DrawLine(formGfx, 450, 590, 100, "SteelBlue", 0.5); DrawText("Pay Date:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 91); DrawText(PayDate, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 530, 91); DrawLine(formGfx, 450, 590, 110, "SteelBlue", 0.5); DrawText("Hours Worked:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 101); DrawText(TimeConnector.Data.Invoice.FinHour, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 530, 101); DrawLine(formGfx, 450, 590, 120, "SteelBlue", 0.5); DrawText("Balance Due:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 111); DrawText(TimeConnector.Data.Invoice.FinCost, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 530, 111); }
public InternalGraphicsState(XGraphicsState state) { GdipGraphicsState = state.GdipState; state.InternalState = this; }
public static void BeginBox(XGraphics gfx, int number, string title, double borderWidth, double borderHeight, XColor shadowColor, XColor backColor, XColor backColor2, XPen borderPen) { const int dEllipse = 15; XRect rect = new XRect(0, 20, 300, 200); if (number % 2 == 0) rect.X = 300 - 5; rect.Y = 40 + ((number - 1) / 2) * (200 - 5); rect.Inflate(-10, -10); XRect rect2 = rect; rect2.Offset(borderWidth, borderHeight); gfx.DrawRoundedRectangle(new XSolidBrush(shadowColor), rect2, new XSize(dEllipse + 8, dEllipse + 8)); XLinearGradientBrush brush = new XLinearGradientBrush(rect, backColor, backColor2, XLinearGradientMode.Vertical); gfx.DrawRoundedRectangle(borderPen, brush, rect, new XSize(dEllipse, dEllipse)); rect.Inflate(-5, -5); XFont font = new XFont("Verdana", 12, XFontStyle.Regular); gfx.DrawString(title, font, XBrushes.Navy, rect, XStringFormats.TopCenter); rect.Inflate(-10, -5); rect.Y += 20; rect.Height -= 20; state = gfx.Save(); gfx.TranslateTransform(rect.X, rect.Y); }