private void propertyController1_ObjectsSet(object sender, Dataweb.NShape.Controllers.PropertyControllerEventArgs e) { if (e.Objects.Count > 0) { char dom = SecurityDemoHelper.NoDomain; foreach (object o in e.Objects) { if (o is ISecurityDomainObject) { if (dom == SecurityDemoHelper.NoDomain) dom = ((ISecurityDomainObject)o).SecurityDomainName; else if (dom != ((ISecurityDomainObject)o).SecurityDomainName) { dom = '!'; break; } } } cboDomain.SelectedIndex = Math.Max(dom - 'A', -1); } else cboDomain.SelectedIndex = -1; // Store security objects and their type for later use if (e.Objects.Count > 0) { currentSecurityObjects = SecurityDemoHelper.GetSecurityDomainObjects(e.Objects); currentSecurityObjectType = e.ObjectsType; } else { currentSecurityObjects = null; currentSecurityObjectType = null; } UpdateDomainPermissionCtrls(currentSecurityObjects, currentSecurityObjectType); }
/// <summary> /// Returns a collection of <see cref="T:Dataweb.NShape.Advanced.MenuItemDef" /> for constructing context menus etc. /// </summary> public IEnumerable<MenuItemDef> GetMenuItemDefs(Diagram diagram, Dataweb.NShape.Advanced.IReadOnlyCollection<Layer> selectedLayers) { if (diagram == null) throw new ArgumentNullException("diagram"); if (selectedLayers == null) throw new ArgumentNullException("selectedLayers"); bool isFeasible; string description; isFeasible = diagram.Layers.Count < Enum.GetValues(typeof (LayerIds)).Length; description = isFeasible ? "Add a new layer to the diagram" : "Maximum number of layers reached"; yield return new DelegateMenuItemDef("Add Layer", Properties.Resources.NewLayer, description, isFeasible, Permission.Data, diagram != null ? diagram.SecurityDomainName : 'A', (a, p) => AddLayer(diagram)); isFeasible = selectedLayers.Count > 0; description = isFeasible ? string.Format("Delete {0} Layers", selectedLayers.Count) : "No layers selected"; yield return new DelegateMenuItemDef(string.Format("Delete Layer{0}", selectedLayers.Count > 1 ? "s" : string.Empty), Properties.Resources.DeleteBtn, description, isFeasible, Permission.Data, diagram != null ? diagram.SecurityDomainName : 'A', (a, p) => this.RemoveLayers(diagram, selectedLayers)); }
private void display_ShapeDoubleClick(object sender, Dataweb.NShape.Controllers.DiagramPresenterShapeClickEventArgs e) { // nothing to do }
private void toolSetController_TemplateEditorSelected(object sender, Dataweb.NShape.Controllers.TemplateEditorEventArgs e) { TemplateEditorDialog dlg = new TemplateEditorDialog(e.Project, e.Template); dlg.Show(this); }
private MenuItemDef CreateFindShapesAction(Dataweb.NShape.Advanced.IReadOnlyCollection<IModelObject> modelObjects) { bool isFeasible = (diagramSetController != null); string description = "Find and select all assigned shapes."; return new DelegateMenuItemDef("Find assigned shapes", Properties.Resources.FindShapes, "FindShapesAction", description, false, isFeasible, Permission.None, (a, p) => FindShapes(modelObjects)); }
private MenuItemDef CreatePasteModelObjectsAction(Dataweb.NShape.Advanced.IReadOnlyCollection<IModelObject> modelObjects) { bool isFeasible = (copyPasteBuffer.Count > 0 && modelObjects.Count <= 1); string description; if (isFeasible) description = string.Format("Paste {0} model object{1}.", copyPasteBuffer.Count, (copyPasteBuffer.Count > 1) ? "s" : string.Empty); else description = "No model objects copied."; IModelObject parent = null; foreach (IModelObject mo in modelObjects) { parent = mo; break; } return new DelegateMenuItemDef("Paste", Properties.Resources.PasteBtn, "PasteModelObjectsAction", description, false, isFeasible, Permission.None, (a, p) => Paste(parent)); }
private MenuItemDef CreateCopyModelObjectsAction(Dataweb.NShape.Advanced.IReadOnlyCollection<IModelObject> modelObjects) { bool isFeasible = (modelObjects != null && modelObjects.Count > 0); string description; if (isFeasible) description = string.Format("Copy {0} model object{1}.", modelObjects.Count, (modelObjects.Count > 1) ? "s" : string.Empty); else description = "No model objects selected"; return new DelegateMenuItemDef("Copy", Properties.Resources.CopyBtn, "CopyModelObjectsAction", description, false, isFeasible, Permission.None, (a, p) => Copy(modelObjects)); }
private MenuItemDef CreateDeleteModelObjectsAction(Dataweb.NShape.Advanced.IReadOnlyCollection<IModelObject> modelObjects) { string description; bool isFeasible; if (modelObjects != null && modelObjects.Count > 0) { isFeasible = true; description = string.Format("Delete {0} model object{1}.", modelObjects.Count, (modelObjects.Count > 0) ? "s" : string.Empty); foreach (IModelObject modelObject in modelObjects) { foreach (IModelObject mo in Project.Repository.GetModelObjects(modelObject)) if (mo.ShapeCount > 0) { isFeasible = false; description = "One or more child model objects are attached to shapes."; } } } else { isFeasible = false; description = "No model objects selected"; } return new DelegateMenuItemDef("Delete", Properties.Resources.DeleteBtn, "DeleteModelObjectsAction", description, false, isFeasible, Permission.None, (a, p) => DeleteModelObjects(modelObjects)); }
/// <summary> /// Returns a collection of <see cref="T:Dataweb.NShape.Advanced.MenuItemDef" /> for constructing context menus etc. /// </summary> public IEnumerable<MenuItemDef> GetMenuItemDefs(Dataweb.NShape.Advanced.IReadOnlyCollection<IModelObject> modelObjects) { if (modelObjects == null) throw new ArgumentNullException("modelObjects"); // New... // Rename yield return CreateDeleteModelObjectsAction(modelObjects); yield return new SeparatorMenuItemDef(); yield return CreateCopyModelObjectsAction(modelObjects); // Cut yield return CreatePasteModelObjectsAction(modelObjects); yield return new SeparatorMenuItemDef(); // Find model object... yield return CreateFindShapesAction(modelObjects); }