Ejemplo n.º 1
0
        /*
         * static void HandleMouseUpOnSlider(Action<double, double> updateEdgesInZoomRange, MouseButtonEventArgs mouseButtonEventArgs, Slider slider) {
         *  mouseButtonEventArgs.Handled = true;
         *  updateEdgesInZoomRange(slider.SelectionStart, slider.SelectionEnd);
         * }
         */
        /*
         * void UpdateThumbOnDrag(Slider slider, double del, Thumb  draggedThumb) {
         *   var currentPosition = Canvas.GetLeft(draggedThumb);
         *   var newPos = currentPosition + del;
         *   if (newPos < 0)
         *       newPos = 0;
         *   else if (newPos > slider.Width)
         *       newPos = slider.Width-draggedThumb.Width;
         *   Canvas.SetLeft(draggedThumb,newPos);
         *   var k = (slider.Maximum - slider.Minimum) / (slider.Width - draggedThumb.Width);
         *
         *   if (del != 0 && Keyboard.Modifiers == ModifierKeys.Control) {
         *       slider.Value += del*k;
         *       return;
         *   }
         *
         *   var thumbVal = k*Canvas.GetLeft(draggedThumb) + slider.Minimum;
         *   slider.SelectionStart = Math.Min(thumbVal, slider.Value);
         *   slider.SelectionEnd = Math.Max(thumbVal, slider.Value);
         *   UpdateEdgesInZoomRange(slider.SelectionStart, slider.SelectionEnd);
         * }
         */



//        void slider_MouseWheel(object sender, MouseWheelEventArgs e) {
//            double scale = e.Delta > 0 ? 1.1 : 0.9;
//            var slider = (Slider) sender;
//            var m = (slider.SelectionEnd + slider.SelectionStart)/2;
//            var w = (slider.SelectionEnd - slider.SelectionStart)/2*scale;
//            slider.SelectionStart = m - w;
//            slider.SelectionEnd = m + w;
//        }


        void SetCommands()
        {
            appWindow.CommandBindings.Add(new CommandBinding(SaveImageCommand, SaveImage));
            appWindow.CommandBindings.Add(new CommandBinding(SaveMsaglCommand, SaveMsagl));
            appWindow.CommandBindings.Add(new CommandBinding(ExitCommand, ExitHandler));
            appWindow.CommandBindings.Add(new CommandBinding(OpenFileCommand, OpenFile));
            appWindow.CommandBindings.Add(new CommandBinding(CancelLayoutCommand,
                                                             (a, b) => { graphViewer.CancelToken.Canceled = true; }));
            appWindow.CommandBindings.Add(new CommandBinding(ReloadCommand, ReloadFile));
            appWindow.CommandBindings.Add(new CommandBinding(HomeViewCommand, (a, b) => graphViewer.SetInitialTransform()));
            appWindow.InputBindings.Add(new InputBinding(OpenFileCommand, new KeyGesture(Key.O, ModifierKeys.Control)));
            appWindow.InputBindings.Add(new InputBinding(ReloadCommand, new KeyGesture(Key.F5)));
            appWindow.InputBindings.Add(new InputBinding(HomeViewCommand, new KeyGesture(Key.H, ModifierKeys.Control)));
            appWindow.InputBindings.Add(new InputBinding(CancelLayoutCommand, new KeyGesture(Key.C, ModifierKeys.Control)));
            appWindow.InputBindings.Add(new InputBinding(ExitCommand, new KeyGesture(Key.F4, ModifierKeys.Alt)));



            appWindow.InputBindings.Add(new InputBinding(ScaleNodeDownCommand, new KeyGesture(Key.S, ModifierKeys.Control)));
            //  appWindow.CommandBindings.Add(new CommandBinding(ScaleNodeDownCommand, ScaleNodeDownTest));
            appWindow.CommandBindings.Add(new CommandBinding(ScaleNodeDownCommand, ScaleNodeUpTest));
            appWindow.InputBindings.Add(new InputBinding(ScaleNodeUpCommand, new KeyGesture(Key.S, ModifierKeys.Control | ModifierKeys.Shift)));
        }
 void SetupCommands()
 {
     appWindow.CommandBindings.Add(new CommandBinding(LoadSampleGraphCommand, CreateAndLayoutAndDisplayGraph));
     appWindow.CommandBindings.Add(new CommandBinding(HomeViewCommand, (a, b) => graphViewer.SetInitialTransform()));
     appWindow.InputBindings.Add(new InputBinding(LoadSampleGraphCommand, new KeyGesture(Key.L, ModifierKeys.Control)));
     appWindow.InputBindings.Add(new InputBinding(HomeViewCommand, new KeyGesture(Key.H, ModifierKeys.Control)));
 }