Ejemplo n.º 1
0
        private async void Loop()
        {
            while (HiddenWindows.ContainsKey(Window) && Window.Exists)
            {
                await Task.Delay(100);

                if (!State && PreviewArea.Contains(Mouse.Position) && Window.IsOnCurrentDesktop)
                {
                    if (Window.HasAnimation())
                    {
                        Window.StopAnimation();
                        Window.Move(HiddenArea);
                        Window.SetOpacity(0);
                        await Task.Yield();
                    }

                    PreviewShow();
                    bool flick = await WaitForFlick();

                    if (flick)
                    {
                        Show();
                    }
                    else
                    {
                        PreviewHide();
                    }
                    await WaitForLeave();
                }
                else if (State && (!ActiveArea.Contains(Mouse.Position) || !Window.IsOnCurrentDesktop))
                {
                    Hide();
                }
            }

            Program.OnExit -= Deactivate;
            if (noCleanup)
            {
                return;
            }
            if (!Window.Exists)
            {
                return;
            }
            if (!IsAlwaysOnTop)
            {
                Window.SetAlwaysOnTop(false);
            }
            Show();
        }
Ejemplo n.º 2
0
        public async Task <bool> WaitForFlick()
        {
            var watch = Stopwatch.StartNew();

            while (watch.ElapsedMilliseconds < previewDelay)
            {
                await Task.Delay(10);

                if (!PeekArea.Contains(Mouse.Position))
                {
                    return(watch.ElapsedMilliseconds < flickDelay && ActiveArea.Contains(Mouse.Position));
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            try {
                if (!_touchDown)
                {
                    var touch = touches.ToArray <UITouch> ()[0];
                    if (ActiveArea.Contains(touch.LocationInView(this)))
                    {
                        _touchDown = true;

                        if (!CanCommand())
                        {
                            if (Def != null && Def.ComponentType == LcarsComponentType.Gray)
                            {
                                Sounds.PlayNotActive();
                            }
                            return;
                        }

                        var prevState = _selState;

                        if (prevState == LcarsComp.SelectionState.NotSelected)
                        {
                            if (_def.NeedsDoubleTap)
                            {
                                _selState = LcarsComp.SelectionState.Pending;
                                NSTimer.CreateScheduledTimer(ConfirmWait, delegate {
                                    _selState = LcarsComp.SelectionState.NotSelected;
                                    OnModelChanged();
                                });
                            }
                            else
                            {
                                _selState = LcarsComp.SelectionState.Selected;
                            }
                        }
                        else
                        {
                            _selState = LcarsComp.SelectionState.Selected;
                        }

                        if (_selState == LcarsComp.SelectionState.Pending)
                        {
                            Sounds.PlayPendingCommand();
                        }
                        else
                        {
                            if (prevState == LcarsComp.SelectionState.Pending)
                            {
                                Sounds.PlayConfirmPendingCommand();
                            }
                            else
                            {
                                PlayConfirmCommand();
                            }
                        }

                        OnModelChanged();
                    }
                }
            } catch (Exception error) {
                Log.Error(error);
            }
        }