public void BeginInvoke(Action action) {
            if(delay == TimeSpan.Zero) {
                BeginInvokeCore(action);
                return;
            }
#if NETFX_CORE
            DispatcherTimer timer = new DispatcherTimer();
#else
            DispatcherTimer timer = new DispatcherTimer(DispatcherPriority, Dispatcher);
#endif
#if NETFX_CORE
            EventHandler<object> onTimerTick = null;
#else
            EventHandler onTimerTick = null;
#endif
            onTimerTick = (s, e) => {
                timer.Tick -= onTimerTick;
                timer.Stop();
                BeginInvokeCore(action);
            };
            timer.Tick += onTimerTick;
            timer.Interval = delay;
            timer.Start();
        }
示例#2
0
        private void OnPreviewKeyDown(object sender, VirtualKeyCodeEventArgs e)
        {
            _pressed?.Add(e.Key);

            // Reset state after a delay
            _timer?.Start();
        }
        private void ScrollViewer_ViewChanging(object sender, ScrollViewerViewChangingEventArgs e)
        {
            //pull to refresh
            if (isPullToRefreshEnabled)
            {
                if (e.NextView.VerticalOffset == 0)
                {
                    timer?.Start();
                }
                else
                {
                    CompletePullToRefresh();

                    if (canvas.ChildrenTransitions != null && canvas.ChildrenTransitions.Count > 0)
                    {
                        canvas.ChildrenTransitions = null;
                    }
                }
            }

            //recycle
            ScrollItems(e.NextView.VerticalOffset
#if DEBUG
                        , "ViewChanging"
#endif
                        );
        }
        private void OpenFlyout()
        {
            Show();
            timer?.Stop();

            RoutedEventArgs args = new(OpenedEvent);

            RaiseEvent(args);


            if (FlyoutAnimationEnabled)
            {
                c_translation = 40;
                PlayOpenAnimation();
            }
            else
            {
                c_translation   = 0;
                RenderTransform = new TranslateTransform();
                BeginAnimation(VisibilityProperty, null);
                BeginAnimation(OpacityProperty, null);
                Visibility = Visibility.Visible;
                Opacity    = 1.0;
            }

            timer?.Start();
        }
示例#5
0
 private void Main_OnReset(object service, int msg)
 {
     if (config.options.Style.IsPreAlert)
     {
         //达到休息时间时重启预提醒
         preAlertTimer?.Stop();
         preAlertTimer?.Start();
     }
 }
示例#6
0
 private void GoNextEv(object sender, RoutedEventArgs e)
 {
     if (PageNum < MaxPage)
     {
         PageNum++;
         DT?.Start();
     }
     else
     {
         GoNextBtn.Visibility = Visibility.Collapsed;
     }
 }
示例#7
0
        private void OpenFlyout()
        {
            Show();
            timer?.Stop();

            RoutedEventArgs args = new(OpenedEvent);

            RaiseEvent(args);

            PlayOpenAnimation();

            timer?.Start();
        }
示例#8
0
 public void Refresh()
 {
     IsClosed      = false;
     _popup.IsOpen = true;
     Timer?.Stop();
     Timer?.Start();
 }
示例#9
0
 private void StartTimer()
 {
     lock (_timerLock)
     {
         _timer?.Start();
     }
 }
示例#10
0
        public void Set(T value)
        {
            _timer?.Stop();

            _lastValue = value;
            _timer?.Start();
        }
示例#11
0
 public void DispatcherTimerSetup()
 {
     _dispatcherTimer = new DispatcherTimer();
     _dispatcherTimer.Tick += dispatcherTimer_Tick;
     _dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1);
     _dispatcherTimer.Start();
 }
 private void HostNameBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     IsValidHost = false;
     Timer?.Stop();
     Timer?.Start();
     e.Handled = false;
 }
示例#13
0
 private void MainPage_Loaded(object sender, RoutedEventArgs e)
 {
     _timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
     _timer.Tick += _timer_Tick;
     _timer.Start();
     ButtonLoad.Visibility = Visibility.Collapsed;
 }
示例#14
0
        private void OnPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            double milliseconds = sldTimeline.Value;

            player.Position = TimeSpan.FromMilliseconds(milliseconds);
            timer?.Start();
        }
