コード例 #1
0
        private void OpenSettings(object sender, RoutedEventArgs e)
        {
            var modalWindow = new Settings {
                Owner = this
            };

            modalWindow.ShowDialog();
            var mainViewModel = (MainViewModel)DataContext;

            mainViewModel.AlwaysOverride = IOManager.ReadSetting("AlwaysOverride") == "True";
            foreach (InputBinding metaShortcut in _metaShortcuts)
            {
                InputBindings.Remove(metaShortcut);
            }

            _metaShortcuts.Clear();

            var viewModel = (MainViewModel)DataContext;

            var newMetaShortcut = SetGetMetaShortcut("Undo", "Ctrl+Z");

            GetKeyModifier(newMetaShortcut.Split('+'), out var metaKey, out var metaModifier);
            _metaShortcuts.Add(AddBinding(viewModel.UndoCommand, metaKey, metaModifier));

            newMetaShortcut = SetGetMetaShortcut("Delete", "Delete");
            GetKeyModifier(newMetaShortcut.Split('+'), out metaKey, out metaModifier);
            _metaShortcuts.Add(AddBinding(viewModel.DeleteFileCommand, metaKey, metaModifier));

            newMetaShortcut = SetGetMetaShortcut("Left", "Left");
            GetKeyModifier(newMetaShortcut.Split('+'), out metaKey, out metaModifier);
            _metaShortcuts.Add(AddBinding(viewModel.PrevCommand, metaKey, metaModifier));

            newMetaShortcut = SetGetMetaShortcut("Right", "Right");
            GetKeyModifier(newMetaShortcut.Split('+'), out metaKey, out metaModifier);
            _metaShortcuts.Add(AddBinding(viewModel.NextCommand, metaKey, metaModifier));
        }
コード例 #2
0
 private void NameBox_OnLostFocus(object sender, RoutedEventArgs e)
 {
     InputBindings.AddRange(_bindings);
     _bindings.Clear();
 }