Exemplo n.º 1
0
		internal override void restoreProperties(ItemProperties props)
		{
			TableProperties tprops = (TableProperties)props;

			caption = tprops.caption;
			captionColor = tprops.captionColor;
			captionFormat = tprops.captionFormat;
			captionHeight = tprops.captionHeight;
			cellBorders = tprops.cellBorders;
			columnWidth = tprops.columnWidth;
			currScrollRow = tprops.currScrollRow;
			linkStyle = tprops.linkStyle;
			picture = tprops.picture;
			picturePos = tprops.picturePos;
			rowHeight = tprops.rowHeight;
			scrollable = tprops.scrollable;
			selStyle = tprops.selStyle;
			style = tprops.style;
			textColor = tprops.textColor;
			EnableStyledText = tprops.enableStyledText;
			customDraw = tprops.customDraw;
			cellCustomDraw = tprops.cellCustomDraw;

			if (captionBackBrush != tprops.captionBackBrush)
			{
				if (captionBackBrush != null)
					captionBackBrush.Release();
				captionBackBrush = tprops.captionBackBrush;
				if (captionBackBrush != null)
					captionBackBrush.AddRef();
			}

			base.restoreProperties(props);
		}
Exemplo n.º 2
0
		public override void loadFrom(BinaryReader reader, PersistContext ctx)
		{
			base.loadFrom(reader, ctx);
			hasHeaderRows = false;

			hasSpanningCells = false;
			ctx.loadReference(this);	// load cells
			ctx.loadReference(this);	// load rows
			ctx.loadReference(this);	// load columns
			currScrollRow = reader.ReadInt32();
			scrollable = reader.ReadBoolean();
			setScrollable(scrollable);
			fillColor = ctx.loadColor();
			frameColor = ctx.loadColor();
			caption = reader.ReadString();
			captionColor = ctx.loadColor();
			captionFormat = ctx.loadStringFormat();

			captionHeight = (float)reader.ReadDouble();
			cellBorders = (CellFrameStyle)reader.ReadInt32();
			rowsCount = reader.ReadInt32();
			rowHeight = (float)reader.ReadDouble();
			columnsCount = reader.ReadInt32();
			columnWidth = (float)reader.ReadDouble();
			textColor = ctx.loadColor();
			picturePos = (ImageAlign)reader.ReadInt32();

			picture = ctx.loadImage();

			pen.Width = PenWidth;
			pen.Color = frameColor;
			pen.DashStyle = PenDashStyle;
			brush.Release();
			brush = new SolidBrush(fillColor);
			brush.AddRef();

			if (ctx.FileVersion > 3)
			{
				pen = (Pen)ctx.loadObject();
				ctx.loadReference(this);

				selStyle = (HandlesStyle)reader.ReadInt32();

				if (ctx.FileVersion > 5)
				{
					// new in save format 6
					rowAnchorPattern = ctx.loadAnchorPattern();
					enabledHandles = (Handles)reader.ReadInt64();
					style = (TableStyle)reader.ReadInt32();

					if (ctx.FileVersion > 7)
					{
						// new in file format 8
						linkStyle = (TableLinkStyle)reader.ReadInt32();

						if (ctx.FileVersion > 8)
						{
							// new in save format 9
							anchorPattern = ctx.loadAnchorPattern();

							// Load table arrows
							ctx.loadReference(this);
							ctx.loadReference(this);

							if (ctx.FileVersion > 13)
							{
								// new in save format 14
								setExpanded(reader.ReadBoolean());
								setExpandable(reader.ReadBoolean());
								useStyledText = reader.ReadBoolean();

								if (ctx.FileVersion > 18)
								{
									// new in save format 19
									customDraw = (CustomDraw)reader.ReadInt32();
									cellCustomDraw = (CustomDraw)reader.ReadInt32();

									if (ctx.FileVersion > 21)
									{
										// new in save format 22
										offsetHeaderRows = reader.ReadBoolean();

										if (ctx.FileVersion > 24)
										{
											// new in save format 25
											ctx.loadReference(this);	// captionBackBrush
										}
									}
								}
							}
						}
					}
				}
			}

			resetCoveredCells();
			updateText();
			layoutText();
		}