示例#15
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _cursor            = GetTemplateChild("PART_Cursor") as Run;
            _cursorTransparent = GetTemplateChild("PART_CursorTransparent") as Run;

            _startDelayTimer          = new DispatcherTimer();
            _startDelayTimer.Interval = TimeSpan.FromMilliseconds(StartDelayInMs);
            _startDelayTimer.Tick    += _startDelayTimer_Tick;

            _endDelayTimer          = new DispatcherTimer();
            _endDelayTimer.Interval = TimeSpan.FromMilliseconds(EndDelayInMs);
            _endDelayTimer.Tick    += _endDelayTimer_Tick;

            _typeTimer          = new DispatcherTimer();
            _typeTimer.Interval = TimeSpan.FromMilliseconds(TimeBetweenInMs);
            _typeTimer.Tick    += _typeTimer_Tick;

            _blinkTimer          = new DispatcherTimer();
            _blinkTimer.Interval = TimeSpan.FromMilliseconds(500);
            _blinkTimer.Tick    += _blinkTimer_Tick;
            _blinkTimer.Start();

            _startDelayTimer?.Start();
        }
        private void ProfilesList_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            InitSorting();

            //запоминаем какой профиль выбрал пользователь
            FLastSelectedProfileKey = SelectedProfileKey();
            TimerSyncSelectedProfile?.Start();
        }
示例#17
0
 private void PdfViewer_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     if (IsLoaded)
     {
         resizeTimer?.Stop();
         resizeTimer?.Start();
     }
 }
        private void RotatorTile_Loaded(object sender, RoutedEventArgs e)
        {
            // set the correct defaults for translate transform
            UpdateTranslateXY();

            // Start timer after control has loaded
            _timer?.Start();
        }
示例#19
0
        private void OnInvoked(object sender, TEventArgs args)
        {
            _timer?.Stop();
            _backgroundTimer?.Change(Timeout.Infinite, Timeout.Infinite);

            _lastSender = sender;
            _lastArgs   = args;
            _timer?.Start();
            _backgroundTimer?.Change(_interval, TimeSpan.Zero);
        }
示例#20
0
 private void StartTimer()
 {
     if (_annotationTimer is null)
     {
         _annotationTimer          = new DispatcherTimer();
         _annotationTimer.Interval = TimeSpan.FromSeconds(0.01);
         _annotationTimer.Tick    += _timer_Tick;
     }
     _annotationTimer?.Start();
 }
示例#21
0
        public static void ScheduleNotify(IEnumerable <NotificationDTO> notifications)
        {
            _timers = new List <DispatcherTimer>();
            EventHandler <NotifyEventArgs> removeFromDataBase = RemoveFromDataBase;
            var missedNotify = new List <NotificationDTO>();

            foreach (var notify in notifications)
            {
                string notifyString = $"{notify.Subject} from {notify.BeginningDate} to {notify.EndingDate} at {notify.Room}";
                if (notify.BeginningDate.AddMinutes(-15) >= DateTime.Now)
                {
                    _notifyTimer = new DispatcherTimer();

                    var interval = TimeSpan.FromTicks(notify.BeginningDate.Ticks - DateTime.Now.Ticks + TimeSpan.FromMinutes(-15).Ticks);
                    _notifyTimer.Interval = interval;

                    _notifyTimer.Tick += delegate
                    {
                        MessageBox.Show(notifyString);
                        removeFromDataBase?.Invoke(null, new NotifyEventArgs(notify.NotificationId));
                    };

                    _timers.Add(_notifyTimer);

                    _notifyWorker         = new BackgroundWorker();
                    _notifyWorker.DoWork += delegate
                    {
                        _notifyTimer?.Start();
                    };
                    _notifyWorker.RunWorkerAsync();
                }
                if (DateTime.Now > notify.BeginningDate.AddMinutes(-15) && DateTime.Now < notify.BeginningDate)
                {
                    MessageBox.Show($"{notifyString} - you have little time!");
                    removeFromDataBase?.Invoke(null, new NotifyEventArgs(notify.NotificationId));
                }
                if (notify.BeginningDate < DateTime.Now)
                {
                    missedNotify.Add(notify);
                    removeFromDataBase?.Invoke(null, new NotifyEventArgs(notify.NotificationId));
                }
            }
            if (missedNotify.Count > 0)
            {
                string missedApp = String.Empty;
                for (int i = 0; i < missedNotify.Count; i++)
                {
                    NotificationDTO infoNotify  = missedNotify.ElementAt(i);
                    string          finallyInfo =
                        $"{infoNotify.Subject} at {infoNotify.Room} from {infoNotify.BeginningDate} to {infoNotify.EndingDate} - MISSED! \r\n \r\n";
                    missedApp += finallyInfo;
                }
                MessageBox.Show(missedApp);
            }
        }
