Exemplo n.º 1
0
        void SetupRecoverDialogGestures()
        {
            var gestureListener = GestureService.GetGestureListener(RecoverDialog);

            gestureListener.DragDelta     += RecoverDiag_DragDelta;
            gestureListener.DragCompleted += RecoverDiag_DragEnd;
        }
    public MyControl()
    {
        InitializeComponent();
        var gl = GestureService.GetGestureListener(asd);

        gl.Flick += new EventHandler <FlickGestureEventArgs>(GestureListener_Flick);
    }
Exemplo n.º 3
0
        void CreateGameGrid()
        {
            currentTime = new TimeSpan(0, 0, 0);
            //Settings.Grid.Clear();

            gameGrid                    = new GameGrid();
            gameGrid.NextLevel         += new EventHandler(gameGrid_NextLevel);
            gameGrid.EndGame           += new EventHandler(gameGrid_EndGame);
            gameGrid.ManipulationDelta += new EventHandler <ManipulationDeltaEventArgs>(gameGrid_ManipulationDelta);
            var gl = GestureService.GetGestureListener(gameGrid);

            //gl.PinchStarted += new EventHandler<PinchStartedGestureEventArgs>(gl_PinchStarted);
            //gl.PinchDelta += new EventHandler<PinchGestureEventArgs>(gl_PinchDelta);
            gl.DoubleTap            += new EventHandler <Microsoft.Phone.Controls.GestureEventArgs>(gl_DoubleTap);
            scale                    = new ScaleTransform();
            scale.ScaleX             = 1.0;
            scale.ScaleY             = 1.0;
            gameGrid.RenderTransform = scale;

            ContentPanel.Children.Add(gameGrid);

            tbTime.Text = String.Format("{0:D2}:{1:D2}", Settings.GameTime.Minutes, Settings.GameTime.Seconds);
            myDispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            myDispatcherTimer.Tick    += new EventHandler(Each_Tick);
            myDispatcherTimer.Start();
        }
Exemplo n.º 4
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            _propertyInfos = typeof(Survelem).GetProperties().ToList();

            gestureListener        = GestureService.GetGestureListener(this);
            gestureListener.Flick += this.GlFlick;

            if (e.NavigationMode == NavigationMode.Back)
            {
                return;
            }



            cmb1.SelectionChanged += cmb1_SelectionChanged;

            _questions = StateService.CurrentQuestionGroup.Questions;


            if (_questions == null)
            {
                return;
            }

            _currentQuestion = _questions.First();

            tb1ForCmb1.TextChanged += tb1ForCmb1_TextChanged;

            await LoadQuestionData();
        }
