/// <summary>
        /// Set the preview pane to a previewable item
        /// </summary>
        /// <param name="item"></param>
        public void SetPreviewItem(object item)
        {
            if (item is Thumbnail)
            {
                // Set the underlying object's preview then add a context menu
                Thumbnail thumb = (Thumbnail)item;
                SetPreviewItem(thumb.ThumbnailOf);
            }
            else if (item is BitmapType)
            {
                BitmapType preview = (BitmapType)item;
                imagePreview.Source = preview.Bitmap;

                InputBindings.Clear();

                MouseBinding doubleclick = new MouseBinding(Commands.CmdFullscreen, new MouseGesture(MouseAction.LeftDoubleClick));
                doubleclick.CommandTarget    = this;
                doubleclick.CommandParameter = preview;
                InputBindings.Add(doubleclick);

                List <MenuItem> menuitems = GetMenuItems(item, item);
                ContextMenu = new ContextMenu()
                {
                    ItemsSource = menuitems
                };
            }
            else
            {
                imagePreview.Source = null;
                InputBindings.Clear();
                ContextMenu = null;
            }
        }
Exemplo n.º 2
0
        public CmdCase(Sugarism.CmdCase model) : base(model)
        {
            _model = model;

            _cmdList = new ObservableCollection <Command>();
            foreach (Sugarism.Command cmdModel in _model.CmdList)
            {
                Command cmdViewModel = Command.Create(cmdModel);
                if (null != cmdViewModel)
                {
                    CmdList.Add(cmdViewModel);
                    cmdViewModel.Owner = this;
                }
                else
                {
                    Log.Error(Properties.Resources.ErrInvalidCmdType);
                }
            }

            _parent = null;

            InputBindings.Clear();
            InputBindings.Add(new KeyBinding(CmdExpand, System.Windows.Input.Key.Enter, ModifierKeys.None));
            InputBindings.Add(new KeyBinding(CmdAddChild, System.Windows.Input.Key.A, ModifierKeys.Control));

            if (_model.CmdList.Count <= 0)
            {
                addSampleCmd();
            }
        }
Exemplo n.º 3
0
        private void SetState(MainWindowState state)
        {
            message.TextChanged    -= Message_TextChanged;
            message.Text            = state.Message;
            message.SelectionStart  = state.SelectionStart;
            message.SelectionLength = 0;
            message.TextChanged    += Message_TextChanged;

            submit.Command   = state.Save;
            emoji.Command    = state.Help;
            settings.Command = state.Settings;

            suggestionList.ItemConfirmed -= OnSuggestionConfirmed;
            suggestionList.ItemsSource    = state.Suggestions;
            suggestionList.ItemConfirmed += OnSuggestionConfirmed;

            if (state.Focus)
            {
                message.Focus();
            }
            if (state.Close)
            {
                Close();
            }

            InputBindings.Clear();
            InputBindings.Add(new KeyBinding(state.Save, new KeyGesture(Key.S, ModifierKeys.Control)));

            if (!state.HasUserEdited)
            {
                InputBindings.Add(new KeyBinding(escape, new KeyGesture(Key.Escape)));
            }
        }
Exemplo n.º 4
0
        public void WithNextCharacter(Action <Char> with)
        {
            defaultInsert = false;

            InputBindings.Clear();

            withCharacter = with;
        }
Exemplo n.º 5
0
 public void Disable()
 {
     IsEnabled = false;
     foreach (var binding in InputBindings)
     {
         binding.DisableHooks();
     }
     InputBindings.Clear();
 }
Exemplo n.º 6
0
 private void GameScreenUnloaded(object sender, RoutedEventArgs e)
 {
     StopDescendantAnimations();
     CommandBindings.Clear();
     InputBindings.Clear();
     ClientEvents.ChatMessageReceived.Unsubscribe(OnChatMessageReceived);
     ClientEvents.AllTurnEnded.Unsubscribe(OnAllTurnEnded);
     ClientEvents.TurnStarted.Unsubscribe(OnTurnStarted);
 }
        protected void InitializeAcObjectPage([NotNull] ViewModel model)
        {
            SelectedAcObject = model.SelectedObject;
            InputBindings.Clear();
            InputBindings.AddRange(new InputBinding[] { });
            DataContext = model;

            if (!_set)
            {
                _set      = true;
                Loaded   += OnLoaded;
                Unloaded += OnUnloaded;
            }

            UpdateBindingsLaterAsync().Ignore();
        }