示例#22
0
        private void ScheduleGeometryChange()
        {
            if (_geometryChanging)
            {
                // we are the source of whatever change caused us to call this, don't recurse
                return;
            }

            // eat all events for a short duration and process only once in case there are a lot of updates
            _geometryChangeTimer?.Start();
        }
示例#23
0
        public void StartTimer()
        {
            if (_timer is null)
            {
                _timer = new DispatcherTimer {
                    Interval = TimeSpan.FromSeconds(1 / 60.0)
                };
                _timer.Tick += AnimationTimerOnTick;
            }

            _timer?.Start();
            IsAnimationRunning = true;
        }
示例#24
0
        private void FinishAnimation()
        {
            DoubleAnimation danime = new DoubleAnimation();

            danime.From = 1;
            DispatcherTimer timer = CreateDispetcherTrue();

            timer?.Start();
            danime.To       = countAnswerTrue * recRed.ActualWidth / myWords.Count;
            danime.Duration = TimeSpan.FromMilliseconds(2000);
            recGreen.BeginAnimation(Rectangle.WidthProperty, danime);
            //dispatcherTimer.Start();
        }
示例#25
0
 private void AutoUpdateButton_Click(object sender, RoutedEventArgs e)
 {
     if (_autoUpdateTimer?.IsEnabled == true)
     {
         _autoUpdateTimer.Stop();
         AutoUpdateButton.Background = null;
     }
     else
     {
         _autoUpdateTimer?.Start();
         AutoUpdateButton.Background = Brushes.PaleVioletRed;
     }
 }
示例#26
0
        private void ScrollViewer_Loaded(object sender, RoutedEventArgs e)
        {
            oneTimeInit();

            //if (_bkgLayer != null)
            //{
            //    var effectType = EffectLayer.EffectGraphType.Glow;
            //    _bkgLayer.DrawUIElements(_root);  //will draw at index 0 (RenderTargetIndexFor_icTabList)
            //    _bkgLayer.InitLayer(_root.ActualWidth, _root.ActualHeight, bkgOffsetX, bkgOffsetY, effectType);
            //}

            _sbHideBgLayer?.Begin();
            dtInvalidate?.Start();
        }
示例#27
0
        private void LocChangeDT_Tick(object sender, EventArgs ea)
        {
            if (LCEA != null && TimeTable.DecidedTTData != null)
            {
                var e = LCEA;
                //停車駅接近
                TIMS.IsStaComingNoticeON = RefreshDistance > e.Location && StopStaComingNotice < e.Location;

                //時刻表更新
                if (RefreshDistance < e.Location)
                {
                    DispingFirstRowStaIndex++;

                    StaListRefreshDT?.Start();
                }

                //徐行設定
                IsJoko1Enabled = IsJoko2Enabled = false;
                JokoClear(0);//1も2も消去
                foreach (TimeTable.SlowPointData spd in TimeTable.DecidedTTData.SlowPointList)
                {
                    if (!IsJoko1Enabled || !IsJoko2Enabled)
                    {
                        if (spd.NoticeStartPoint <= e.Location && e.Location <= spd.EndPoint)
                        {
                            if (IsJoko1Enabled)
                            {
                                JokoSet(false, spd.LimitStartPoint, spd.EndPoint, (int)spd.LimitSpeed);
                                IsJoko2Enabled = true;
                            }
                            else
                            {
                                IsJoko1Enabled = true;
                                JokoSet(true, spd.LimitStartPoint, spd.EndPoint, (int)spd.LimitSpeed);
                            }
                        }
                    }
                }
                if (Joko1Grid.Visibility == Visibility.Collapsed && Joko2Grid.Visibility == Visibility.Collapsed)
                {
                    JokoGrid.Visibility = Visibility.Collapsed;
                }
                else
                {
                    JokoGrid.Visibility = Visibility.Visible;
                }
            }
            LocChangeDT.Stop();
        }
示例#28
0
        void Instance_CurrentStateChanged(object sender, RoutedEventArgs e)
        {
            mediaState = Instance.CurrentState;
            switch (mediaState)
            {
            case MediaPlayerState.Playing:
                Debug.WriteLine("Media State Changed: Playing");
                StatusChanged?.Invoke(this, MediaState.Playing);
                dispatchTimer?.Start();
                break;

            case MediaPlayerState.Paused:
                Debug.WriteLine("Media State Changed: Paused");
                StatusChanged?.Invoke(this, MediaState.Paused);
                dispatchTimer?.Stop();
                break;
            }
        }
示例#29
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
#if WINDOWS_UWP
            CenterF.Navigate(typeof(Driver.D01AA));
