⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainform.cs

📁 一个C#加上flowchart控件的例程
💻 CS
📖 第 1 页 / 共 4 页
字号:
			this._flowChart.AutoScroll = true;
			this._flowChart.AutoSizeDoc = false;
			this._flowChart.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(212)), ((System.Byte)(208)), ((System.Byte)(200)));
			this._flowChart.Behavior = MindFusion.FlowChartX.EBehavior.bhCreateArrow;
			this._flowChart.BkgrImagePos = MindFusion.FlowChartX.EImagePos.imgCenter;
			this._flowChart.BoxCustomDraw = MindFusion.FlowChartX.ECustomDraw.cdNone;
			this._flowChart.BoxesExpandable = false;
			this._flowChart.BoxFillColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(191)), ((System.Byte)(255)));
			this._flowChart.BoxFrameColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)));
			this._flowChart.BoxIncmAnchor = MindFusion.FlowChartX.EArrowAnchor.aaNoAnchor;
			this._flowChart.BoxOutgAnchor = MindFusion.FlowChartX.EArrowAnchor.aaNoAnchor;
			this._flowChart.BoxSelStyle = MindFusion.FlowChartX.ESelStyle.sstSquareHandles;
			this._flowChart.BoxStyle = MindFusion.FlowChartX.EBoxStyle.bsRoundRect;
			this._flowChart.ControlHostsExpandable = false;
			this._flowChart.CurArrowCannotCreate = System.Windows.Forms.Cursors.No;
			this._flowChart.CurArrowEnd = System.Windows.Forms.Cursors.Hand;
			this._flowChart.CurArrowStart = System.Windows.Forms.Cursors.Hand;
			this._flowChart.CurCannotCreate = System.Windows.Forms.Cursors.No;
			this._flowChart.CurHorzResize = System.Windows.Forms.Cursors.SizeWE;
			this._flowChart.CurMainDgnlResize = System.Windows.Forms.Cursors.SizeNWSE;
			this._flowChart.CurModify = System.Windows.Forms.Cursors.SizeAll;
			this._flowChart.CurPointer = System.Windows.Forms.Cursors.Arrow;
			this._flowChart.CurSecDgnlResize = System.Windows.Forms.Cursors.SizeNESW;
			this._flowChart.CurVertResize = System.Windows.Forms.Cursors.SizeNS;
			this._flowChart.DefaultControlType = typeof(System.Windows.Forms.Button);
			this._flowChart.Dirty = true;
			this._flowChart.DisabledMnpColor = System.Drawing.Color.FromArgb(((System.Byte)(200)), ((System.Byte)(0)), ((System.Byte)(0)));
			this._flowChart.DocExtents = ((System.Drawing.RectangleF)(resources.GetObject("_flowChart.DocExtents")));
			this._flowChart.Dock = System.Windows.Forms.DockStyle.Fill;
			this._flowChart.DoubleBuffer = false;
			this._flowChart.DynamicArrows = false;
			this._flowChart.EnableStyledText = false;
			this._flowChart.ExpandBtnPos = MindFusion.FlowChartX.EExpandBtnPos.ebpOuterRight;
			this._flowChart.ExpandOnIncoming = false;
			this._flowChart.GridColor = System.Drawing.Color.Black;
			this._flowChart.GridSize = 4F;
			this._flowChart.HighSpeedRouting = false;
			this._flowChart.HitTestPriority = MindFusion.FlowChartX.EHitTestPriority.htpNodesBeforeArrows;
			this._flowChart.HostedCtrlMouseAction = MindFusion.FlowChartX.EHostMouseAction.hmaPassToControl;
			this._flowChart.InplaceEditAcceptOnEnter = false;
			this._flowChart.InplaceEditCancelOnEsc = true;
			this._flowChart.InplaceEditFont = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
			this._flowChart.IntermArrowHead = MindFusion.FlowChartX.EArrowHead.ahNone;
			this._flowChart.Location = new System.Drawing.Point(0, 0);
			this._flowChart.MeasureUnit = System.Drawing.GraphicsUnit.Millimeter;
			this._flowChart.ModificationStart = MindFusion.FlowChartX.EModificationStyle.mdSelectedOnly;
			this._flowChart.Name = "_flowChart";
			this._flowChart.PenDashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
			this._flowChart.PenWidth = 0F;
			this._flowChart.PolyTextLayout = false;
			this._flowChart.PrpArrowStartOrnt = MindFusion.FlowChartX.EOrientation.soAuto;
			this._flowChart.RecursiveExpand = false;
			this._flowChart.RestrObjsToDoc = MindFusion.FlowChartX.ERestrictToDoc.rdIntersection;
			this._flowChart.RouteArrows = false;
			this._flowChart.ScrollX = 129F;
			this._flowChart.ScrollY = 65F;
			this._flowChart.SelectAfterCreate = true;
			this._flowChart.SelHandleSize = 2F;
			this._flowChart.SelMnpColor = System.Drawing.Color.FromArgb(((System.Byte)(170)), ((System.Byte)(170)), ((System.Byte)(170)));
			this._flowChart.ShadowColor = System.Drawing.Color.FromArgb(((System.Byte)(100)), ((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)));
			this._flowChart.ShadowOffsetX = 1F;
			this._flowChart.ShadowOffsetY = 1F;
			this._flowChart.ShadowsStyle = MindFusion.FlowChartX.EShadowsStyle.shdOneLevel;
			this._flowChart.ShapeRotation = 0F;
			this._flowChart.ShowAnchors = MindFusion.FlowChartX.EShowAnchors.saAuto;
			this._flowChart.ShowDisabledHandles = true;
			this._flowChart.ShowGrid = true;
			this._flowChart.ShowScrollbars = true;
			this._flowChart.ShowToolTips = false;
			this._flowChart.Size = new System.Drawing.Size(488, 240);
			this._flowChart.SnapToAnchor = MindFusion.FlowChartX.ESnapToAnchor.saOnCreateOrModify;
			this._flowChart.TabIndex = 7;
			this._flowChart.TableCaption = "Table";
			this._flowChart.TableCaptionHeight = 5F;
			this._flowChart.TableCellBorders = MindFusion.FlowChartX.ECellBorders.cbSystem3D;
			this._flowChart.TableColumnsCount = 2;
			this._flowChart.TableColWidth = 18F;
			this._flowChart.TableFillColor = System.Drawing.Color.FromArgb(((System.Byte)(180)), ((System.Byte)(160)), ((System.Byte)(160)));
			this._flowChart.TableFrameColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)));
			this._flowChart.TableLinkStyle = MindFusion.FlowChartX.ETableLinkStyle.tlsRows;
			this._flowChart.TableRowHeight = 6F;
			this._flowChart.TableRowsCount = 4;
			this._flowChart.TableSelStyle = MindFusion.FlowChartX.ESelStyle.sstDashFrame;
			this._flowChart.TablesExpandable = false;
			this._flowChart.TablesScrollable = false;
			this._flowChart.TableStyle = MindFusion.FlowChartX.ETableStyle.tsRect;
			this._flowChart.TextColor = System.Drawing.Color.Black;
			this._flowChart.ToolTip = "";
			this._flowChart.ZoomFactor = ((short)(100));
			this._flowChart.BoxDeactivated += new MindFusion.FlowChartX.BoxEvent(this.FlowChart_OnBoxDeactivated);
			this._flowChart.DragDrop += new System.Windows.Forms.DragEventHandler(this.FlowChart_OnDrop);
			this._flowChart.BoxActivated += new MindFusion.FlowChartX.BoxEvent(this.FlowChart_OnBoxActivated);
			this._flowChart.DragOver += new System.Windows.Forms.DragEventHandler(this.FlowChart_OnDragOver);
			this._flowChart.BoxClicked += new MindFusion.FlowChartX.BoxMouseEvent(this.FlowChart_OnBoxClicked);
			this._flowChart.ArrowClicked += new MindFusion.FlowChartX.ArrowMouseEvent(this.FlowChart_OnArrowClicked);
			this._flowChart.Click += new System.EventHandler(this._flowChart_Click);
			this._flowChart.BackBrush = MindFusion.FlowChartX.Brush.Deserialize("solid;#FFD4D0C8");
			this._flowChart.BoxBrush = MindFusion.FlowChartX.Brush.Deserialize("solid;#FF00BFFF");
			this._flowChart.TableBrush = MindFusion.FlowChartX.Brush.Deserialize("solid;#FFB4A0A0");
			this._flowChart.ArrowBrush = MindFusion.FlowChartX.Brush.Deserialize("solid;#FFFFFFFF");
			this._flowChart.BoxPen = MindFusion.FlowChartX.Pen.Deserialize("pen;0;#FF000000;0;0;0;");
			this._flowChart.TablePen = MindFusion.FlowChartX.Pen.Deserialize("pen;0;#FF000000;0;0;0;");
			this._flowChart.ArrowPen = MindFusion.FlowChartX.Pen.Deserialize("pen;0;#FF000000;0;0;0;");
			this._flowChart.TextFormat = new System.Drawing.StringFormat();
			this._flowChart.TextFormat.Alignment = System.Drawing.StringAlignment.Center;
			this._flowChart.TextFormat.LineAlignment = System.Drawing.StringAlignment.Center;
			// 
			// _rightPanel
			// 
			this._rightPanel.Controls.Add(this._propertyGrid);
			this._rightPanel.Controls.Add(this._splitter2);
			this._rightPanel.Controls.Add(this._tab);
			this._rightPanel.Location = new System.Drawing.Point(0, 240);
			this._rightPanel.Name = "_rightPanel";
			this._rightPanel.Size = new System.Drawing.Size(488, 224);
			this._rightPanel.TabIndex = 8;
			this._rightPanel.Paint += new System.Windows.Forms.PaintEventHandler(this._rightPanel_Paint);
			// 
			// _propertyGrid
			// 
			this._propertyGrid.CommandsVisibleIfAvailable = true;
			this._propertyGrid.Cursor = System.Windows.Forms.Cursors.HSplit;
			this._propertyGrid.LargeButtons = false;
			this._propertyGrid.LineColor = System.Drawing.SystemColors.ScrollBar;
			this._propertyGrid.Location = new System.Drawing.Point(240, 8);
			this._propertyGrid.Name = "_propertyGrid";
			this._propertyGrid.Size = new System.Drawing.Size(240, 208);
			this._propertyGrid.TabIndex = 2;
			this._propertyGrid.Text = "propertyGrid1";
			this._propertyGrid.ViewBackColor = System.Drawing.SystemColors.Window;
			this._propertyGrid.ViewForeColor = System.Drawing.SystemColors.WindowText;
			this._propertyGrid.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.OnPropertyValueChanged);
			// 
			// _splitter2
			// 
			this._splitter2.Dock = System.Windows.Forms.DockStyle.Top;
			this._splitter2.Location = new System.Drawing.Point(0, 0);
			this._splitter2.Name = "_splitter2";
			this._splitter2.Size = new System.Drawing.Size(488, 3);
			this._splitter2.TabIndex = 1;
			this._splitter2.TabStop = false;
			// 
			// _tab
			// 
			this._tab.Appearance = System.Windows.Forms.TabAppearance.FlatButtons;
			this._tab.Controls.Add(this._tabNodes);
			this._tab.Controls.Add(this._tabConnectors);
			this._tab.HotTrack = true;
			this._tab.Location = new System.Drawing.Point(0, 0);
			this._tab.Name = "_tab";
			this._tab.SelectedIndex = 0;
			this._tab.Size = new System.Drawing.Size(240, 224);
			this._tab.TabIndex = 0;
			// 
			// _tabNodes
			// 
			this._tabNodes.Controls.Add(this._nodeList);
			this._tabNodes.Location = new System.Drawing.Point(4, 24);
			this._tabNodes.Name = "_tabNodes";
			this._tabNodes.Size = new System.Drawing.Size(232, 196);
			this._tabNodes.TabIndex = 0;
			this._tabNodes.Text = "Nodes";
			// 
			// _nodeList
			// 
			this._nodeList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this._nodeList.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
			this._nodeList.ForeColor = System.Drawing.SystemColors.WindowText;
			this._nodeList.Location = new System.Drawing.Point(0, -8);
			this._nodeList.Name = "_nodeList";
			this._nodeList.Size = new System.Drawing.Size(232, 200);
			this._nodeList.Sorted = true;
			this._nodeList.TabIndex = 7;
			this._nodeList.MouseDown += new System.Windows.Forms.MouseEventHandler(this.NodeList_OnMouseDown);
			this._nodeList.MeasureItem += new System.Windows.Forms.MeasureItemEventHandler(this.NodeList_OnMeasureItem);
			this._nodeList.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.NodeList_OnDrawItem);
			// 
			// _tabConnectors
			// 
			this._tabConnectors.Controls.Add(this._connectorList);
			this._tabConnectors.Controls.Add(this._connectorTypeCombo);
			this._tabConnectors.Location = new System.Drawing.Point(4, 24);
			this._tabConnectors.Name = "_tabConnectors";
			this._tabConnectors.Size = new System.Drawing.Size(232, 196);
			this._tabConnectors.TabIndex = 1;
			this._tabConnectors.Text = "Connectors";
			// 
			// _connectorList
			// 
			this._connectorList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this._connectorList.Dock = System.Windows.Forms.DockStyle.Fill;
			this._connectorList.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
			this._connectorList.Location = new System.Drawing.Point(0, 0);
			this._connectorList.Name = "_connectorList";
			this._connectorList.Size = new System.Drawing.Size(232, 176);
			this._connectorList.TabIndex = 2;
			this._connectorList.MeasureItem += new System.Windows.Forms.MeasureItemEventHandler(this.ConnectorList_OnMeasureItem);
			this._connectorList.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ConnectorList_OnDrawItem);
			this._connectorList.SelectedIndexChanged += new System.EventHandler(this.ConnectorList_OnSelectionChanged);
			// 
			// _connectorTypeCombo
			// 
			this._connectorTypeCombo.Dock = System.Windows.Forms.DockStyle.Bottom;
			this._connectorTypeCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this._connectorTypeCombo.Items.AddRange(new object[] {
																	 "Polyline",
																	 "Bezier",
																	 "Perpendicular"});
			this._connectorTypeCombo.Location = new System.Drawing.Point(0, 176);
			this._connectorTypeCombo.Name = "_connectorTypeCombo";
			this._connectorTypeCombo.Size = new System.Drawing.Size(232, 20);
			this._connectorTypeCombo.TabIndex = 1;
			this._connectorTypeCombo.SelectedValueChanged += new System.EventHandler(this.ConnectorTypeCombo_OnSelectedValueChange);
			// 
			// _openFileDialog
			// 
			this._openFileDialog.DefaultExt = "fcs";
			this._openFileDialog.FileName = "Flowchart";
			this._openFileDialog.Filter = "FlowCharter documents|*.fcs|All files|*.*";
			this._openFileDialog.Title = "Open document";
			// 
			// _saveFileDialog
			// 
			this._saveFileDialog.DefaultExt = "fcs";
			this._saveFileDialog.FileName = "Flowchart";
			this._saveFileDialog.Filter = "FlowCharter documents|*.fcs|All files|*.*";
			this._saveFileDialog.Title = "Save document";
			// 
			// _contextMenu
			// 
			this._contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						 this._menuItemDelete});
			// 
			// _menuItemDelete
			// 
			this._menuItemDelete.Index = 0;
			this._menuItemDelete.Text = "Delete";
			this._menuItemDelete.Click += new System.EventHandler(this.OnDelete);
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this._hidden);
			this.panel1.Controls.Add(this._flowChart);
			this.panel1.Location = new System.Drawing.Point(0, 8);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(488, 240);
			this.panel1.TabIndex = 9;
			// 
			// MainForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(592, 505);
			this.Controls.Add(this._borderPanel);
			this.Controls.Add(this._rightPanel);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Menu = this._mainMenu;
			this.Name = "MainForm";
			this.Text = "FlowCharter";
			this._borderPanel.ResumeLayout(false);
			this._rightPanel.ResumeLayout(false);
			this._tab.ResumeLayout(false);
			this._tabNodes.ResumeLayout(false);
			this._tabConnectors.ResumeLayout(false);
			this.panel1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new MainForm());
		}


		#region hidden
		private void ListBox_DrawItem(ListBox lb, System.Windows.Forms.DrawItemEventArgs e)
		{
			Rectangle rcc;
			RectangleF rc;

			System.Drawing.SolidBrush brush;
			System.Drawing.Pen selPen;
			System.Drawing.SolidBrush selBrush;
			StringFormat sf;

			rcc = e.Bounds;
			rcc.Inflate(-1, -1);
			rc = new RectangleF((float)e.Bounds.Left + 32,
				(float)e.Bounds.Top, (float)e.Bounds.Width - 32,
				(float)e.Bounds.Height);

			brush = new System.Drawing.SolidBrush(Color.Black);
			selPen = new System.Drawing.Pen(Color.Goldenrod);
			selBrush = new System.Drawing.SolidBrush(Color.LightYellow);

			sf = StringFormat.GenericDefault;
			sf.LineAlignment = StringAlignment.Center;

			// Draw the selection if any
			if((e.State & DrawItemState.Selected) > 0)
			{
				e.Graphics.FillRectangle(selBrush, rcc);
				e.Graphics.DrawRectangle(selPen, rcc);
			}
			else
			{
				System.Drawing.SolidBrush tb = new
					System.Drawing.SolidBrush(Color.White);
				e.Graphics.FillRectangle(tb, e.Bounds);
				tb.Dispose();
			}

			e.Graphics.DrawString((string)lb.Items[e.Index],
				_nodeList.Font, brush, rc, sf);

			brush.Dispose();
			selPen.Dispose();
			selBrush.Dispose();
		}

		private void NodeList_OnMeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e)
		{
			e.ItemHeight = 32;
		}

		private void NodeList_OnDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
		{
			if(e.Index < 0)
				return;

			// Draw the item
			ListBox_DrawItem(_nodeList, e);

			if((e.State & DrawItemState.Selected) > 0)
				_hidden.BackColor = Color.LightYellow;
			else
				_hidden.BackColor = Color.White;

			// Draw the node
			Box b;
			_hidden.ClearAll();
			b = _hidden.CreateBox(1, 1, 24, 24);
			b.ShapeTemplate = _nodes[e.Index].Template;
			b.Style = EBoxStyle.bsComplex;

			Bitmap bmp = _hidden.CreateBmpFromChart();
			Rectangle rci = new Rectangle(e.Bounds.Left + 3,
				e.Bounds.Top + 4, 24, 24);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -