/// <ToBeCompleted></ToBeCompleted> public void RenameLayer(Diagram diagram, Layer layer, string oldName, string newName) { if (diagram == null) { throw new ArgumentNullException("diagram"); } if (layer == null) { throw new ArgumentNullException("layer"); } if (oldName == null) { throw new ArgumentNullException("oldName"); } if (newName == null) { throw new ArgumentNullException("newName"); } AssertDiagramSetControllerIsSet(); PropertyInfo pi = typeof(Layer).GetProperty("Name"); ICommand cmd = new LayerPropertySetCommand(diagram, layer, pi, oldName, newName); Project.ExecuteCommand(cmd); if (LayerModified != null) { LayerModified(this, LayerHelper.GetLayersEventArgs(LayerHelper.GetLayers(layer.Id, diagram))); } }
/// <ToBeCompleted></ToBeCompleted> public void SetLayerZoomBounds(Diagram diagram, Layer layer, int lowerZoomBounds, int upperZoomBounds) { if (diagram == null) { throw new ArgumentNullException("diagram"); } if (layer == null) { throw new ArgumentNullException("layer"); } AssertDiagramSetControllerIsSet(); ICommand cmdMinZoom = null; ICommand cmdMaxZoom = null; if (layer.LowerZoomThreshold != lowerZoomBounds) { PropertyInfo piMinZoom = typeof(Layer).GetProperty("LowerZoomThreshold"); cmdMinZoom = new LayerPropertySetCommand(diagram, layer, piMinZoom, layer.LowerZoomThreshold, lowerZoomBounds); } if (layer.UpperZoomThreshold != upperZoomBounds) { PropertyInfo piMaxZoom = typeof(Layer).GetProperty("UpperZoomThreshold"); cmdMaxZoom = new LayerPropertySetCommand(diagram, layer, piMaxZoom, layer.UpperZoomThreshold, upperZoomBounds); } ICommand cmd; if (cmdMinZoom != null && cmdMaxZoom != null) { cmd = new AggregatedCommand(); ((AggregatedCommand)cmd).Add(cmdMinZoom); ((AggregatedCommand)cmd).Add(cmdMaxZoom); } else if (cmdMinZoom != null && cmdMaxZoom == null) { cmd = cmdMinZoom; } else if (cmdMaxZoom != null && cmdMinZoom == null) { cmd = cmdMaxZoom; } else { cmd = null; } if (cmd != null) { Project.ExecuteCommand(cmd); if (LayerModified != null) { LayerModified(this, LayerHelper.GetLayersEventArgs(LayerHelper.GetLayers(layer.Id, diagram))); } } }
/// <ToBeCompleted></ToBeCompleted> public void CommitSetProperty() { AssertProjectExists(); if (propertySetBuffer != null) { ICommand command = null; if (propertySetBuffer.Objects.Count != 0) { if (IsOfType(propertySetBuffer.ObjectType, typeof(Shape))) { command = new ShapePropertySetCommand( ConvertEnumerator<Shape>.Create(propertySetBuffer.Objects), propertySetBuffer.PropertyInfo, propertySetBuffer.OldValues, propertySetBuffer.NewValue); } else if (IsOfType(propertySetBuffer.ObjectType, typeof(IModelObject))) { command = new ModelObjectPropertySetCommand( ConvertEnumerator<IModelObject>.Create(propertySetBuffer.Objects), propertySetBuffer.PropertyInfo, propertySetBuffer.OldValues, propertySetBuffer.NewValue); } else if (IsOfType(propertySetBuffer.ObjectType, typeof(Diagram))) { command = new DiagramPropertySetCommand( ConvertEnumerator<Diagram>.Create(propertySetBuffer.Objects), propertySetBuffer.PropertyInfo, propertySetBuffer.OldValues, propertySetBuffer.NewValue); } else if (IsOfType(propertySetBuffer.ObjectType, typeof(Layer))) { Diagram diagram = null; foreach (Diagram d in project.Repository.GetDiagrams()) { foreach (Layer l in ConvertEnumerator<Layer>.Create(propertySetBuffer.Objects)) { if (d.Layers.Contains(l)) { diagram = d; break; } if (diagram != null) break; } } command = new LayerPropertySetCommand( diagram, ConvertEnumerator<Layer>.Create(propertySetBuffer.Objects), propertySetBuffer.PropertyInfo, propertySetBuffer.OldValues, propertySetBuffer.NewValue); } else if (IsOfType(propertySetBuffer.ObjectType, typeof(Design))) { command = new DesignPropertySetCommand( ConvertEnumerator<Design>.Create(propertySetBuffer.Objects), propertySetBuffer.PropertyInfo, propertySetBuffer.OldValues, propertySetBuffer.NewValue); } else if (IsOfType(propertySetBuffer.ObjectType, typeof(Style))) { Design design = null; if (project.Repository != null) { foreach (Design d in project.Repository.GetDesigns()) { foreach (Style s in ConvertEnumerator<Style>.Create(propertySetBuffer.Objects)) { if (d.ContainsStyle(s)) { design = d; break; } } if (design != null) break; } } else design = project.Design; if (design != null) { command = new StylePropertySetCommand( design, ConvertEnumerator<Style>.Create(propertySetBuffer.Objects), propertySetBuffer.PropertyInfo, propertySetBuffer.OldValues, propertySetBuffer.NewValue); } } else throw new NotSupportedException(); } if (command != null) { if (!command.IsAllowed(Project.SecurityManager)) throw new NShapeSecurityException(command); if (updateRepository) Project.ExecuteCommand(command); else command.Execute(); if (PropertyChanged != null) { int pageIndex; Hashtable selectedObjectsList; GetSelectedObjectList(propertySetBuffer.Objects, out pageIndex, out selectedObjectsList); if (pageIndex >= 0) { PropertyControllerPropertyChangedEventArgs e = new PropertyControllerPropertyChangedEventArgs( pageIndex, propertySetBuffer.Objects, propertySetBuffer.PropertyInfo, propertySetBuffer.OldValues, propertySetBuffer.NewValue); PropertyChanged(this, e); } } } else CancelSetProperty(); } propertySetBuffer = null; }
/// <ToBeCompleted></ToBeCompleted> public void CommitSetProperty() { AssertProjectExists(); if (propertySetBuffer != null) { ICommand command = null; if (propertySetBuffer.Objects.Count != 0) { if (IsOfType(propertySetBuffer.ObjectType, typeof(Shape))) { command = new ShapePropertySetCommand( ConvertEnumerator <Shape> .Create(propertySetBuffer.Objects), propertySetBuffer.PropertyInfo, propertySetBuffer.OldValues, propertySetBuffer.NewValue); } else if (IsOfType(propertySetBuffer.ObjectType, typeof(IModelObject))) { command = new ModelObjectPropertySetCommand( ConvertEnumerator <IModelObject> .Create(propertySetBuffer.Objects), propertySetBuffer.PropertyInfo, propertySetBuffer.OldValues, propertySetBuffer.NewValue); } else if (IsOfType(propertySetBuffer.ObjectType, typeof(Diagram))) { command = new DiagramPropertySetCommand( ConvertEnumerator <Diagram> .Create(propertySetBuffer.Objects), propertySetBuffer.PropertyInfo, propertySetBuffer.OldValues, propertySetBuffer.NewValue); } else if (IsOfType(propertySetBuffer.ObjectType, typeof(Layer))) { Diagram diagram = null; foreach (Diagram d in project.Repository.GetDiagrams()) { foreach (Layer l in ConvertEnumerator <Layer> .Create(propertySetBuffer.Objects)) { if (d.Layers.Contains(l)) { diagram = d; break; } if (diagram != null) { break; } } } command = new LayerPropertySetCommand( diagram, ConvertEnumerator <Layer> .Create(propertySetBuffer.Objects), propertySetBuffer.PropertyInfo, propertySetBuffer.OldValues, propertySetBuffer.NewValue); } else if (IsOfType(propertySetBuffer.ObjectType, typeof(Design))) { command = new DesignPropertySetCommand( ConvertEnumerator <Design> .Create(propertySetBuffer.Objects), propertySetBuffer.PropertyInfo, propertySetBuffer.OldValues, propertySetBuffer.NewValue); } else if (IsOfType(propertySetBuffer.ObjectType, typeof(Style))) { Design design = null; if (project.Repository != null) { foreach (Design d in project.Repository.GetDesigns()) { foreach (Style s in ConvertEnumerator <Style> .Create(propertySetBuffer.Objects)) { if (d.ContainsStyle(s)) { design = d; break; } } if (design != null) { break; } } } else { design = project.Design; } if (design != null) { command = new StylePropertySetCommand( design, ConvertEnumerator <Style> .Create(propertySetBuffer.Objects), propertySetBuffer.PropertyInfo, propertySetBuffer.OldValues, propertySetBuffer.NewValue); } } else { throw new NotSupportedException(); } } if (command != null) { // Check if command execution is allowed Exception exc = command.CheckAllowed(Project.SecurityManager); if (exc != null) { throw exc; } // if (updateRepository) { Project.ExecuteCommand(command); } else { command.Execute(); } if (PropertyChanged != null) { int pageIndex; Hashtable selectedObjectsList; GetSelectedObjectList(propertySetBuffer.Objects, out pageIndex, out selectedObjectsList); if (pageIndex >= 0) { PropertyControllerPropertyChangedEventArgs e = new PropertyControllerPropertyChangedEventArgs( pageIndex, propertySetBuffer.Objects, propertySetBuffer.PropertyInfo, propertySetBuffer.OldValues, propertySetBuffer.NewValue); PropertyChanged(this, e); } } } else { CancelSetProperty(); } } propertySetBuffer = null; }
/// <ToBeCompleted></ToBeCompleted> public void SetLayerZoomBounds(Diagram diagram, Layer layer, int lowerZoomBounds, int upperZoomBounds) { if (diagram == null) throw new ArgumentNullException("diagram"); if (layer == null) throw new ArgumentNullException("layer"); AssertDiagramSetControllerIsSet(); ICommand cmdMinZoom = null; ICommand cmdMaxZoom = null; if (layer.LowerZoomThreshold != lowerZoomBounds) { PropertyInfo piMinZoom = typeof(Layer).GetProperty("LowerZoomThreshold"); cmdMinZoom = new LayerPropertySetCommand(diagram, layer, piMinZoom, layer.LowerZoomThreshold, lowerZoomBounds); } if (layer.UpperZoomThreshold != upperZoomBounds) { PropertyInfo piMaxZoom = typeof(Layer).GetProperty("UpperZoomThreshold"); cmdMaxZoom = new LayerPropertySetCommand(diagram, layer, piMaxZoom, layer.UpperZoomThreshold, upperZoomBounds); } ICommand cmd; if (cmdMinZoom != null && cmdMaxZoom != null) { cmd = new AggregatedCommand(); ((AggregatedCommand)cmd).Add(cmdMinZoom); ((AggregatedCommand)cmd).Add(cmdMaxZoom); } else if (cmdMinZoom != null && cmdMaxZoom == null) cmd = cmdMinZoom; else if (cmdMaxZoom != null && cmdMinZoom == null) cmd = cmdMaxZoom; else cmd = null; if (cmd != null) { Project.ExecuteCommand(cmd); if (LayerModified != null) LayerModified(this, LayerHelper.GetLayersEventArgs(LayerHelper.GetLayers(layer.Id, diagram))); } }
/// <ToBeCompleted></ToBeCompleted> public void RenameLayer(Diagram diagram, Layer layer, string oldName, string newName) { if (diagram == null) throw new ArgumentNullException("diagram"); if (layer == null) throw new ArgumentNullException("layer"); if (oldName == null) throw new ArgumentNullException("oldName"); if (newName == null) throw new ArgumentNullException("newName"); AssertDiagramSetControllerIsSet(); PropertyInfo pi = typeof(Layer).GetProperty("Name"); ICommand cmd = new LayerPropertySetCommand(diagram, layer, pi, oldName, newName); Project.ExecuteCommand(cmd); if (LayerModified != null) LayerModified(this, LayerHelper.GetLayersEventArgs(LayerHelper.GetLayers(layer.Id, diagram))); }