#elif WPF
            CenterF.Navigate(new Uri("Driver/D01AA.xaml", UriKind.Relative));
#endif

            DT.Tick += DT_Tick;
            if (!DT.IsEnabled)
            {
                DT?.Start();
            }
            BIDSSMemLib.SMemLib.BIDSSMemChanged += SMemLib_BIDSSMemChanged;
            BIDSSMemLib.SMemLib.OpenDChanged    += SMemLib_OpenDChanged;
            TimeTable.ManyTTDataInput           += TimeTable_ManyTTDataInput;
            Driver.D10AA.TimeTableDecidedEvent  += D10AA_TimeTableDecidedEvent;
        }
示例#30
0
        private void PauseOrResume(object sender, RoutedEventArgs e)
        {
            if (playing)
            {
                media.Pause();
                timer?.Stop();
            }
            else
            {
                media.Play();
            }

            timer?.Start();

            playing = !playing;

            txtPlayOrPause.Text = playing ? "\uE103" : "\uE102";
        }
示例#31
0
 private static void Current_CurrentPlayerStateChanged(Windows.Media.Playback.MediaPlayer sender, object args)
 {
     if (UDPServer.Current.ClientList?.Count > 0)
     {
         SendPlayerStateChanged(sender.CurrentState);
     }
     DispatcherHelper.CheckBeginInvokeOnUI(() =>
     {
         if (sender.CurrentState == MediaPlayerState.Playing)
         {
             SendTrackChanged(MediaController.Current.CurrentPlayingIndex);
             _positionUpdateTimer?.Start();
         }
         else
         {
             _positionUpdateTimer?.Stop();
         }
     });
 }
示例#32
0
        internal void Play(MusicViewModel music)
        {
            if (_Player == null)
            {
                _Player      = new MediaPlayer();
                _PlayerTimer = new DispatcherTimer()
                {
                    Interval = TimeSpan.FromSeconds(0.25)
                };
                _PlayerTimer.Tick += _PlayerTimer_Tick;
            }
            var u = new Uri(music.FullPath);

            if (_Player.Source != u)
            {
                _Player.Open(u);
            }
            _Player.Play();
            _PlayerTimer?.Start();
        }
示例#33
0
        private void Element_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            switch (_leftClickState)
            {
            case CurrentState.Idle:
            case CurrentState.FirstClickDownHeld:                     // Occurs if the mouse moved after the last mouse down
                _leftClickState = CurrentState.FirstClickDown;
                _leftMouseMoved = false;
                _leftClickWaitTimer?.Start();
                break;

            case CurrentState.FirstClickUp:
                _leftClickState = CurrentState.SecondClickDown;
                break;

            default:
                _leftClickWaitTimer?.Stop();
                _leftClickState = CurrentState.Idle;
                break;
            }
        }
示例#34
0
        public ViewModel()
        {
            MapCenter = new Location(53.5, 8.2);

            Points = new ObservableCollection<VmPoint>();
            Points.Add(
                new VmPoint
                {
                    Name = "Steinbake Leitdamm",
                    Location = new Location(53.51217, 8.16603)
                });
            Points.Add(
                new VmPoint
                {
                    Name = "Buhne 2",
                    Location = new Location(53.50926, 8.15815)
                });
            Points.Add(
                new VmPoint
                {
                    Name = "Buhne 4",
                    Location = new Location(53.50468, 8.15343)
                });
            Points.Add(
                new VmPoint
                {
                    Name = "Buhne 6",
                    Location = new Location(53.50092, 8.15267)
                });
            Points.Add(
                new VmPoint
                {
                    Name = "Buhne 8",
                    Location = new Location(53.49871, 8.15321)
                });
            Points.Add(
                new VmPoint
                {
                    Name = "Buhne 10",
                    Location = new Location(53.49350, 8.15563)
                });
            Points.Add(
                new VmPoint
                {
                    Name = "Moving",
                    Location = new Location(53.5, 8.25)
                });

            Pushpins = new ObservableCollection<VmPoint>();
            Pushpins.Add(
                new VmPoint
                {
                    Name = "WHV - Eckwarderhörne",
                    Location = new Location(53.5495, 8.1877)
                });
            Pushpins.Add(
                new VmPoint
                {
                    Name = "JadeWeserPort",
                    Location = new Location(53.5914, 8.14)
                });
            Pushpins.Add(
                new VmPoint
                {
                    Name = "Kurhaus Dangast",
                    Location = new Location(53.447, 8.1114)
                });
            Pushpins.Add(
                new VmPoint
                {
                    Name = "Eckwarderhörne",
                    Location = new Location(53.5207, 8.2323)
                });

            //for (double lon = -720; lon <= 720; lon += 15)
            //{
            //    var lat = lon / 10;
            //    Pushpins.Add(
            //        new VmPoint
            //        {
            //            Name = string.Format("{0:00.0}°, {1:000}°", lat, lon),
            //            Location = new Location(lat, lon)
            //        });
            //}

            Polylines = new ObservableCollection<VmPolyline>();
            Polylines.Add(
                new VmPolyline
                {
                    Locations = LocationCollection.Parse("53.5140,8.1451 53.5123,8.1506 53.5156,8.1623 53.5276,8.1757 53.5491,8.1852 53.5495,8.1877 53.5426,8.1993 53.5184,8.2219 53.5182,8.2386 53.5195,8.2387")
                });
            Polylines.Add(
                new VmPolyline
                {
                    Locations = LocationCollection.Parse("53.5978,8.1212 53.6018,8.1494 53.5859,8.1554 53.5852,8.1531 53.5841,8.1539 53.5802,8.1392 53.5826,8.1309 53.5867,8.1317 53.5978,8.1212")
                });

            var timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(0.1)
            };

            timer.Tick += (s, e) =>
            {
                var p = Points.Last();
                p.Location = new Location(p.Location.Latitude + 0.001, p.Location.Longitude + 0.002);

                if (p.Location.Latitude > 54d)
                {
                    p.Name = "Stopped";
                    ((DispatcherTimer)s).Stop();
                }
            };

            timer.Start();
        }