Exemplo n.º 8
0
 private void UpdateBindings()
 {
     InputBindings.Clear();
     InputBindings.AddRange(new[] {
         new InputBinding(Model.Entry.RefreshCommand, new KeyGesture(Key.R, ModifierKeys.Alt)),
         new InputBinding(Model.Entry.JoinCommand, new KeyGesture(Key.G, ModifierKeys.Control)),
         new InputBinding(Model.Entry.ToggleFavouritedCommand, new KeyGesture(Key.D, ModifierKeys.Control)),
         new InputBinding(Model.Entry.ToggleHiddenCommand, new KeyGesture(Key.H, ModifierKeys.Control | ModifierKeys.Shift)),
         new InputBinding(Model.Entry.CancelBookingCommand, new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift)),
         new InputBinding(Model.ManageListsCommand, new KeyGesture(Key.D, ModifierKeys.Control | ModifierKeys.Shift)),
         new InputBinding(Model.Entry.JoinCommand, new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Alt))
         {
             CommandParameter = ServerEntry.ForceJoin
         }
     });
     InputBindingBehavior.UpdateBindings(this);
 }
Exemplo n.º 9
0
        public void WithMotion(Action <Range> with)
        {
            defaultInsert = false;

            InputBindings.Clear();

            foreach (var ghp in currentMode.Motions.Gestures)
            {
                InputBindings.Add(
                    new InputBinding(EditingCommands.HandleKey, ghp.Key)
                {
                    CommandParameter = ghp.Value
                });
            }

            withMotion = with;
        }
Exemplo n.º 10
0
 private void InputField_IsKeyboardFocusedChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue != e.OldValue)
     {
         if ((bool)e.NewValue)
         {
             InputBindings.Clear();
         }
         else
         {
             if (InputBindings.Count > 0)
             {
                 InputBindings.Clear();
             }
             InputBindings.AddRange(hotKeys);
         }
     }
 }
Exemplo n.º 11
0
        protected void InitializeAcObjectPage([NotNull] ISelectedAcObjectViewModel model)
        {
            SelectedAcObject = model.SelectedAcObject;
            InputBindings.Clear();
            InputBindings.AddRange(new[] {
                new InputBinding(SelectedAcObject.ToggleFavouriteCommand, new KeyGesture(Key.B, ModifierKeys.Control)),
                new InputBinding(SelectedAcObject.CopyIdCommand, new KeyGesture(Key.C, ModifierKeys.Control)), // TODO: why doesn’t work after quick switching?
                new InputBinding(SelectedAcObject.CopyIdCommand, new KeyGesture(Key.C, ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)),
                new InputBinding(SelectedAcObject.CopyIdCommand, new KeyGesture(Key.C, ModifierKeys.Control | ModifierKeys.Shift))
                {
                    CommandParameter = @"name"
                },
                new InputBinding(SelectedAcObject.CopyIdCommand, new KeyGesture(Key.C, ModifierKeys.Control | ModifierKeys.Alt))
                {
                    CommandParameter = @"path"
                },
                new InputBinding(SelectedAcObject.ViewInExplorerCommand, new KeyGesture(Key.F, ModifierKeys.Control)),
                new InputBinding(SelectedAcObject.ReloadCommand, new KeyGesture(Key.R, ModifierKeys.Control))
                {
                    CommandParameter = @"full"
                },
                // new InputBinding(SelectedAcObject.ToggleCommand, new KeyGesture(Key.D, ModifierKeys.Control)),
                new InputBinding(new DelegateCommand(ToggleObject), new KeyGesture(Key.D, ModifierKeys.Control)),
                new InputBinding(SelectedAcObject.SaveCommand, new KeyGesture(Key.S, ModifierKeys.Control)),
                new InputBinding(model.ChangeIdCommand, new KeyGesture(Key.F2, ModifierKeys.Control | ModifierKeys.Shift)),
                new InputBinding(model.CloneCommand, new KeyGesture(Key.D, ModifierKeys.Control | ModifierKeys.Shift)),
                new InputBinding(model.FindInformationCommand, new KeyGesture(Key.I, ModifierKeys.Control)),
                new InputBinding(SelectedAcObject.DeleteCommand, new KeyGesture(Key.Delete, ModifierKeys.Control))
            });
            DataContext = model;

            if (!_set)
            {
                _set      = true;
                Loaded   += OnLoaded;
                Unloaded += OnUnloaded;
            }
            else
            {
                model.Load();
            }

            UpdateBindingsLaterAsync().Forget();
        }