Exemplo n.º 5
0
        static int setSwipeListener(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.UserData, LConst.Function))
            {
                return(0);
            }

            Object control   = Lua.Lua_touserdata(L, 2);
            int    callbackF = Lua.LuaL_ref(L, Lua._LUA_REGISTRYINDEX);

            if (control != null && callbackF != 0)
            {
                var pi = control.GetType().GetProperty("View_");
                var fe = pi.GetValue(control, null);

                if (EventsList.Any(c => (c.FE == fe as FrameworkElement) && c.EventsName.Equals("setSwipeListener")))
                {
                    ClearLastUselessEvents(fe as FrameworkElement, "setSwipeListener");
                }

                var lisenter = GestureService.GetGestureListener(fe as FrameworkElement);
                EventHandler <Microsoft.Phone.Controls.FlickGestureEventArgs> FlickGestureHandler = null;
                lisenter.Flick += FlickGestureHandler = (s, e) =>
                {
                    Dictionary <string, object> dict = new Dictionary <string, object>();
                    string value = string.Empty;
                    if (e.Direction == Orientation.Horizontal)
                    {
                        if (e.HorizontalVelocity > 0)
                        {
                            value = "right";
                        }
                        else
                        {
                            value = "left";
                        }
                    }
                    else if (e.Direction == Orientation.Vertical)
                    {
                        if (e.VerticalVelocity > 0)
                        {
                            value = "down";
                        }
                        else
                        {
                            value = "up";
                        }
                    }
                    dict.Add("direction", value);

                    LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithAnyParams(callbackF, dict, control);
                };

                EventsList.Add(new GestureEventRegisterInfo()
                {
                    FE = fe as FrameworkElement, EventsName = "setSwipeListener", FlickGestureEventHandler = FlickGestureHandler
                });
            }
            return(0);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets all the template parts and initializes the corresponding state.
        /// </summary>
        public override void OnApplyTemplate()
        {
            if (_track != null)
            {
                _track.SizeChanged -= SizeChangedHandler;
            }
            if (_thumb != null)
            {
                _thumb.SizeChanged -= SizeChangedHandler;
            }
            base.OnApplyTemplate();
            _root = GetTemplateChild(SwitchRootPart) as Grid;
            UIElement background = GetTemplateChild(SwitchBackgroundPart) as UIElement;

            _backgroundTranslation = background == null ? null : background.RenderTransform as TranslateTransform;
            _track            = GetTemplateChild(SwitchTrackPart) as Grid;
            _thumb            = GetTemplateChild(SwitchThumbPart) as Border;
            _thumbTranslation = _thumb == null ? null : _thumb.RenderTransform as TranslateTransform;
            if (_root != null && _track != null && _thumb != null && (_backgroundTranslation != null || _thumbTranslation != null))
            {
                GestureListener gestureListener = GestureService.GetGestureListener(_root);
                gestureListener.DragStarted   += DragStartedHandler;
                gestureListener.DragDelta     += DragDeltaHandler;
                gestureListener.DragCompleted += DragCompletedHandler;
                _track.SizeChanged            += SizeChangedHandler;
                _thumb.SizeChanged            += SizeChangedHandler;
            }
            ChangeVisualState(false);
        }
            public GestureListenerBehavioursBehaviour(Control element)
            {
                var gestureListener = GestureService.GetGestureListener(element);

                gestureListener.Tap       += TapCalled;
                gestureListener.DoubleTap += DoubleTapCalled;
                //element.MouseEnter += new MouseEventHandler(MouseIsOverChanged);
            }
 /// <summary>
 /// Create a new LoopingSelectorItem.
 /// </summary>
 public LoopingSelectorItem()
 {
     DefaultStyleKey      = typeof(LoopingSelectorItem);
     MouseLeftButtonDown += LoopingSelectorItem_MouseLeftButtonDown;
     MouseLeftButtonUp   += LoopingSelectorItem_MouseLeftButtonUp;
     LostMouseCapture    += LoopingSelectorItem_LostMouseCapture;
     GestureService.GetGestureListener(this).Tap += new EventHandler <GestureEventArgs>(LoopingSelectorItem_Tap);
 }
Exemplo n.º 9
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(MainPage_Loaded);
            var gl = GestureService.GetGestureListener(LayoutRoot);

            gl.Flick     += new EventHandler <FlickGestureEventArgs>(GestureListener_Flick);
            gl.DragDelta += new EventHandler <DragDeltaGestureEventArgs>(GestureListener_DragDelta);
            gl.DoubleTap += new EventHandler <Microsoft.Phone.Controls.GestureEventArgs>(GestureListener_Doubletap);
        }
Exemplo n.º 10
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            _image = GetTemplateChild("ImgZoom") as Image;
            var gl = GestureService.GetGestureListener(_image);

            gl.PinchDelta    += OnPinchDelta;
            gl.PinchStarted  += OnPinchStarted;
            gl.DragDelta     += OnDragDelta;
            _image.DoubleTap += OnDoubleTap;
        }