Exemplo n.º 3
0
		internal static void drawSelHandles(
			Graphics g, Color rgb, Color rgbDis,
			RectangleF rc, float rotationAngle,
			Handles mask, bool showDsbl, HandlesStyle st, float size)
		{
			// these styles must not be painted
			if (st == HandlesStyle.Invisible ||
				st == HandlesStyle.InvisibleMove)
				return;

			// draw square selection handles for these styles
			if (st == HandlesStyle.SquareHandles ||
				st == HandlesStyle.SquareHandles2 ||
				st == HandlesStyle.EasyMove)
			{
				drawSquareHandles(g, mask, rgb, rgbDis, showDsbl,
					rc, rotationAngle, st, size);

				return;
			}

			PointF center = getCenter(rc);

			if (st == HandlesStyle.DashFrame)
			{
				try
				{
					// drawing with a dashed pen sometimes throws a generic exception
					// in GDIPLUS.DLL, so catch everything or everyone will blame us;
					System.Drawing.Pen pen = new System.Drawing.Pen(rgb, 0);
					pen.DashStyle = DashStyle.Dash;

					if (rotationAngle == 0)
					{
						g.DrawRectangle(pen, rc.X, rc.Y, rc.Width, rc.Height);
					}
					else
					{
						GraphicsPath path = rotateRectAt(rc, center, rotationAngle);
						g.DrawPath(pen, path);
						path.Dispose();
					}

					pen.Dispose();

					drawRotationHandle(g, rgb, rgbDis,
						rc, rotationAngle, mask, showDsbl, size);
				}
				catch (Exception)
				{
					// sometimes the exception says 'out of memory'
					GC.Collect();
				}

				return;
			}

			if (st == HandlesStyle.HatchFrame)
			{
				rc.Inflate(size / 2, size / 2);

				System.Drawing.Drawing2D.HatchBrush hatchBrush =
					new System.Drawing.Drawing2D.HatchBrush(
					HatchStyle.BackwardDiagonal, Color.Black, Color.White);

				RectangleF[] rects = new RectangleF[] {
					new RectangleF(rc.Left + size, rc.Top, rc.Width - 2 * size, size),
					new RectangleF(rc.Left + size, rc.Bottom - size, rc.Width - 2 * size, size),
					new RectangleF(rc.Left, rc.Top, size, rc.Height),
					new RectangleF(rc.Right - size, rc.Top, size, rc.Height) };

				if (rotationAngle == 0)
				{
					for (int i = 0; i < 4; ++i)
						g.FillRectangle(hatchBrush, rects[i]);
				}
				else
				{
					for (int i = 0; i < 4; ++i)
					{
						GraphicsPath path = rotateRectAt(
							rects[i], center, rotationAngle);
						g.FillPath(hatchBrush, path);
						path.Dispose();
					}
				}

				hatchBrush.Dispose();

				drawRotationHandle(g, rgb, rgbDis,
					rc, rotationAngle, mask, showDsbl, size);

				return;
			}

			if (st == HandlesStyle.HatchHandles || st == HandlesStyle.HatchHandles2 ||
				st == HandlesStyle.HatchHandles3 || st == HandlesStyle.MoveOnly)
			{
				RectangleF rch = rc;
				rch.Inflate(size / 4, size / 4);

				System.Drawing.Drawing2D.HatchBrush hatchBrush = null;

				if (st == HandlesStyle.HatchHandles3 || st == HandlesStyle.MoveOnly)
					hatchBrush = new System.Drawing.Drawing2D.HatchBrush(
						HatchStyle.Percent50, Color.Black, Color.FromArgb(50, Color.Black));
				else
					hatchBrush = new System.Drawing.Drawing2D.HatchBrush(
						HatchStyle.BackwardDiagonal, Color.Black, Color.White);

				RectangleF[] rects = new RectangleF[] {
					new RectangleF(rch.Left + size*2/4, rch.Top, rch.Width - size, size*2/4),
					new RectangleF(rch.Left + size*2/4, rch.Bottom - size*2/4, rch.Width - size, size*2/4),
					new RectangleF(rch.Left, rch.Top, size*2/4, rch.Height),
					new RectangleF(rch.Right - size*2/4, rch.Top, size*2/4, rch.Height) };

				if (rotationAngle == 0)
				{
					for (int i = 0; i < 4; ++i)
						g.FillRectangle(hatchBrush, rects[i]);
				}
				else
				{
					for (int i = 0; i < 4; ++i)
					{
						GraphicsPath path = rotateRectAt(
							rects[i], center, rotationAngle);
						g.FillPath(hatchBrush, path);
						path.Dispose();
					}
				}

				hatchBrush.Dispose();

				if (st == HandlesStyle.MoveOnly)
					return;

				drawSquareHandles(g, mask, rgb, rgbDis, showDsbl,
					rc, rotationAngle, st, size);

				return;
			}
		}
