Example #1
0
        /// <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();
            ICommand cmd = new EditLayerCommand(diagram, layer, EditLayerCommand.ChangedProperty.Name, oldName, newName);

            Project.ExecuteCommand(cmd);
            if (LayerModified != null)
            {
                LayerModified(this, LayerHelper.GetLayersEventArgs(LayerHelper.GetLayers(layer.Id, diagram)));
            }
        }
Example #2
0
        /// <ToBeCompleted></ToBeCompleted>
        public void RemoveLayer(Diagram diagram, string layerName)
        {
            if (diagram == null)
            {
                throw new ArgumentNullException("diagram");
            }
            if (string.IsNullOrEmpty(layerName))
            {
                throw new ArgumentNullException("layerName");
            }
            AssertDiagramSetControllerIsSet();
            Layer layer = diagram.Layers.FindLayer(layerName);

            if (layer == null)
            {
                throw new NShapeException("Layer '{0}' does not exist.", layerName);
            }
            Command cmd = new RemoveLayerCommand(diagram, layer);

            Project.ExecuteCommand(cmd);
            if (LayersRemoved != null)
            {
                LayersRemoved(this, LayerHelper.GetLayersEventArgs(LayerHelper.GetLayers(layerName, diagram)));
            }
        }
Example #3
0
 private void SetSelectedLayers(IEnumerable <Layer> layers)
 {
     selectedLayers.Clear();
     foreach (Layer l in layers)
     {
         selectedLayers.Add(l);
     }
     OnSelectedLayersChanged(this, LayerHelper.GetLayersEventArgs(selectedLayers));
 }
Example #4
0
        /// <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)
            {
                cmdMinZoom = new EditLayerCommand(diagram, layer,
                                                  EditLayerCommand.ChangedProperty.LowerZoomThreshold,
                                                  layer.LowerZoomThreshold, lowerZoomBounds);
            }
            if (layer.UpperZoomThreshold != upperZoomBounds)
            {
                cmdMaxZoom = new EditLayerCommand(diagram, layer,
                                                  EditLayerCommand.ChangedProperty.UpperZoomThreshold,
                                                  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)));
                }
            }
        }
Example #5
0
        /// <ToBeCompleted></ToBeCompleted>
        public void RemoveLayers(Diagram diagram, IEnumerable <Layer> layers)
        {
            if (diagram == null)
            {
                throw new ArgumentNullException("diagram");
            }
            if (layers == null)
            {
                throw new ArgumentNullException("layers");
            }
            AssertDiagramSetControllerIsSet();
            Command cmd = new RemoveLayerCommand(diagram, layers);

            Project.ExecuteCommand(cmd);
            if (LayersRemoved != null)
            {
                LayersRemoved(this, LayerHelper.GetLayersEventArgs(layers));
            }
        }
Example #6
0
        /// <ToBeCompleted></ToBeCompleted>
        public void AddLayer(Diagram diagram, string layerName)
        {
            if (diagram == null)
            {
                throw new ArgumentNullException("diagram");
            }
            if (layerName == null)
            {
                throw new ArgumentNullException("layerName");
            }
            AssertDiagramSetControllerIsSet();
            if (diagram.Layers.FindLayer(layerName) != null)
            {
                throw new NShapeException("Layer name '{0}' already exists.", layerName);
            }
            Command cmd = new AddLayerCommand(diagram, layerName);

            Project.ExecuteCommand(cmd);
            if (LayersAdded != null)
            {
                LayersAdded(this, LayerHelper.GetLayersEventArgs(LayerHelper.GetLayers(layerName, diagram)));
            }
        }
Example #7
0
 private void UnselectAllLayers()
 {
     selectedLayers.Clear();
     OnSelectedLayersChanged(this, LayerHelper.GetLayersEventArgs(selectedLayers));
 }
Example #8
0
 private void UnselectLayer(Layer layer)
 {
     selectedLayers.Remove(layer);
     OnSelectedLayersChanged(this, LayerHelper.GetLayersEventArgs(selectedLayers));
 }
Example #9
0
 private void SetSelectedLayers(Layer layer)
 {
     selectedLayers.Clear();
     selectedLayers.Add(layer);
     OnSelectedLayersChanged(this, LayerHelper.GetLayersEventArgs(selectedLayers));
 }
Example #10
0
 private void SelectLayer(Layer layer)
 {
     _selectedLayers.Add(layer);
     OnSelectedLayersChanged(this, LayerHelper.GetLayersEventArgs(_selectedLayers));
 }