示例#35
0
 static ThemeManager()
 {
     _ThemeUpdateTimer = new DispatcherTimer();
     _ThemeUpdateTimer.Interval = TimeSpan.FromSeconds(0.25);
     _ThemeUpdateTimer.Tick += UpdateTheme;
     _ThemeUpdateTimer.Start();
 }
        /// <summary>
        /// Waits for the BitmapImage to load.
        /// </summary>
        /// <param name="bitmapImage">The bitmap image.</param>
        /// <param name="timeoutInMs">The timeout in ms.</param>
        /// <returns></returns>
        public static async Task<ExceptionRoutedEventArgs> WaitForLoadedAsync(this BitmapImage bitmapImage, int timeoutInMs = 0)
        {
            var tcs = new TaskCompletionSource<ExceptionRoutedEventArgs>();

            // TODO: NOTE: This returns immediately if the image is already loaded,
            // but if the image already failed to load - the task will never complete and the app might hang.
            if (bitmapImage.PixelWidth > 0 || bitmapImage.PixelHeight > 0)
            {
                tcs.SetResult(null);

                return await tcs.Task;
            }

            //var tc = new TimeoutCheck(bitmapImage);

            // Need to set it to null so that the compiler does not
            // complain about use of unassigned local variable.
            RoutedEventHandler reh = null;
            ExceptionRoutedEventHandler ereh = null;
            EventHandler progressCheckTimerTickHandler = null;
            var progressCheckTimer = new DispatcherTimer();
            Action dismissWatchmen = () =>
            {
                bitmapImage.ImageOpened -= reh;
                bitmapImage.ImageFailed -= ereh;
                progressCheckTimer.Tick -= progressCheckTimerTickHandler;
                progressCheckTimer.Stop();
                //tc.Stop();
            };

            int totalWait = 0;
            progressCheckTimerTickHandler = (sender, o) =>
            {
                totalWait += 10;

                if (bitmapImage.PixelWidth > 0)
                {
                    dismissWatchmen.Invoke();
                    tcs.SetResult(null);
                }
                else if (timeoutInMs > 0 && totalWait >= timeoutInMs)
                {
                    dismissWatchmen.Invoke();
                    tcs.SetResult(null);
                    //ErrorMessage = string.Format("BitmapImage loading timed out after {0}ms for {1}.", totalWait, bitmapImage.UriSource)
                }
            };

            progressCheckTimer.Interval = TimeSpan.FromMilliseconds(10);
            progressCheckTimer.Tick += progressCheckTimerTickHandler;
            progressCheckTimer.Start();
                
            reh = (s, e) =>
            {
                dismissWatchmen.Invoke();
                tcs.SetResult(null);
            };

            ereh = (s, e) =>
            {
                dismissWatchmen.Invoke();
                tcs.SetResult(e);
            };

            bitmapImage.ImageOpened += reh;
            bitmapImage.ImageFailed += ereh;

            return await tcs.Task; 
        }
 private void InitializeTimer()
 {
     timer = new DispatcherTimer();
     timer.Interval = PollingInterval;
     timer.Tick += timer_Tick;
     timer.Start();
 }
