Exemple #1
0
		/// <summary>
		/// Initializes a new instance of the FlowChart class.
		/// </summary>
		public FlowChart()
		{
			license = LicenseManager.Validate(typeof(FlowChart), this);

			measureUnit = GraphicsUnit.Millimeter;

			// set control styles for flicker-free redraw
			SetStyle(ControlStyles.UserPaint, true);
			SetStyle(ControlStyles.AllPaintingInWmPaint, true);
			SetStyle(ControlStyles.Opaque, true);
			SetStyle(ControlStyles.ResizeRedraw, true);

			// we want to process keyboard input
			SetStyle(ControlStyles.Selectable, true);
     
			// init static objects
			lock (syncRoot)
			{
				Arrow.initHeadTemplates();
				CustomCursors.Init(new ResourceManager(
					"MindFusion.FlowChartX.Cursors", typeof(ChartObject).Assembly));
			}

			mouseMoved = false;

			boxFillColor = Color.FromArgb(220, 220, 255);
			boxFrameColor = Color.Black;
			arrowColor = Color.Black;
			arrowTextStyle = ArrowTextStyle.Center;
			arrowFillColor = Color.FromArgb(120, 220, 255);
			tableFrameColor = Color.Black;
			tableFillColor = Color.FromArgb(180, 160, 160);
			penDashStyle = DashStyle.Solid;
			penWidth = 0;
			BackColor = Color.FromArgb(170, 170, 200);

			// grid properties
			alignToGrid = true;
			showGrid = false;
			gridColor = Color.FromArgb(140, 140, 150);
			gridSizeX = 4;
			gridSizeY = 4;
			gridStyle = GridStyle.Points;

			// shadows properties
			shadowOffsetX = 1;
			shadowOffsetY = 1;
			shadowColor = Color.FromArgb(110, 110, 140);
			shadowsStyle = ShadowsStyle.OneLevel;

			activeMnpColor = Color.White;
			selMnpColor = Color.FromArgb(170, 170, 170);
			disabledMnpColor = Color.FromArgb(200, 0, 0);

			textFormat = new StringFormat();
			textFormat.Alignment = StringAlignment.Center;
			textFormat.LineAlignment = StringAlignment.Center;

			// Set some flags, because otherwise the serializer
			// generates noncompilable code
			textFormat.FormatFlags = StringFormatFlags.NoFontFallback;

			imagePos = ImageAlign.Document;

			boxStyle = BoxStyle.RoundedRectangle;
			tableStyle = TableStyle.Rectangle;

			boxPen = new Pen(boxFrameColor, penWidth);
			boxBrush = new SolidBrush(boxFillColor);
			boxBrush.AddRef();
			arrowPen = new Pen(arrowColor, penWidth);
			arrowBrush = new SolidBrush(arrowFillColor);
			arrowBrush.AddRef();
			tablePen = new Pen(tableFrameColor, penWidth);
			tableBrush = new SolidBrush(tableFillColor);
			tableBrush.AddRef();

			exteriorBrush = null;
			brush = new SolidBrush(BackColor);
			brush.AddRef();

			boxes = new BoxCollection();
			controlHosts = new ControlHostCollection();
			tables = new TableCollection();
			arrows = new ArrowCollection();
			selection = new Selection(this);
			selectionOnTop = true;

			groups = new GroupCollection();

			zOrder = new ChartObjectCollection();

			textColor = Color.Black;
			arrowStyle = MindFusion.FlowChartX.ArrowStyle.Polyline;
			arrowSegments = 1;
			activeObject = null;

			modificationStart = ModificationStyle.SelectedOnly;
			autoHandlesObj = null;
			autoAnchorsObj = null;

			interaction = null;

			scrollX = scrollY = 0;
			zoomFactor = 100.0f;
			allowRefLinks = true;
			Behavior = BehaviorType.FlowChart;
			arrowEndsMovable = true;
			selectAfterCreate = true;

			// init default custom draw properties
			boxCustomDraw = CustomDraw.None;
			tableCustomDraw = CustomDraw.None;
			cellCustomDraw = CustomDraw.None;
			arrowCustomDraw = CustomDraw.None;

			restrObjsToDoc = RestrictToDoc.Intersection;
			dynamicArrows = false;
			arrowsSnapToBorders = false;
			arrowsRetainForm = false;
			arrowCascadeOrientation = Orientation.Auto;

			curPointer = Cursors.Arrow;
			curCannotCreate = Cursors.No;
			curModify = Cursors.SizeAll;
			curArrowStart = Cursors.Hand;
			curArrowEnd = Cursors.Hand;
			curArrowCannotCreate = Cursors.No;
			curHorzResize = Cursors.SizeWE;
			curVertResize = Cursors.SizeNS;
			curMainDgnlResize = Cursors.SizeNWSE;
			curSecDgnlResize = Cursors.SizeNESW;
			curRotateShape = CustomCursors.Rotate;
			panCursor = Cursors.NoMove2D;

			tableRowsCount = 4;
			tableColumnsCount = 2;
			tableRowHeight = 6;
			tableColWidth = 18;
			tableCaptionHeight = 5;
			tableCaption = "Table";
			tableCellBorders = CellFrameStyle.System3D;

			selHandleSize = 2;

			showDisabledHandles = true;
			arrowSelStyle = HandlesStyle.SquareHandles;
			boxSelStyle = HandlesStyle.SquareHandles;
			chostSelStyle = HandlesStyle.HatchHandles;
			tableSelStyle = HandlesStyle.DashFrame;

			recursiveExpand = false;
			expandOnIncoming = false;
			boxesExpandable = false;
			tablesScrollable = false;
			tablesExpandable = false;
			controlHostsExpandable = false;

			arrowHead = ArrowHead.Arrow;
			arrowBase = ArrowHead.None;
			arrowInterm = ArrowHead.None;

			arrowHeadSize = 5;
			arrowBaseSize = 5;
			arrowIntermSize = 5;

			ShowScrollbars = true;
			DocExtents = new RectangleF(0, 0, 210, 297);

			autoScroll = true;
			autoScrDX = autoScrDY = 0;

			dirty = false;
			antiAlias = SmoothingMode.None;
			textRendering = TextRenderingHint.SystemDefault;
			sortGroupsByZ = false;

			// tooltips
			showToolTips = true;
			toolTip = "";
			toolTipCtrl = new ToolTip();
			toolTipCtrl.Active = showToolTips;

			shapeRotation = 0;
			DefaultShape = ShapeTemplate.FromId("Cylinder");

			inplaceEditAllowed = false;
			inplaceObject = null;
			nowEditing = false;
			inplaceEditFont = (Font)Font.Clone();
			inplaceAcceptOnEnter = false;
			inplaceCancelOnEsc = true;

			allowSplitArrows = false;

			printOptions = new PrintOptions(this);
			printOptions.EnableBackground = false;
			printOptions.EnableBackgroundImage = false;
			printOptions.PaintControls = true;

			displayOptions = new PrintOptions(this);
			renderOptions = displayOptions;

			previewOptions = new PreviewOptions();

			allowLinksRepeat = true;
			showAnchors = ShowAnchors.Auto;
			snapToAnchor = SnapToAnchor.OnCreate;

			beginPrintHandler = new PrintEventHandler(this.BeginPrint);
			printPageHandler = new PrintPageEventHandler(this.PrintPage);
			printRect = new RectangleF(0, 0, 1, 1);

			usePolyTextLt = false;

			userAction = false;

			tableLinkStyle = TableLinkStyle.Rows;

			undoManager = new UndoManager(this);

			defaultControlType = typeof(System.Windows.Forms.Button);
			hostedCtrlMouseAction = HostMouseAction.SelectHost;

			dummy = new DummyNode(this);
			allowUnconnectedArrows = false;
			allowUnanchoredArrows = true;

			autoSizeDoc = MindFusion.FlowChartX.AutoSize.None;
			panMode = false;

			enableStyledText = false;

			expandBtnPos = ExpandButtonPosition.OuterRight;
			focusLost = false;

			hitTestPriority = HitTestPriority.NodesBeforeArrows;

			boxText = arrowText = "";

			// arrow crossings
			arrowCrossings = ArrowCrossings.Straight;
			crossRadius = 1.5f;
			redrawNonModified = false;

			roundRectFactor = 1;

			scriptHelper = new ScriptHelper(this);

			// link routing options
			routingOptions = new RoutingOptions(this);
			routingGrid = new RoutingGrid(this);
			routeArrows = false;
			dontRouteForAwhile = false;

			validityChecks = true;
			_modifierKeyActions = new ModifierKeyActions();
			middleButtonAction = MouseButtonAction.None;
			forceCacheRedraw = false;

			showHandlesOnDrag = true;
			mergeThreshold = 0;

			expandButtonAction = ExpandButtonAction.ExpandTreeBranch;
		}
