private void CreateShapesLayer() { // create the shapes layer and modify its styles shapesLayer = new NLayer(); shapesLayer.Name = "Shapes Layer"; shapesLayer.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(0x00, 0x00, 0xaa)); shapesLayer.Style.FillStyle = new NColorFillStyle(Color.FromArgb(0xaa, 0xaa, 0xff)); shapesLayer.Style.ShadowStyle = new NShadowStyle( ShadowType.Solid, Color.FromArgb(80, 0, 0, 0), new NPointL(3, 3), 1, new NLength(1)); // add it to the document and make it the active one document.Layers.AddChild(shapesLayer); document.ActiveLayerUniqueId = shapesLayer.UniqueId; // create two shapes in it NRectangleShape rect = new NRectangleShape(new NRectangleF(60, 60, 70, 70)); shapesLayer.AddChild(rect); NEllipseShape ellipse = new NEllipseShape(new NRectangleF(120, 120, 70, 70)); shapesLayer.AddChild(ellipse); }
private void CreateGraphLayer() { // create the graph layer and modify its styles graphLayer = new NLayer(); graphLayer.Name = "Graph Layer"; graphLayer.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(0xaa, 0x00, 0x00)); graphLayer.Style.FillStyle = new NColorFillStyle(Color.FromArgb(0xff, 0x99, 0x77)); graphLayer.Style.ShadowStyle = new NShadowStyle( ShadowType.Solid, Color.FromArgb(80, 0, 0, 0), new NPointL(3, 3), 1, new NLength(1)); // add it to the document and make it the active one document.Layers.AddChild(graphLayer); document.ActiveLayerUniqueId = graphLayer.UniqueId; // create an elliptical grid template with pentagrams in it NEllipticalGridTemplate ellipticalGrid = new NEllipticalGridTemplate(); ellipticalGrid.VerticesShape = BasicShapes.Pentagram; ellipticalGrid.Origin = new NPointF(60, 60); // create it ellipticalGrid.Create(document); }
private void NavigateToButton_Click(object sender, EventArgs e) { if (cbCity.SelectedIndex == -1) { return; } // Find the map point label corresponding to the selected city NLayer citiesLayer = (NLayer)document.Layers.GetChildByName("cities"); NMapLabelsShape mapLabelsShape = (NMapLabelsShape)citiesLayer.GetChildAt(0); NMapPointLabel pointLabel = (NMapPointLabel)mapLabelsShape.MapLabels.GetChildByName(cbCity.Text); if (pointLabel == null) { return; } view.Zoom(2.0f, pointLabel.PinPoint, true); if (m_ZoomedCity != null) { m_ZoomedCity.StyleSheetName = String.Empty; } pointLabel.StyleSheetName = "Zoomed City"; m_ZoomedCity = pointLabel; }
public void ReleaseNet() { if (inputlayer != null) { inputlayer = null; inputlayer = new NLayer(); } if (outputLayer != null) { outputLayer = null; outputLayer = new NLayer(); } for (int i = 0; i < hiddenLayers.Count; i++) { if (hiddenLayers[i] != null) { hiddenLayers[i] = null; } } hiddenLayers.Clear(); hiddenLayers = new List <NLayer> (); }
void INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument) { NThinDiagramControl diagramControl = (NThinDiagramControl)control; NDrawingDocument document = diagramControl.Document; string[] args = argument.Split(','); string cityName = args[0]; float x = Single.Parse(args[1], CultureInfo.InvariantCulture); float y = Single.Parse(args[2], CultureInfo.InvariantCulture); if (document.Tag is NPointElement) { ((NPointElement)document.Tag).StyleSheetName = String.Empty; document.Tag = null; } NLayer cityLayer = diagramControl.Document.Layers.GetChildByName("cities") as NLayer; if (cityLayer != null) { // Apply the new style to the newly zoomed city NMapLabelsShape labelsShape = (NMapLabelsShape)cityLayer.GetChildAt(0); NMapPointLabel city = (NMapPointLabel)labelsShape.MapLabels.GetChildByName(cityName); city.StyleSheetName = "ZoomedCity"; // Remember the currently highlighted city in the document's tag document.Tag = city; } diagramControl.View.Layout = CanvasLayout.Normal; diagramControl.Zoom(2, new NPointF(x, y)); }
private void CreateTreeLayer() { // create the tree layer and modify its styles treeLayer = new NLayer(); treeLayer.Name = "Tree Layer"; treeLayer.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(30, 30, 0)); treeLayer.Style.FillStyle = new NColorFillStyle(Color.FromArgb(0xaa, 0xaa, 0)); treeLayer.Style.ShadowStyle = new NShadowStyle( ShadowType.Solid, Color.FromArgb(50, 0, 0, 0), new NPointL(3, 3), 1, new NLength(1)); // add it to the document and make it the active one document.Layers.AddChild(treeLayer); document.ActiveLayerUniqueId = treeLayer.UniqueId; // create a tree template with pentagons in it NGenericTreeTemplate treeTemplate = new NGenericTreeTemplate(); treeTemplate.VerticesShape = BasicShapes.Pentagon; treeTemplate.Origin = new NPointF(10, 10); // create it treeTemplate.Create(document); }
public void FromGenome(Genome genome, int numofInputs, int neuronsPerHidden, int numOfOutputs) { ReleaseNet(); outputAmount = numOfOutputs; inputAmount = numofInputs; int weightsForHidden = numofInputs * neuronsPerHidden; NLayer hidden = new NLayer(); List <Neuron> neurons = new List <Neuron>(); for (int i = 0; i < neuronsPerHidden; i++) { //init neurons.Add(new Neuron()); List <float> weights = new List <float>(); //init for (int j = 0; j < numofInputs + 1; j++) { weights.Add(0.0f); weights[j] = genome.weights[i * neuronsPerHidden + j]; } neurons[i].weights = new List <float>(); neurons[i].Initilise(weights, numofInputs); } hidden.LoadLayer(neurons); //Debug.Log ("fromgenome, hiddenlayer neruons#: " + neurons.Count); //Debug.Log ("fromgenome, hiddenlayer numInput: " + neurons [0].numInputs); this.hiddenLayers.Add(hidden); //Clear weights and reasign the weights to the output int weightsForOutput = neuronsPerHidden * numOfOutputs; List <Neuron> outneurons = new List <Neuron> (); for (int i = 0; i < numOfOutputs; i++) { outneurons.Add(new Neuron()); List <float> weights = new List <float>(); for (int j = 0; j < neuronsPerHidden + 1; j++) { weights.Add(0.0f); weights[j] = genome.weights[i * neuronsPerHidden + j]; } outneurons[i].weights = new List <float>(); outneurons[i].Initilise(weights, neuronsPerHidden); } this.outputLayer = new NLayer(); this.outputLayer.LoadLayer(outneurons); //Debug.Log ("fromgenome, outputlayer neruons#: " + outneurons.Count); //Debug.Log ("fromgenome, outputlayer numInput: " + outneurons [0].numInputs); }
public void CreateNet(int numOfHIddenLayers, int numOfInputs, int NeuronsPerHidden, int numOfOutputs) { outputAmount = numOfOutputs; for (int i = 0; i < numOfHIddenLayers; i++) { NLayer layer = new NLayer(); layer.PopulateLayer(NeuronsPerHidden, numOfInputs); hiddenLayers.Add(layer); } outputLayer = new NLayer(); outputLayer.PopulateLayer(numOfOutputs, NeuronsPerHidden); }
public void FromGenome(Genome genome, int numofInputs, int neuronsPerHidden, int numOfOutputs) { ReleaseNet(); outputAmount = numOfOutputs; NLayer hidden = new NLayer(); List <Neuron> neurons = new List <Neuron>(); for (int i = 0; i < neuronsPerHidden; i++) { neurons.Add(new Neuron()); List <float> weights = new List <float>(); for (int j = 0; j < numofInputs + 1; j++) { weights.Add(0.0f); weights[j] = genome.weights[i * neuronsPerHidden + j]; } neurons[i].weights = new List <float>(); neurons[i].Initilise(weights, numofInputs); } hidden.LoadLayer(neurons); this.hiddenLayers.Add(hidden); //Clear weights and reasign the weights to the output List <Neuron> outneurons = new List <Neuron> (); for (int i = 0; i < numOfOutputs; i++) { outneurons.Add(new Neuron()); List <float> weights = new List <float>(); for (int j = 0; j < neuronsPerHidden + 1; j++) { weights.Add(0.0f); weights[j] = genome.weights[i * neuronsPerHidden + j]; } outneurons[i].weights = new List <float>(); outneurons[i].Initilise(weights, neuronsPerHidden); } this.outputLayer = new NLayer(); this.outputLayer.LoadLayer(outneurons); }
public void CreateNet(int numOfInputs, int numOfHIddenLayers, int neuronsPerHidden, int numOfOutputs) { hiddenLayers.Clear(); inputAmount = numOfInputs; outputAmount = numOfOutputs; inputlayer = new NLayer(LayerType.NInput); inputlayer.PopulateLayer(numOfInputs, 1); for (int i = 0; i < numOfHIddenLayers; i++) { NLayer layer = new NLayer(LayerType.NHidden); layer.PopulateLayer(neuronsPerHidden, numOfInputs); hiddenLayers.Add(layer); numOfInputs = neuronsPerHidden; } outputLayer = new NLayer(LayerType.NOutput); outputLayer.PopulateLayer(numOfOutputs, numOfInputs); }
/// <summary> /// Overriden to create the fully connected graph template /// </summary> /// <param name="document">document in which to create the template</param> protected override void CreateTemplate(NDrawingDocument document) { int i; NShape vertex; NShape edge; NPointF pt; ArrayList vertices = new ArrayList(); NLayer layer = document.ActiveLayer; // create the ellipse vertices float curAngle = 0, stepAngle = ((float)Math.PI * 2) / m_nRimNodesCount; PointF center = new PointF(Origin.X + m_fRadiusX + VerticesSize.Width / 2, Origin.Y + m_fRadiusY + VerticesSize.Height / 2); for (i = 0; i < m_nRimNodesCount; i++) { pt = new NPointF(center.X + m_fRadiusX * (float)Math.Cos(curAngle) - VerticesSize.Width / 2, center.Y + m_fRadiusY * (float)Math.Sin(curAngle) - VerticesSize.Height / 2); vertex = CreateVertex(VerticesShape); vertex.Bounds = new NRectangleF(pt, VerticesSize); layer.AddChild(vertex); vertices.Add(vertex); curAngle += stepAngle; } // connect them for (i = 0; i < vertices.Count; i++) { for (int j = i + 1; j < vertices.Count; j++) { edge = CreateEdge(ConnectorType.DynamicPolyline); layer.AddChild(edge); edge.FromShape = (NShape)vertices[i]; edge.ToShape = (NShape)vertices[j]; } } }
private void CreateDiagram(Type type) { document.BeginInit(); document.Layers.RemoveAllChildren(); NClassImporter importer = new NClassImporter(document); if (cbFormatStyle.SelectedIndex != -1) { importer.MemberFormatStyle = (MemberFormatStyle)cbFormatStyle.SelectedItem; } NLayer layer = importer.Import(type); document.ActiveLayerUniqueId = layer.UniqueId; document.SizeToContent(); document.EndInit(); NShape shape = (NShape)layer.GetChildByName(type.Name); view.ViewportOrigin = new NPointF(shape.Center.X - view.ViewportSize.Width / 2, 0); }
private void InitDocument() { // we do not need history for this example document.HistoryService.Pause(); // create a layer which to host the desired size rect shape NLayer layer = new NLayer(); document.Layers.AddChild(layer); // create the desired size rect shape m_DesiredSizeShape = new NRectangleShape(0, 0, 1, 1); m_DesiredSizeShape.Style.FillStyle = new NColorFillStyle(System.Drawing.Color.FromArgb(200, 128, 128, 128)); m_DesiredSizeShape.Style.StrokeStyle = new NStrokeStyle(1, KnownArgbColorValue.Red); m_DesiredSizeShape.Visible = ShowDesiredSizeCheckBox.Checked; layer.AddChild(m_DesiredSizeShape); // create a sample diagram CreateDiagram(); // layout it LayoutButton.PerformClick(); }
public void SetDownlayer(NLayer.iLayer downLayer, int[,] downWeight) { _DownLayer = downLayer; _DownWeights = downWeight; }
public void SetUplayer(NLayer.iLayer upLayer, int[,] upWeight) { _UpLayer = upLayer; _UpWeights = upWeight; }
private void InitDocument() { // modify the connectors style sheet NStyleSheet styleSheet = (document.StyleSheets.GetChildByName(NDR.NameConnectorsStyleSheet, -1) as NStyleSheet); styleSheet.Style.StrokeStyle = new NStrokeStyle(1, Color.Black); styleSheet.Style.StartArrowheadStyle.Shape = ArrowheadShape.None; styleSheet.Style.EndArrowheadStyle.StrokeStyle = new NStrokeStyle(1, Color.Black); // create a stylesheet for the CPA shapes styleSheet = new NStyleSheet("CPA"); styleSheet.Style.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(68, 90, 108), Color.FromArgb(162, 173, 182)); document.StyleSheets.AddChild(styleSheet); // create a stylesheet for the CLIENT shapes styleSheet = new NStyleSheet("CLIENT"); styleSheet.Style.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(247, 150, 56), Color.FromArgb(251, 203, 156)); document.StyleSheets.AddChild(styleSheet); // create a stylesheet for the stripes styleSheet = new NStyleSheet("STRIPE"); styleSheet.Style.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.FromArgb(221, 221, 221)); styleSheet.Style.StrokeStyle = new NStrokeStyle(0, Color.White); document.StyleSheets.AddChild(styleSheet); // create a stylesheet for the ABC texts styleSheet = new NStyleSheet("ABC"); styleSheet.Style.TextStyle = new NTextStyle(new Font("Ariel", 12), Color.FromArgb(150, 150, 150)); document.StyleSheets.AddChild(styleSheet); float abcWidth = 150; // configure the document base.DefaultGridCellSize = new NSizeF(100, 70); base.DefaultGridSpacing = new NSizeF(30, 30); base.DefaultGridOrigin = new NPointF(60, 30); document.Bounds = new NRectangleF(0, 0, 1000, (6 * base.DefaultGridCellSize.Height) + (7 * base.DefaultGridSpacing.Height)); document.ShadowsZOrder = ShadowsZOrder.BehindLayer; // create the stripes NRectanglePath rect = new NRectanglePath(0, 0, document.Width, document.Height / 3); rect.StyleSheetName = "STRIPE"; document.ActiveLayer.AddChild(rect); rect = new NRectanglePath(0, document.Height / 3, document.Width, document.Height / 3); rect.StyleSheetName = "STRIPE"; document.ActiveLayer.AddChild(rect); rect = new NRectanglePath(0, 2 * document.Height / 3, document.Width, document.Height / 3); rect.StyleSheetName = "STRIPE"; document.ActiveLayer.AddChild(rect); // create A,B,C texts NTextPrimitive text = new NTextPrimitive("A", document.Width - abcWidth, 0, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; rect.StyleSheetName = "ABC"; document.ActiveLayer.AddChild(text); text = new NTextPrimitive("B", document.Width - abcWidth, document.Height / 3, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; rect.StyleSheetName = "ABC"; document.ActiveLayer.AddChild(text); text = new NTextPrimitive("C", document.Width - abcWidth, 2 * document.Height / 3, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; rect.StyleSheetName = "ABC"; document.ActiveLayer.AddChild(text); // add stripe texts text = new NTextPrimitive("Sing up client", document.Width - abcWidth, document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); text = new NTextPrimitive("Monthly Accounting Services", document.Width - abcWidth, 2 * document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); text = new NTextPrimitive("Additional Services", document.Width - abcWidth, 3 * document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); // create a layer for the foreground shapes NLayer layer = new NLayer(); document.Layers.AddChild(layer); document.ActiveLayerUniqueId = layer.UniqueId; // all shapes in the foreground layer have a shadow layer.Style.ShadowStyle = new NShadowStyle( ShadowType.GaussianBlur, Color.Gray, new NPointL(5, 5), 1, new NLength(10)); // shapes in row 1 NShape newClient = base.CreateFlowChartingShape(FlowChartingShapes.Decision, base.GetGridCell(0, 0), "New Client", "CPA"); NShape register = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(0, 1), "Register", "CPA"); NShape clientAccountInfo = base.CreateFlowChartingShape(FlowChartingShapes.Data, base.GetGridCell(0, 2), "Client account info", "CPA"); NShape explainDataEntryProcedures = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(0, 3), "Explain data entry procedures", "CPA"); // shapes in row 2 NShape dataEntry = base.CreateFlowChartingShape(FlowChartingShapes.ManualInput, base.GetGridCell(2, 0), "Data Entry", "CLIENT"); NShape emailCompleted = base.CreateFlowChartingShape(FlowChartingShapes.Document, base.GetGridCell(2, 1), "E-mail Completed", "CLIENT"); NShape review = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(2, 2), "Review", "CPA"); NShape needsRevising = base.CreateFlowChartingShape(FlowChartingShapes.Decision, base.GetGridCell(2, 3), "Needs revising", "CPA"); NShape emailRevisions = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(2, 4), "E-mail revisions", "CPA"); NShape evaluateRevisions = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(2, 5), "Evaluate revisions", "CLIENT"); // shapes in row 3 NShape emailApprovedRevisions = base.CreateFlowChartingShape(FlowChartingShapes.Document, base.GetGridCell(3, 2), "E-mail Approved Revisions", "CLIENT"); NShape evaluateRevisions2 = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(3, 4), "Evaluate Revisions", "CLIENT"); NShape answerClientEmail = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(3, 5), "Answer Client E-mail", "CPA"); // shapes in row 4 NShape paywoll = base.CreateFlowChartingShape(FlowChartingShapes.Document, base.GetGridCell(5, 2), "Payroll", "CLIENT"); NShape taxes = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(5, 3), "Taxes", "CLIENT"); NShape controller = base.CreateFlowChartingShape(FlowChartingShapes.Process, base.GetGridCell(5, 4), "Controller", "CPA"); // some shapes need to have extra ports NRotatedBoundsPort port = new NRotatedBoundsPort(evaluateRevisions.UniqueId, new NContentAlignment(-25, 50)); port.Name = "BottomLeft"; evaluateRevisions.Ports.AddChild(port); port = new NRotatedBoundsPort(evaluateRevisions.UniqueId, new NContentAlignment(+25, 50)); port.Name = "BottomRight"; evaluateRevisions.Ports.AddChild(port); port = new NRotatedBoundsPort(answerClientEmail.UniqueId, new NContentAlignment(-25, -50)); port.Name = "TopLeft"; answerClientEmail.Ports.AddChild(port); port = new NRotatedBoundsPort(answerClientEmail.UniqueId, new NContentAlignment(+25, -50)); port.Name = "TopRight"; answerClientEmail.Ports.AddChild(port); // connect shapes in levels base.CreateConnector(newClient, "Center", register, "Center", ConnectorType.Line, "YES"); base.CreateConnector(register, "Center", clientAccountInfo, "Center", ConnectorType.Line, ""); base.CreateConnector(clientAccountInfo, "Center", explainDataEntryProcedures, "Center", ConnectorType.Line, ""); base.CreateConnector(dataEntry, "Center", emailCompleted, "Center", ConnectorType.Line, ""); base.CreateConnector(emailCompleted, "Center", review, "Center", ConnectorType.Line, ""); base.CreateConnector(review, "Center", needsRevising, "Center", ConnectorType.Line, ""); base.CreateConnector(needsRevising, "Center", emailRevisions, "Center", ConnectorType.Line, "YES"); base.CreateConnector(emailRevisions, "Center", evaluateRevisions, "Center", ConnectorType.Line, ""); base.CreateConnector(evaluateRevisions2, "Center", emailApprovedRevisions, "Center", ConnectorType.Line, ""); // connect accross levels NStep3Connector connector = (base.CreateConnector(newClient, "Center", dataEntry, "Center", ConnectorType.SideToSide, "NO") as NStep3Connector); connector.UseMiddleControlPointPercent = false; connector.MiddleControlPointOffset = -55; base.CreateConnector(explainDataEntryProcedures, "Center", dataEntry, "Center", ConnectorType.TopToBottom, ""); base.CreateConnector(emailApprovedRevisions, "Center", review, "Center", ConnectorType.Line, ""); base.CreateConnector(emailRevisions, "Center", evaluateRevisions2, "Center", ConnectorType.Line, ""); base.CreateConnector(evaluateRevisions, "BottomLeft", answerClientEmail, "TopLeft", ConnectorType.Line, ""); base.CreateConnector(answerClientEmail, "TopRight", evaluateRevisions, "BottomRight", ConnectorType.Line, ""); connector = (base.CreateConnector(needsRevising, "Center", paywoll, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; connector = (base.CreateConnector(needsRevising, "Center", taxes, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; connector = (base.CreateConnector(needsRevising, "Center", controller, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; // create the legend as a group NGroup legend = new NGroup(); NRectangleShape legendBackground = new NRectangleShape(0, 0, 1, 3); legendBackground.Style.FillStyle = new NColorFillStyle(Color.White); legend.Shapes.AddChild(legendBackground); NRectangleF bounds = new NRectangleF(0, 1, 1, 1); bounds.Inflate(-0.2f, -0.2f); NRectangleShape cpaItem = new NRectangleShape(bounds); cpaItem.Text = "CPA"; cpaItem.StyleSheetName = "CPA"; legend.Shapes.AddChild(cpaItem); bounds = new NRectangleF(0, 2, 1, 1); bounds.Inflate(-0.2f, -0.2f); NRectangleShape clientItem = new NRectangleShape(bounds); clientItem.Text = "Client"; clientItem.StyleSheetName = "CLIENT"; legend.Shapes.AddChild(clientItem); legend.UpdateModelBounds(); legend.Bounds = base.GetGridCell(4, 0, 1, 1); document.ActiveLayer.AddChild(legend); }
protected static void InitDocument(NDrawingDocument document, string stateId, int boardCellCount) { // clean up existing layers document.Layers.RemoveAllChildren(); // modify the connectors style sheet document.Style.TextStyle = new NTextStyle(); document.Style.TextStyle.FontStyle = new NFontStyle("Arial", 20f, FontStyle.Bold); document.Style.TextStyle.FillStyle = new NColorFillStyle(Color.SteelBlue); document.Style.TextStyle.BorderStyle = new NStrokeStyle(1f, Color.White); // configure the document document.Bounds = new NRectangleF(0, 0, imagePixelWidth, imagePixelHeight); document.ShadowsZOrder = ShadowsZOrder.BehindLayer; document.GraphicsSettings.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; document.GraphicsSettings.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; document.GraphicsSettings.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None; document.MeasurementUnit = NGraphicsUnit.Pixel; document.DrawingScaleMode = DrawingScaleMode.NoScale; document.BackgroundStyle.FrameStyle.Visible = false; NLayer backgroundLayer = new NLayer(); NLayer gridLayer = new NLayer(); document.Layers.AddChild(gridLayer); document.ActiveLayerUniqueId = gridLayer.UniqueId; // frame NBasicShapesFactory factory = new NBasicShapesFactory(document); // grid ArrayList randomizedNumbers = CreateRandomizedNumbersArray(boardCellCount); Hashtable grid = new Hashtable(); NNodeList cells = new NNodeList(); for (int x = 0; x < boardCellCount; x++) { for (int y = 0; y < boardCellCount; y++) { if (x == boardCellCount - 1 && y == boardCellCount - 1) { break; } NRectangleShape cell = CreateCell(document, x, y, (int)randomizedNumbers[y + x * boardCellCount]); cells.Add(cell); grid[new Point((int)cell.Bounds.X, (int)cell.Bounds.Y)] = new Point(x, y); } } NGroup cellsGroup; NBatchGroup batchGroup = new NBatchGroup(document); batchGroup.Build(cells); NTransactionResult result = batchGroup.Group(document.ActiveLayer, true, out cellsGroup); cellsGroup.Name = "cellsGroup"; // save the default empty cell coordinates Point emptyCellCoords = new Point(boardCellCount - 1, boardCellCount - 1); Point emptyCellPixelCoords = new Point(boardMarginLeft + cellPixelWidth * (boardCellCount - 1) + boardPadding, boardMarginTop + cellPixelWidth * (boardCellCount - 1) + boardPadding); HttpContext.Current.Session[stateId.ToString() + "-emptyCellCoords"] = emptyCellCoords; HttpContext.Current.Session[stateId.ToString() + "-emptyCellPixelCoords"] = emptyCellPixelCoords; // save the default cells grid grid[new Point(emptyCellPixelCoords.X, emptyCellPixelCoords.Y)] = new Point(emptyCellCoords.X, emptyCellCoords.Y); HttpContext.Current.Session[stateId.ToString() + "-grid"] = grid; // clean up any other related session state HttpContext.Current.Session.Remove(stateId.ToString() + "-cellsList"); }
public void SetUplayer(NLayer.iLayer upLayer, int[,] upWeight) { }
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--; } }
private void CreateScene(NDrawingDocument document) { document.BackgroundStyle.FrameStyle.Visible = false; NFillStyle cpaFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(102, 204, 255), Color.FromArgb(0, 128, 128)); NFillStyle clientFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(255, 102, 0), Color.FromArgb(255, 204, 0)); NFillStyle stripeFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.FromArgb(221, 221, 221)); NTextStyle abcTextStyle = new NTextStyle(new Font("Arial", 12), Color.FromArgb(150, 150, 150)); float abcWidth = 150; NDrawingDocumentHelper helper = new NDrawingDocumentHelper(document); // configure the document helper.DefaultGridCellSize = new NSizeF(100, 70); helper.DefaultGridSpacing = new NSizeF(30, 30); helper.DefaultGridOrigin = new NPointF(60, 30); document.Bounds = new NRectangleF(0, 0, 1000, (6 * helper.DefaultGridCellSize.Height) + (7 * helper.DefaultGridSpacing.Height)); document.ShadowsZOrder = ShadowsZOrder.BehindLayer; // create the stripes NRectangleShape rect = new NRectangleShape(0, 0, document.Width, document.Height / 3); rect.Style.FillStyle = (NFillStyle)stripeFillStyle.Clone(); rect.Style.StrokeStyle = new NStrokeStyle(0, Color.White); document.ActiveLayer.AddChild(rect); rect = new NRectangleShape(0, document.Height / 3, document.Width, document.Height / 3); rect.Style.FillStyle = (NFillStyle)stripeFillStyle.Clone(); rect.Style.StrokeStyle = new NStrokeStyle(0, Color.White); document.ActiveLayer.AddChild(rect); rect = new NRectangleShape(0, 2 * document.Height / 3, document.Width, document.Height / 3); rect.Style.FillStyle = (NFillStyle)stripeFillStyle.Clone(); rect.Style.StrokeStyle = new NStrokeStyle(0, Color.White); document.ActiveLayer.AddChild(rect); // create A,B,C texts NTextShape text = new NTextShape("A", document.Width - abcWidth, 0, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; text.Style.TextStyle = (abcTextStyle.Clone() as NTextStyle); document.ActiveLayer.AddChild(text); text = new NTextShape("B", document.Width - abcWidth, document.Height / 3, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; text.Style.TextStyle = (abcTextStyle.Clone() as NTextStyle); document.ActiveLayer.AddChild(text); text = new NTextShape("C", document.Width - abcWidth, 2 * document.Height / 3, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; text.Style.TextStyle = (abcTextStyle.Clone() as NTextStyle); document.ActiveLayer.AddChild(text); // add stripe texts text = new NTextShape("Sing up client", document.Width - abcWidth, document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); text = new NTextShape("Monthly Accounting Services", document.Width - abcWidth, 2 * document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); text = new NTextShape("Additional Services", document.Width - abcWidth, 3 * document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); // create a layer for the forground shapes NLayer layer = new NLayer(); document.Layers.AddChild(layer); document.ActiveLayerUniqueId = layer.UniqueId; layer.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.Gray, new Nevron.GraphicsCore.NPointL(5, 5), 1, new NLength(10)); // shapes in row 1 NShape newClient = helper.CreateBasicShape(BasicShapes.Diamond, helper.GetGridCell(0, 0), "New Client", cpaFillStyle); NShape register = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(0, 1), "Register", cpaFillStyle); NShape clientAccountInfo = helper.CreateFlowChartingShape(FlowChartingShapes.Data, helper.GetGridCell(0, 2), "Client account info", cpaFillStyle); NShape explainDataEntryProcedures = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(0, 3), "Explain data entry procedures", cpaFillStyle); // shapes in row 2 NShape dataEntry = helper.CreateFlowChartingShape(FlowChartingShapes.ManualInput, helper.GetGridCell(2, 0), "Data Entry", clientFillStyle); NShape emailCompleted = helper.CreateFlowChartingShape(FlowChartingShapes.Document, helper.GetGridCell(2, 1), "E-mail Completed", clientFillStyle); NShape review = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(2, 2), "Review", cpaFillStyle); NShape needsRevising = helper.CreateBasicShape(BasicShapes.Diamond, helper.GetGridCell(2, 3), "Needs revising", cpaFillStyle); NShape emailRevisions = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(2, 4), "E-mail revisions", cpaFillStyle); NShape evaluateRevisions = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(2, 5), "Evaluate revisions", clientFillStyle); // shapes in row 3 NShape emailApprovedRevisions = helper.CreateFlowChartingShape(FlowChartingShapes.Document, helper.GetGridCell(3, 2), "E-mail Approved Revisions", clientFillStyle); NShape evaluateRevisions2 = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(3, 4), "Evaluate Revisions", clientFillStyle); NShape answerClientEmail = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(3, 5), "Answer Client E-mail", cpaFillStyle); // shapes in row 4 NShape paywoll = helper.CreateFlowChartingShape(FlowChartingShapes.Document, helper.GetGridCell(5, 2), "Payroll", clientFillStyle); NShape taxes = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(5, 3), "Taxes", clientFillStyle); NShape controller = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(5, 4), "Controller", cpaFillStyle); // create the optional ports of the shape evaluateRevisions.CreateShapeElements(ShapeElementsMask.Ports); // some shapes need to have extra ports NRotatedBoundsPort port = new NRotatedBoundsPort(evaluateRevisions.UniqueId, new NContentAlignment(-25, 50)); port.Name = "BottomLeft"; evaluateRevisions.Ports.AddChild(port); port = new NRotatedBoundsPort(evaluateRevisions.UniqueId, new NContentAlignment(+25, 50)); port.Name = "BottomRight"; evaluateRevisions.Ports.AddChild(port); // create the optional ports of the shape answerClientEmail.CreateShapeElements(ShapeElementsMask.Ports); port = new NRotatedBoundsPort(answerClientEmail.UniqueId, new NContentAlignment(-25, -50)); port.Name = "TopLeft"; answerClientEmail.Ports.AddChild(port); port = new NRotatedBoundsPort(answerClientEmail.UniqueId, new NContentAlignment(+25, -50)); port.Name = "TopRight"; answerClientEmail.Ports.AddChild(port); // connect shapes in levels helper.CreateConnector(newClient, "Center", register, "Center", ConnectorType.Line, "YES"); helper.CreateConnector(register, "Center", clientAccountInfo, "Center", ConnectorType.Line, ""); helper.CreateConnector(clientAccountInfo, "Center", explainDataEntryProcedures, "Center", ConnectorType.Line, ""); helper.CreateConnector(dataEntry, "Center", emailCompleted, "Center", ConnectorType.Line, ""); helper.CreateConnector(emailCompleted, "Center", review, "Center", ConnectorType.Line, ""); helper.CreateConnector(review, "Center", needsRevising, "Center", ConnectorType.Line, ""); helper.CreateConnector(needsRevising, "Center", emailRevisions, "Center", ConnectorType.Line, "YES"); helper.CreateConnector(emailRevisions, "Center", evaluateRevisions, "Center", ConnectorType.Line, ""); helper.CreateConnector(evaluateRevisions2, "Center", emailApprovedRevisions, "Center", ConnectorType.Line, ""); // connect accross levels NStep3Connector connector = (helper.CreateConnector(newClient, "Center", dataEntry, "Center", ConnectorType.SideToSide, "NO") as NStep3Connector); connector.UseMiddleControlPointPercent = false; connector.MiddleControlPointOffset = -50; helper.CreateConnector(explainDataEntryProcedures, "Center", dataEntry, "Center", ConnectorType.TopToBottom, ""); helper.CreateConnector(emailApprovedRevisions, "Center", review, "Center", ConnectorType.Line, ""); helper.CreateConnector(emailRevisions, "Center", evaluateRevisions2, "Center", ConnectorType.Line, ""); helper.CreateConnector(evaluateRevisions, "BottomLeft", answerClientEmail, "TopLeft", ConnectorType.Line, ""); helper.CreateConnector(answerClientEmail, "TopRight", evaluateRevisions, "BottomRight", ConnectorType.Line, ""); connector = (helper.CreateConnector(needsRevising, "Center", paywoll, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; connector = (helper.CreateConnector(needsRevising, "Center", taxes, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; connector = (helper.CreateConnector(needsRevising, "Center", controller, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; // create the legend NGroup legend = new NGroup(); NRectangleShape ledendBackground = new NRectangleShape(0, 0, 1, 3); ledendBackground.Style.FillStyle = new NColorFillStyle(Color.White); legend.Shapes.AddChild(ledendBackground); NTextShape legendTitle = new NTextShape("Legend", 0, 0, 1, 1); legend.Shapes.AddChild(legendTitle); NRectangleF bounds = new NRectangleF(0, 1, 1, 1); bounds.Inflate(-0.2f, -0.2f); NShape shape = helper.CreateBasicShape(BasicShapes.Rectangle, bounds, "CPA", (NFillStyle)cpaFillStyle.Clone(), false); legend.Shapes.AddChild(shape); bounds = new NRectangleF(0, 2, 1, 1); bounds.Inflate(-0.2f, -0.2f); shape = helper.CreateBasicShape(BasicShapes.Rectangle, bounds, "Client", (NFillStyle)clientFillStyle.Clone(), false); legend.Shapes.AddChild(shape); legend.UpdateModelBounds(); legend.Bounds = helper.GetGridCell(4, 0, 1, 1); document.ActiveLayer.AddChild(legend); }