示例#38
0
        public MainWindow()
        {
            // This should only be done once,
            // so it is being done here.
            //             Processing.Audio.Initialize();
            InitializeComponent();

            MainWindow.height = (int)this.Height;
            MainWindow.width = (int)this.Width;

            DispatcherTimer Timer = new DispatcherTimer();
            Timer.Interval = TimeSpan.FromMilliseconds(tickAmount);

            Path path = new Path();
            path.Stroke = System.Windows.Media.Brushes.RoyalBlue;
            path.StrokeThickness = 10;
            mainCanvas.Children.Add(path);

            Timer.Tick += (delegate(object s, EventArgs args)
            {
                if (!_isManipulating)
                {
                    if (currentlySelectedObject != null )
                    {
                        if (angle > 360)
                        {
                            if (currentlySelectedObject is Button)
                            {
                                ((Button)currentlySelectedObject).PerformClick();
                            }
                            else if (currentlySelectedObject is NavigationButton)
                            {
                                ((NavigationButton)currentlySelectedObject).Click();
                            }
                            else
                            {
                                ((SelectionPage)currentPage).Click();
                            }
                            path.Visibility = Visibility.Hidden;
                            angle = 0;
                        }
                        else
                        {
                            path.Visibility = Visibility.Visible;
                            System.Windows.Point mousePos = Mouse.GetPosition(mainCanvas);
                            System.Windows.Point endPoint = new System.Windows.Point(mousePos.X + 40 * Math.Sin(angle / 180.0 * Math.PI), mousePos.Y - 40 * Math.Cos(angle / 180.0 * Math.PI));

                            PathFigure figure = new PathFigure();
                            figure.StartPoint = new System.Windows.Point(mousePos.X, mousePos.Y - 40);

                            figure.Segments.Add(new ArcSegment(
                                endPoint,
                                new System.Windows.Size(40, 40),
                                0,
                                angle >= 180,
                                SweepDirection.Clockwise,
                                true
                            ));

                            PathGeometry geometry = new PathGeometry();
                            geometry.Figures.Add(figure);

                            path.Data = geometry;
                            // Number of ticks in one second --> number of degrees
                            angle += (360 / (1000 / tickAmount)); // <<<< CHANGE THIS BACK!!
                        }
                    }
                    else
                    {
                        path.Visibility = Visibility.Hidden;
                        angle = 0;
                    }
                }
            });

            homePage = new HomePage();
            browseMusicPage = new BrowseMusic();
            browseTutorialsPage = new BrowseTutorials();
            freeFormPage = new FreeFormMode();
            // tutorPage = new TutorMode();
            soloPage = new SoloPage();
            loadingPage = new LoadingPage();

            frame.Navigate(homePage);
            currentPage = homePage;
            Timer.Start();
            AddHandler(Keyboard.KeyDownEvent, (KeyEventHandler)HandleKeyDownEvent);
            AddHandler(Keyboard.KeyUpEvent, (KeyEventHandler)HandleKeyUpEvent);

            // Set the cursor to a hand image
            this.Cursor = new Cursor(new System.IO.MemoryStream(Properties.Resources.hand));
        }
        /// <summary>
        /// Shows the please wait window using the specific <paramref name="service"/>.
        /// </summary>
        /// <param name="service">The service.</param>
        /// <param name="status">The status.</param>
        private void ShowPleaseWaitWindow(IPleaseWaitService service, string status)
        {
            string determinateFormatString = "Updating item {0} of {1} (" + status + ")";

            const int CounterMax = 25;
            int counter = 0;
            bool isIndeterminate = IsPleaseWaitIndeterminate;

            var dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100);
            dispatcherTimer.Tick += (sender, e) =>
                                        {
                                            bool exit = false;

                                            counter++;

                                            if (counter >= CounterMax + 1)
                                            {
                                                exit = true;
                                            }
                                            else if (!isIndeterminate)
                                            {
                                                service.UpdateStatus(counter, CounterMax, determinateFormatString);
                                            }

                                            if (exit)
                                            {
                                                dispatcherTimer.Stop();
                                                service.Hide();
                                            }
                                        };

            if (isIndeterminate)
            {
                service.Show(status);
            }
            else
            {
                service.UpdateStatus(1, CounterMax, determinateFormatString);
            }

            dispatcherTimer.Start();
        }