Exemple #2
0
		internal void printFlowChart(Graphics g, RectangleF pageRect)
		{
			renderOptions = printOptions;
			nowPrinting = true;
			g.SetClip(pageRect);

			// fill the background
			if (renderOptions.EnableBackground)
			{
				if (imagePos < ImageAlign.Document)
				{
					System.Drawing.Brush fillBrush = brush.CreateGDIBrush(pageRect);
					g.FillRectangle(fillBrush, pageRect);
					fillBrush.Dispose();
				}
				else
				{
					System.Drawing.Brush fillBrush = brush.CreateGDIBrush(
						DocExtents, -DocExtents.Left, -DocExtents.Top);
					g.FillRectangle(fillBrush, pageRect);
					fillBrush.Dispose();
				}
			}
			g.SmoothingMode = this.antiAlias;
			g.TextRenderingHint = this.textRendering;

			// print the background image
			if (BackgroundImage != null && renderOptions.EnableBackgroundImage)
			{
				// Printing of back images occur only if ImageAlign.Document is set
				if (imagePos < ImageAlign.Document)
				{
					Utilities.drawImage(g, BackgroundImage, pageRect, imagePos);
				}
				else
				{
					Utilities.drawImage(g, BackgroundImage, DocExtents,
						(ImageAlign)(imagePos - ImageAlign.Document));
				}
			}

			// draw shadows
			if (renderOptions.EnableShadows &&
				shadowsStyle == ShadowsStyle.OneLevel)
				drawShadows(g, pageRect, false);

			// draw all objects
			foreach (ChartObject obj in zOrder)
			{
				if (obj != activeObject || !selectionOnTop)
				{
					RectangleF rc = obj.getRepaintRect(false);
					if (!rc.IntersectsWith(pageRect))
						continue;

					if (renderOptions.EnableShadows &&
						shadowsStyle == ShadowsStyle.ZOrder)
						drawObjectWithShadow(g, obj, false);
					else
						drawObject(g, obj, false);
				}
			}

			// draw the active object at the top
			if (activeObject != null && selectionOnTop)
			{
				if (renderOptions.EnableShadows &&
					shadowsStyle == ShadowsStyle.ZOrder)
					drawObjectWithShadow(g, activeObject, true);
				else
					drawObject(g, activeObject, true);
			}

			renderOptions = displayOptions;
			nowPrinting = false;
		}