Exemplo n.º 11
0
        static void ClearLastUselessEvents(FrameworkElement fe, string eventName)
        {
            var lisenter = GestureService.GetGestureListener(fe as FrameworkElement);
            List <GestureEventRegisterInfo> uselessEventsList_ = new List <GestureEventRegisterInfo>();

            foreach (var e in EventsList)
            {
                if (e.FE == fe as FrameworkElement)
                {
                    if (e.EventsName.Equals(eventName))
                    {
                        if (e.EventsName.Equals("setTapListener") && e.TapGestureEventHandler != null)
                        {
                            fe.Tap -= e.TapGestureEventHandler;
                            uselessEventsList_.Add(e);
                        }
                        else if (e.EventsName.Equals("setDoubleTapListener") && e.TapGestureEventHandler != null)
                        {
                            fe.DoubleTap -= e.TapGestureEventHandler;
                            uselessEventsList_.Add(e);
                        }
                        else if (e.EventsName.Equals("setLongTapListener") && e.GestureEventHandler != null)
                        {
                            lisenter.Hold -= e.GestureEventHandler;
                            uselessEventsList_.Add(e);
                        }
                        else if (e.EventsName.Equals("setSwipeListener") && e.FlickGestureEventHandler != null)
                        {
                            lisenter.Flick -= e.FlickGestureEventHandler;
                            uselessEventsList_.Add(e);
                        }
                        else if (e.EventsName.Equals("setDragListener") && e.DragDeltaGestureEventHandler != null)
                        {
                            fe.ManipulationDelta -= e.DragDeltaGestureEventHandler;
                            uselessEventsList_.Add(e);
                        }
                        else if (e.EventsName.Equals("setRotationListener") && e.RotationDeltaEventHandler != null)
                        {
                            fe.ManipulationDelta -= e.RotationDeltaEventHandler;
                            uselessEventsList_.Add(e);
                        }
                        else if (e.EventsName.Equals("setScaleListener") && e.ScaleDeltaEventHandler != null)
                        {
                            fe.ManipulationDelta -= e.ScaleDeltaEventHandler;
                            uselessEventsList_.Add(e);
                        }
                    }
                }
            }
            foreach (var e in uselessEventsList_)
            {
                EventsList.Remove(e);
            }
        }
        public SwipeContentControl()
        {
            this.RenderTransform = new TranslateTransform();

            this.DefaultStyleKey = typeof(ContentControl);

            GestureListener listener = GestureService.GetGestureListener(this);

            listener.DragStarted   += DragStarted;
            listener.DragDelta     += DragDelta;
            listener.DragCompleted += DragCompleted;
        }
        private void CreateEventHandlers()
        {
            SizeChanged += new SizeChangedEventHandler(LoopingSelector_SizeChanged);

            GestureListener listener = GestureService.GetGestureListener(this);

            listener.DragStarted   += new EventHandler <DragStartedGestureEventArgs>(listener_DragStarted);
            listener.DragDelta     += new EventHandler <DragDeltaGestureEventArgs>(listener_DragDelta);
            listener.DragCompleted += new EventHandler <DragCompletedGestureEventArgs>(listener_DragCompleted);
            listener.Flick         += new EventHandler <FlickGestureEventArgs>(listener_Flick);
            listener.Tap           += new EventHandler <GestureEventArgs>(listener_Tap);

            AddHandler(MouseLeftButtonDownEvent, new MouseButtonEventHandler(LoopingSelector_MouseLeftButtonDown), true);
            AddHandler(MouseLeftButtonUpEvent, new MouseButtonEventHandler(LoopingSelector_MouseLeftButtonUp), true);
        }
Exemplo n.º 14
0
        public UCPullToRefreshListBox()
        {
            Application.Current.Resources.Source = new Uri(
                "/PullToRefreshListBox;component/Ressources/Ressources.xaml", UriKind.Relative);
            Style = (Style)Application.Current.Resources["PullToRefreshListBoxStyle2"];

            Loaded += OnLoaded;

            #region GestureListenerConfig

            var gl = GestureService.GetGestureListener(this);
            gl.DragDelta     += GestureListener_OnDragDelta;
            gl.DragCompleted += GestureListener_OnDragCompleted;

            #endregion
        }
        private void AddItem()
        {
            Border b = new Border()
            {
                Width           = 100, Height = 100,
                Background      = new SolidColorBrush(Color.FromArgb(255, (byte)rnd.Next(256), (byte)rnd.Next(256), (byte)rnd.Next(256))),
                BorderThickness = new Thickness(2), Margin = new Thickness(8)
            };

            b.BorderBrush = (SolidColorBrush)Resources["PhoneForegroundBrush"];

            GestureListener listener = GestureService.GetGestureListener(b);

            listener.Tap += new EventHandler <GestureEventArgs>(WrapPanelSample_Tap);

            wrapPanel.Children.Add(b);
        }
