private void CreateGroup(int row, int col, AbilitiesMask protection) { // create a group NGroup group = new NGroup(); group.Protection = new NAbilities(protection); // add two rectangle shapes in it group.Shapes.AddChild(new NRectangleShape(new NRectangleF(0, 0, 1, 1))); group.Shapes.AddChild(new NRectangleShape(new NRectangleF(2, 2, 1, 1))); // update the group model bounds to fit the shapes group.UpdateModelBounds(); // transform the group to fit in the specified bounds group.Bounds = base.GetGridCell(row, col); // create the labels shape element group.CreateShapeElements(ShapeElementsMask.Labels); // create the default label NRotatedBoundsLabel label = new NRotatedBoundsLabel("", group.UniqueId, new Nevron.Diagram.NMargins(0)); group.Labels.AddChild(label); group.Labels.DefaultLabelUniqueId = label.UniqueId; // assign text to the group group.Text = "Protected from: " + protection.ToString(); // add the group to the active layer document.ActiveLayer.AddChild(group); }
private void CreateRectangle(int row, int col, AbilitiesMask protection) { // create a rectangle NRectangleShape rect = new NRectangleShape(base.GetGridCell(row, col)); rect.Protection = new NAbilities(protection); rect.Text = "Protected from: " + protection.ToString(); document.ActiveLayer.AddChild(rect); }
private void CreateLine(int row, int col, AbilitiesMask protection) { // create a line NRectangleF rect = base.GetGridCell(row, col); NLineShape line = new NLineShape(rect.X, rect.Y, rect.Right, rect.Bottom); line.Protection = new NAbilities(protection); line.Text = "Protected from: " + protection.ToString(); document.ActiveLayer.AddChild(line); }
private void InitDocument() { document.Style.TextStyle = new NTextStyle(new Font("Arial Narrow", 8.75f)); document.Style.FillStyle = new NColorFillStyle(Color.MintCream); int row = 0; int col = 0; Array values = Enum.GetValues(typeof(AbilitiesMask)); for (int i = 0; i < values.Length; i++) { AbilitiesMask cur = (AbilitiesMask)values.GetValue(i); if (!cur.Equals(AbilitiesMask.All) && !cur.Equals(AbilitiesMask.None)) { if (col >= 4) { col = 0; row++; } if (cur.Equals(AbilitiesMask.Ungroup)) { CreateGroup(row, col, cur); } else if (cur.Equals(AbilitiesMask.Group) || cur.Equals(AbilitiesMask.Compose)) { CreateTwoRectangles(row, col, cur); } else if (cur.Equals(AbilitiesMask.Decompose)) { CreateCompositeShape(row, col, cur); } else if (cur.Equals(AbilitiesMask.ChangeStartPoint) || cur.Equals(AbilitiesMask.ChangeEndPoint)) { CreateLine(row, col, cur); } else { CreateRectangle(row, col, cur); } col++; } } document.SizeToContent(); }
private void CreateCompositeShape(int row, int col, AbilitiesMask protection) { // create a composite shape NCompositeShape shape = new NCompositeShape(); shape.Protection = new NAbilities(protection); shape.Text = "Protected from: " + protection.ToString(); shape.Primitives.AddChild(new NRectanglePath(new NRectangleF(0, 0, 1, 1))); shape.Primitives.AddChild(new NRectanglePath(new NRectangleF(2, 2, 1, 1))); shape.UpdateModelBounds(); shape.Bounds = base.GetGridCell(row, col); document.ActiveLayer.AddChild(shape); }
private void InitFormControls() { PauseEventsHandling(); protectionListBox.Items.Clear(); foreach (object obj in Enum.GetValues(typeof(AbilitiesMask))) { AbilitiesMask cur = (AbilitiesMask)obj; if (!cur.Equals(AbilitiesMask.All) && !cur.Equals(AbilitiesMask.None)) { protectionListBox.Items.Add(cur); } } ResumeEventsHandling(); }
private void CreateTwoRectangles(int row, int col, AbilitiesMask protection) { // create the first rectangle shape NRectangleF rect = base.GetGridCell(row, col); rect = new NRectangleF(rect.X, rect.Y, rect.Width / 2, rect.Height / 2); NRectangleShape rect1 = new NRectangleShape(rect); rect1.Protection = new NAbilities(protection); rect1.Text = "Protected from: " + protection.ToString(); document.ActiveLayer.AddChild(rect1); // create the second rectangle shape rect = base.GetGridCell(row, col); rect = new NRectangleF(rect.X + rect.Width / 2, rect.Y + rect.Height / 2, rect.Width / 2, rect.Height / 2); NRectangleShape rect2 = new NRectangleShape(rect); rect2.Protection = new NAbilities(protection); rect2.Text = "Protected from: " + protection.ToString(); document.ActiveLayer.AddChild(rect2); }