Example #1
0
 public InternalGraphicsState(XGraphics gfx, XGraphicsContainer container)
 {
     this.gfx = gfx;
     container.InternalState = this;
     //#if GDI
     //      //GdiGraphicsState = container.GdiState;
     //      this.gfx = gfx;
     //      container.InternalState = this;
     //#endif
     //#if WPF
     //      this.gfx = gfx;
     //      container.InternalState = this;
     //#endif
 }
 public InternalGraphicsState(XGraphics gfx, XGraphicsContainer container)
 {
   this.gfx = gfx;
   container.InternalState = this;
   //#if GDI
   //      //GdiGraphicsState = container.GdiState;
   //      this.gfx = gfx;
   //      container.InternalState = this;
   //#endif
   //#if WPF
   //      this.gfx = gfx;
   //      container.InternalState = this;
   //#endif
 }
Example #3
0
    /// <summary>
    /// Closes the current graphics container and restores the state of this XGraphics 
    /// to the state saved by a call to the BeginContainer method.
    /// </summary>
    public void EndContainer(XGraphicsContainer container)
    {
      if (container == null)
        throw new ArgumentNullException("container");

      this.gsStack.Restore(container.InternalState);
#if GDI
      if (this.targetContext == XGraphicTargetContext.GDI)
        this.gfx.Restore(container.GdiState);
#endif
#if WPF
      // nothing to do
#endif
      this.transform = container.InternalState.Transform;

      if (this.renderer != null)
        this.renderer.EndContainer(container);
    }
Example #4
0
    /// <summary>
    /// Saves a graphics container with the current state of this XGraphics and 
    /// opens and uses a new graphics container.
    /// </summary>
    public XGraphicsContainer BeginContainer(XRect dstrect, XRect srcrect, XGraphicsUnit unit)
    {
      // TODO: unit
      if (unit != XGraphicsUnit.Point)
        throw new ArgumentException("The current implementation supports XGraphicsUnit.Point only.", "unit");

      XGraphicsContainer xContainer = null;
#if GDI
      if (this.targetContext == XGraphicTargetContext.GDI)
        xContainer = new XGraphicsContainer(this.gfx.Save());
#endif
#if WPF
      if (this.targetContext == XGraphicTargetContext.WPF)
        xContainer = new XGraphicsContainer();
#endif
      InternalGraphicsState iState = new InternalGraphicsState(this, xContainer);
      iState.Transform = this.transform;

      this.gsStack.Push(iState);

      if (this.renderer != null)
        this.renderer.BeginContainer(xContainer, dstrect, srcrect, unit);

      XMatrix matrix = new XMatrix();  //XMatrix.Identity;
#if true
      double scaleX = dstrect.Width / srcrect.Width;
      double scaleY = dstrect.Height / srcrect.Height;
      matrix.TranslatePrepend(-srcrect.X, -srcrect.Y);
      matrix.ScalePrepend(scaleX, scaleY);
      matrix.TranslatePrepend(dstrect.X / scaleX, dstrect.Y / scaleY);
#else
      matrix.Translate(-dstrect.X, -dstrect.Y);
      matrix.Scale(dstrect.Width / srcrect.Width, dstrect.Height / srcrect.Height);
      matrix.Translate(srcrect.X, srcrect.Y);
#endif
      AddTransform(matrix, XMatrixOrder.Prepend);

      return xContainer;
    }
Example #5
0
 public InternalGraphicsState(XGraphics gfx, XGraphicsContainer container)
 {
     _gfx = gfx;
     container.InternalState = this;
 }
Example #6
0
 public InternalGraphicsState(XGraphics gfx, XGraphicsContainer container)
 {
     _gfx = gfx;
     container.InternalState = this;
 }
Example #7
0
    /// <summary>
    /// Closes the current graphics container and restores the state of this XGraphics 
    /// to the state saved by a call to the BeginContainer method.
    /// </summary>
    public void EndContainer(XGraphicsContainer container)
    {
      if (container == null)
        throw new ArgumentNullException("container");

      this.gsStack.Restore(container.InternalState);

      //this.gfx.EndContainer(container.GdipState);
      this.gfx.Restore(container.GdipState);
      this.transform = container.InternalState.Transform;

      if (this.renderer != null)
        this.renderer.EndContainer(container);
    }
Example #8
0
    /// <summary>
    /// Saves a graphics container with the current state of this XGraphics and 
    /// opens and uses a new graphics container.
    /// </summary>
    public XGraphicsContainer BeginContainer(XRect dstrect, XRect srcrect, XGraphicsUnit unit)
    {
      // TODO: unit
      if (unit != XGraphicsUnit.Point)
        throw new ArgumentException("The current implementation supports XGraphicsUnit.Point only.", "unit");
#if true
      XGraphicsContainer xContainer = new XGraphicsContainer(this.gfx.Save());
      InternalGraphicsState iState = new InternalGraphicsState(xContainer);
      iState.Transform = this.transform;

      this.gsStack.Push(iState);

      if (this.renderer != null)
        this.renderer.BeginContainer(xContainer, dstrect, srcrect, unit);

      XMatrix matrix = XMatrix.Identity;
#if true
      double scaleX = dstrect.Width / srcrect.Width;
      double scaleY = dstrect.Height / srcrect.Height;
      matrix.Translate(-srcrect.X, -srcrect.Y);
      matrix.Scale(scaleX, scaleY);
      matrix.Translate(dstrect.X / scaleX, dstrect.Y / scaleY);
#else
      matrix.Translate(-dstrect.X, -dstrect.Y);
      matrix.Scale(dstrect.Width / srcrect.Width, dstrect.Height / srcrect.Height);
      matrix.Translate(srcrect.X, srcrect.Y);
#endif
      Transform = matrix;

      return xContainer;
#else
      XGraphicsContainer container = new XGraphicsContainer(this.gfx.BeginContainer(dstrect, srcrect, this.gfx.PageUnit));
      container.Transform = this.transform;

      if (this.renderer != null)
        this.renderer.BeginContainer(container, dstrect, srcrect, unit);

      return container;
#endif
    }
 public InternalGraphicsState(XGraphicsContainer container)
 {
   //GdipGraphicsContainer = container.GdipContainer;
   GdipGraphicsState = container.GdipState;
   container.InternalState = this;
 }