Exemplo n.º 16
0
 protected override void OnAttached()
 {
     base.OnAttached();
     AssociatedObject.RenderTransform = new CompositeTransform();
     _listener                = GestureService.GetGestureListener(AssociatedObject);
     _listener.PinchDelta    += OnPinchDelta;
     _listener.PinchStarted  += OnPinchStarted;
     _listener.DragStarted   += OnDragStarted;
     _listener.DragDelta     += OnDragDelta;
     _listener.DragCompleted += OnDragCompleted;
     _listener.Flick         += OnFlick;
     _listener.Tap           += OnTap;
     _listener.DoubleTap     += OnDoubleTap;
     // wait for the RootVisual to be initialized
     //Dispatcher.BeginInvoke(() =>
     //    ((PhoneApplicationFrame)Application.Current.RootVisual).OrientationChanged += OrientationChanged);
 }
Exemplo n.º 17
0
        public ThreadPageSlideView()
        {
            InitializeComponent();

            this._toggleAppBar = ToggleAppBarDummy;

            HideTitleOverlay();
            VisualStateManager.GoToState(this, "Loading", false);

            var gestures = GestureService.GetGestureListener(this.LayoutRoot);

            gestures.DoubleTap += ShowThreadTitle;

            gestures.PinchStarted   += OnLayoutPinchStarted;
            gestures.PinchDelta     += OnLayoutPinchDelta;
            gestures.PinchCompleted += OnLayoutPinchCompleted;

            Loaded   += OnLoad;
            Unloaded += OnUnload;
        }
Exemplo n.º 18
0
        static int setLongTapListener(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.UserData, LConst.Function))
            {
                return(0);
            }

            var control   = Lua.Lua_touserdata(L, 2);
            int callbackF = Lua.LuaL_ref(L, Lua._LUA_REGISTRYINDEX);

            if (control != null && callbackF != 0)
            {
                var pi       = control.GetType().GetProperty("View_");
                var fe       = pi.GetValue(control, null);
                var lisenter = GestureService.GetGestureListener(fe as FrameworkElement);
                if (EventsList.Any(c => (c.FE == fe as FrameworkElement) && c.EventsName.Equals("setLongTapListener")))
                {
                    ClearLastUselessEvents(fe as FrameworkElement, "setLongTapListener");
                }

                EventHandler <System.Windows.Input.GestureEventArgs> holdGestureHandler = null;
                (fe as FrameworkElement).Hold += holdGestureHandler = (s, e) =>
                {
                    e.Handled = true;

                    Point p = e.GetPosition(null);
                    Dictionary <string, object> dict = new Dictionary <string, object>();
                    dict.Add("x", p.X / LuaManager.WidthScale);
                    dict.Add("y", p.Y / LuaManager.HeightScale);
                    LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithAnyParams(callbackF, dict, control);
                };
                EventsList.Add(new GestureEventRegisterInfo()
                {
                    FE = fe as FrameworkElement, EventsName = "setLongTapListener", LongTapGestureEventHandler = holdGestureHandler
                });
            }
            return(0);
        }
Exemplo n.º 19
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var listener = GestureService.GetGestureListener(this);

            listener.PinchStarted += OnPinchStarted;
            listener.PinchDelta   += OnPinchDelta;
            listener.DragDelta    += OnDragDelta;
#endif

            _content = (ContentPresenter)GetTemplateChild("content");
            if (_content.Content == null)
            {
                _content.Content = Content;
            }

            _geometry = new RectangleGeometry();
            Clip      = _geometry;

            SizeChanged += delegate { UpdateGeometry(); };
            UpdateGeometry();
        }
