Esempio n. 1
0
        public KeymapViewModel()
        {
            var keymapDir = Path.Combine(ServiceProvider.AppDir, "keymaps");

            if (Directory.Exists(keymapDir))
            {
                var files = Directory.EnumerateFiles(keymapDir, "*.json");

                _keymaps.AddRange(files
                                  .Where(M => !M.Contains("schema"))
                                  .Select(M =>
                {
                    var content = File.ReadAllText(M);

                    var name = JObject.Parse(content)["Name"];

                    return(new KeymapItem(M, name.ToString()));
                }));
            }

            if (AvailableKeymaps.Count == 0)
            {
                var empty = new KeymapItem("", "Empty");

                _keymap = new Keymap();

                _keymaps.Add(empty);

                _selectedKeymap = empty;
            }
            else
            {
                SelectedKeymap = AvailableKeymaps[0];
            }
        }
Esempio n. 2
0
        public KeymapViewModel()
        {
            var location  = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            var keymapDir = string.IsNullOrEmpty(location) ? null : Path.Combine(location, "keymaps");

            if (Directory.Exists(keymapDir))
            {
                var files = Directory.EnumerateFiles(keymapDir, "*.json");

                _keymaps.AddRange(files
                                  .Where(s => !s.Contains("schema"))
                                  .Select(fileName =>
                {
                    var content = File.ReadAllText(fileName);

                    var name = JObject.Parse(content)["Name"];

                    return(new KeymapItem(fileName, name.ToString()));
                }));
            }

            if (AvailableKeymaps.Count == 0)
            {
                var empty = new KeymapItem("", "Empty");

                _keymap = new Keymap();

                _keymaps.Add(empty);

                _selectedKeymap = empty;
            }
            else
            {
                SelectedKeymap = AvailableKeymaps[0];
            }
        }