示例#1
0
 private void TimeOfMatches()
 {
     Device.StartTimer(TimeSpan.FromMilliseconds(300), () =>
     {
         _viewModel.TimeCounter.MatchesTime(_viewModel);
         return(true);
     });
 }
 /// <inheritdoc />
 protected override void OnStart()
 {
     base.OnStart();
     if (Device.RuntimePlatform == Device.Windows)
     {
         Device.StartTimer(
             TimeSpan.FromSeconds(3),
             () =>
         {
             m_dialogs.Alert(
                 "");
             return(false);
         });
     }
 }
示例#3
0
 /// <inheritdoc />
 protected override void OnStart()
 {
     base.OnStart();
     if (Device.RuntimePlatform == Device.Windows)
     {
         Device.StartTimer(
             TimeSpan.FromSeconds(3),
             () =>
         {
             m_dialogs.Alert(
                 "The UWP API can listen for advertisements but is not yet able to connect to devices.",
                 "Quick Note",
                 "Aww, ok");
             return(false);
         });
     }
 }
示例#4
0
        private async Task StartStopwatch()
        {
            Stopwatch stopwatch = new Stopwatch();

            CanShowStopwatchPopup = true;
            Device.StartTimer(
                TimeSpan.FromSeconds(1), () =>
            {
                stopwatch.Start();
                if (CanShowStopwatchPopup)
                {
                    int elapsedSec = (int)stopwatch.ElapsedMilliseconds / 1000 % 60;
                    int elapsedMin = (int)stopwatch.ElapsedMilliseconds / 1000 / 60;
                    StopwatchTime  = "Elapsed Time\n" + elapsedMin + "m " + elapsedSec + "s";
                    return(true);
                }
                stopwatch.Reset();
                return(false);
            });
            await Task.Delay(100);
        }
示例#5
0
        /// <inheritdoc />
        protected override void OnStart()
        {
            base.OnStart();
#if RELEASE
            MobileCenter.Start(
                "ios=6b6689d5-0d94-476a-a632-81145dde8706;android=56864a4d-0dc3-4ab8-819b-bb5d412ba595",
                typeof(Analytics),
                typeof(Crashes));
#endif
            if (Device.RuntimePlatform == Device.Windows)
            {
                Device.StartTimer(
                    TimeSpan.FromSeconds(1),
                    () =>
                {
                    m_dialogs.Alert(
                        "The UWP API can listen for advertisements but is not yet able to connect to devices.",
                        "Quick Note",
                        "Aww, ok");
                    return(false);
                });
            }
        }
