void Window3_Loaded(object sender, RoutedEventArgs e)
        {
            MouseGesture runCmdMouseGesture = new MouseGesture();
            runCmdMouseGesture.MouseAction = MouseAction.LeftClick;
            runCmdMouseGesture.Modifiers = ModifierKeys.Control;

            MouseBinding runCmdMouseBinding = new MouseBinding();
            runCmdMouseBinding.Gesture = runCmdMouseGesture;
            runCmdMouseBinding.Command = MyCommands.Run;
            myCanvas.InputBindings.Add(runCmdMouseBinding);
        }
        public CustomerExplorerControl()
        {
            InitializeComponent();
            BindCommands();
            CustomerDoubleClick = new MouseBinding();
            CustomerDoubleClick.MouseAction = MouseAction.LeftDoubleClick;
            CustomerDoubleClick.Command = TreeItemDoubleClick.TreeViewDoubleClick;
            CustomerDoubleClick.CommandParameter = WindowOpenMode.EditCustomer;

            ContactDoubleClick = new MouseBinding();
            ContactDoubleClick.MouseAction = MouseAction.LeftDoubleClick;
            ContactDoubleClick.Command = TreeItemDoubleClick.TreeViewDoubleClick;
            ContactDoubleClick.CommandParameter = WindowOpenMode.EditContact;

        }
Esempio n. 3
0
        public void AddMouseBinding(string target, MouseBinding mb)
        {
            var commandbinding = BindingOperations.GetBinding(mb, InputBinding.CommandProperty);
            var parameterbinding = BindingOperations.GetBinding(mb, InputBinding.CommandParameterProperty);

            var source = "datacontext";

            string cb, sb;
            if (!ConvertBinding(commandbinding, source, out cb))
            {
                Log.Warning("binding has not Command set.");
                return;
            }

            ConvertBinding(parameterbinding, source, out sb);

            string js = "new MouseBinding(" + target + ", " + ConvertMouseAction(mb.MouseAction) + ", " + cb + ", " + sb + ");";
            _writer.WriteLine(js);
        }
Esempio n. 4
0
 public Hotkeys(MainWindow parentwindow, ProgramSettings settings)
 {
     programSettings = settings;
     parent = parentwindow;
     InitializeComponent();
     rightClickGesture.MouseAction = MouseAction.RightClick;
     MouseBinding rightClickBinding = new MouseBinding();
     RoutedCommand rightClickCmd = new RoutedCommand();
     rightClickBinding.Gesture = rightClickGesture;
     rightClickBinding.Command = rightClickCmd;
     CommandBinding rightClickCmdBinding = new CommandBinding();
     rightClickCmdBinding.Command = rightClickCmd;
     rightClickCmdBinding.Executed += Button_RightClick;
     Uri uri = new Uri("pack://application:,,,/B_32x32.ico", UriKind.RelativeOrAbsolute);
     this.Icon = BitmapFrame.Create(uri);
     for (int i = 0; i < programSettings.NumHotKeys; i++)
     {
         Button btn = new Button();
         btn.Name = "btn" + i.ToString();
         btn.Click += Button_Click;
         btn.Width = 56;
         btn.InputBindings.Add(rightClickBinding);
         btn.CommandBindings.Add(rightClickCmdBinding);
         pnlButtons.Children.Add(btn);
         if (programSettings.HotkeyCommands.Count <= i)
         {
             Alias alias = new Alias();
             alias.Keyword = "(None)";
             btn.Content = "(none)";
             alias.Expansion = String.Empty;
             programSettings.HotkeyCommands.Add(alias);
         }
         else
         {
             btn.Content = programSettings.HotkeyCommands[i].Keyword;
         }
     }
 }
Esempio n. 5
0
        private static void OnMouseActionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MouseBinding mouseBinding = (MouseBinding)d;

            mouseBinding.SynchronizeGestureFromProperties((MouseAction)(e.NewValue));
        }
 public void AddMouseBinding(IControlConverter target, MouseBinding mb)
 {
     new BindingConverter(CodeBuilder).AddMouseBinding(target.ID, mb);
 }
Esempio n. 7
0
        /// <summary>
        /// Initialize hotkeys and mouse actions
        /// </summary>
        private void InitHotkeys()
        {
            KeyGesture key_gesture = null;
            MouseGesture mouse_gesture = null;
            InputBinding bind = null;

            CommandBindings.Add(new CommandBinding(back_command, GoBack));
            key_gesture = new KeyGesture(Key.Escape, ModifierKeys.None);
            mouse_gesture = new MouseGesture(MouseAction.RightClick);

            bind = new KeyBinding(back_command, key_gesture);
            InputBindings.Add(bind);

            bind = new MouseBinding(back_command, mouse_gesture);
            InputBindings.Add(bind);

            CommandBindings.Add(new CommandBinding(upscroll_command, RightScroll));
            key_gesture = new KeyGesture(Key.Left);
            bind = new KeyBinding(upscroll_command, key_gesture);
            InputBindings.Add(bind);

            CommandBindings.Add(new CommandBinding(downscroll_command, LeftScroll));
            key_gesture = new KeyGesture(Key.Right);
            bind = new KeyBinding(downscroll_command, key_gesture);
            InputBindings.Add(bind);

            CommandBindings.Add(new CommandBinding(fullscreen_command, SetFullscreen));
            key_gesture = new KeyGesture(Key.F12);
            bind = new KeyBinding(fullscreen_command, key_gesture);
            InputBindings.Add(bind);
        }