Exemple #1
0
 public Drawing(DrawingSettings settings, ReadOnlyTree <string, Layer> layers, string currentLayerName, string author)
 {
     if (settings == null)
     {
         throw new ArgumentNullException("settings");
     }
     if (layers == null)
     {
         throw new ArgumentNullException("layers");
     }
     if (layers.Count == 0)
     {
         throw new ArgumentException("At least one layer must be specified.");
     }
     if (currentLayerName == null)
     {
         throw new ArgumentNullException("currentLayerName");
     }
     if (!layers.KeyExists(currentLayerName))
     {
         throw new InvalidOperationException("The current layer is not part of the layers collection.");
     }
     this.settings         = settings;
     this.layers           = layers;
     this.currentLayerName = currentLayerName;
     this.author           = author;
 }
Exemple #2
0
        private static Layer GetOrCreateLayer(ref ReadOnlyTree <string, Layer> layers, string layerName)
        {
            Layer layer = null;

            // entities without a layer go to '0'
            layerName = layerName ?? "0";
            if (layers.KeyExists(layerName))
            {
                layer = layers.GetValue(layerName);
            }
            else
            {
                // add the layer if previously undefined
                layer  = new Layer(layerName);
                layers = layers.Insert(layer.Name, layer);
            }

            return(layer);
        }