Exemple #1
0
        private void AddNewLayer()
        {
            object lastHit  = m_layerLister.LastHit;
            ILayer newLayer = new DomNode(Schema.layerType.Type).As <ILayer>();

            newLayer.Name = "New Layer".Localize();

            IList <ILayer> layerList = null;
            var            layer     = lastHit.As <ILayer>();

            if (layer != null)
            {
                layerList = layer.Layers;
            }
            else
            {
                LayeringContext layeringContext = m_layerLister.TreeView.As <LayeringContext>();
                if (layeringContext != null)
                {
                    layerList = layeringContext.Layers;
                }
            }
            if (layerList != null)
            {
                var transactionContext = m_layerLister.TreeView.As <ITransactionContext>();
                transactionContext.DoTransaction(
                    delegate
                {
                    layerList.Add(newLayer);
                },
                    m_addLayer.Text);
            }
        }
Exemple #2
0
        void ICommandClient.DoCommand(object commandTag)
        {
            if (CommandTag.AddLayerFolder.Equals(commandTag))
            {
                ILayer newLayer = new DomNode(Schema.layerType.Type).As <ILayer>();
                newLayer.Name = "New Layer".Localize();

                IList <ILayer> layerList = null;
                object         target    = m_targetRef.Target;
                if (target != null)
                {
                    ILayer parentLayer = Adapters.As <ILayer>(target);
                    if (parentLayer != null)
                    {
                        layerList = parentLayer.Layers;
                    }
                    else
                    {
                        LayeringContext layeringContext = Adapters.As <LayeringContext>(target);
                        if (layeringContext != null)
                        {
                            layerList = layeringContext.Layers;
                        }
                    }
                }

                if (layerList != null)
                {
                    ILayeringContext    layeringContext    = m_contextRegistry.GetMostRecentContext <ILayeringContext>();
                    ITransactionContext transactionContext = Adapters.As <ITransactionContext>(layeringContext);
                    TransactionContexts.DoTransaction(
                        transactionContext,
                        delegate
                    {
                        layerList.Add(newLayer);
                    },
                        "Add Layer".Localize());
                }
            }
        }