private void InitDocument() { // Set up visual formatting document.BackgroundStyle.FrameStyle.Visible = false; // Create the stylesheets int i = 0, count = COLORS.Length; m_Cells = new int[count]; for (i = 0; i < count; i++) { NStyleSheet styleSheet = new NStyleSheet(COLORS[i].ToString()); NStyle.SetFillStyle(styleSheet, new NAdvancedGradientFillStyle(COLORS[i], 4)); document.StyleSheets.AddChild(styleSheet); cells[i] = 0; } // Create the table score = 0; CreateTableShape(); CreateInfoShape(); table.Location = new NPointF(info.Bounds.Right + info.Width / 2, table.Location.Y); // Resize the document to fit all shapes document.SizeToContent(); document.Tag = m_Cells; document.ActiveLayer.Tag = m_Score; }
private void CreateTextShape(ref NShape shape) { shape = new NRectangleShape(0, 0, SEAT_SIZE.Width * 10, SEAT_SIZE.Height); NStyle.SetFillStyle(shape, new NColorFillStyle(Color.White)); NStyle.SetStrokeStyle(shape, new NStrokeStyle(0, Color.White)); NStyle.SetTextStyle(shape, new NTextStyle()); shape.Style.TextStyle.StringFormatStyle = new NStringFormatStyle(StringFormatType.GenericTypographic, HorzAlign.Left, VertAlign.Center); SetProtections(shape); document.ActiveLayer.AddChild(shape); }
private void CreateScene(NDrawingDocument document) { document.BackgroundStyle.FrameStyle.Visible = false; document.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial Narrow", 8)); NNetworkShapesFactory factory = new NNetworkShapesFactory(document); factory.DefaultSize = new NSizeF(240, 180); NShape server = factory.CreateShape(NetworkShapes.Server); NShape computer = factory.CreateShape(NetworkShapes.Computer); NShape laptop = factory.CreateShape(NetworkShapes.Laptop); document.ActiveLayer.AddChild(server); document.ActiveLayer.AddChild(computer); document.ActiveLayer.AddChild(laptop); NRoutableConnector link1 = new NRoutableConnector(); document.ActiveLayer.AddChild(link1); link1.FromShape = server; link1.ToShape = computer; NRoutableConnector link2 = new NRoutableConnector(); document.ActiveLayer.AddChild(link2); link2.FromShape = server; link2.ToShape = laptop; // layout the shapes in the active layer using a table layout NLayeredGraphLayout layout = new NLayeredGraphLayout(); // get the shapes to layout NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D); // layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(document)); // resize document to fit all shapes document.SizeToContent(); // add the data shape const float shapeSize = 10; NEllipseShape data = new NEllipseShape(link2.EndPoint.X - shapeSize / 2, link2.EndPoint.Y - shapeSize, shapeSize, shapeSize); document.ActiveLayer.AddChild(data); NStyle.SetStrokeStyle(data, new NStrokeStyle(0, KnownArgbColorValue.Transparent)); NStyle.SetFillStyle(data, new NColorFillStyle(KnownArgbColorValue.Red)); // set the animations style SetAnimationsStyle(data, link1, link2); // resize document to fit all shapes document.SizeToContent(); }
/// <summary> /// Creates the zoom rect /// </summary> /// <remarks> /// This implementation will currently create a zoom rectangle and add it to the preview layer /// </remarks> protected virtual void CreateZoomRect() { // create the zoom rect m_ZoomRect = new NRectanglePath(); NStyle.SetFillStyle(m_ZoomRect, new NColorFillStyle(Color.FromArgb(0, 0, 0, 0))); NStyle.SetStrokeStyle(m_ZoomRect, new NStrokeStyle(1, Color.Black, LinePattern.Dash)); View.PreviewLayer.AddChild(m_ZoomRect); // start dragging View.OnDraggingStarted(); }
private void CreateStyleSheets(NDrawingDocument document) { // Create the zoomed city style sheet NStyleSheet zoomedCity = new NStyleSheet(); zoomedCity.Name = "ZoomedCity"; NTextStyle textStyle = (NTextStyle)document.ComposeTextStyle().Clone(); textStyle.FontStyle = new NFontStyle(textStyle.FontStyle.Name, textStyle.FontStyle.EmSize, FontStyle.Bold); NStyle.SetTextStyle(zoomedCity, textStyle); NStyle.SetFillStyle(zoomedCity, new NColorFillStyle(Color.Red)); document.StyleSheets.AddChild(zoomedCity); }
/// <summary> /// Shows the fill style editor for the specified styleable node /// </summary> /// <param name="styleable"></param> protected void ShowFillStyleEditor(INStyleable styleable) { if (styleable == null) { return; } NFillStyle fillStyle = styleable.ComposeFillStyle(); NFillStyle newFillStyle = null; if (NFillStyleTypeEditor.Edit(fillStyle, out newFillStyle)) { NStyle.SetFillStyle(styleable, newFillStyle); document.RefreshAllViews(); } }
public void InitDocument(NDrawingDocument document) { // Set up visual formatting document.BackgroundStyle.FrameStyle.Visible = false; document.BackgroundStyle.FillStyle = new NColorFillStyle(Color.LightBlue); document.GraphicsSettings.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; // Create style sheets NStyleSheet clickedCounty = new NStyleSheet("ClickedCounty"); NStyle.SetFillStyle(clickedCounty, new NColorFillStyle(KnownArgbColorValue.Red)); NStyle.SetTextStyle(clickedCounty, new NTextStyle(document.ComposeTextStyle().FontStyle, Color.White)); document.StyleSheets.AddChild(clickedCounty); // Load the map of the USA LoadUsaMap(document); }
protected NCompositeShape CreateLegendItem(NRectangleF bounds, string str, NFillStyle fillStyle) { NCompositeShape item = new NCompositeShape(); NRectanglePath rect = new NRectanglePath(0, 0, 2, 2); NStyle.SetFillStyle(rect, (fillStyle.Clone() as NFillStyle)); item.Primitives.AddChild(rect); NTextPrimitive text = new NTextPrimitive(str, new NRectangleF(2, 0, 4, 2)); item.Primitives.AddChild(text); item.UpdateModelBounds(); item.Bounds = bounds; return(item); }
private void InitDocument() { document.Style.StrokeStyle = new NStrokeStyle(0, Color.Empty); // Add some gradient fill style sheets NStyleSheet styleSheet = new NStyleSheet("Style1"); NStyle.SetFillStyle(styleSheet, new NColorFillStyle(Color.Red)); document.StyleSheets.AddChild(styleSheet); styleSheet = new NStyleSheet("Style2"); NStyle.SetFillStyle(styleSheet, new NColorFillStyle(Color.Green)); document.StyleSheets.AddChild(styleSheet); styleSheet = new NStyleSheet("Style3"); NStyle.SetFillStyle(styleSheet, new NColorFillStyle(Color.Blue)); document.StyleSheets.AddChild(styleSheet); }
private void InitDocument(NDrawingDocument document) { // Set up visual formatting document.BackgroundStyle.FrameStyle.Visible = false; document.Style.TextStyle.FontStyle = new NFontStyle(document.Style.TextStyle.FontStyle.Name, 14); // Create the stylesheets int i = 0; int count = GradientSchemes.Length; for (i = 0; i < count; i++) { AdvancedGradientScheme scheme = GradientSchemes[i]; NStyleSheet styleSheet = new NStyleSheet(scheme.ToString()); NAdvancedGradientFillStyle fill = new NAdvancedGradientFillStyle(scheme, 4); if (scheme.Equals(AdvancedGradientScheme.Green)) { // Make the green color dark ((NAdvancedGradientPoint)fill.Points[0]).Color = Color.FromArgb(0, 128, 0); } NStyle.SetFillStyle(styleSheet, fill); document.StyleSheets.AddChild(styleSheet); NAdvancedGradientFillStyle highlightedFill = (NAdvancedGradientFillStyle)fill.Clone(); ((NAdvancedGradientPoint)highlightedFill.Points[0]).Color = ControlPaint.LightLight(((NAdvancedGradientPoint)fill.Points[0]).Color); NStyleSheet highlightedStyleSheet = new NStyleSheet(styleSheet.Name + HighlightedSuffix); NStyle.SetFillStyle(highlightedStyleSheet, highlightedFill); document.StyleSheets.AddChild(highlightedStyleSheet); } // Create the board and info shapes NClickomaniaGame game = new NClickomaniaGame(); CreateBoardShape(document, game); CreateInfoShape(document, game); game.BoardShape.Location = new NPointF(game.InfoShape.Bounds.Right + game.InfoShape.Width / 2, game.BoardShape.Location.Y); // Resize the document to fit all shapes document.SizeToContent(); game.InfoShape.Location = new NPointF(game.InfoShape.Location.X, game.BoardShape.Location.Y); document.Tag = game; }
private void CreateMechanicalEngineeringDocument() { // create the key shape NCompositeShape key = new NCompositeShape(); NRectanglePath keyRect = new NRectanglePath(new NRectangleF(12.5f, 30, 5f, 50)); key.Primitives.AddChild(keyRect); NEllipsePath keyCircle = new NEllipsePath(new NRectangleF(0, 0, 30, 30)); key.Primitives.AddChild(keyCircle); NEllipsePath keyHole = new NEllipsePath(new NRectangleF(13f, 2f, 4f, 4f)); NStyle.SetFillStyle(keyHole, new NColorFillStyle(Color.White)); NStyle.SetStrokeStyle(keyHole, new NStrokeStyle(0, Color.Black)); key.Primitives.AddChild(keyHole); key.UpdateModelBounds(); key.Style.FillStyle = new NColorFillStyle(Color.DarkGray); key.Style.StrokeStyle = new NStrokeStyle(0, Color.Black); document.ActiveLayer.AddChild(key); // create the octagram NBasicShapesFactory factory = new NBasicShapesFactory(document); NShape octagram = factory.CreateShape((int)BasicShapes.Octagram); octagram.Bounds = new NRectangleF(40, 0, 40, 40); octagram.Style.FillStyle = new NColorFillStyle(Color.DarkGray); octagram.Style.StrokeStyle = new NStrokeStyle(0, Color.Black); document.ActiveLayer.AddChild(octagram); // update the drawing bounds to size to content with some margins document.AutoBoundsMinSize = new NSizeF(1, 1); document.AutoBoundsPadding = new Nevron.Diagram.NMargins(5f); document.AutoBoundsMode = AutoBoundsMode.AutoSizeToContent; }
private void InitDocument() { // Create the stylesheets int i = 0, count = COLORS.Length; cells = new int[count]; for (i = 0; i < count; i++) { NStyleSheet styleSheet = new NStyleSheet(COLORS[i].ToString()); NStyle.SetFillStyle(styleSheet, new NAdvancedGradientFillStyle(COLORS[i], 4)); document.StyleSheets.AddChild(styleSheet); cells[i] = 0; } // Create the table score = 0; table = CreateTableShape(); info = CreateInfoShape(); table.Location = new NPointF(info.Bounds.Right + info.Width / 2, table.Location.Y); // Resize the document to fit all shapes document.SizeToContent(); }
protected void NDrawingView1_AsyncClick(object sender, EventArgs e) { NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs; NNodeList nodes = NDrawingView1.HitTest(args); NNodeList shapes = nodes.Filter(CELL_FILTER); if (shapes.Count == 0) { return; } NTableCell cell = (NTableCell)shapes[0]; if (cell.ParentNode.ParentNode != table) { return; } if (cell.StyleSheetName != null && cell.StyleSheetName != string.Empty) { if (CellClicked(cell)) { UpdateInfo(); // Check for end of the game string status = string.Empty; if (AllClear()) { score *= 2; status = "You've cleared all cells !!!" + Environment.NewLine; } if (status == string.Empty && GameOver()) { status = "Game Over !" + Environment.NewLine; } if (status != string.Empty) { status += "Your score is " + score.ToString(); NTableShape gameOver = new NTableShape(); document.ActiveLayer.AddChild(gameOver); gameOver.BeginUpdate(); gameOver.CellPadding = new Nevron.Diagram.NMargins(2, 2, 8, 8); gameOver[0, 0].Text = status; NStyle.SetFillStyle(gameOver, new NAdvancedGradientFillStyle(AdvancedGradientScheme.Ocean1, 0)); NStyle.SetStrokeStyle(gameOver, new NStrokeStyle(Color.DarkBlue)); NTextStyle textStyle = (NTextStyle)table.ComposeTextStyle().Clone(); textStyle.FillStyle = new NColorFillStyle(Color.DarkBlue); NStyle.SetTextStyle(gameOver, textStyle); gameOver.EndUpdate(); gameOver.Center = table.Center; } } } }
private void ImportData() { NDrawingDocument document = NDrawingView1.Document; document.BackgroundStyle.FrameStyle.Visible = false; // create two stylesheets - one for the vertices and one for the edges NStyleSheet vertexStyleSheet = new NStyleSheet(); vertexStyleSheet.Name = "Vertices"; NStyle.SetFillStyle(vertexStyleSheet, new NColorFillStyle(Color.FromArgb(236, 97, 49))); document.StyleSheets.AddChild(vertexStyleSheet); NStyleSheet edgeStyleSheet = new NStyleSheet(); edgeStyleSheet.Name = "Edges"; NStyle.SetStrokeStyle(edgeStyleSheet, new NStrokeStyle(Color.Blue)); NStyle.SetEndArrowheadStyle(edgeStyleSheet, new NArrowheadStyle(ArrowheadShape.OpenedArrow, null, new NSizeL(6, 4), null, new NStrokeStyle(Color.Blue))); NTextStyle textStyle = (NTextStyle)document.ComposeTextStyle().Clone(); textStyle.StringFormatStyle.VertAlign = Nevron.VertAlign.Bottom; NStyle.SetTextStyle(edgeStyleSheet, textStyle); document.StyleSheets.AddChild(edgeStyleSheet); // create the graph data source importer NGraphDataSourceImporter graphImporter = new NGraphDataSourceImporter(); // set the document in the active layer of which the shapes will be imported graphImporter.Document = document; // SET THE DATA SOURCE // the tree data source importer supports the following data sources // DataTable // DataView // OleDbDataAdapter // SqlDataAdapter // OdbcDataAdapter // OleDbCommand // SqlCommand // OdbcCommand // in this example we have created an OleDbDataAdapter, // which selects all columns and records from the Sources and Links tables of the Data.xlsx file string databasePath = Server.MapPath(@"..\Examples\Import\Data.xlsx"); string connectionString = @"Data Source=""" + databasePath + @""";Provider=""Microsoft.ACE.OLEDB.12.0""; Extended Properties=""Excel 12.0 Xml;HDR=YES"";"; graphImporter.VertexDataSource = new OleDbDataAdapter("SELECT * FROM [Sources$]", connectionString); graphImporter.EdgeDataSource = new OleDbDataAdapter("SELECT * FROM [Links$]", connectionString); // vertex records are uniquely identified by their Id (in the Sources table) // edges link the vertices with the Fro and ToPageId (in the Links table) graphImporter.VertexIdColumnName = "Id"; graphImporter.FromVertexIdColumnName = "From"; graphImporter.ToVertexIdColumnName = "To"; // create vertices as group shapes, with default size NShapesFactory shapesFactory = new GroupShapesFactory(); shapesFactory.DefaultSize = VertexSize; graphImporter.VertexShapesFactory = shapesFactory; graphImporter.VertexShapesName = GroupShapes.Group.ToString(); // set stylesheets to be applied to imported vertices and edges graphImporter.VertexStyleSheetName = "Vertices"; graphImporter.EdgeStyleSheetName = "Edges"; // use layered graph layout NLayeredGraphLayout layout = new NLayeredGraphLayout(); layout.LayerSpacing = 70; layout.Direction = LayoutDirection.LeftToRight; layout.LayerAlignment = RelativeAlignment.Near; graphImporter.Layout = layout; // subscribe for the vertex and edge imported events, // which are raised when a shape was created for a data source record graphImporter.VertexImported += new ShapeImportedDelegate(OnVertexImported); graphImporter.EdgeImported += new ShapeImportedDelegate(OnEdgeImported); // import graphImporter.Import(); }
private void CreateAnimatedGrid(int rows, int columns, float cellFadeDuration) { NDrawingDocument document = DrawingView.Document; // Create the grid layer NLayer grid = new NLayer(); grid.Name = "grid"; document.Layers.AddChild(grid); // Create the cells style sheet NStyleSheet style = new NStyleSheet("gridCell"); NStyle.SetFillStyle(style, new NColorFillStyle(KnownArgbColorValue.White)); NStyle.SetStrokeStyle(style, new NStrokeStyle(1, KnownArgbColorValue.Black)); document.StyleSheets.AddChild(style); int i, j, count; float x, y, time = 0; float cellWidth = document.Width / rows; float cellHeight = document.Height / columns; NFadeAnimation fade; NRectangleShape rect; List <NRectangleShape> cells = new List <NRectangleShape>(); // Create the shapes for (i = 0, y = 0; i < rows; i++, y += cellHeight) { for (j = 0, x = 0; j < columns; j++, x += cellWidth) { rect = new NRectangleShape(x, y, cellWidth, cellHeight); cells.Add(rect); grid.AddChild(rect); rect.StyleSheetName = style.Name; } } // Create the fade animations count = cells.Count; Random random = new Random(); int counter = 1; while (count > 0) { i = random.Next(count); rect = cells[i]; rect.Style.AnimationsStyle = new NAnimationsStyle(); if (time > 0) { fade = new NFadeAnimation(0, time); fade.StartAlpha = 1; fade.EndAlpha = 1; rect.Style.AnimationsStyle.AddAnimation(fade); } fade = new NFadeAnimation(time, cellFadeDuration); fade.StartAlpha = 1; fade.EndAlpha = 0; rect.Style.AnimationsStyle.AddAnimation(fade); if (counter == 3) { // Show 3 cells at a time time += cellFadeDuration; counter = 1; } else { counter++; } cells.RemoveAt(i); count--; } }
protected NCompositeShape CreateCoffeeCupShape(NPointF location, float scale) { NCompositeShape shape = new NCompositeShape(); // create the cup as a polygon path NPolygonPath cup = new NPolygonPath(new NPointF[] { new NPointF(45, 268), new NPointF(63, 331), new NPointF(121, 331), new NPointF(140, 268) }); shape.Primitives.AddChild(cup); // create the cup hangle as a closed curve path NClosedCurvePath handle = new NClosedCurvePath(new NPointF[] { new NPointF(175, 295), new NPointF(171, 278), new NPointF(140, 283), new NPointF(170, 290), new NPointF(128, 323) }, 1); NStyle.SetFillStyle(handle, new NColorFillStyle(Color.LightSalmon)); shape.Primitives.AddChild(handle); // create the steam as a custom filled path GraphicsPath path = new GraphicsPath(); path.AddBeziers(new PointF[] { new PointF(92, 258), new PointF(53, 163), new PointF(145, 160), new PointF(86, 50), new PointF(138, 194), new PointF(45, 145), new PointF(92, 258) }); path.CloseAllFigures(); NCustomPath steam = new NCustomPath(path, PathType.ClosedFigure); NStyle.SetFillStyle(steam, new NColorFillStyle(Color.FromArgb(50, 122, 122, 122))); shape.Primitives.AddChild(steam); // update the shape model bounds to fit the primitives it contains shape.UpdateModelBounds(); // create the shape ports shape.CreateShapeElements(ShapeElementsMask.Ports); // create dynamic port anchored to the cup center NDynamicPort dynamicPort = new NDynamicPort(cup.UniqueId, ContentAlignment.MiddleCenter, DynamicPortGlueMode.GlueToContour); shape.Ports.AddChild(dynamicPort); // create rotated bounds port anchored to the middle right side of the handle NRotatedBoundsPort rotatedBoundsPort = new NRotatedBoundsPort(handle.UniqueId, ContentAlignment.MiddleRight); shape.Ports.AddChild(rotatedBoundsPort); // apply style to the shape shape.Style.FillStyle = new NColorFillStyle(Color.LightCoral); // position it and scale the shape shape.Location = location; shape.Width = shape.Width * scale; shape.Height = shape.Height * scale; return(shape); }
void InitDocument() { // set up visual formatting NDrawingView1.Document.Style.FillStyle = new NColorFillStyle(Color.White); NDrawingView1.Document.BackgroundStyle.FrameStyle.Visible = false; NCustomToolsData.NBookEntry[] books = NCustomToolsData.CreateBooks(); // set up the shape factories NBasicShapesFactory bookItemsFactory = new NBasicShapesFactory(NDrawingView1.Document); bookItemsFactory.DefaultSize = new NSizeF(150, 100); // create a table layout, which will align te thumbnail and the text within a group NTableLayout bookThumbLayout = new NTableLayout(); bookThumbLayout.Direction = LayoutDirection.LeftToRight; bookThumbLayout.ConstrainMode = CellConstrainMode.Ordinal; bookThumbLayout.MaxOrdinal = 1; // create a table layout, which will align all books in a grid NTableLayout tableLayout = new NTableLayout(); tableLayout.Direction = LayoutDirection.LeftToRight; tableLayout.ConstrainMode = CellConstrainMode.Ordinal; tableLayout.MaxOrdinal = 4; tableLayout.HorizontalSpacing = 7; tableLayout.VerticalSpacing = 7; NLayoutContext layoutContext = new NLayoutContext(); layoutContext.GraphAdapter = new NShapeGraphAdapter(); layoutContext.BodyAdapter = new NShapeBodyAdapter(NDrawingView1.Document); layoutContext.BodyContainerAdapter = new NDrawingBodyContainerAdapter(NDrawingView1.Document); int length = books.Length; for (int i = 0; i < length; i++) { NCustomToolsData.NBookEntry book = books[i]; NShape bookThumbnailShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle); NImageFillStyle fs1 = new NImageFillStyle(this.MapPathSecure(@"..\..\..\..\Images\CustomTools\" + book.ThumbnailFile)); fs1.TextureMappingStyle.MapLayout = MapLayout.Centered; NStyle.SetFillStyle(bookThumbnailShape, fs1); NStyle.SetStrokeStyle(bookThumbnailShape, new NStrokeStyle(0, Color.White)); NShape bookTextShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle); NStyle.SetStrokeStyle(bookTextShape, new NStrokeStyle(0, Color.White)); bookTextShape.Text = book.Title; bookTextShape.Height = 50f; bookThumbnailShape.Style.InteractivityStyle = new NInteractivityStyle(true, book.Id.ToString(), null, CursorType.Hand); bookTextShape.Style.InteractivityStyle = new NInteractivityStyle(true, book.Id.ToString(), null, CursorType.Hand); // create the book tumbnail group NGroup g = new NGroup(); NBatchGroup bgroup = new NBatchGroup(NDrawingView1.Document); NNodeList shapes = new NNodeList(); shapes.Add(bookThumbnailShape); shapes.Add(bookTextShape); // perform layout bookThumbLayout.Layout(shapes, layoutContext); // group shapes bgroup.Build(shapes); bgroup.Group(null, false, out g); NDrawingView1.Document.ActiveLayer.AddChild(g); } // layout the books tableLayout.Layout(NDrawingView1.Document.ActiveLayer.Children(null), layoutContext); }
protected NCompositeShape CreateOrgChartShape(NPersonalInfo info) { NRectangleF bounds = info.Bounds; float bottomPortAlignment = info.BottomPortAlignment; Bitmap photo = new Bitmap(this.MapPathSecure(info.Picture)); // compose a new graph vertex from a frame and an image NRectanglePath frame = new NRectanglePath(bounds); NRectanglePath image = new NRectanglePath(new NPointF(bounds.X + 5, bounds.Y + 5), new NSizeF(photo.Size)); NImageFillStyle imgageFillStyle = new NImageFillStyle(photo, 0xff); NStyle.SetFillStyle(image, imgageFillStyle); NCompositeShape shape = new NCompositeShape(); shape.Primitives.AddChild(frame); shape.Primitives.AddChild(image); shape.UpdateModelBounds(); Document.ActiveLayer.AddChild(shape); // set the vertex fill style NColorFillStyle fillStyle = null; switch (info.Level) { case 0: fillStyle = new NColorFillStyle(Color.FromArgb(241, 100, 34)); break; case 1: fillStyle = new NColorFillStyle(Color.FromArgb(249, 167, 26)); break; case 2: fillStyle = new NColorFillStyle(Color.FromArgb(255, 247, 151)); break; } fillStyle.ImageFiltersStyle.Filters.Add(new NLightingImageFilter()); shape.Style.FillStyle = fillStyle; NInteractivityStyle interactivityStyle = new NInteractivityStyle(); interactivityStyle.Tooltip.Text = "Click to show " + info.Name + " personal information"; interactivityStyle.UrlLink.Url = "../Examples/WebControl/GettingStarted/NPersonalInfoPage.aspx?" + info.Id.ToString(); shape.Style.InteractivityStyle = interactivityStyle; // add a new label for the person name NRotatedBoundsLabel nameLabel = new NRotatedBoundsLabel(info.Name, shape.UniqueId, new Nevron.Diagram.NMargins(40, 1, 50, 1)); shape.Labels.AddChild(nameLabel); NStyle.SetTextStyle(nameLabel, nameLabel.ComposeTextStyle().Clone() as NTextStyle); nameLabel.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Right; nameLabel.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Top; // configure default label (used for the person position) NRotatedBoundsLabel positionLabel = shape.Labels.DefaultLabel as NRotatedBoundsLabel; NStyle.SetTextStyle(positionLabel, positionLabel.ComposeTextStyle().Clone() as NTextStyle); positionLabel.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial", 10, FontStyle.Bold)); positionLabel.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Right; positionLabel.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Bottom; positionLabel.Margins = new Nevron.Diagram.NMargins(40, 5, 1, 50); positionLabel.Text = info.Position; // create the optional ports of the shape shape.CreateShapeElements(ShapeElementsMask.Ports); // add rotated bounds ports NPort leftPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(ContentAlignment.MiddleLeft)); leftPort.Name = "Left"; shape.Ports.AddChild(leftPort); NPort rightPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(ContentAlignment.MiddleRight)); rightPort.Name = "Right"; shape.Ports.AddChild(rightPort); NPort topPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(ContentAlignment.TopCenter)); topPort.Name = "Top"; shape.Ports.AddChild(topPort); NRotatedBoundsPort bottomPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(bottomPortAlignment, 50)); bottomPort.Name = "Bottom"; shape.Ports.AddChild(bottomPort); return(shape); }
/// <summary> /// Clears all highlighted cells. /// </summary> public void ClearHighlightedCells() { int cellCount = m_CellsToClear.Count; if (cellCount == 0) { return; } string colorString = BoardShape[m_CellsToClear[0].X, m_CellsToClear[0].Y].StyleSheetName; colorString = colorString.Remove(colorString.Length - HighlightedSuffix.Length); CellCount[IndexOf(colorString)] -= cellCount; Score += cellCount * cellCount; for (int i = 0; i < cellCount; i++) { NPoint p = m_CellsToClear[i]; BoardShape[p.X, p.Y].StyleSheetName = String.Empty; } // Apply gravity ApplyGravity(); // Update the cell count info UpdateInfo(); // Clear the cells to clear list m_CellsToClear.Clear(); // Check for end of the game string status = String.Empty; if (AllClear()) { Score *= 2; status = "You've cleared all cells !!!" + Environment.NewLine; } if (status == String.Empty && GameOver()) { status = "Game Over !" + Environment.NewLine; } if (status != String.Empty) { status += "Your score is " + Score.ToString(); NTableShape gameOver = new NTableShape(); ((NDrawingDocument)BoardShape.Document).ActiveLayer.AddChild(gameOver); gameOver.BeginUpdate(); gameOver.CellPadding = new Nevron.Diagram.NMargins(2, 2, 8, 8); gameOver[0, 0].Text = status; NStyle.SetFillStyle(gameOver, new NAdvancedGradientFillStyle(AdvancedGradientScheme.Mahogany2, 5)); NTextStyle textStyle = (NTextStyle)InfoShape.ComposeTextStyle().Clone(); textStyle.FillStyle = new NColorFillStyle(Color.White); NStyle.SetTextStyle(gameOver, textStyle); gameOver.EndUpdate(); gameOver.Center = BoardShape.Center; } }
private void CreateScene(NDrawingDocument document) { document.BackgroundStyle.FrameStyle.Visible = false; // change default document styles document.Style.TextStyle.TextFormat = TextFormat.XML; document.Style.StartArrowheadStyle.Shape = ArrowheadShape.None; document.Style.EndArrowheadStyle.Shape = ArrowheadShape.None; document.Style.FillStyle = new NGradientFillStyle(GradientStyle.DiagonalUp, GradientVariant.Variant1, new NArgbColor(155, 184, 209), new NArgbColor(83, 138, 179)); // the fill style for the cells NStyleSheet transparent = new NStyleSheet("transparent"); NStyle.SetFillStyle(transparent, new NColorFillStyle(KnownArgbColorValue.Transparent)); document.StyleSheets.AddChild(transparent); NNodeList shapes = new NNodeList(); NShape shape1, shape2, winner = null; int i, depth = 0; int count = MATCHES.Length; for (i = 0; i < count; i++) { winner = CreateShape(MATCHES[i]); shapes.Add(winner); if (i >= 8) { if (i < 12) { // The quarter finals depth = 0; shape1 = (NShape)shapes[(i - 8) * 2]; shape2 = (NShape)shapes[(i - 8) * 2 + 1]; } else if (i < 14) { // The semi finals depth = 2; shape1 = (NShape)shapes[8 + (i - 12) * 2]; shape2 = (NShape)shapes[8 + (i - 12) * 2 + 1]; } else { // The final depth = 4; shape1 = (NShape)shapes[12]; shape2 = (NShape)shapes[13]; } SetAnimationsStyle(shape1, depth); SetAnimationsStyle(shape2, depth); ConnectShapes(shape1, shape2, winner, depth + 1); } } SetAnimationsStyle(winner, depth + 2); NLayeredGraphLayout layout = new NLayeredGraphLayout(); layout.Direction = LayoutDirection.LeftToRight; layout.Layout(shapes, new NDrawingLayoutContext(document)); // resize document to fit all shapes document.SizeToContent(); }
NDrawingDocument CreateDocument(int bookId) { NDrawingDocument document = new NDrawingDocument(); // setup the document document.AutoBoundsPadding = new Nevron.Diagram.NMargins(0f, 7f, 7f, 7f); document.Style.FillStyle = new NColorFillStyle(Color.White); document.Style.TextStyle.FillStyle = new NColorFillStyle(Color.DarkGray); document.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left; document.Style.StrokeStyle = new NStrokeStyle(0, Color.White); NStandardFrameStyle frame = document.BackgroundStyle.FrameStyle as NStandardFrameStyle; frame.InnerBorderColor = Color.Gray; document.MeasurementUnit = NGraphicsUnit.Pixel; // set up the shape factories NBasicShapesFactory bookItemsFactory = new NBasicShapesFactory(document); bookItemsFactory.DefaultSize = new NSizeF(320, 200); NCustomToolsData.NBookEntry[] books = NCustomToolsData.CreateBooks(); NCustomToolsData.NBookEntry book = null; int length = books.Length; for (int i = 0; i < length; i++) { if (books[i].Id == bookId) { book = books[i]; break; } } if (bookId == -1 || book == null) { document.Style.StrokeStyle = new NStrokeStyle(1, Color.Red); document.ActiveLayer.AddChild(bookItemsFactory.CreateShape(BasicShapes.Pentagram)); document.SizeToContent(); return(document); } // create a table layout, which will align te thumbnail and the text lines // in two columns NTableLayout mainLayout = new NTableLayout(); mainLayout.Direction = LayoutDirection.LeftToRight; mainLayout.ConstrainMode = CellConstrainMode.Ordinal; mainLayout.MaxOrdinal = 2; mainLayout.VerticalContentPlacement = ContentPlacement.Near; // create a stack layout, which will align the text lines in rows NStackLayout textLayout = new NStackLayout(); textLayout.Direction = LayoutDirection.TopToBottom; textLayout.HorizontalContentPlacement = ContentPlacement.Near; textLayout.VerticalSpacing = 13; // create a stack layout, which will align the stars in 5 columns NStackLayout starsLayout = new NStackLayout(); starsLayout.Direction = LayoutDirection.LeftToRight; starsLayout.VerticalContentPlacement = ContentPlacement.Center; starsLayout.HorizontalSpacing = 1; NLayoutContext layoutContext = new NLayoutContext(); layoutContext.GraphAdapter = new NShapeGraphAdapter(); layoutContext.BodyAdapter = new NShapeBodyAdapter(document); layoutContext.BodyContainerAdapter = new NDrawingBodyContainerAdapter(document); // create the shapes for the book image and text lines NShape bookImageShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle); bookImageShape.Width = 240f; bookImageShape.Height = 240f; NImageFillStyle fs1 = new NImageFillStyle(HttpContext.Current.Server.MapPath(@"~\Images\CustomTools\" + book.ImageFile)); fs1.TextureMappingStyle.MapLayout = MapLayout.Centered; NStyle.SetFillStyle(bookImageShape, fs1); NShape bookTitleShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle); bookTitleShape.Text = book.Title; bookTitleShape.Width = 160f; bookTitleShape.Height = 32f; NShape bookAuthorShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle); bookAuthorShape.Text = "by " + book.Author; bookAuthorShape.Width = 160f; bookAuthorShape.Height = 32f; NShape bookPriceShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle); bookPriceShape.Text = "Price: $" + book.Price.ToString(); bookPriceShape.Width = 160f; bookPriceShape.Height = 32f; // create the star shapes NNodeList starShapes = new NNodeList(); for (int i = 0; i < 5; i++) { NShape star = bookItemsFactory.CreateShape(BasicShapes.Pentagram); star.Width = 10f; star.Height = 10f; if (i < book.Rating) { star.Style.FillStyle = new NColorFillStyle(Color.Orange); } else { star.Style.FillStyle = new NColorFillStyle(Color.LightGray); } starShapes.Add(star); } // prepare to layout NBatchGroup bgroup = new NBatchGroup(document); // create the stars group NGroup starsGroup = new NGroup(); // group the star shapes bgroup.Build(starShapes); bgroup.Group(null, false, out starsGroup); // collect the text shapes NNodeList textShapes = new NNodeList(); textShapes.Add(bookTitleShape); textShapes.Add(bookAuthorShape); textShapes.Add(bookPriceShape); textShapes.Add(starsGroup); // create the text group NGroup textGroup = new NGroup(); // group the text shapes bgroup.Build(textShapes); bgroup.Group(null, false, out textGroup); // collect the main layout shapes NNodeList mainElements = new NNodeList(); mainElements.Add(bookImageShape); mainElements.Add(textGroup); // create the main group NGroup mainGroup = new NGroup(); // group the main elements bgroup.Build(mainElements); bgroup.Group(null, false, out mainGroup); document.ActiveLayer.AddChild(mainGroup); // size all text shapes to text bookTitleShape.SizeToText(new NMarginsF(6f, 0f, 6f, 0f)); bookAuthorShape.SizeToText(new NMarginsF(6f, 0f, 6f, 0f)); bookPriceShape.SizeToText(new NMarginsF(6f, 0f, 6f, 0f)); // layout the star shapes starsLayout.Layout(starShapes, layoutContext); starsGroup.UpdateModelBounds(); // perform layout on the text textLayout.Layout(textShapes, layoutContext); textGroup.UpdateModelBounds(); // layout all elements mainLayout.Layout(mainElements, layoutContext); mainGroup.UpdateModelBounds(); // correct the text left padding bookTitleShape.Location = new NPointF(bookTitleShape.Location.X - 6f, bookTitleShape.Location.Y); bookAuthorShape.Location = new NPointF(bookAuthorShape.Location.X - 6f, bookAuthorShape.Location.Y); bookPriceShape.Location = new NPointF(bookPriceShape.Location.X - 6f, bookPriceShape.Location.Y); document.SizeToContent(); return(document); }
protected NCompositeShape CreateComputer() { NCompositeShape computer = new NCompositeShape(); // create the frame NEllipsePath frame = new NEllipsePath(-28, -28, 140, 140); NStyle.SetFillStyle(frame, new NColorFillStyle(Color.WhiteSmoke)); computer.Primitives.AddChild(frame); // create display 1 computer.Primitives.AddChild(new NRectanglePath(0, 0, 57, 47)); // create display 2 computer.Primitives.AddChild(new NRectanglePath(6, 4, 47, 39)); // create the keyboard computer.Primitives.AddChild(new NRectanglePath(-21, 53, 60, 14)); // create the tower case computer.Primitives.AddChild(new NRectanglePath(65, 0, 32, 66)); // create floppy 1 computer.Primitives.AddChild(new NRectanglePath(70, 5, 20, 3.75f)); // create floppy 2 computer.Primitives.AddChild(new NRectanglePath(70, 15, 20, 3.75f)); // create floppy 3 computer.Primitives.AddChild(new NRectanglePath(70, 25, 20, 3.75f)); // create the mouse tail computer.Primitives.AddChild(new NBezierCurvePath(new NPointF(38, 82), new NPointF(61, 74), new NPointF(27, 57), new NPointF(63, 54))); // create the mouse NEllipsePath mouse = new NEllipsePath(26, 79, 11, 19); mouse.Rotate(CoordinateSystem.Scene, 42, new NPointF(36.5f, 88.5f)); computer.Primitives.AddChild(mouse); // update the model bounds to fit the primitives computer.UpdateModelBounds(); // the default fill style is dold computer.Style.FillStyle = new NColorFillStyle(Color.Gold); // create the computer ports computer.CreateShapeElements(ShapeElementsMask.Ports); // create a dynamic port anchored to the center of the frame NDynamicPort port = new NDynamicPort(frame.UniqueId, ContentAlignment.MiddleCenter, DynamicPortGlueMode.GlueToContour); port.Name = "port"; // make the new port the one and default port of the computer computer.Ports.RemoveAllChildren(); computer.Ports.AddChild(port); computer.Ports.DefaultInwardPortUniqueId = port.UniqueId; return(computer); }
void InitToolbar() { if (nDrawingViewToolbar.RequiresInitialization) { ActiveCommand = toolbarButtons[0].CommandName; // begin view init nDrawingViewToolbar.ViewLayout = CanvasLayout.Normal; nDrawingViewToolbar.DocumentPadding = new Nevron.Diagram.NMargins(0); // init document nDrawingViewToolbar.Document.BeginInit(); nDrawingViewToolbar.Document.AutoBoundsPadding = new Nevron.Diagram.NMargins(4); nDrawingViewToolbar.Document.GraphicsSettings.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; nDrawingViewToolbar.Document.GraphicsSettings.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; nDrawingViewToolbar.Document.GraphicsSettings.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; // set up visual formatting nDrawingViewToolbar.Document.Style.FillStyle = new NColorFillStyle(Color.White); nDrawingViewToolbar.Document.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial Narrow", 8)); nDrawingViewToolbar.Document.BackgroundStyle.FrameStyle.Visible = false; // set up the shape factories NBasicShapesFactory buttonFactory = new NBasicShapesFactory(nDrawingViewToolbar.Document); buttonFactory.DefaultSize = new NSizeF(24, 24); NBrainstormingShapesFactory iconFactory = new NBrainstormingShapesFactory(nDrawingViewToolbar.Document); iconFactory.DefaultSize = new NSizeF(16, 16); // create a batch layout, which will align shapes NBatchLayout batchLayout = new NBatchLayout(nDrawingViewToolbar.Document); // create buttons int count = toolbarButtons.Length; for (int i = 0; i < count; i++) { ToolbarButton btn = toolbarButtons[i]; bool isActive = (this.ActiveCommand == btn.CommandName); NShape buttonShape = buttonFactory.CreateShape(BasicShapes.RoundedRectangle); // create the button shape group NGroup g = new NGroup(); NBatchGroup bgroup = new NBatchGroup(nDrawingViewToolbar.Document); NNodeList shapes = new NNodeList(); if (btn.IsSeparator) { buttonShape.Width /= 2; buttonShape.Style.StrokeStyle = new NStrokeStyle(Color.White); shapes.Add(buttonShape); } else if (!btn.IsColorSelector) { shapes.Add(buttonShape); } else { buttonShape.Style.FillStyle = new NColorFillStyle(btn.Color); shapes.Add(buttonShape); } NRectanglePath imagePath = new NRectanglePath(0f, 0f, btn.IconSize.Width, btn.IconSize.Height); NImageFillStyle fs1 = new NImageFillStyle(this.MapPathSecure(@"..\..\..\Images\FlowChartBuilder\" + btn.IconFile)); NStyle.SetFillStyle(imagePath, fs1); NStyle.SetStrokeStyle(imagePath, new NStrokeStyle(0, Color.White)); NCompositeShape imageShape = new NCompositeShape(); imageShape.Primitives.AddChild(imagePath); imageShape.UpdateModelBounds(); shapes.Add(imageShape); NShape coverShape = buttonFactory.CreateShape(BasicShapes.RoundedRectangle); coverShape.Width = buttonShape.Width; coverShape.Name = "coverShape"; shapes.Add(coverShape); if (!isActive && !btn.IsClientSide && !btn.IsSeparator) { if (btn.IsColorSelector) { coverShape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(180, Color.White)); } else { coverShape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(160, Color.White)); } coverShape.Style.StrokeStyle = new NStrokeStyle(Color.FromArgb(160, Color.White)); } else { coverShape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(0, Color.White)); coverShape.Style.StrokeStyle = new NStrokeStyle(Color.FromArgb(0, Color.White)); if (!btn.IsSeparator) { coverShape.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(70, Color.Black), new NPointL(1, 0)); } } // perform layout batchLayout.Build(shapes); batchLayout.AlignVertically(buttonShape, VertAlign.Center, false); batchLayout.AlignHorizontally(buttonShape, HorzAlign.Center, false); // group shapes bgroup.Build(shapes); bgroup.Group(null, false, out g); // enable interactivity if (!btn.IsSeparator) { g.Style.InteractivityStyle = new NInteractivityStyle(true, btn.CommandName, btn.Title, CursorType.Hand); } // set the command of the button g.Tag = btn.CommandName; nDrawingViewToolbar.Document.ActiveLayer.AddChild(g); } // layout the shapes in the active layer using a table layout NTableLayout layout = new NTableLayout(); // setup the table layout layout.Direction = LayoutDirection.LeftToRight; layout.ConstrainMode = CellConstrainMode.Ordinal; layout.MaxOrdinal = toolbarButtons.Length; layout.HorizontalSpacing = 7; // create a layout context NLayoutContext layoutContext = new NLayoutContext(); layoutContext.GraphAdapter = new NShapeGraphAdapter(); layoutContext.BodyAdapter = new NShapeBodyAdapter(nDrawingViewToolbar.Document); layoutContext.BodyContainerAdapter = new NDrawingBodyContainerAdapter(nDrawingViewToolbar.Document); // layout the shapes layout.Layout(nDrawingViewToolbar.Document.ActiveLayer.Children(null), layoutContext); nDrawingViewToolbar.Document.EndInit(); } }
private void InitDocument() { Bitmap bitmap = NResourceHelper.BitmapFromResource(GetType(), "Airplane.png", "Nevron.Examples.Diagram.WinForm.Resources"); document.Width = bitmap.Width; document.Height = bitmap.Height + 62; document.BackgroundStyle.FillStyle = new NImageFillStyle(bitmap); // Create the style sheets NStyleSheet free = new NStyleSheet("free"); NStyle.SetInteractivityStyle(free, new NInteractivityStyle(string.Empty, CursorType.Hand)); NStyle.SetFillStyle(free, new NColorFillStyle(SEAT_COLOR)); NStyle.SetStrokeStyle(free, new NStrokeStyle(1, Color.Black)); NStyle.SetTextStyle(free, new NTextStyle(new Font(view.Font, FontStyle.Bold), Color.Blue)); document.StyleSheets.AddChild(free); NStyleSheet reserved = new NStyleSheet("reserved"); NHatchFillStyle hatch = new NHatchFillStyle(HatchStyle.LightUpwardDiagonal, Color.Red, SEAT_COLOR); hatch.TextureMappingStyle.MapMode = MapMode.RelativeToViewer; NStyle.SetFillStyle(reserved, hatch); NStyle.SetStrokeStyle(reserved, new NStrokeStyle(1, Color.Black)); document.StyleSheets.AddChild(reserved); float x, y; float distance = DISTANCE; NShape shape; Point startPoint = LINE1_LEFT; m_Seats = new List <NShape>(); // Draw the seats for (y = LINE1_LEFT.Y; y < 350; y += SEAT_SIZE.Height) { if (y > 260 && y < LINE2_LEFT.Y) { y = LINE2_LEFT.Y; startPoint = LINE2_LEFT; } if (y >= LINE2_LEFT.Y) { distance = 5.25f; } for (x = startPoint.X; x < 970; x += SEAT_SIZE.Width + distance) { if (x > 460 && x < LINE1_RIGHT.X) { x = LINE1_RIGHT.X; distance = DISTANCE; } m_nFreeSeats++; shape = new NRectangleShape(x, y, SEAT_SIZE.Width, SEAT_SIZE.Height); shape.StyleSheetName = "free"; SetProtections(shape); document.ActiveLayer.AddChild(shape); m_Seats.Add(shape); } } // Free seats shape = new NRectangleShape(MARGINS, MARGINS, SEAT_SIZE.Width, SEAT_SIZE.Height); shape.StyleSheetName = "free"; SetProtections(shape); document.ActiveLayer.AddChild(shape); CreateTextShape(ref m_FreeSeats); m_FreeSeats.Location = new NPointF(shape.Bounds.Right + MARGINS, shape.Bounds.Y); // Reserved seats shape = new NRectangleShape(MARGINS, 2 * MARGINS + SEAT_SIZE.Height, SEAT_SIZE.Width, SEAT_SIZE.Height); shape.StyleSheetName = "reserved"; SetProtections(shape); document.ActiveLayer.AddChild(shape); CreateTextShape(ref m_ReservedSeats); m_ReservedSeats.Location = new NPointF(shape.Bounds.Right + MARGINS, shape.Bounds.Y); // Total revenue CreateTextShape(ref m_Revenue); m_Revenue.Location = new NPointF(shape.Bounds.Right + MARGINS, shape.Bounds.Bottom + MARGINS); m_Revenue.Style.TextStyle.FontStyle.Style = FontStyle.Bold; m_Revenue.Style.TextStyle.FillStyle = new NColorFillStyle(Color.MediumBlue); UpdateTexts(); }