Exemple #3
0
		public void SetRenderOptions(PrintOptions options)
		{
			prevRenderOptions = renderOptions;
			renderOptions = options;
		}
Exemple #4
0
		public void ResetRenderOptions()
		{
			renderOptions = prevRenderOptions;
		}
Exemple #5
0
		private void drawBack(Graphics g, Rectangle clip, bool toScreen, PrintOptions renderOptions)
		{
			if (imagePos < ImageAlign.Document)
			{
				// the background image does not scroll or scale, the brush shouldn't too
				System.Drawing.Brush fillBrush = brush.CreateGDIBrush(ClientRectangle);
				g.FillRectangle(fillBrush, clip);
				fillBrush.Dispose();
			}
			else
			{
				if (toScreen)
				{
					// now drawing on the screen, include translation for
					// the scroll X and Y position
					setTransforms(g);
				}
				else
				{
					// exporting to bitmap; do not include translation, but just scaling
					g.PageUnit = measureUnit;
					g.PageScale = zoomFactor / 100F;
				}

				RectangleF rc = Utilities.deviceToDoc(g, clip);

				Point pt = Utilities.docToDevice(g, new PointF(0, 0));
				g.RenderingOrigin = pt;

				// paint with exterior brush if applicable
				bool paintExterior = exteriorBrush != null && toScreen &&
					!docExtents.Contains(rc) && !exteriorBrush.equals(BackBrush);
				if (paintExterior)
				{
					System.Drawing.Brush extBrush = exteriorBrush.CreateGDIBrush(
						docExtents, -docExtents.Left, -docExtents.Top);

					// paint the exterior to the left
					if (rc.Left < docExtents.Left)
					{
						RectangleF ext = rc;
						ext.Width = docExtents.Left - ext.Left;
						g.FillRectangle(extBrush, ext);
					}

					// paint the exterior to the top
					if (rc.Top < docExtents.Top)
					{
						RectangleF ext = rc;
						ext.Height = docExtents.Top - ext.Top;
						g.FillRectangle(extBrush, ext);
					}

					// paint the exterior to the right
					if (rc.Right > docExtents.Right)
					{
						RectangleF ext = rc;
						ext.X = Math.Max(rc.Left, docExtents.Right);
						ext.Width = rc.Right - ext.Left;
						g.FillRectangle(extBrush, ext);
					}

					// paint the exterior to the bottom
					if (rc.Bottom > docExtents.Bottom)
					{
						RectangleF ext = rc;
						ext.Y = Math.Max(rc.Top, docExtents.Bottom);
						ext.Height = rc.Bottom - ext.Top;
						g.FillRectangle(extBrush, ext);
					}
					
					extBrush.Dispose();
					rc.Intersect(docExtents);
				}

				// paint the document area with BackBrush
				System.Drawing.Brush fillBrush = brush.CreateGDIBrush(
					docExtents, -docExtents.Left, -docExtents.Top);
				g.FillRectangle(fillBrush, rc);
				fillBrush.Dispose();

				unsetTransforms(g);
			}
		}