Пример #1
0
        public CommandBindings GetBindings(IExplorerViewModel explorerViewModel)
        {
            if (Resolve == null)
            {
                throw new InvalidOperationException("CommandBindngs Resolve must be set in application startup.");
            }

            if (explorerViewModel == null)
            {
                throw new Exception(nameof(explorerViewModel));
            }

            var commandBindings = new List <CommandBinding>();
            var descriptors     = CommandDescriptorProvider.GetCommandDescriptors()
                                  .Where(x => x is ExplorerCommandDescriptor).Cast <ExplorerCommandDescriptor>();

            foreach (var commandDescriptor in descriptors)
            {
                var command = Resolve(commandDescriptor.CommandType) as ICommand;
                if (command == null)
                {
                    throw new Exception($"No instance resoled for {commandDescriptor.CommandType.FullName} command.");
                }

                var commandName            = commandDescriptor.Attribute.UniqueName ?? commandDescriptor.CommandType.Name;
                var commandPreferredHotkey = commandDescriptor.PreferredHotkey ?? null;
                var commandInfo            = new CommandBinding(commandName, command, commandPreferredHotkey);
                commandBindings.Add(commandInfo);
            }

            var bindings = new CommandBindings(commandBindings);

            return(bindings);
        }
Пример #2
0
        public static async Task ResetToDefaultsAsync()
        {
            var commandDescriptors = CommandDescriptorProvider.GetCommandDescriptors().Where(x => x.HasHotkey);

            foreach (var commandDescriptor in commandDescriptors)
            {
                await ConfigPrefferedHotkeyAsync(commandDescriptor.UniqueName, commandDescriptor.DefaultHotkey);
            }
        }
Пример #3
0
        public static void AddExplorerDefaultCommands(this IServiceCollection sp)
        {
            sp.AddSingleton <IExplorerCommandBindingsProvider, ExplorerCommandBindingsProvider>();

            var commandDescriptors = CommandDescriptorProvider.GetCommandDescriptors();

            foreach (var commandDescriptor in commandDescriptors)
            {
                if (commandDescriptor is ExplorerCommandDescriptor explorerCommandDescriptor)
                {
                    sp.AddSingleton(explorerCommandDescriptor.CommandType);
                }
            }
        }
Пример #4
0
        private ObservableCollection <HotkeySettingAdapter> GetHotkeySettings()
        {
            var hotkeySettings     = new List <HotkeySettingAdapter>();
            var commandDescriptors = CommandDescriptorProvider.GetCommandDescriptors().Where(x => x.HasHotkey);

            foreach (var commandDescriptor in commandDescriptors)
            {
                var hotkeySettingAdapter = HotkeySettingAdapter.From(commandDescriptor);
                hotkeySettings.Add(hotkeySettingAdapter);
                hotkeySettingAdapter.PropertyChanged += HotkeySettingAdapter_PropertyChanged;
            }

            return(new ObservableCollection <HotkeySettingAdapter>(hotkeySettings));
        }
        public ExplorerTabsControl()
        {
            InitializeComponent();
            ExplorerTabs.ItemsSource = Items;
            Loaded   += ExplorerTabsControl_Loaded;
            Unloaded += ExplorerTabsControl_Unloaded;
            Items.CollectionChanged += Items_CollectionChanged;

            var explorerTabsCommands = CommandDescriptorProvider.GetCommandDescriptors().Where(x => x is ExplorerTabsCommandDescriptor);

            _addTabHotkey              = explorerTabsCommands.FirstOrDefault(x => x.UniqueName == "AddTab").PreferredHotkey;
            _removeTabHotkey           = explorerTabsCommands.FirstOrDefault(x => x.UniqueName == "RemoveTab").PreferredHotkey;
            _copyToOtherExplorerHotkey = explorerTabsCommands.FirstOrDefault(x => x.UniqueName == "CopyToOtherExplorer").PreferredHotkey;
            _moveToOtherExplorerHotkey = explorerTabsCommands.FirstOrDefault(x => x.UniqueName == "MoveToOtherExplorer").PreferredHotkey;
        }