Cause and Effect Shapes Example for Blazor

Nevron NOV Diagram for Blazor ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All Blazor Diagram examples are also available as a stand-alone Visual Studio solution in C#, which you can download from the links below.

Cause and Effect Shapes Example for Blazor Description

This example shows the cause and effect shapes created by the NCauseAndEffectShapeFactory in the Nevron.Nov.Diagram.Shapes assembly.


Cause and Effect Shapes Example

C# Cause and Effect Shapes Example Code for Nevron Diagram for Blazor
Language: C#

using Nevron.Nov;
using Nevron.Nov.Diagram;
using Nevron.Nov.Diagram.Shapes;
using Nevron.Nov.Diagram.Shapes.CauseAndEffect;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System.Windows.Forms;

namespace NovWinFormsProject
{
	public partial class Form1 : Form
	{
		#region Constructors

		public Form1()
		{
			InitializeComponent();

			// Set form title
			Text = "NOV WinForms - NCauseAndEffectShapesExample";

			// Create the NOV example and its controls
			NWidget exampleContent = CreateExampleContent();
			NWidget exampleControls = CreateExampleControls();
			if (exampleControls != null)
			{
				exampleControls.PreferredWidth = 300;
			}

			// Place the example and its controls in a pair box
			NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
			pairBox.FillMode = ENStackFillMode.First;
			pairBox.FitMode = ENStackFitMode.First;
			pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);

			// Host the example in the form
			NNovWidgetHost host = new NNovWidgetHost(pairBox);
			host.Dock = DockStyle.Fill;
			Controls.Add(host);
		}

		#endregion

        #region Example

        public NWidget CreateExampleContent()
        {
			// Create a simple drawing
			NDrawingViewWithRibbon drawingViewWithRibbon = new NDrawingViewWithRibbon();
			drawingViewWithRibbon.GetRibbon().Tab.Expanded = false;
			m_DrawingView = drawingViewWithRibbon.View;

			m_DrawingView.Document.HistoryService.Pause();
			try
			{
				InitDiagram(m_DrawingView.Document);
			}
			finally
			{
				m_DrawingView.Document.HistoryService.Resume();
			}

			return drawingViewWithRibbon;
		}
		public NWidget CreateExampleControls()
        {
            return null;
        }
        public string GetExampleDescription()
        {
            return @"

This example shows the cause and effect shapes created by the NCauseAndEffectShapeFactory in the Nevron.Nov.Diagram.Shapes assembly.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Predefined Libraries", "https://www.nevron.com/docs/openvision/diagram-predefined-libraries.html"), ("Libraries", "https://www.nevron.com/docs/openvision/diagram-libraries.html"), ("Shapes", "https://www.nevron.com/docs/openvision/diagram-shapes.html"), ("Library Browser", "https://www.nevron.com/docs/openvision/diagram-library-browser.html"), }; } #endregion #region Implementation private void InitDiagram(NDrawingDocument drawingDocument) { NPage page = drawingDocument.Content.ActivePage; page.ZoomMode = ENZoomMode.Fit; // Create some Cause and Effect shapes, setting the number of desired ports of each shape to its "Tag" property. // Ports will be created when the code-behind of the shapes has been compiled. // Create an Effect shape m_EffectShape = m_ShapeFactory.CreateShape(ENCauseAndEffectShape.Effect); m_EffectShape.Text = "Desired Effect"; m_EffectShape.PinX = 700; m_EffectShape.PinY = 250; m_EffectShape.Controls[0].X = -600; CreatePorts(m_EffectShape, 4); page.Items.Add(m_EffectShape); // Craete 4 Category shapes m_CategoryShape1 = m_ShapeFactory.CreateShape(ENCauseAndEffectShape.Category1); m_CategoryShape1.Text = "Category 1"; m_CategoryShape1.PinX = 70; m_CategoryShape1.PinY = 100; page.Items.Add(m_CategoryShape1); m_CategoryShape2 = m_ShapeFactory.CreateShape(ENCauseAndEffectShape.Category1); m_CategoryShape2.Text = "Category 2"; m_CategoryShape2.PinX = 340; m_CategoryShape2.PinY = 100; CreatePorts(m_CategoryShape2, 1); page.Items.Add(m_CategoryShape2); m_CategoryShape3 = m_ShapeFactory.CreateShape(ENCauseAndEffectShape.Category2); m_CategoryShape3.Text = "Category 3"; m_CategoryShape3.PinX = 200; m_CategoryShape3.PinY = 400; CreatePorts(m_CategoryShape3, 1); page.Items.Add(m_CategoryShape3); m_CategoryShape4 = m_ShapeFactory.CreateShape(ENCauseAndEffectShape.Category2); m_CategoryShape4.Text = "Category 4"; m_CategoryShape4.PinX = 470; m_CategoryShape4.PinY = 400; page.Items.Add(m_CategoryShape4); // Create 2 Cause shapes m_CauseShape1 = m_ShapeFactory.CreateShape(ENCauseAndEffectShape.PrimaryCause2); m_CauseShape1.Text = "Cause 1"; m_CauseShape1.PinX = 500; m_CauseShape1.PinY = 175; page.Items.Add(m_CauseShape1); m_CauseShape2 = m_ShapeFactory.CreateShape(ENCauseAndEffectShape.PrimaryCause1); m_CauseShape2.Text = "Cause 2"; m_CauseShape2.PinX = 120; m_CauseShape2.PinY = 325; page.Items.Add(m_CauseShape2); ConnectShapes(); page.SizeToContent(); } private void CreatePorts(NShape shape, int numberOfPortsToCreate) { NFishboneBaseShapeCodeBehind codeBehind = (NFishboneBaseShapeCodeBehind)shape.CodeBehind; for (int i = 0; i < numberOfPortsToCreate; i++) { codeBehind.AddPort(); } } private void ConnectShapes() { m_CategoryShape1.Controls[0].GlueToPort(m_EffectShape.Ports[3]); m_CategoryShape2.Controls[0].GlueToPort(m_EffectShape.Ports[1]); m_CategoryShape3.Controls[0].GlueToPort(m_EffectShape.Ports[2]); m_CategoryShape4.Controls[0].GlueToPort(m_EffectShape.Ports[0]); m_CauseShape1.Controls[0].GlueToPort(m_CategoryShape2.Ports[0]); m_CauseShape2.Controls[0].GlueToPort(m_CategoryShape3.Ports[0]); } #endregion #region Event Handlers #endregion #region Fields private NCauseAndEffectShapeFactory m_ShapeFactory; private NDrawingView m_DrawingView; // Shapes private NShape m_EffectShape; private NShape m_CategoryShape1; private NShape m_CategoryShape2; private NShape m_CategoryShape3; private NShape m_CategoryShape4; private NShape m_CauseShape1; private NShape m_CauseShape2; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Cause and Effect Shapes Example for Blazor Solution