Exemplo n.º 4
0
		internal static void drawSquareHandles(Graphics g,
			Handles mask, Color rgb, Color rgbDis, bool showDsbl,
			RectangleF rc, float rotationAngle, HandlesStyle st, float size)
		{
			PointF center = getCenter(rc);

			// select pen and brush for drawing the selection handles
			System.Drawing.Pen pen = new System.Drawing.Pen(Color.Black, 0);
			System.Drawing.Brush enbBrush = new System.Drawing.SolidBrush(rgb);
			System.Drawing.Brush dsbBrush = new System.Drawing.SolidBrush(rgbDis);
			System.Drawing.Brush brush;

			// calculate selection handles coordinates
			PointF[] handlePoints = new PointF[10];
			handlePoints[0] = new PointF(rc.Left, rc.Top);
			handlePoints[1] = new PointF(rc.Right, rc.Top);
			handlePoints[2] = new PointF(rc.Right, rc.Bottom);
			handlePoints[3] = new PointF(rc.Left, rc.Bottom);
			handlePoints[4] = new PointF(center.X, rc.Top);
			handlePoints[5] = new PointF(rc.Right, center.Y);
			handlePoints[6] = new PointF(center.X, rc.Bottom);
			handlePoints[7] = new PointF(rc.Left, center.Y);
			handlePoints[8] = center;
			handlePoints[9] = new PointF(
				center.X, rc.Top - 6 * Constants.getMillimeter(g.PageUnit));

			// apply rotation
			if (rotationAngle != 0)
			{
				Matrix rotation = new Matrix();
				rotation.RotateAt(rotationAngle, center);
				rotation.TransformPoints(handlePoints);
				rotation.Dispose();
			}

			// draw the handles
			float hsize = size / 2;
			for (int h = 0; h <= 9; h++)
			{
				bool draw = true;

				// determine whether this handle should be drawn
				if (((long)mask & (1 << h)) != 0)
				{
					brush = enbBrush;
				}
				else
				{
					brush = dsbBrush;
					draw = showDsbl && h != 9;
				}

				if (draw) 
				{
					PointF point = handlePoints[h];

					// the side and corner handles
					if (h < 8)
					{
						g.FillRectangle(brush,
							point.X - hsize, point.Y - hsize, size, size);
						g.DrawRectangle(pen,
							point.X - hsize, point.Y - hsize, size, size);
					}
					// the center handle
					else if (h == 8)
					{
						if (st == HandlesStyle.EasyMove)
						{
							//g.FillEllipse(brush,
							//	point.X - size, point.Y - size, 2*size, 2*size);
							//g.DrawEllipse(pen,
							//	point.X - size, point.Y - size, 2*size, 2*size);
						}
						if (st == HandlesStyle.SquareHandles)
						{
							g.FillRectangle(brush,
								point.X - hsize, point.Y - hsize, size, size);
							g.DrawRectangle(pen,
								point.X - hsize, point.Y - hsize, size, size);
						}
					}
					// the rotation handle
					else if (h == 9)
					{
						g.FillEllipse(brush,
							point.X - 2.8F*size/4, point.Y - 2.8F*size/4, 2.8F*size/2, 2.8F*size/2);
						g.DrawEllipse(pen,
							point.X - 2.8F*size/4, point.Y - 2.8F*size/4, 2.8F*size/2, 2.8F*size/2);

						System.Drawing.Pen rotMarker =
							new System.Drawing.Pen(brush, 0);
						rotMarker.DashStyle = DashStyle.Dot;
						g.DrawLine(rotMarker, point, handlePoints[4]);
						rotMarker.Dispose();
					}
				}
			}

			//cleanup
			pen.Dispose();
			enbBrush.Dispose();
			dsbBrush.Dispose();
		}
