Esempio n. 1
0
        void OnOwnerManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            ISimpleManupulationSupport sms = this.owner as ISimpleManupulationSupport;

            if (sms != null)
            {
                double sx   = 1.0 + (e.DeltaManipulation.Scale.X - 1.0) / 1.0;
                double sy   = 1.0 + (e.DeltaManipulation.Scale.Y - 1.0) / 1.0;
                double prec = 0.0005;
                bool   b1   = Math.Abs(sx - 1.0) <= prec;
                bool   b2   = Math.Abs(sy - 1.0) <= prec;
                if (!b1 || !b2)
                {
                    sms.ScaleBy(sx, false);
                }
                else
                {
                    sms.ScrollBy(-e.DeltaManipulation.Translation.X, -e.DeltaManipulation.Translation.Y, false);
                }
            }
            e.Handled = true;
        }
Esempio n. 2
0
 void OnOwnerMouseWheel(object sender, MouseWheelEventArgs e)
 {
     if ((Keyboard.Modifiers & ModifierKeys.Control) == 0)
     {
         e.Handled = true;
         ISimpleManupulationSupport sms = this.owner as ISimpleManupulationSupport;
         if (sms != null)
         {
             RenderScrollViewer rsv = this.owner as RenderScrollViewer;
             if (rsv == null)
             {
                 return;
             }
             bool   vScroll = rsv.ComputedVerticalScrollBarVisibility == Visibility.Visible;
             bool   hScroll = rsv.ComputedHorizontalScrollBarVisibility == Visibility.Visible;
             double delta   = -e.Delta * 1.0;
             if (vScroll)
             {
                 sms.ScrollBy(0, delta, true);
             }
             else if (hScroll)
             {
                 sms.ScrollBy(delta, 0, true);
             }
         }
     }
     else
     {
         e.Handled = true;
         ISimpleManupulationSupport sms = this.owner as ISimpleManupulationSupport;
         if (sms != null)
         {
             sms.ScaleBy((double)e.Delta, true);
         }
     }
 }