Пример #1
0
 public void enableLink(SymLink link)
 {
     MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(
         delegate(object sender, System.Windows.Input.MouseButtonEventArgs args)
     {
         try
         {
             NavigateTo(link.filename, link.line, link.column);
         }
         catch { }
     });
     MouseEnter += new System.Windows.Input.MouseEventHandler(
         delegate(object sender, System.Windows.Input.MouseEventArgs args)
     {
         TextDecorations.Add(System.Windows.TextDecorations.Underline);
     });
     MouseLeave += new System.Windows.Input.MouseEventHandler(
         delegate(object sender, System.Windows.Input.MouseEventArgs args)
     {
         foreach (var td in System.Windows.TextDecorations.Underline)
         {
             TextDecorations.Remove(td);
         }
     });
 }
        /// <summary>
        /// Helper for adding mouse events
        /// </summary>
        /// <param name="view">The view to listen for events on.</param>
        /// <param name="onMove">Action when the mouse moves.</param>
        /// <param name="onTapped">Action when the view is tapped.</param>
        /// <param name="onDoubleTapped">Action when the view is double tapped.</param>
        /// <returns>An Action that cleans up all the event handlers.</returns>
        private static Action SetUpHandlers(SceneView view, Action <MapPoint> onMove, Action <MapPoint> onTapped, Action <MapPoint> onDoubleTapped)
        {
#if NETFX_CORE
            Windows.UI.Xaml.Input.PointerEventHandler movehandler = null;
#else
            System.Windows.Input.MouseEventHandler movehandler = null;
#endif

            if (onMove != null)
            {
#if NETFX_CORE
                movehandler        = (s, e) => onMove(view.ScreenToLocation(e.GetCurrentPoint(view).Position));
                view.PointerMoved += movehandler;
#else
                movehandler     = (s, e) => onMove(view.ScreenToLocation(e.GetPosition(view)));
                view.MouseMove += movehandler;
#endif
            }
            EventHandler <MapViewInputEventArgs> tappedHandler = null;
            if (onTapped != null)
            {
                tappedHandler         = (s, e) => onTapped(e.Location);
                view.SceneViewTapped += tappedHandler;
            }
            EventHandler <MapViewInputEventArgs> doubletappedHandler = null;
            if (onDoubleTapped != null)
            {
                doubletappedHandler         = (s, e) => { e.Handled = true; onDoubleTapped(e.Location); };
                view.SceneViewDoubleTapped += doubletappedHandler;
            }
            Action cleanup = () =>
            {
                if (movehandler != null)
#if NETFX_CORE
                { view.PointerMoved -= movehandler; }
#else
                { view.MouseMove -= movehandler; }
#endif
                if (tappedHandler != null)
                {
                    view.SceneViewTapped -= tappedHandler;
                }
                if (doubletappedHandler != null)
                {
                    view.SceneViewDoubleTapped -= doubletappedHandler;
                }
            };
            return(cleanup);
        }
Пример #3
0
 public void enableLink()
 {
     MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(
         delegate(object sender, System.Windows.Input.MouseButtonEventArgs args)
     {
         // Text = "clicked!";
     });
     MouseEnter += new System.Windows.Input.MouseEventHandler(
         delegate(object sender, System.Windows.Input.MouseEventArgs args)
     {
         TextDecorations.Add(System.Windows.TextDecorations.Underline);
     });
     MouseLeave += new System.Windows.Input.MouseEventHandler(
         delegate(object sender, System.Windows.Input.MouseEventArgs args)
     {
         foreach (var td in System.Windows.TextDecorations.Underline)
         {
             TextDecorations.Remove(td);
         }
     });
 }
Пример #4
0
        void SliderPanel_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (!isMouseDown)
                return;
            isMouseDown = false;
            try
            {
                MouseMove -= new System.Windows.Input.MouseEventHandler(SliderPanel_MouseMove);

                mouseFinal = e.GetPosition(this);
                ReleaseMouseCapture();

                if ((mouseFinal.X - mouseFirst.X) > 0)
                {
                    if (Math.Abs(mouseFinal.X - mouseFirst.X) > 50)
                        Counter = Counter + 1;
                }
                else
                {
                    if (Math.Abs(mouseFinal.X - mouseFirst.X) > 50)
                        Counter = Counter - 1;
                }

                double pTo, pFrom;

                pTo = Counter * (finalWidth + span) + 2 * span;
                pFrom = (mouseFinal.X - mouseFirst.X) > 0 ? (pTo - finalWidth) + (mouseFinal.X - mouseFirst.X) : (pTo + finalWidth) + (mouseFinal.X - mouseFirst.X);

                if (Math.Abs(mouseFinal.X - mouseFirst.X) < 50)
                    pFrom = pTo + (mouseFinal.X - mouseFirst.X);

                if (Counter > 0)
                {
                    pTo = (Counter - 1) * finalWidth + 2 * span;
                    Counter = Counter - 1;
                }
                else if (Counter <= Children.Count * -1)
                {
                    pTo = (Counter + 1) * finalWidth;
                    Counter = Counter + 1;
                }


                for (int i = 0; i < Children.Count; i++)
                {
                    DoubleAnimation da = new DoubleAnimation(pFrom, pTo, new Duration(TimeSpan.FromSeconds(Duration)));
                    ((TranslateTransform)Children[i].RenderTransform).BeginAnimation(TranslateTransform.XProperty, da);
                }

                SelectedIndex = Math.Abs(Counter);
            }
            catch { }
        }
Пример #5
0
        void SliderPanel_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            isMouseDown = true;
            CaptureMouse();

            mouseStart = e.GetPosition(this);
            mouseNow = mouseStart;
            mouseFirst = mouseStart;

            MouseMove -= new System.Windows.Input.MouseEventHandler(SliderPanel_MouseMove);
            MouseMove += new System.Windows.Input.MouseEventHandler(SliderPanel_MouseMove);
        }