Esempio n. 1
0
 // Get the toolkit version of this pen for a specific toolkit.
 internal IToolkitPen GetPen(IToolkit toolkit)
 {
     lock (this)
     {
         if (toolkitPen == null)
         {
             // We don't yet have a toolkit pen yet.
             toolkitPen   = toolkit.CreatePen(this);
             this.toolkit = toolkit;
             return(toolkitPen);
         }
         else if (this.toolkit == toolkit)
         {
             // Same toolkit - return the cached pen information.
             return(toolkitPen);
         }
         else
         {
             // We have a pen for another toolkit,
             // so dispose it and create for this toolkit.
             // We null out "toolkitPen" before calling
             // "CreatePen()" just in case an exception
             // is thrown while creating the toolkit pen.
             toolkitPen.Dispose();
             toolkitPen   = null;
             toolkitPen   = toolkit.CreatePen(this);
             this.toolkit = toolkit;
             return(toolkitPen);
         }
     }
 }
Esempio n. 2
0
 // Dispose of this pen.
 public void Dispose()
 {
     lock (this)
     {
         if (toolkitPen != null)
         {
             toolkitPen.Dispose();
             toolkitPen = null;
         }
         toolkit = null;
         if (brush != null)
         {
             brush.Modified();
         }
     }
 }
Esempio n. 3
0
 // Dispose of this pen.
 public void Dispose()
 {
     if (_disposed)
     {
         return;
     }
     lock (this)
     {
         _disposed = true;
         if (toolkitPen != null)
         {
             toolkitPen.Dispose();
             toolkitPen = null;
         }
         toolkit = null;
         if (brush != null)
         {
             brush.Modified();
         }
     }
 }
Esempio n. 4
0
	// Get the toolkit version of this pen for a specific toolkit.
	internal IToolkitPen GetPen(IToolkit toolkit)
			{
				lock(this)
				{
					if(this.toolkitPen == null)
					{
						// We don't yet have a toolkit pen yet.
						this.toolkitPen = toolkit.CreatePen(this);
						this.toolkit = toolkit;
						return this.toolkitPen;
					}
					else if(this.toolkit == toolkit)
					{
						// Same toolkit - return the cached pen information.
						return this.toolkitPen;
					}
					else
					{
						// We have a pen for another toolkit,
						// so dispose it and create for this toolkit.
						// We null out "toolkitPen" before calling
						// "CreatePen()" just in case an exception
						// is thrown while creating the toolkit pen.
						this.toolkitPen.Dispose();
						this.toolkitPen = null;
						this.toolkitPen = toolkit.CreatePen(this);
						this.toolkit = toolkit;
						return this.toolkitPen;
					}
				}
			}
Esempio n. 5
0
	// Dispose of this pen.
	public void Dispose()
			{
				lock(this)
				{
					if(toolkitPen != null)
					{
						toolkitPen.Dispose();
						toolkitPen = null;
					}
					toolkit = null;
					if(brush != null)
					{
						brush.Modified();
					}
				}
			}
Esempio n. 6
0
		// Draw a line between two points using the current pen.
		// Fast version of Bresenham's algorithm.
		public override void DrawLine(int x1, int y1, int x2, int y2)
				{
					IToolkitPen pen = Pen;
					ToolkitPenBase penBase;

					if (pen == null)
						return;
					penBase = pen as ToolkitPenBase;

					int color = penBase.Color.ToArgb();
					Frame frame = image.image.GetFrame(0);
					// TODO: Finish off
					int dy = y2 - y1;
					int dx = x2 - x1;
					int stepx, stepy;

					if (dy < 0)
					{
						dy = -dy;
						stepy = -frame.Stride;
					} 
					else
						stepy = frame.Stride;
					if (dx < 0)
					{
						dx = -dx;
						stepx = -1;
					} 
					else
					{
						stepx = 1;
					}
					dy <<= 1;
					dx <<= 1;

					y1 *= frame.Stride;
					y2 *= frame.Stride;
					SetPixelLine(frame, x1,y1, color);
					if (dx > dy) 
					{
						int fraction = dy - (dx >> 1);
						while (x1 != x2) 
						{
							if (fraction >= 0) 
							{
								y1 += stepy;
								fraction -= dx;
							}
							x1 += stepx;
							fraction += dy;
							SetPixelLine(frame, x1,y1, color);
						}
					} 
					else 
					{
						int fraction = dx - (dy >> 1);
						while (y1 != y2) 
						{
							if (fraction >= 0) 
							{
								x1 += stepx;
								fraction -= dy;
							}
							y1 += stepy;
							fraction += dx;
							SetPixelLine(frame, x1,y1, color);
						}
					}
					this.image.ImageChanged();
				}