Exemplo n.º 1
0
        public IImmutableDictionary <CommandDefinition, IEnumerable <string> > GetKeyGestures()
        {
            if (_keyGestures != null)
            {
                return(_keyGestures);
            }

            var commandSettings = _commandSettingsService.GetCommandSettings();
            var builder         = ImmutableDictionary.CreateBuilder <CommandDefinition, IEnumerable <string> >();

            foreach (var command in _commands)
            {
                if (command.Value != null)
                {
                    if (!commandSettings.Commands.TryGetValue(command.Metadata.Name, out var settings))
                    {
                        settings = new Command();

                        if (command.Metadata.DefaultKeyGestures != null)
                        {
                            settings.KeyGestures.AddRange(command.Metadata.DefaultKeyGestures);
                        }

                        commandSettings.Commands.Add(command.Metadata.Name, settings);
                    }

                    builder.Add(command.Value, settings.KeyGestures);
                }
            }

            return(_keyGestures = builder.ToImmutable());
        }
Exemplo n.º 2
0
        public IImmutableDictionary <CommandDefinition, string> GetKeyGesture()
        {
            if (_keyGestures != null)
            {
                return(_keyGestures);
            }

            var commandSettings = _commandSettingsService.GetCommandSettings();
            var builder         = ImmutableDictionary.CreateBuilder <CommandDefinition, string>();

            foreach (var command in _commands)
            {
                if (command.Value != null)
                {
                    if (!commandSettings.Commands.TryGetValue(command.Metadata.Name, out var settings))
                    {
                        settings = new Command();

                        var gesture = command.Metadata.DefaultKeyGesture;

                        switch (Platform.PlatformIdentifier)
                        {
                        case PlatformID.MacOSX:
                            if (command.Metadata.OSXKeyGesture != null)
                            {
                                gesture = command.Metadata.OSXKeyGesture;
                            }
                            break;

                        case PlatformID.Unix:
                            if (command.Metadata.LinuxKeyGesture != null)
                            {
                                gesture = command.Metadata.LinuxKeyGesture;
                            }
                            break;

                        case PlatformID.Win32NT:
                            if (command.Metadata.WindowsKeyGesture != null)
                            {
                                gesture = command.Metadata.WindowsKeyGesture;
                            }
                            break;
                        }

                        settings.Gesture = gesture;

                        commandSettings.Commands.Add(command.Metadata.Name, settings);
                    }

                    builder.Add(command.Value, settings.Gesture);
                }
            }

            return(_keyGestures = builder.ToImmutable());
        }