private void protectionCheckBox_CheckStateChanged(object sender, EventArgs e) { if (EventsHandlingPaused) { return; } // get the selected element NDiagramElement element = (view.Selection.AnchorNode as NDiagramElement); if (element == null) { return; } PauseEventsHandling(); // update the element protection NAbilities protection = element.Protection; protection.Copy = copyCheckBox.Checked; protection.Delete = deleteCheckBox.Checked; protection.Select = selectCheckBox.Checked; element.Protection = protection; document.SmartRefreshAllViews(); ResumeEventsHandling(); }
private void protectionListBox_CheckedChanged(object sender, Nevron.UI.WinForm.Controls.NListBoxItemCheckEventArgs e) { if (EventsHandlingPaused) { return; } NShape shape = (view.Selection.AnchorNode as NShape); if (shape == null) { return; } PauseEventsHandling(); for (int i = 0; i < protectionListBox.Items.Count; i++) { NListBoxItem item = protectionListBox.Items[i]; NAbilities protection = shape.Protection; if (item.Checked) { protection.Mask = protection.Mask | (AbilitiesMask)item.Tag; } else { protection.Mask = protection.Mask & ~(AbilitiesMask)item.Tag; } shape.Protection = protection; } document.SmartRefreshAllViews(); ResumeEventsHandling(); }
private void ApplyProtections(NShape shape, bool trackersEdit, bool move) { NAbilities protection = shape.Protection; protection.TrackersEdit = trackersEdit; protection.MoveX = move; protection.MoveY = move; shape.Protection = protection; }
private void ApplyProtections(NShape shape) { NAbilities protection = shape.Protection; protection.MoveX = true; protection.MoveY = true; protection.InplaceEdit = true; protection.Select = true; shape.Protection = protection; }
private void SetProtections(NShape shape) { NAbilities protection = shape.Protection; protection.ResizeX = true; protection.ResizeY = true; protection.Rotate = true; protection.InplaceEdit = true; protection.TrackersEdit = true; shape.Protection = protection; }
private void OnEdgeImported(NDataSourceImporter dataSourceImporter, NShape shape, INDataRecord dataRecord) { // Set the text of the edge shape.Text = dataRecord.GetColumnValue("Desc").ToString(); // Get the symbol name if any object symbol = dataRecord.GetColumnValue("Symbol"); if (symbol == null || Convert.IsDBNull(symbol)) { return; } // Add a logical line port NLogicalLinePort linePort = new NLogicalLinePort(20); shape.CreateShapeElements(ShapeElementsMask.Ports); shape.Ports.AddChild(linePort); // Attach a custom shape based on the symbol name NShape customShape = null; switch (symbol.ToString()) { case "Stop": customShape = m_BusinessProcessShapesFactory.CreateShape(BusinessProcessShapes.StopAccepted); break; case "Question": customShape = m_BusinessProcessShapesFactory.CreateShape(BusinessProcessShapes.Question); break; } ((NDrawingDocument)shape.Document).ActiveLayer.AddChild(customShape); // Protect the symbol from user interactions NAbilities protection = customShape.Protection; protection.All = true; customShape.Protection = protection; // Add an outward port to the shape NRotatedBoundsPort outwardPort = new NRotatedBoundsPort(new NContentAlignment(ContentAlignment.MiddleCenter)); outwardPort.Type = PortType.Outward; customShape.CreateShapeElements(ShapeElementsMask.Ports); customShape.Ports.AddChild(outwardPort); outwardPort.Connect(linePort); }
private void UpdateFromSelectedNode() { // get the selected element NDiagramElement element = (view.Selection.AnchorNode as NDiagramElement); if (element == null) { return; } // update the protection checks NAbilities protection = element.Protection; copyCheckBox.Checked = protection.Copy; deleteCheckBox.Checked = protection.Delete; selectCheckBox.Checked = protection.Select; }
private void OnShapeCountComboBoxSelectedIndexChanged(object sender, EventArgs e) { // Create the shapes int shapeCount = 0; document.ActiveLayer.RemoveAllChildren(); switch (ShapeCountComboBox.SelectedIndex) { case 0: shapeCount = 200; break; case 1: shapeCount = 500; break; case 2: shapeCount = 1000; break; } m_Shapes = new NShape[shapeCount]; int xMax = (int)document.Width - ShapeWidth; int yMax = (int)document.Height - ShapeHeight; for (int i = 0; i < shapeCount; i++) { // Create a rectangle shape NShape shape = new NRectangleShape(m_Random.Next(xMax), m_Random.Next(yMax), ShapeWidth, ShapeHeight); shape.StyleSheetName = "Style" + m_Random.Next(1, 4).ToString(CultureInfo.InvariantCulture); // Set its protections NAbilities protection = shape.Protection; protection.All = true; shape.Protection = protection; // Generate a random direction angle shape.Tag = m_Random.Next(90) * NMath.Degree2Rad; document.ActiveLayer.AddChild(shape); m_Shapes[i] = shape; } }
private void SetProtections(NGroup group) { // Set the protections of the group NAbilities protection = group.Protection; protection.Ungroup = true; group.Protection = protection; // Get all shapes in the group NNodeList shapes = group.Shapes.Children(null); // Set the protections of the shapes for (int i = 0, count = shapes.Count; i < count; i++) { NShape shape = (NShape)shapes[i]; protection = shape.Protection; protection.Select = true; protection.InplaceEdit = true; shape.Protection = protection; } }
protected override void CreateDefaultFlowDiagram() { base.CreateDefaultFlowDiagram(); // create a rectangle shape NRectangleShape rect = new NRectangleShape(new NRectangleF(10, 10, 100, 60)); rect.Text = "Non-image exportable shape"; rect.Style.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(0xff, 0x55, 0x55), Color.FromArgb(0x66, 0x00, 0x00)); // protect from export NAbilities protection = rect.Protection; protection.Export = true; rect.Protection = protection; // add it to the active layer document.ActiveLayer.AddChild(rect); }
private void protectFromGroupCheckBox_CheckedChanged(object sender, System.EventArgs e) { if (EventsHandlingPaused) { return; } // get the selected shape NShape shape = (view.Selection.AnchorNode as NShape); if (shape == null) { return; } // change the ungroup protection NAbilities protection = shape.Protection; protection.Group = protectFromGroupCheckBox.Checked; shape.Protection = protection; // update form control UpdateControlsState(); }
private UDNGroup CreateInstance(string name, List <Port> ports, string id) { int instanceWidth = 50; int instanceHeight = 50; int InputMaxSize = 10; int InputCnt = 0; int OutputMaxSize = 10; int OutputCnt = 0; int offsetWidth = 9; int offsetHeight = 30; int widthPadding = 10; int heightPadding = 10; int textWidth = 30; int textHeight = 15; double textOffset = 1.5; int curInPtCnt = 0; int curOutPtCnt = 0; UDNGroup group = new UDNGroup(); group.Name = name; group.UDFullName = name; group.UDPorts = ports; // find max input/output port size for (int i = 0; i < ports.Count; i++) { if (ports[i].Type == PortType.IN) { InputCnt += 1; if (InputMaxSize < ports[i].Name.Length) { InputMaxSize = ports[i].Name.Length; } } else { OutputCnt += 1; if (OutputMaxSize < ports[i].Name.Length) { OutputMaxSize = ports[i].Name.Length; } } } instanceWidth = (InputMaxSize * offsetWidth) + (OutputMaxSize * offsetWidth) + widthPadding; instanceHeight = (InputCnt > OutputCnt ? InputCnt : OutputCnt) * offsetHeight + heightPadding; textWidth = instanceWidth; // Add Instance NRectangleShape node = new NRectangleShape(0, 0, (int)instanceWidth, (int)instanceHeight); NAbilities protection = node.Protection; protection.InplaceEdit = true; node.Protection = protection; node.Name = name; group.Shapes.AddChild(node); NTextShape nodeName = new NTextShape(name, 0, -15, textWidth, textHeight); nodeName.Style.TextStyle = new NTextStyle(); nodeName.Style.TextStyle.FontStyle = new NFontStyle(new Font("Arial", 9)); protection = nodeName.Protection; protection.InplaceEdit = true; nodeName.Protection = protection; group.Shapes.AddChild(nodeName); // Add Port for (int i = 0; i < ports.Count; i++) { NShape port = createPort(ports[i].Name, ports[i].Type); protection = port.Protection; protection.InplaceEdit = true; port.Protection = protection; group.Shapes.AddChild(port); if (ports[i].Type == PortType.IN) { curInPtCnt += 1; port.Location = new NPointF(-port.Bounds.Width / 2, (node.Bounds.Height / (InputCnt + 1)) * curInPtCnt); NTextShape portName = new NTextShape(ports[i].Name, port.Bounds.Width / 2, (node.Bounds.Height / (InputCnt + 1)) * curInPtCnt, ports[i].Name.Length * 9, (int)(port.Bounds.Height * textOffset)); portName.Style.TextStyle = new NTextStyle(); portName.Style.TextStyle.FontStyle = new NFontStyle(new Font("Arial", 9)); portName.Style.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Left; protection = portName.Protection; protection.InplaceEdit = true; portName.Protection = protection; group.Shapes.AddChild(portName); } else { curOutPtCnt += 1; port.Location = new NPointF((-port.Bounds.Width / 2) + node.Bounds.Width, (node.Bounds.Height / (OutputCnt + 1)) * curOutPtCnt); NTextShape portName = new NTextShape(ports[i].Name, node.Bounds.Width - (port.Bounds.Width / 2) - (ports[i].Name.Length * 9), (node.Bounds.Height / (OutputCnt + 1)) * curOutPtCnt, ports[i].Name.Length * 9, (int)(port.Bounds.Height * textOffset)); portName.Style.TextStyle = new NTextStyle(); portName.Style.TextStyle.FontStyle = new NFontStyle(new Font("Arial", 9)); portName.Style.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Right; protection = portName.Protection; protection.InplaceEdit = true; portName.Protection = protection; group.Shapes.AddChild(portName); } port.CreateShapeElements(ShapeElementsMask.Ports); NDynamicPort portInner; if (ports[i].Type == PortType.IN) { portInner = new NDynamicPort(new NContentAlignment(-50, 0), DynamicPortGlueMode.GlueToContour); portInner.Name = ports[i].Name; } else { portInner = new NDynamicPort(new NContentAlignment(50, 0), DynamicPortGlueMode.GlueToContour); portInner.Name = ports[i].Name; } port.Ports.AddChild(portInner); } group.UpdateModelBounds(); return(group); }