private void groupButton_Click(object sender, System.EventArgs e) { // get the selected nodes NNodeList selectedNodes = view.Selection.Nodes; // determine whether they can be grouped NBatchGroup batchGroup = new NBatchGroup(document, selectedNodes); if (batchGroup.CanGroup(document.ActiveLayer, false) == false) { return; } // group them NGroup group; NTransactionResult res = batchGroup.Group(document.ActiveLayer, false, out group); // single select the new group if the group was successful if (res.Succeeded) { view.Selection.SingleSelect(group); } // ask the view to display any information about the transaction status (if it was not completed) view.ProcessTransactionResult(res); }
private void InitDocument() { // configure the document NDrawingView1.Document.Bounds = new NRectangleF(0, 0, imagePixelWidth, imagePixelHeight); NDrawingView1.Document.ShadowsZOrder = ShadowsZOrder.BehindElement; NDrawingView1.Document.GraphicsSettings.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; NDrawingView1.Document.GraphicsSettings.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; NDrawingView1.Document.GraphicsSettings.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None; NDrawingView1.Document.MeasurementUnit = NGraphicsUnit.Pixel; NDrawingView1.Document.DrawingScaleMode = DrawingScaleMode.NoScale; NDrawingView1.Document.BackgroundStyle.FrameStyle.Visible = false; // shapes NRectangleShape backgroundFrame = factory.CreateShape((int)BasicShapes.Rectangle) as NRectangleShape; backgroundFrame.Bounds = new NRectangleF(boardMarginLeft, boardMarginTop, boardPixelWidth, boardPixelHeight); backgroundFrame.Style.StrokeStyle = new NStrokeStyle(new NLength(1f, NGraphicsUnit.Pixel), Color.Black); backgroundFrame.Style.FillStyle = new NColorFillStyle(Color.White); backgroundFrame.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(65, Color.Black), new NPointL(shadowOffset, shadowOffset), 1, new NLength(shadowOffset * 2)); backgroundFrame.Name = "background"; NDrawingView1.Document.ActiveLayer.AddChild(backgroundFrame); NNodeList cells = new NNodeList(); for (int x = 0; x < boardCellCountWidth; x++) { for (int y = 0; y < boardCellCountHeight; y++) { cells.Add(CreateEmptyCell(x, y)); } } NGroup cellsGroup; NBatchGroup batchGroup = new NBatchGroup(NDrawingView1.Document); batchGroup.Build(cells); NTransactionResult result = batchGroup.Group(NDrawingView1.Document.ActiveLayer, true, out cellsGroup); cellsGroup.Name = "cellsGroup"; }
private void ungroupToParentGroupButton_Click(object sender, System.EventArgs e) { // get the group and its parent group NGroup group = (view.Selection.AnchorNode as NGroup); if (group == null) { return; } NGroup parentGroup = group.Group; if (parentGroup == null) { return; } // create a new batch ungroup and check whether it can be executed NBatchUngroup batchUngroup = new NBatchUngroup(document, view.Selection.Nodes); if (batchUngroup.CanUngroup(parentGroup, false) == false) { return; } // ungroup the selected groups to the active layer NNodeList shapes; NTransactionResult res = batchUngroup.Ungroup(parentGroup, false, out shapes); // single select the parent group if the ungroup was successful if (res.Succeeded) { view.Selection.SingleSelect(parentGroup); } // ask the view to display any information about the transaction status (if it was not completed) view.ProcessTransactionResult(res); }
private void ungroupToLayerButton_Click(object sender, System.EventArgs e) { // create a new batch ungroup and check whether it can be executed NBatchUngroup batchUngroup = new NBatchUngroup(document, view.Selection.Nodes); if (batchUngroup.CanUngroup(document.ActiveLayer, false) == false) { return; } // ungroup the selected groups to the active layer NNodeList shapes; NTransactionResult res = batchUngroup.Ungroup(document.ActiveLayer, false, out shapes); // single select the ungrouped shapes if the ungroup was successful if (res.Succeeded) { view.Selection.SingleSelect(shapes); } // ask the view to display any information about the transaction status (if it was not completed) view.ProcessTransactionResult(res); }
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"); }