Exemplo n.º 20
0
        private void createElement(GameShape shape, int size, Color color)
        {
            Shape element = null;

            switch (shape)
            {
            case GameShape.Circle:
                element = new Ellipse();
                break;

            case GameShape.Square:
                element = new Rectangle();

                break;

            case GameShape.Traingle:
                element = new Polygon();
                Polygon polygon = element as Polygon;
                /*"90, 0, 0, 50, 90, 10*/
                polygon.Points.Add(new Point(0, size - 10));
                polygon.Points.Add(new Point(size / 2, 0));
                polygon.Points.Add(new Point(size, size - 10));
                break;
            }
            if (element != null)
            {
                element.Width           = size;
                element.Height          = size;
                element.Stroke          = new SolidColorBrush(Colors.Black);
                element.StrokeThickness = 3;
                Canvas.SetTop(element, random.Next(100, (int)gamePanel.Height - 100));
                Canvas.SetLeft(element, random.Next(100, (int)gamePanel.Width - 100));
                element.Fill = new SolidColorBrush(color);
                GestureService.GetGestureListener(element).Flick += cleanObject;
                gamePanel.Children.Add(element);
            }
        }
Exemplo n.º 21
0
        public RouteEditor()
        {
            // remove the navigation visibility.
            // This control is redundant with the multi-touch capabilities of the phone.
            //this.BingMap.NavigationVisibility = System.Windows.Visibility.Collapsed;
            // removes the copyright note
            this.BingMap.CopyrightVisibility = System.Windows.Visibility.Collapsed;
            // removes the Bing logo
            this.BingMap.LogoVisibility = System.Windows.Visibility.Collapsed;
            //this.BingMap.NavigationVisibility = System.Windows.Visibility.Collapsed;

            this.BingMap.Mode = new Microsoft.Phone.Controls.Maps.RoadMode();
            //this.BingMap.MouseDoubleClick += new EventHandler<Microsoft.Phone.Controls.Maps.MapMouseEventArgs>(BingMap_MouseDoubleClick);
            // this.BingMap.MousePan += new EventHandler<Microsoft.Phone.Controls.Maps.MapMouseDragEventArgs>(BingMap_MousePan);
            //this.BingMap.MapZoom += new EventHandler<Microsoft.Phone.Controls.Maps.MapZoomEventArgs>(BingMap_MapZoom);
            //this.BingMap.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(BingMap_MouseLeftButtonUp);

            layer = new Microsoft.Phone.Controls.Maps.MapLayer();
            this.BingMap.Children.Add(layer);

            List <RouteAvoidPair> avoids = new List <RouteAvoidPair>();

            int i             = 0;
            int selectedIndex = 0;

            while (Enum.IsDefined(typeof(MobileSrc.Commuter.Shared.RouteServices.Rest.RouteAvoid), i))
            {
                if ((int)DataContextManager.SelectedRoute.AvoidanceMeasures == i)
                {
                    selectedIndex = i;
                }
                avoids.Add(new RouteAvoidPair((MobileSrc.Commuter.Shared.RouteServices.Rest.RouteAvoid)i));
                i++;
            }

            highwayToggle.ItemsSource   = avoids;
            highwayToggle.SelectedIndex = selectedIndex;

            Binding highwayBinding = new Binding();

            highwayBinding.Source = DataContextManager.SelectedRoute;
            highwayBinding.Path   = new PropertyPath("AvoidanceMeasures");
            highwayBinding.Mode   = BindingMode.TwoWay;

            highwayToggle.SelectionChanged += new SelectionChangedEventHandler(highwayToggle_SelectionChanged);

            if (DataContextManager.SelectedRoute.RoutePoints.Count > 0)
            {
                RenderRoute();
            }
            else
            {
                // We have a new route
                PerformRouting(true);
            }

            if (DataContextManager.SelectedRoute.Name == null)
            {
                DataContextManager.SelectedRoute.Name = "untitled";
                this.Loaded += new RoutedEventHandler(RouteEditor_Loaded);
            }

            wayPointList.ItemsSource = DataContextManager.SelectedRoute.WayPoints;
            nameTextBox.Text         = DataContextManager.SelectedRoute.Name;

            menu = new ContextMenu();
            MenuItem routeMenu = new MenuItem();

            routeMenu.Header = "Route through here...";
            routeMenu.Click += new RoutedEventHandler(routeMenu_Click);

            MenuItem headerMenu = new MenuItem();

            headerMenu.Header      = "Route through...";
            headerMenu.FontSize    = 20;
            headerMenu.IsEnabled   = false;
            headerMenu.FontStretch = FontStretches.UltraExpanded;

            MenuItem customMenu = new MenuItem();

            customMenu.Header    = "Specify Custom Address...";
            customMenu.IsEnabled = true;
            customMenu.Click    += new RoutedEventHandler(customMenu_Click);

            menu.Items.Add(headerMenu);
            menu.Items.Add(new Separator());
            menu.Items.Add(routeMenu);
            menu.Items.Add(customMenu);

            GestureListener listener = GestureService.GetGestureListener(this.BingMap);

            listener.Hold += new EventHandler <GestureEventArgs>(listener_Hold);
        }