示例#6
0
 private void StartSponsors()
 {
     Device.StartTimer(TimeSpan.FromMilliseconds(10000), () =>
     {
         if (_viewModel.Sponsors != null && _viewModel.Sponsors.Count > 0)
         {
             var tempList = new ObservableCollection <Sponsor>(_viewModel.Sponsors);
             var item     = tempList.FirstOrDefault();
             tempList.Remove(item);
             tempList.Add(item);
             _viewModel.Sponsors = new ObservableCollection <Sponsor>(tempList);
         }
         if (_viewModel.AllMainSponsors != null && _viewModel.AllMainSponsors.Count > 0)
         {
             var tempList = new ObservableCollection <Sponsor>(_viewModel.AllMainSponsors);
             var item     = tempList.FirstOrDefault();
             tempList.Remove(item);
             tempList.Add(item);
             _viewModel.AllMainSponsors = new ObservableCollection <Sponsor>(tempList);
             _viewModel.SponsorsMain    = new ObservableCollection <Sponsor>(tempList.Take(2));
         }
         return(true);
     });
 }
        private void SkCanvasView_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e)
        {
            try
            {
                var x = (int)(e.Location.X / scale.Width);
                var y = (int)(e.Location.Y / scale.Height);

                Console.WriteLine(Extensions.ToJSON(e, Formatting.None));
                XplatUIMine.PaintPending = true;

                if (e.ActionType == SKTouchAction.Moved)
                {
                    if (touchDictionary.ContainsKey(e.Id))
                    {
                        if (Math.Abs(touchDictionary[e.Id].atdown.Location.X / scale.Width - x) > 5 &&
                            Math.Abs(touchDictionary[e.Id].atdown.Location.Y / scale.Height - y) > 5)
                        {
                            //Console.WriteLine("Mouse has moved");
                            touchDictionary[e.Id].hasmoved = true;
                        }

                        touchDictionary[e.Id].prev = touchDictionary[e.Id].now;
                        touchDictionary[e.Id].now  = e;
                    }

                    if (touchDictionary.Count >= 2)
                    {
                        // Copy two dictionary keys into array
                        long[] keys = new long[touchDictionary.Count];
                        touchDictionary.Keys.CopyTo(keys, 0);

                        // Find index non-moving (pivot) finger
                        int pivotIndex = (keys[0] == e.Id) ? 1 : 0;

                        // Get the three points in the transform
                        SKPoint pivotPoint = touchDictionary[keys[pivotIndex]].atdown.Location;
                        SKPoint prevPoint  = touchDictionary[e.Id].atdown.Location;
                        SKPoint newPoint   = e.Location;

                        // Calculate two vectors
                        SKPoint oldVector = prevPoint - pivotPoint;
                        SKPoint newVector = newPoint - pivotPoint;

                        SKPoint center = (pivotPoint + prevPoint);
                        center.X /= 2;
                        center.Y /= 2;

                        // Find angles from pivot point to touch points
                        float oldAngle = (float)Math.Atan2(oldVector.Y, oldVector.X);
                        float newAngle = (float)Math.Atan2(newVector.Y, newVector.X);

                        float scale1 = Magnitude(newVector) / Magnitude(oldVector);

                        if (!float.IsNaN(scale1) && !float.IsInfinity(scale1))
                        {
                            //var centre = pivotPoint;
                            x = (int)(center.X / scale.Width);
                            y = (int)(center.Y / scale.Height);

                            Console.WriteLine("scale: {0} {1} {2}", scale, newVector.Length, oldVector.Length);
                            if (scale1 >= 2)
                            {
                                XplatUI.driver.SendMessage(IntPtr.Zero, Msg.WM_MOUSEWHEEL,
                                                           new IntPtr((int)(1) << 16),
                                                           (IntPtr)((y) << 16 | (x)));
                                touchDictionary[e.Id].atdown = e;
                            }

                            if (scale1 <= 0.5)
                            {
                                XplatUI.driver.SendMessage(IntPtr.Zero, Msg.WM_MOUSEWHEEL,
                                                           new IntPtr((int)(-1) << 16),
                                                           (IntPtr)((y) << 16 | (x)));
                                touchDictionary[e.Id].atdown = e;
                            }
                        }

                        e.Handled = true;
                        return;
                    }

                    if (e.InContact)
                    {
                        XplatUI.driver.SendMessage(IntPtr.Zero, Msg.WM_MOUSEMOVE,
                                                   new IntPtr((int)MsgButtons.MK_LBUTTON),
                                                   (IntPtr)((y) << 16 | (x)));
                    }
                    else
                    {
                        XplatUI.driver.SendMessage(IntPtr.Zero, Msg.WM_MOUSEMOVE, new IntPtr(),
                                                   (IntPtr)((y) << 16 | (x)));
                    }
                }

                if (e.ActionType == SKTouchAction.Pressed && e.MouseButton == SKMouseButton.Left)
                {
                    var now = DateTime.Now;
                    touchDictionary.Add(e.Id, new TouchInfo()
                    {
                        now = e, prev = e, DownTime = now, atdown = e
                    });

                    // right click handler
                    Device.StartTimer(TimeSpan.FromMilliseconds(1000), () =>
                    {
                        /*
                         * Console.WriteLine("Mouse rightclick check true={0} 1={1} {2} {3} {4}",
                         *  touchDictionary.ContainsKey(e.Id),
                         *  touchDictionary.Count,
                         *  touchDictionary.ContainsKey(e.Id) ? touchDictionary[e.Id] : null, now, DateTime.Now);
                         */
                        if (touchDictionary.ContainsKey(e.Id) && touchDictionary.Count == 1)
                        {
                            if (!touchDictionary[e.Id].hasmoved && touchDictionary[e.Id].DownTime == now)
                            {
                                touchDictionary[e.Id].wasright = true;
                                XplatUI.driver.SendMessage(IntPtr.Zero, Msg.WM_RBUTTONDOWN,
                                                           new IntPtr((int)MsgButtons.MK_RBUTTON), (IntPtr)((y) << 16 | (x)));
                                XplatUI.driver.SendMessage(IntPtr.Zero, Msg.WM_RBUTTONUP,
                                                           new IntPtr((int)MsgButtons.MK_RBUTTON), (IntPtr)((y) << 16 | (x)));
                                touchDictionary.Remove(e.Id);
                                return(false);
                            }
                        }
                        return(false);
                    });

                    XplatUI.driver.SendMessage(IntPtr.Zero, Msg.WM_MOUSEMOVE, new IntPtr(), (IntPtr)((y) << 16 | (x)));

                    if (LastPressed.AddMilliseconds(500) > DateTime.Now && Math.Abs(LastPressedX - x) < 20 &&
                        Math.Abs(LastPressedY - y) < 20)
                    {
                        XplatUI.driver.SendMessage(IntPtr.Zero, Msg.WM_LBUTTONDBLCLK, new IntPtr((int)MsgButtons.MK_LBUTTON),
                                                   (IntPtr)((y) << 16 | (x)));
                        LastPressed = DateTime.MinValue;
                    }
                    else
                    {
                        XplatUI.driver.SendMessage(IntPtr.Zero, Msg.WM_LBUTTONDOWN,
                                                   new IntPtr((int)MsgButtons.MK_LBUTTON), (IntPtr)((y) << 16 | (x)));
                    }
                }

                if (e.ActionType == SKTouchAction.Released && e.MouseButton == SKMouseButton.Left)
                {
                    if (touchDictionary.ContainsKey(e.Id) && touchDictionary[e.Id].wasright)
                    {
                        // no action here
                    }
                    else
                    {
                        // only up if we have seen the down
                        if (touchDictionary.ContainsKey(e.Id))
                        {
                            XplatUI.driver.SendMessage(IntPtr.Zero, Msg.WM_LBUTTONUP,
                                                       new IntPtr((int)MsgButtons.MK_LBUTTON), (IntPtr)((y) << 16 | (x)));
                        }
                    }

                    LastPressed  = DateTime.Now;
                    LastPressedX = x;
                    LastPressedY = y;
                    touchDictionary.Remove(e.Id);
                }

                if (e.ActionType == SKTouchAction.Entered)
                {
                    XplatUI.driver.SendMessage(IntPtr.Zero, Msg.WM_MOUSEMOVE, new IntPtr(), (IntPtr)((y) << 16 | (x)));
                    touchDictionary.Clear();
                }

                if (e.ActionType == SKTouchAction.Cancelled)
                {
                    touchDictionary.Clear();
                }

                if (e.ActionType == SKTouchAction.Exited)
                {
                    XplatUI.driver.SendMessage(IntPtr.Zero, Msg.WM_MOUSEMOVE, new IntPtr(), (IntPtr)((y) << 16 | (x)));
                    touchDictionary.Clear();
                }

                e.Handled = true;
            } catch {}
        }