Exemplo n.º 12
0
        /// <summary>Raises the System.Windows.Controls.Primitives.Selector.SelectionChanged routed event</summary>
        /// <param name="e">Provides data for System.Windows.Controls.SelectionChangedEventArgs.</param>
        protected override void OnSelectionChanged(SelectionChangedEventArgs e)
        {
            base.OnSelectionChanged(e);

            var result = SelectedContent as ViewResult;

            if (result == null || result.View == null)
            {
                return;
            }

            FocusHelper.FocusDelayed(this);

            InputBindings.Clear();
            foreach (InputBinding binding in result.View.InputBindings)
            {
                InputBindings.Add(binding);
            }
        }
Exemplo n.º 13
0
        public void Show(Status status)
        {
            var inputs         = new UpdateViewInputs(status);
            var update_command = new UpdateCommand(inputs, status);
            var update_hotkey  = new KeyBinding(update_command, new KeyGesture(Key.Enter, ModifierKeys.Control));

            DevTool.Print("count", InputBindings.Count);
            InputBindings.Clear();
            InputBindings.Add(update_hotkey);
            DataContext = new
            {
                Status   = status,
                Inputs   = inputs,
                Config   = ((App)Application.Current).Config,
                Commands = new
                {
                    Update = update_command,
                },
            };
            Visibility = Visibility.Visible;
            Activate();
        }
Exemplo n.º 14
0
        public void UpdateShortcuts(AppSettings settings)
        {
            // ================ WINDOW ================
            InputBindings.Clear();
            foreach (var sc in settings.Shortcuts.Where(s => s.Value.Scope == AlephShortcutScope.Window))
            {
                var sckey = sc.Key;
                var cmd   = new RelayCommand(() => ShortcutManager.Execute(this, sckey));
                var ges   = new KeyGesture((Key)sc.Value.Key, (ModifierKeys)sc.Value.Modifiers);
                InputBindings.Add(new InputBinding(cmd, ges));
            }

            // ================ NOTESLIST ================
            NotesViewControl.SetShortcuts(this, settings.Shortcuts.ToList());             // via InputBindings

            // ================ GLOBAL ================
            _scManager.Clear();
            foreach (var sc in settings.Shortcuts.Where(s => s.Value.Scope == AlephShortcutScope.Global))
            {
                _scManager.Register(sc.Value.Modifiers, sc.Value.Key, sc.Key);
            }
        }
Exemplo n.º 15
0
        private void RevertMode()
        {
            defaultInsert = currentMode.DefaultInsert;

            InputBindings.Clear();

            foreach (var ghp in currentMode.Gestures)
            {
                InputBindings.Add(
                    new InputBinding(EditingCommands.HandleKey, ghp.Key)
                {
                    CommandParameter = ghp.Value
                });
            }
            if (MapResolver.HasMacros(currentMode))
            {
                foreach (var ghp in MapResolver.GetMacros(currentMode))
                {
                    BindMacro(ghp.Key, ghp.Value);
                }
            }
        }
Exemplo n.º 16
0
 private void NameBox_OnGotFocus(object sender, RoutedEventArgs e)
 {
     _bindings.AddRange(InputBindings);
     InputBindings.Clear();
 }
Exemplo n.º 17
0
 /// <summary>
 /// Removes all InputBinding instances from the cache.
 /// </summary>
 public void ClearInputBindings()
 {
     InputBindings.Clear();
 }
Exemplo n.º 18
0
 public void SuspendKeyboardShortcuts()
 {
     InputBindings.Clear();
 }
Exemplo n.º 19
0
 private void OnAddNewCommandChanged(CommandBase newValue)
 {
     InputBindings.Clear();
     InputBindings.Add(new InputBinding(newValue, new KeyGesture(Key.N, ModifierKeys.Control | ModifierKeys.Shift)));
 }