示例#40
0
        public HBRelogHelper()
        {
            Instance = this;
            try
            {
                AppDomain.CurrentDomain.ProcessExit += CurrentDomainProcessExit;
                AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;

                HbProcId = Process.GetCurrentProcess().Id;
                _pipeFactory = new ChannelFactory<IRemotingApi>(new NetNamedPipeBinding(),
                        new EndpointAddress("net.pipe://localhost/HBRelog/Server"));

                HBRelogRemoteApi = _pipeFactory.CreateChannel();
                //instead of spawning a new thread use the GUI one.
                Application.Current.Dispatcher.Invoke(new Action(
                    delegate
                    {
                        _monitorTimer = new DispatcherTimer();
                        _monitorTimer.Tick += MonitorTimerCb;
                        _monitorTimer.Interval = TimeSpan.FromSeconds(10);
                        _monitorTimer.Start();
                    }));
                IsConnected = HBRelogRemoteApi.Init(HbProcId);
                if (IsConnected)
                {
                    Logging.Write("HBRelogHelper: Connected with HBRelog");
                    CurrentProfileName = HBRelogRemoteApi.GetCurrentProfileName(HbProcId);
                }
                else
                {
                    Logging.Write("HBRelogHelper: Could not connect to HBRelog");
                }
            }
            catch (Exception ex)
            {
                // fail silently.
                Logging.Write(Colors.Red, ex.ToString());
            }
            // since theres no point of this plugin showing up in plugin list lets just throw an exception.
            // new HB doesn't catch exceptions
            //  throw new Exception("Ignore this exception");
        }