Exemplo n.º 22
0
        public void setTapEvent(EventHandler <Microsoft.Phone.Controls.GestureEventArgs> tapEventHandler)
        {
            var gl = GestureService.GetGestureListener(this);

            gl.Tap += tapEventHandler;
        }
        private void DisplayMarkers(double angle)
        {
            augmentedReality.SetDisplaySize(ARGrid.ActualWidth, ARGrid.ActualHeight);
            List <GeoPlacemark> placemarksToShow = augmentedReality.VisiblePlacemarks(angle);

            StackPanel basePanel;
            TextBlock  placeText;
            double     panelWidth = 170, panelHeight = 45;

            ARGrid.Children.Clear();
            ARNavigateGrid.Children.Clear();
            MarkersLayer.Children.Clear();

            try
            {
                if (augmentedReality.Mode == AugmentedPlacemarks.AugmentedMode.Explorer)
                {
                    foreach (GeoPlacemark place in placemarksToShow)
                    {
                        placeText            = new TextBlock();
                        placeText.Text       = place.AdjustedName;
                        placeText.Foreground = new SolidColorBrush(Colors.White);
                        placeText.FontSize   = 22;
                        //placeText.TextWrapping = TextWrapping.Wrap;
                        placeText.TextAlignment = TextAlignment.Left;
                        placeText.Margin        = new Thickness(6, 0, 0, 0);

                        basePanel = new StackPanel
                        {
                            Background = new SolidColorBrush(Colors.Gray),
                            Opacity    = 0.85,
                            Width      = panelWidth,
                            Height     = panelHeight
                        };

                        basePanel.Children.Add(placeText);
                        var gl = GestureService.GetGestureListener(basePanel);
                        gl.Tap += new EventHandler <GestureEventArgs>(TapOnPlacemark);
                        basePanel.DataContext = place;

                        placeText            = new TextBlock();
                        placeText.Margin     = new Thickness(6, -6, 0, 0);
                        placeText.Foreground = new SolidColorBrush(Colors.LightGray);
                        placeText.Text       = String.Format("{0:0} meters away", place.Distance);
                        placeText.FontSize   = 15;
                        //placeText.TextWrapping = TextWrapping.Wrap;
                        placeText.TextAlignment = TextAlignment.Left;

                        basePanel.HorizontalAlignment = HorizontalAlignment.Left;
                        basePanel.VerticalAlignment   = VerticalAlignment.Top;
                        basePanel.Children.Add(placeText);

                        basePanel.Margin = new Thickness(place.DisplayX - (panelWidth / 2), place.DisplayY - (panelHeight / 2), 0, 0);
                        ARGrid.Children.Add(basePanel);

                        MarkersLayer.Children.Add(new Pushpin {
                            Background = new SolidColorBrush(Colors.Blue), Content = place.Name, Location = place.Position
                        });
                    }
                }
            }
            catch (Exception exp) { }
        }