示例#1
0
        private static IEnumerable <EntityDesignerCommand> GetCommands(IEntityDesignerLayer layer = null)
        {
            var commandsToReturn = new List <EntityDesignerCommand>();
            var commandsForLayer = EscherExtensionPointManager.LoadCommandExtensions(layer == null, layer != null);

            foreach (var lazyFactory in commandsForLayer)
            {
                var factory = lazyFactory.Value;
                if (factory != null)
                {
                    commandsToReturn.AddRange(factory.Commands);
                }
            }
            return(commandsToReturn);
        }
示例#2
0
        internal void Load()
        {
            // Load all the layers first
            var extensions = EscherExtensionPointManager.LoadLayerExtensions();

            if (extensions != null)
            {
                var selectedEFElement = SelectedEFObject as EFElement;
                foreach (var ex in extensions)
                {
                    var layer = ex.Value;
                    if (layer != null)
                    {
                        var isLayerEnabled = IsLayerEnabled(layer.Name);
                        EntityDesignerCommand enableCommand;
                        var addedCommand = AddEnableLayerCommand(layer, isLayerEnabled, out enableCommand);
                        if (addedCommand && enableCommand != null)
                        {
                            if (isLayerEnabled)
                            {
                                LoadLayer(layer, selectedEFElement != null ? selectedEFElement.XObject : null);
                            }

                            var layerState = new LayerState {
                                IsEnabled = isLayerEnabled, EnableCommand = enableCommand
                            };
                            _layer2state.Add(layer, layerState);
                        }
                    }
                }
            }

            // TODO Now we load the commands from the command factories. At some point we should move this out of the layer manager
            // into a more global object (not tied to the lifetime of the artifact)
            foreach (var command in GetCommands())
            {
                AddCommand(command);
            }
            ListenToSelections();
        }