示例#41
0
文件: Log.cs 项目: Xarlot/DXVcs2Git
 public static void Start(Dispatcher currentDispatcher, Action refreshed)
 {
     Timer = new DispatcherTimer(DispatcherPriority.ContextIdle, currentDispatcher);
     Timer.Interval = TimeSpan.FromSeconds(2);
     Timer.Tick += (s, e) => refreshed();
     Timer.Start();
 }
        private void OnSourceDownloadCompleted(DownloadStringCompletedEventArgs e, VastAdUnit ad, Action<bool> Completed)
        {
#if LATENCYTEST
            var latencySimulatorTimer = new DispatcherTimer();
            latencySimulatorTimer.Interval = TimeSpan.FromSeconds(3);
            latencySimulatorTimer.Start();
            latencySimulatorTimer.Tick += (ts, te) => {
#endif
            if (e.Error == null)
            {
                Exception ex;
                VAST vast;

                if (VAST.Deserialize(e.Result, out vast, out ex) && vast != null)
                {
                    var key = GetAdSourceKey(ad.Source);
                    if (!AvailableAds.ContainsKey(key))
                    {
                        AvailableAds.Add(key, vast);
                    }
                    ad.Vast = vast;

                    if (Completed != null) Completed(true);
                }
                if (ex != null)
                {
                    if (Completed != null) Completed(false);
                }
            }
            else
            {
                //Log.Output(OutputType.Error, "Unknown error handling VAST doc from source url: " + t.Source.uri);
                if (Completed != null) Completed(false);
            }
#if LATENCYTEST
            latencySimulatorTimer.Stop();
        };
#endif
        }
		private async void init(AdDesc desc, AdCreatedCallbackMethod createdCallback)
		#endif
		{
			if (WinRTPlugin.AdGrid == null)
			{
				if (createdCallback != null) createdCallback(false);
				return;
			}

			#if WINDOWS_PHONE
			WinRTPlugin.Dispatcher.BeginInvoke(delegate()
			#else
			await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate()
			#endif
			{
				bool pass = true;
				try
				{
					adControl = new AdControl();
					#if WINDOWS_PHONE || UNITY_WP_8_1
					adControl.IsAutoRefreshEnabled = desc.WP8_MicrosoftAdvertising_UseBuiltInRefresh;
					if (!desc.WP8_MicrosoftAdvertising_UseBuiltInRefresh)
					{
						manualRefreshTimer = new DispatcherTimer();
						manualRefreshTimer.Interval = TimeSpan.FromSeconds(desc.WP8_MicrosoftAdvertising_RefreshRate);
						manualRefreshTimer.Tick += timer_Tick;
						manualRefreshTimer.Start();
					}

					adControl.IsEngagedChanged += adControl_IsEngagedChanged;
					adControl.AdRefreshed += adControl_AdRefreshed;
					#else
					adControl.IsAutoRefreshEnabled = desc.WinRT_MicrosoftAdvertising_UseBuiltInRefresh;
					if (!desc.WinRT_MicrosoftAdvertising_UseBuiltInRefresh)
					{
						manualRefreshTimer = new DispatcherTimer();
						manualRefreshTimer.Interval = TimeSpan.FromSeconds(desc.WinRT_MicrosoftAdvertising_RefreshRate);
						manualRefreshTimer.Tick += timer_Tick;
						manualRefreshTimer.Start();
					}

					adControl.IsEngagedChanged += adControl_IsEngagedChanged;
					adControl.AdRefreshed += adControl_AdRefreshed;
					#endif

					adControl.ErrorOccurred += adControl_ErrorOccurred;
					#if WINDOWS_PHONE
					adControl.SetValue(System.Windows.Controls.Canvas.ZIndexProperty, 98);
					#else
					adControl.SetValue(Windows.UI.Xaml.Controls.Canvas.ZIndexProperty, 98);
					#endif
			
					#if WINDOWS_PHONE || UNITY_WP_8_1
					adControl.ApplicationId = desc.Testing ? "test_client" : desc.WP8_MicrosoftAdvertising_ApplicationID;
					adControl.AdUnitId = desc.WP8_MicrosoftAdvertising_UnitID;
					switch (desc.WP8_MicrosoftAdvertising_AdSize)
					{
						case WP8_MicrosoftAdvertising_AdSize.Wide_640x100:
							adControl.Width = 640;
							adControl.Height = 100;
							if (desc.Testing) adControl.AdUnitId = "Image640_100";
							break;

						case WP8_MicrosoftAdvertising_AdSize.Wide_480x80:
							adControl.Width = 480;
							adControl.Height = 80;
							if (desc.Testing) adControl.AdUnitId = "Image480_80";
							break;

						case WP8_MicrosoftAdvertising_AdSize.Wide_320x50:
							adControl.Width = 320;
							adControl.Height = 50;
							if (desc.Testing) adControl.AdUnitId = "Image320_50";
							break;

						case WP8_MicrosoftAdvertising_AdSize.Wide_300x50:
							adControl.Width = 300;
							adControl.Height = 50;
							if (desc.Testing) adControl.AdUnitId = "Image300_50";
							break;

						default:
							Debug.LogError("AdPlugin: Unsuported Ad size");
							break;
					}
					#elif UNITY_METRO
					adControl.ApplicationId = desc.Testing ? "d25517cb-12d4-4699-8bdc-52040c712cab" : desc.WinRT_MicrosoftAdvertising_ApplicationID;
					adControl.AdUnitId = desc.WinRT_MicrosoftAdvertising_UnitID;
					switch (desc.WinRT_MicrosoftAdvertising_AdSize)
					{
						case WinRT_MicrosoftAdvertising_AdSize.Tall_160x600:
							adControl.Width = 160;
							adControl.Height = 600;
							if (desc.Testing) adControl.AdUnitId = "10043134";
							break;

						case WinRT_MicrosoftAdvertising_AdSize.Tall_300x600:
							adControl.Width = 300;
							adControl.Height = 600;
							if (desc.Testing) adControl.AdUnitId = "10043030";
							break;

						case WinRT_MicrosoftAdvertising_AdSize.Wide_300x250:
							adControl.Width = 300;
							adControl.Height = 250;
							if (desc.Testing) adControl.AdUnitId = "10043008";
							break;

						case WinRT_MicrosoftAdvertising_AdSize.Wide_728x90:
							adControl.Width = 728;
							adControl.Height = 90;
							if (desc.Testing) adControl.AdUnitId = "10042998";
							break;

						case WinRT_MicrosoftAdvertising_AdSize.Square_250x250:
							adControl.Width = 250;
							adControl.Height = 250;
							if (desc.Testing) adControl.AdUnitId = "10043105";
							break;

						default:
							Debug.LogError("AdPlugin: Unsuported Ad size");
							break;
					}
					#endif

					#if WINDOWS_PHONE || UNITY_WP_8_1
					setGravity(desc.WP8_MicrosoftAdvertising_AdGravity);
					#else
					setGravity(desc.WinRT_MicrosoftAdvertising_AdGravity);
					#endif
					
					eventCallback = desc.EventCallback;
					WinRTPlugin.AdGrid.Children.Add(adControl);
					setVisible(desc.Visible);
					Debug.Log("Created Ad of ApplicationID: " + adControl.ApplicationId + " AdUnitID" + adControl.AdUnitId);
				}
				catch (Exception e)
				{
					adControl = null;
					Debug.LogError(e.Message);
				}

				ReignServices.InvokeOnUnityThread(delegate
				{
					if (createdCallback != null) createdCallback(pass);
				});
			});
		}