Exemplo n.º 5
0
		internal static bool pointInHandle(PointF pt, ref int handle,
			RectangleF rc, float rotationAngle, Handles mask,
			float ht, HandlesStyle st, float handleSize, GraphicsUnit measureUnit)
		{
			if (rotationAngle != 0)
				pt = rotatePointAt(pt, getCenter(rc), -rotationAngle);

			if (st == HandlesStyle.MoveOnly || st == HandlesStyle.InvisibleMove)
			{
				handle = 8;
				return rc.Contains(pt) && (mask & Handles.Move) != 0;
			}

			if (st == HandlesStyle.SquareHandles || st == HandlesStyle.HatchHandles ||
				st == HandlesStyle.EasyMove)
			{
				PointF[] pts = new PointF[10];

				//the corner points
				pts[0].X = rc.X;
				pts[0].Y = rc.Y;
				pts[1].X = rc.Right;
				pts[1].Y = rc.Y;
				pts[2].X = rc.Right;
				pts[2].Y = rc.Bottom;
				pts[3].X = rc.X;
				pts[3].Y = rc.Bottom;

				//the side points
				pts[4].X = (pts[0].X + pts[1].X) / 2;
				pts[4].Y = pts[0].Y;
				pts[5].X = pts[1].X;
				pts[5].Y = (pts[1].Y + pts[2].Y) / 2;
				pts[6].X = pts[4].X;
				pts[6].Y = pts[2].Y;
				pts[7].X = pts[0].X;
				pts[7].Y = pts[5].Y;

				//the center point
				pts[8].X = pts[4].X;
				pts[8].Y = pts[5].Y;

				// the rotation handle
				pts[9].X = pts[4].X;
				pts[9].Y = pts[4].Y - 6*Constants.getMillimeter(measureUnit);

				//if (st == HandlesStyle.EasyMove && (Distance(pts[8], pt) < 1.5 * handleSize))
				//	return false;

				for (int i = 0; i < 10; ++i)
				{
					if (Math.Abs(pts[i].X - pt.X) <= (handleSize/2) &&
						Math.Abs(pts[i].Y - pt.Y) <= (handleSize/2) &&
						((long)mask & (1 << i)) != 0)
					{
						handle = i;
						return true;
					}
				}

				if (st == HandlesStyle.EasyMove && rc.Contains(pt) && (mask & Handles.Move) != 0)
				{
					handle = 8;
					return true;
				}

				rc.Inflate(handleSize / 2, handleSize / 2);
				if (st == HandlesStyle.HatchHandles && rc.Contains(pt) &&
					(mask & Handles.Move) != 0)
				{
					rc.Inflate(- handleSize, - handleSize);
					handle = 8;
					return !rc.Contains(pt);
				}
			}
			else
			{
				// check the corners
				PointF[] ptCorner = new PointF[4];
				ptCorner[0].X = rc.Left;
				ptCorner[0].Y = rc.Top;
				ptCorner[1].X = rc.Right;
				ptCorner[1].Y = rc.Top;
				ptCorner[2].X = rc.Right;
				ptCorner[2].Y = rc.Bottom;
				ptCorner[3].X = rc.Left;
				ptCorner[3].Y = rc.Bottom;
				for (int i = 0; i < 4; ++i)
				{
					if (Math.Abs(ptCorner[i].X - pt.X) <= (handleSize/2) &&
						Math.Abs(ptCorner[i].Y - pt.Y) <= (handleSize/2) &&
						((long)mask & (1 << i)) != 0)
					{
						handle = i;
						return true;
					}
				}

				//the side points
				rc.Inflate(Constants.getSelPtTest(measureUnit)*2, Constants.getSelPtTest(measureUnit)*2);
				if (Utilities.pointInRect(pt, rc))
				{
					float inflate = -Constants.getSelPtTest(measureUnit)*2;
					rc.Inflate(inflate, inflate);
					if (Math.Abs(rc.Top - pt.Y) <= (handleSize/2) &&
						(mask & Handles.ResizeTopCenter) != 0)
					{
						handle = 4;
						return true;
					}
					if (Math.Abs(rc.Right - pt.X) <= (handleSize/2) &&
						(mask & Handles.ResizeMiddleRight) != 0)
					{
						handle = 5;
						return true;
					}
					if (Math.Abs(rc.Bottom - pt.Y) <= (handleSize/2) &&
						(mask & Handles.ResizeBottomCenter) != 0)
					{
						handle = 6;
						return true;
					}
					if (Math.Abs(rc.Left - pt.X) <= (handleSize/2) &&
						(mask & Handles.ResizeMiddleLeft) != 0)
					{
						handle = 7;
						return true;
					}
				}

				// the rotation handle
				PointF rotHandle = new PointF(
					(ptCorner[0].X + ptCorner[1].X) / 2,
					ptCorner[0].Y - 6*Constants.getMillimeter(measureUnit));
				if (Math.Abs(rotHandle.X - pt.X) <= (handleSize/2) &&
					Math.Abs(rotHandle.Y - pt.Y) <= (handleSize/2) &&
					(mask & Handles.Rotate) != 0)
				{
					handle = 9;
					return true;
				}

				// check if the point is in the title area
				RectangleF rcCpt = rc;
				if (ht != 0)
					rcCpt.Height = ht;
				else
					rcCpt.Inflate(- handleSize * 2, - handleSize * 2);
				if (Utilities.pointInRect(pt, rcCpt) && (mask & Handles.Move) != 0)
				{
					handle = 8;
					return true;
				}
			}

			return false;
		}
Exemplo n.º 6
0
		internal override void restoreProperties(ItemProperties props)
		{
			BoxProperties bprops = (BoxProperties)props;

			customDraw = bprops.customDraw;
			image = bprops.image;
			picturePos = bprops.picturePos;
			selStyle = bprops.selStyle;
			text = bprops.text;
			textColor = bprops.textColor;
			textFormat = bprops.textFormat;
			transparent = bprops.transparent;

			Style = bprops.style;
			ShapeOrientation = bprops.shapeRotation;
			Shape = bprops.shapeTemplate;
			PolyTextLayout = bprops.usePolyTextLt;
			EnableStyledText = bprops.useStyledText;

			base.restoreProperties(props);
		}