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();
        }
 public void DispatcherTimerSetup()
 {
     _dispatcherTimer = new DispatcherTimer();
     _dispatcherTimer.Tick += dispatcherTimer_Tick;
     _dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1);
     _dispatcherTimer.Start();
 }
Esempio n. 3
0
 /// <summary>
 /// Construct a timer
 /// </summary>
 /// <param name="eve">The event you want to be called on each tick</param>
 /// <param name="inter">The interval that you want the event to be called</param>
 /// <param name="dur">The amount of times you want the event to be called</param>
 public gameTimer(EventHandler eve, TimeSpan inter, int dur)
 {
     interval = inter;
     duration = dur;
     timer_event = eve;
     timer = new DispatcherTimer();
 }
		public void Dispose()
		{
			_isLoaded = false;

			if (_changeImageTimer != null)
			{
				_changeImageTimer.Stop();
				_changeImageTimer.Tick -= ChangeImageTimerTick;

				_changeImageTimer = null;
			}

			if (_imageContainer != null)
			{
				_imageContainer.Children.Clear();
			}

			foreach (var item in _animationTracking)
			{
				item.Storyboard.Stop();
			}

			var rootFrame = ApplicationSpace.RootFrame;

			if (rootFrame != null)
				rootFrame.Navigated -= FrameNavigated;

			//_imageCurrentLocation.Clear();
			//_imagesBeingShown.Clear();
			//_availableSpotsOnGrid.Clear();
			//_animationTracking.Clear();
		}
Esempio n. 5
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;
 }
Esempio n. 6
0
 public ClockTimer()
 {
     this._dispatcherTimer = new DispatcherTimer();
      this._dispatcherTimer.Tick += dispatcherTimer_Tick;
      this._dispatcherTimer.Interval = new TimeSpan( 0, 0, 1 );
      this._dispatcherTimer.Start();
 }
        public MapImageLayer()
        {
            Children.Add(new MapImage { Opacity = 0d });
            Children.Add(new MapImage { Opacity = 0d });

            updateTimer = new DispatcherTimer { Interval = UpdateInterval };
            updateTimer.Tick += (s, e) => UpdateImage();
        }
Esempio n. 8
0
 /// <summary>
 /// Construct a timer with a certian Priority
 /// </summary>
 /// <param name="eve">The event you want to be called on each tick</param>
 /// <param name="inter">The interval that you want the event to be called</param>
 /// <param name="dur">The number of times you want the event to be called</param>
 /// <param name="proi">The proiority of the timer event</param>
 public gameTimer(EventHandler eve, TimeSpan inter, int dur, DispatcherPriority proi)
 {
     interval = inter;
     duration = dur;
     timer_event = eve;
     priority = proi;
     timer = new DispatcherTimer(priority);
 }
        public SilverlightGraphicsCanvas()
        {
            MinFps = 4;
            MaxFps = 30;

            _drawTimer = new DispatcherTimer();
            _drawTimer.Tick += DrawTick;

            Unloaded += HandleUnloaded;
            Loaded += HandleLoaded;
        }
Esempio n. 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ThrottleTimer"/> class.
 /// </summary>
 /// <param name="milliseconds">Milliseconds to throttle.</param>
 /// <param name="handler">The delegate to invoke.</param>
 internal ThrottleTimer(int milliseconds, Action handler)
 {
     Action = handler;
     _throttleTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(milliseconds) };
     _throttleTimer.Tick += (s, e) =>
     {
         _throttleTimer.Stop();
         if (Action != null)
             Action.Invoke();
     };
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RouteLocationSimulator"/> class.
 /// </summary>
 /// <param name="route">The route to use for simulation. The spatial reference of the route
 /// must be in geographic coordinates (WGS84).</param>
 /// <param name="startPoint">An optional starting point.</param>
 public RouteLocationSimulator(RouteResult route, MapPoint startPoint = null)
 {
     if (route == null)
         throw new ArgumentNullException("route");
     m_route = route;
     timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1) };
     if (startPoint == null)
     {
         startPoint = new MapPoint((route.Routes.First().RouteGraphic.Geometry as Polyline).Paths[0][0], SpatialReferences.Wgs84);
     }
     timer.Tick += timer_Tick;
     Speed = 50; // double.NaN;
     directionIndex = 0;
     lineLength = 0;// GeometryEngine.GeodesicLength(route.Directions.First().MergedGeometry);
     drivePath = route.Routes.First().RouteGraphic.Geometry as Polyline;
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="RouteLocationSimulator"/> class.
		/// </summary>
		/// <param name="route">The route to use for simulation. The spatial reference of the route
		/// must be in geographic coordinates (WGS84).</param>
		/// <param name="startPoint">An optional starting point.</param>
		public RouteLocationSimulator(RouteResult route, MapPoint startPoint = null)
		{
			if (route == null)
				throw new ArgumentNullException("route");
			m_route = route;
			timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1) };
			if (startPoint == null)
			{
				startPoint = (route.Routes.First().RouteFeature.Geometry as Polyline).Parts.GetPartsAsPoints().First().First();
			}
			timer.Tick += timer_Tick;
			Speed = 50;
			directionIndex = 0;
			lineLength = 0;
			drivePath = route.Routes.First().RouteFeature.Geometry as Polyline;
		}
Esempio n. 13
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));
        }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Timer"/> class.
 /// </summary>
 public Timer()
 {
     _timer = new DispatcherTimer();
     _timer.Tick += OnTimerTick;
 }
Esempio n. 15
0
 public TileContainer()
 {
     RenderTransform = new MatrixTransform();
     updateTimer = new DispatcherTimer { Interval = UpdateInterval };
     updateTimer.Tick += UpdateTiles;
 }
Esempio n. 16
0
        /// <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 async static 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 <object>       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);
        }
			public DelayTimer(Action action)
			{
				m_timer = new DispatcherTimer();
				m_timer.Tick += m_timer_Tick;
				m_action = action;
			}
        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
        }
Esempio n. 19
0
        public LogMessages()
        {
            ((ViewInformation)Info).Description = DESCRIPTION;
            presenter = new LogMessagesControl {
                DataContext = this
            };

            Messages         = new ObservableCollection <ILogEntry>();
            PropertyChanged += PropertyChangedHandler;

            var dt = new DispatcherTimer(DispatcherPriority.Normal)
            {
                Interval = TimeSpan.FromMilliseconds(200)
            };

            dt.Tick += UpdateTick;
            dt.Start();

            filteringService = ServiceLocator.Instance.Get <IFilteringService <IFilter> >();
            if (filteringService != null)
            {
                var notify = filteringService as INotifyPropertyChanged;
                if (notify != null)
                {
                    notify.PropertyChanged += (sender, e) => ApplyFiltering();
                }
            }

            extractingService = ServiceLocator.Instance.Get <IExtractingService <IExtractor> >();
            if (extractingService != null)
            {
                var notify = extractingService as INotifyPropertyChanged;
                if (notify != null)
                {
                    notify.PropertyChanged += (sender, e) => ApplyExtracting();
                }
            }

            var preferences = ServiceLocator.Instance.Get <IUserPreferences>();

            if (preferences != null)
            {
                var notify = preferences as INotifyPropertyChanged;
                if (notify != null)
                {
                    notify.PropertyChanged += (sender, args) =>
                    {
                        var prop = args.PropertyName;
                        switch (prop)
                        {
                        case "SelectedTimeFormatOption":
                        case "ConvertUtcTimesToLocalTimeZone":
                        case "SelectedDateOption":
                            rebuildList = true;
                            break;
                        }
                    };
                }
            }

            InitialiseToolbar();
        }
Esempio n. 20
0
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;

            var b = BitmapFromSource(MinecraftSkin.Steve.GetSegment(2, 2, 2, 2));

            App.TrayIcon.Icon = System.Drawing.Icon.FromHandle(b.GetHicon());
            b.Dispose();

            if (File.Exists("settings"))
            {
                Settings.Load("settings", "1.0");
            }
            ApplySettings();

            App.TrayIcon.MenuActivation = Hardcodet.Wpf.TaskbarNotification.PopupActivationMode.All;

            App.TrayIcon.ContextMenu = new ContextMenu();
            var config = new MenuItem()
            {
                Header = "Configuration"
            };

            config.Click += (s, e) => {
                var cwin = new ConfigWindow();
                cwin.PropertyChanged += (t, f) => ApplySettings();
                cwin.Show();
            };
            App.TrayIcon.ContextMenu.Items.Add(config);
            var exit = new MenuItem()
            {
                Header = "Close"
            };

            exit.Click += (s, e) => Application.Current.Shutdown();
            App.TrayIcon.ContextMenu.Items.Add(exit);

            Closed += (s, e) => {
                Settings.Save("settings", "1.0");
                App.TrayIcon.Dispose();
            };

            var dispatcherTimer = new DispatcherTimer(DispatcherPriority.ContextIdle);
            var animRunning     = 0;

            dispatcherTimer.Tick += (t, f) => {
                if (!Settings.goaway)
                {
                    return;
                }
                if (IsPointOverForm(MouseWatchingHead.GetMousePosition()))
                {
                    if (Opacity > 0 && animRunning != 1)
                    {
                        BeginAnimation(OpacityProperty,
                                       new DoubleAnimation(0, new Duration(TimeSpan.FromMilliseconds(150)), FillBehavior.HoldEnd),
                                       HandoffBehavior.SnapshotAndReplace);
                        animRunning = 1;
                    }
                }
                else
                {
                    if (Opacity < Settings.opacity && animRunning != 2)
                    {
                        BeginAnimation(OpacityProperty,
                                       new DoubleAnimation(Settings.opacity, new Duration(TimeSpan.FromMilliseconds(150)), FillBehavior.Stop),
                                       HandoffBehavior.SnapshotAndReplace);
                        animRunning = 2;
                    }
                }
            };
            dispatcherTimer.Interval = TimeSpan.FromSeconds(1 / 25.0);
            dispatcherTimer.Start();
        }
Esempio n. 21
0
        public void Initialize()
        {
            FlyoutWindow = new FlyoutWindow();
            CreateWndProc();

            UIManager = new UIManager();
            UIManager.Initialize(FlyoutWindow);

            DUIHook = new DUIHook();
            DUIHook.Hook();
            DUIHook.DUIShown     += DUIShown;
            DUIHook.DUIDestroyed += DUIDestroyed;
            rehooktimer           = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(3), IsEnabled = false
            };
            rehooktimer.Tick += (_, __) => TryRehook();

            KeyboardHook = new KeyboardHook();

            #region App Data

            var adEnabled   = AppDataHelper.AudioModuleEnabled;
            var apmdEnabled = AppDataHelper.AirplaneModeModuleEnabled;
            var lkkyEnabled = AppDataHelper.LockKeysModuleEnabled;
            var brEnabled   = AppDataHelper.BrightnessModuleEnabled;

            DefaultFlyout = AppDataHelper.DefaultFlyout;

            TopBarEnabled         = AppDataHelper.TopBarEnabled;
            DefaultFlyoutPosition = AppDataHelper.DefaultFlyoutPosition;

            async void getStartupStatus()
            {
                RunAtStartup = await StartupHelper.GetRunAtStartupEnabled();
            }

            getStartupStatus();

            #endregion

            #region Initiate Helpers

            AudioFlyoutHelper = new AudioFlyoutHelper()
            {
                IsEnabled = adEnabled
            };
            AirplaneModeFlyoutHelper = new AirplaneModeFlyoutHelper()
            {
                IsEnabled = apmdEnabled
            };
            LockKeysFlyoutHelper = new LockKeysFlyoutHelper()
            {
                IsEnabled = lkkyEnabled
            };
            BrightnessFlyoutHelper = new BrightnessFlyoutHelper()
            {
                IsEnabled = brEnabled
            };

            AudioFlyoutHelper.ShowFlyoutRequested        += ShowFlyout;
            AirplaneModeFlyoutHelper.ShowFlyoutRequested += ShowFlyout;
            LockKeysFlyoutHelper.ShowFlyoutRequested     += ShowFlyout;
            BrightnessFlyoutHelper.ShowFlyoutRequested   += ShowFlyout;

            #endregion

            HasInitialized = true;
            Initialized?.Invoke(null, null);
        }
Esempio n. 22
0
 /// <summary>
 /// Instantiates a new instance of the BusyIndicator control.
 /// </summary>
 public BusyIndicator()
 {
     DefaultStyleKey          = typeof(BusyIndicator);
     _displayAfterTimer       = new DispatcherTimer();
     _displayAfterTimer.Tick += new EventHandler(DisplayAfterTimerElapsed);
 }
Esempio n. 23
0
 private void StopTimer()
 {
     _timer.Stop();
     _timer.Tick -= OnTimerTick;
     _timer       = null;
 }
 /// <summary>
 /// Restarts a timer.
 /// </summary>
 void Restart(DispatcherTimer timer)
 {
     timer.Stop();
     timer.Start();
 }
Esempio n. 25
0
        public MainWindowViewModel(MainWindow mainWindow)
        {
            this.MainWindow = mainWindow;

            // set default values
            WeatherModel = new WeatherModel
            {
                Status = "Weather forecast is loading...",
                Fact   = new Fact
                {
                    Temp        = "Loading...",
                    Feels_like  = "Loading...",
                    Humidity    = "Loading...",
                    Pressure_mm = "Loading...",
                    UvIndex     = "Loading..."
                }
            };

            ToDoListModel = new ToDoListModel
            {
                Status        = "To-do list is loading...",
                toDoListItems = new List <ToDoListItem>()
            };

            TimerModel = new TimerModel
            {
                Hours   = 1,
                Minutes = 30,
                Seconds = 0
            };

            ButtonStatModel = new ButtonStatModel
            {
                IsTimerStarted = false,
                IsTimerTicking = false,
                Text           = "Старт",
                ButtonColor    = SolidColorBrush.Parse("#1A361F"),
                TextColor      = SolidColorBrush.Parse("#56D45B")
            };

            WidgetColor = new WidgetColor
            {
                TimeColor     = SolidColorBrush.Parse("#505356"),
                WeatherColor  = SolidColorBrush.Parse("#3F4041"),
                TimerColor    = SolidColorBrush.Parse("#282828"),
                TodoListColor = SolidColorBrush.Parse("#252328"),
                NewsColor     = SolidColorBrush.Parse("#4E4C48"),
                EngWordColor  = SolidColorBrush.Parse("#393E41")
            };

            EngTranslatedWordModel = new EngTranslatedWordModel
            {
                Status = "Word of the day is loading..."
            };

            NewsModel = new NewsModel
            {
                LatestTitle = "News are loading..."
            };

            // set timers condition
            timerForecast = new DispatcherTimer
            {
                Interval = TimeSpan.FromHours(1)
            };
            timerForecast.Tick += OnTimedEventForecast;
            timerForecast.Start();

            timerToDo = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(5)
            };
            timerToDo.Tick += OnTimedEventToDoList;
            timerToDo.Start();

            timerTime = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(1)
            };
            timerTime.Tick += OnTimedEventTime;
            timerTime.Start();

            timerTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(1)
            };
            timerTimer.Tick += OnTimedEventTimer;

            timerFlash = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(250)
            };
            timerFlash.Tick += OnTimedEventFlash;

            timerEngWord = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(500)
            };
            timerEngWord.Tick += OnTimedEvent5AM;
            timerEngWord.Start();

            timerNews = new DispatcherTimer
            {
                Interval = TimeSpan.FromMinutes(1)
            };
            timerNews.Tick += OnTimedEventNews;
            timerNews.Start();

            // trigger some events one time at start of project
            OnTimedEventForecast();
            OnTimedEventToDoList();
            OnTimedEventTime();
            OnTimedEvent5AM();
            OnTimedEventNews();
        }
Esempio n. 26
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "DelayBindingUpdate" /> class.
        /// </summary>
        public DelayBindingUpdate()
        {
            UpdateDelay = 100;

            _timer = new DispatcherTimer();
        }
Esempio n. 27
0
        public MainWindow()
        {
            InitializeComponent();

            DataContext = this;

            var client = ClientStateSingleton.Instance;

            this.WindowStartupLocation = WindowStartupLocation.Manual;
            this.Left = AppConfiguration.Instance.ClientX;
            this.Top  = AppConfiguration.Instance.ClientY;


            GCSettings.LatencyMode = GCLatencyMode.SustainedLowLatency;

            SetupLogging();

            Title = Title + " - " + UpdaterChecker.VERSION;

            Logger.Info("Started DCS-SimpleRadio Client " + UpdaterChecker.VERSION);

            InitExpandControls();

            InitInput();

            _appConfig = AppConfiguration.Instance;
            _guid      = ShortGuid.NewGuid().ToString();

            InitAudioInput();

            InitAudioOutput();

            _connectCommand           = new DelegateCommand(Connect, () => ServerAddress != null);
            FavouriteServersViewModel = new FavouriteServersViewModel(new CsvFavouriteServerStore());

            InitDefaultAddress();

            MicrophoneBoost.Value = _appConfig.MicBoost;
            SpeakerBoost.Value    = _appConfig.SpeakerBoost;

            _audioManager              = new AudioManager(_clients);
            _audioManager.MicBoost     = (float)MicrophoneBoost.Value;
            _audioManager.SpeakerBoost = (float)SpeakerBoost.Value;

            if ((BoostLabel != null) && (MicrophoneBoost != null))
            {
                BoostLabel.Content = (int)(MicrophoneBoost.Value * 100) - 100 + "%";
            }

            if ((SpeakerBoostLabel != null) && (SpeakerBoost != null))
            {
                SpeakerBoostLabel.Content = (int)(SpeakerBoost.Value * 100) - 100 + "%";
            }

            UpdaterChecker.CheckForUpdate();

            InitRadioSwitchIsPTT();

            InitRadioRxEffectsToggle();

            InitRadioTxEffectsToggle();

            InitRadioEncryptionEffectsToggle();

            InitRadioSoundEffects();

            InitAutoConnectPrompt();

            InitRadioOverlayTaskbarHide();

            InitRefocusDCS();

            InitFlowDocument();

            _dcsAutoConnectListener = new DCSAutoConnectListener(AutoConnect);

            _updateTimer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(100)
            };
            _updateTimer.Tick += UpdateClientCount_VUMeters;
            _updateTimer.Start();
        }
Esempio n. 28
0
        public WindowDDos()
        {
            InitializeComponent();

            hacker = new BitmapImage(new Uri(@"/ModelDanSimulasi;component/Images/user.png", UriKind.Relative));
            computer = new BitmapImage(new Uri(@"/ModelDanSimulasi;component/Images/computer.png", UriKind.Relative));
            serverOK = new BitmapImage(new Uri(@"/ModelDanSimulasi;component/Images/computer_ok.png", UriKind.Relative));
            serverX = new BitmapImage(new Uri(@"/ModelDanSimulasi;component/Images/computer_x.png", UriKind.Relative));

            _random = new Random(17 * DateTime.Now.Millisecond);

            _canvas.Children.Add(textBoxInfoServer = new TextBox
            {
                Name = "infoRAM",
                Margin = new Thickness(X_ETC + 205, 5, 0, 0),
                Height = 20,
                Width = 300,
                IsReadOnly = true
            });

            _canvas.Children.Add(listBoxPing = new ListBox
            {
                Name = "listPing",
                Margin = new Thickness(X_ETC + 205, 30, 0, 0),
                Height = getHeight() - 30,
                Width = 300
            });

            _canvas.Children.Add(listBoxRequestSent = new ListBox
            {
                Margin = new Thickness(X_ETC, 180, 20, 20),
                Height = getHeight() - 180,
                Width = 200
            });

            // Slider
            Label speed;
            _canvas.Children.Add(speed = new Label
            {
                Content = "Speed (500ms)",
                Margin = new Thickness(X_ETC, 5, 0, 0)
            });
            _canvas.Children.Add(sliderSpeed = new Slider
            {
                Name = "sliderSpeed",
                Orientation = Orientation.Horizontal,
                Margin = new Thickness(X_ETC, 30, 0, 0),
                Width = 200,
                BorderBrush = Brushes.Black,
                BorderThickness = new Thickness(0.5),
                Maximum = 2000,
                Minimum = 50,
                Value = 500,
                SmallChange = 10,
                LargeChange = 10
            });
            _canvas.Children.Add(new Label
            {
                Content = "Faster",
                Margin = new Thickness(X_ETC, 50, 0, 0)
            });
            _canvas.Children.Add(new Label
            {
                Content = "Slower",
                Margin = new Thickness(X_ETC + 155, 50, 0, 0)
            });

            // N Zombie
            _canvas.Children.Add(new Label
            {
                Content = "N Zombie",
                Margin = new Thickness(X_ETC, 75, 0, 0)
            });
            _canvas.Children.Add(textBoxNZombie = new TextBox
            {
                Name = "textBoxNZombie",
                Margin = new Thickness(X_ETC + 100, 75, 0, 0),
                Width = 100
            });

            // Server RAM
            _canvas.Children.Add(new Label
            {
                Content = "Target RAM(MB)",
                Margin = new Thickness(X_ETC, 100, 0, 0)
            });
            _canvas.Children.Add(textBoxRAM = new TextBox
            {
                Name = "textBoxRAM",
                Margin = new Thickness(X_ETC + 100, 100, 0, 0),
                Width = 100
            });

            fadeOut = new DoubleAnimation
            {
                Name = "fadeOut",
                From = 1.0,
                To = 0.0,
                Duration = new Duration(TimeSpan.FromMilliseconds(sliderSpeed.Value + 100))
            };

            timerPing = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(sliderSpeed.Value)
            };

            timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(sliderSpeed.Value)
            };

            timerPing.Tick += (s, e) =>
            {
                int idx, n = _random.Next(2, listLineReflector.Count);
                int packetSize;
                for (int i = 0; i < n; i++)
                {
                    idx = _random.Next(listIpReflector.Count);
                    packetSize = 1 << _random.Next(5, 11);
                    queuePingSize += packetSize;
                    listLineReflector[idx].BeginAnimation(Line.OpacityProperty, fadeOut);
                    listBoxRequestSent.Items.Add(new ListBoxItem
                    {
                        Content = listIpReflector[idx] + " send request, size = " + packetSize
                    });
                    queuePing.Enqueue(new PingRequest { IP = listIpReflector[idx], lineIndex = idx, size = packetSize });
                }
            };

            timer.Tick += (s, e) =>
            {
                int n = _random.Next(4, 7);
                while (n-- > 0 && queuePing.Count > 0)
                {
                    PingRequest p = queuePing.Dequeue();
                    queuePingSize -= p.size;
                    (listBoxRequestSent.Items[idxListRequest++] as ListBoxItem).Background = Brushes.Green;
                    listBoxPing.Items.Add("Request from " + p.IP + " size = " + p.size);
                    listLineReflector[p.lineIndex].BeginAnimation(Line.OpacityProperty, fadeOut);
                }
                textBoxInfoServer.Text = "RAM = " + queuePingSize + "kB / " + ramSize + "kB (" + Math.Round(((double)queuePingSize * 100 / ramSize), 2) + " %)";
                if (queuePingSize > ramSize)
                {
                    //DOWN
                    timerPing.Stop();
                    timer.Stop();
                    imageTarget.Source = serverX;
                    labelTarget.Background = Brushes.Red;
                    buttonSimulate.IsEnabled = true;
                }
            };

            sliderSpeed.ValueChanged += (s, e) =>
            {
                speed.Content = "Speed (" + sliderSpeed.Value + "ms)";
                timerPing.Interval = TimeSpan.FromMilliseconds(sliderSpeed.Value);
                timer.Interval = TimeSpan.FromMilliseconds(sliderSpeed.Value);
                fadeOut.Duration = TimeSpan.FromMilliseconds(sliderSpeed.Value + 100);
            };

            countBasic = _canvas.Children.Add(buttonSimulate = new Button
            {
                Name = "buttonSimulate",
                Content = "DDos",
                Margin = new Thickness(X_ETC, 150, 20, 20)
            });

            countBasic++;

            buttonSimulate.Click += (s, e) => { simulasi(); };
        }
Esempio n. 29
0
		private void FinishLoadAndTemplateApply()
		{
			if (!_isLoaded)
				return;

			if (_changeImageTimer == null)
				_changeImageTimer = new DispatcherTimer();

			_changeImageTimer.Tick -= ChangeImageTimerTick;
			_changeImageTimer.Tick += ChangeImageTimerTick;

			GridSizeChanged();
			ResetGridStateManagement();

			_createAnimation = false;

			if (!ApplicationSpace.IsDesignMode)
			{
				for (var i = 0; i < Rows; i++)
				{
					for (var j = 0; j < Columns; j++)
					{
						CycleImage(i, j);
					}
				}
			}

			_createAnimation = true;

			ImageCycleIntervalChanged();
			IsFrozenPropertyChanged();
		}
Esempio n. 30
0
 void OnMouseHoverTimerElapsed(object sender, EventArgs e)
 {
     mouseHoverTimer.Stop();
     mouseHoverTimer = null;
 }
		private async void disposeAsync()
		#endif
		{
			#if WINDOWS_PHONE
			WinRTPlugin.Dispatcher.BeginInvoke(delegate()
			#else
			await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate()
			#endif
			{
				if (adControl != null)
				{
					adControl.IsEnabled = false;
					WinRTPlugin.AdGrid.Children.Remove(adControl);
					adControl = null;
				}

				if (manualRefreshTimer != null)
				{
					manualRefreshTimer.Stop();
					manualRefreshTimer.Tick -= timer_Tick;
					manualRefreshTimer = null;
				}
			});
		}
Esempio n. 32
0
        public MainWindow()
        {
            Class7.RIuqtBYzWxthF();
            this.InitializeComponent();
            Global.MAIN_WINDOW = this;
            this.MenusFrame.Navigate(Global.ViewDashboard);
            this.lvMenu.SelectedIndex    = 0;
            this.txtTotalTasks.Text      = "Total tasks: " + Global.SETTINGS.TASKS.Count;
            this.txtTotalProfiles.Text   = "Total profiles: " + Global.SETTINGS.PROFILES.Count;
            this.txtTotalProxyLists.Text = "Total proxy lists: " + Global.SETTINGS.PROXIES.Count;
            int num2 = 0;

            foreach (ProxyListObject obj4 in Global.SETTINGS.PROXIES)
            {
                num2 += obj4.Proxies.Count;
            }
            this.txtTotalProxies.Text = "Total proxies: " + num2;
            EveAIO.Helpers.Notify("logon", Global.VERSION + " | " + Global.IP + "|" + Global.TmpKey);
            if (!Directory.Exists("checkouts"))
            {
                Directory.CreateDirectory("checkouts");
            }
            if (!Directory.Exists("Cache"))
            {
                Directory.CreateDirectory("Cache");
            }
            this._versionTimer          = new DispatcherTimer();
            this._versionTimer.Interval = new TimeSpan(0, 0, 10);
            this._versionTimer.Tick    += new EventHandler(this._versionTimer_Tick);
            this._versionTimer.Start();
            this._licenseTimer          = new DispatcherTimer();
            this._licenseTimer.Interval = new TimeSpan(0, 4, 0);
            this._licenseTimer.Tick    += new EventHandler(this._licenseTimer_Tick);
            this._licenseTimer.Start();
            Global.SERIAL64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(Global.SERIAL));
            ServicePointManager.SecurityProtocol        = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
            ServicePointManager.DefaultConnectionLimit  = 0x1388;
            ServicePointManager.MaxServicePointIdleTime = 0x1388;
            ServicePointManager.MaxServicePoints        = 0x3e8;
            Type       type   = Global.ASM.GetType("SvcHost.SvcHost");
            MethodInfo method = type.GetMethod("Efkf3kfo_");
            object     obj2   = Activator.CreateInstance(type);

            Runtime.AddLicense((string)method.Invoke(obj2, null));
            Type       type2 = Global.ASM.GetType("SvcHost.SvcHost");
            MethodInfo info2 = type2.GetMethod("JeokfEp3");
            object     obj3  = Activator.CreateInstance(type2);

            WebsitesInfo.SUPPORTED_PLATFORMS  = (List <KeyValuePair <string, string> >)info2.Invoke(obj3, null);
            Global.CAPTCHA_SOLVER1            = new CaptchaSolverWindow("window1");
            Global.CAPTCHA_SOLVER1.Visibility = Visibility.Hidden;
            Global.CAPTCHA_SOLVER1.Show();
            Global.CAPTCHA_SOLVER1.Hide();
            Global.CAPTCHA_SOLVER2            = new CaptchaSolverWindow("window2");
            Global.CAPTCHA_SOLVER2.Visibility = Visibility.Hidden;
            Global.CAPTCHA_SOLVER2.Show();
            Global.CAPTCHA_SOLVER2.Hide();
            Global.CAPTCHA_SOLVER3            = new CaptchaSolverWindow("window3");
            Global.CAPTCHA_SOLVER3.Visibility = Visibility.Hidden;
            Global.CAPTCHA_SOLVER3.Show();
            Global.CAPTCHA_SOLVER3.Hide();
            Global.CAPTCHA_SOLVER4            = new CaptchaSolverWindow("window4");
            Global.CAPTCHA_SOLVER4.Visibility = Visibility.Hidden;
            Global.CAPTCHA_SOLVER4.Show();
            Global.CAPTCHA_SOLVER4.Hide();
            Global.CAPTCHA_SOLVER5            = new CaptchaSolverWindow("window5");
            Global.CAPTCHA_SOLVER5.Visibility = Visibility.Hidden;
            Global.CAPTCHA_SOLVER5.Show();
            Global.CAPTCHA_SOLVER5.Hide();
            Global.SENSOR = new Sensor();
            if (!Global.AsmLoaded)
            {
                List <KeyValuePair <string, string> > list = new List <KeyValuePair <string, string> >();
                foreach (KeyValuePair <string, string> pair in WebsitesInfo.SUPPORTED_PLATFORMS)
                {
                    list.Add(new KeyValuePair <string, string>("", pair.Value));
                }
                WebsitesInfo.SUPPORTED_PLATFORMS = list;
            }
        }
        /// <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();
        }
Esempio n. 34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BusyIndicator"/> class.
 /// </summary>
 public BusyIndicator()
 {
     DefaultStyleKey              = typeof(BusyIndicator);
     this.displayAfterTimer       = new DispatcherTimer();
     this.displayAfterTimer.Tick += this.DisplayAfterTimerElapsed;
 }
 private void ShutdownTimer()
 {
     if (timer != null)
     {
         timer.Tick -= timer_Tick;
         if (timer.IsEnabled) timer.Stop();
         timer = null;
     }
 }
Esempio n. 36
0
 static bool TryGetBufferTimer(ITextBuffer buffer, out DispatcherTimer timer)
 {
     return(buffer.Properties.TryGetProperty(bufferTimerKey, out timer));
 }
Esempio n. 37
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RadialGaugePiece"/> class.
        /// </summary>
        public RadialGaugePiece()
        {
#if NETFX_CORE
            this.DefaultStyleKey = typeof(RadialGaugePiece);
#endif
#if SILVERLIGHT
            this.DefaultStyleKey = typeof(RadialGaugePiece);
#endif
            timer = new DispatcherTimer();
            timer.Tick += timer_Tick;

            Loaded += RadialGaugePiece_Loaded;
        }
Esempio n. 38
0
        /// <summary>
        /// Complete constructor
        /// </summary>
        public MainWindow(MainWindowVM viewModel)
        {
            mapper    = viewModel.Mapper;
            ViewModel = viewModel;

            // Set the main window view model actions
            ViewModel.UploadLogAction    = UploadLogAction;
            ViewModel.ShowOptionsAction  = ShowOptionsWindow;
            ViewModel.LaunchArenaAction  = LaunchArenaAction;
            ViewModel.ValidateUserAction = ValidateUserAction;

            // Set the resource locator
            ResourcesLocator = viewModel.ResourcesLocator;

            // Set the problem action
            ResourcesLocator.SetProblem = ViewModel.SetProblem;

            // Locate the log file
            ResourcesLocator.LocateLogFilePath(ViewModel.Config);

            // Locate the game path
            ResourcesLocator.LocateGameClientFilePath(ViewModel.Config);

            // Set the reference to the draft helper
            DraftHelperRunner = viewModel.DraftHelperRunner;


            Reader         = viewModel.ReaderMtgaOutputLog;
            Api            = viewModel.Api;
            StartupManager = viewModel.StartupManager;
            FileMonitor    = viewModel.FileMonitor;
            FileMonitor.OnFileSizeChangedNewText += OnFileSizeChangedNewText;
            DraftHelper = viewModel.DraftHelper;
            //this.logProcessor = logProcessor;
            InGameTracker  = viewModel.InMatchTracker;
            TokenManager   = viewModel.TokenManager;
            PasswordHasher = viewModel.PasswordHasher;
            DraftRatings   = viewModel.DraftRatings;

            FileMonitor.SetFilePath(ViewModel.Config.LogFilePath);

            // Set the data context to the view model
            DataContext = ViewModel;

            InitializeComponent();

            PlayingControl.Init(ViewModel);
            DraftingControl.Init(ViewModel.DraftingVM, ViewModel.Config.LimitedRatingsSource);
            DraftingControl.SetPopupRatingsSource(ViewModel.Config.ShowLimitedRatings, ViewModel.Config.LimitedRatingsSource);

            // Set the process monitor status changed action
            viewModel.ProcessMonitor.OnProcessMonitorStatusChanged = OnProcessMonitorStatusChanged;

            // Start the process monitor without awaiting the task completion
            _ = viewModel.ProcessMonitor.Start(new System.Threading.CancellationToken());

            // Start the file monitor without awaiting the task completion
            _ = FileMonitor.Start(new System.Threading.CancellationToken());

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(200)
            };

            timer.Tick += (sender, e) =>
            {
                ViewModel.DraftingVM.SetCardsDraftFromBuffered();
                ViewModel.InMatchState.SetInMatchStateFromBuffered();
            };
            timer.Start();

            var timerTokenRefresh = new DispatcherTimer {
                Interval = TimeSpan.FromMinutes(9)
            };

            timerTokenRefresh.Tick += (sender, e) =>
            {
                RefreshAccessToken();
            };
            timerTokenRefresh.Start();
        }
Esempio n. 39
0
 private void leaveTimer_Tick(object sender, EventArgs e)
 {
     leaveTimer.Stop();
     leaveTimer = null;
     StopShowing();
 }
Esempio n. 40
0
        public Waypoint(MainWindow window, GMapMarker marker, bool mode, int _no, bool _icon)
        {
            InitializeComponent();

            DeviceFlag = mode;


            //アイコンを変更
            if (_icon)
            {
                icon.Source = new BitmapImage(new Uri(System.IO.Path.GetFullPath("Resources/UavWayPoint.png")));
            }
            else
            {
                if (_no != 1)
                {
                    icon.Source          = new BitmapImage(new Uri(System.IO.Path.GetFullPath("Resources/MultiWayPoint.png")));
                    Main.RenderTransform = new ScaleTransform(0.5, 0.5);        //マーカーサイズ縮小
                }
                else
                {
                    icon.Source          = new BitmapImage(new Uri(System.IO.Path.GetFullPath("Resources/UavWayPoint.png")));
                    Main.RenderTransform = new ScaleTransform(0.5, 0.5);        //マーカーサイズ縮小
                }
            }

            /*
             * //イベント管理
             * if (DeviceFlag)
             * {
             *  this.MouseLeave -= new System.Windows.Input.MouseEventHandler(this.MarkerControl_MouseLeave);
             *  this.MouseMove -= new System.Windows.Input.MouseEventHandler(this.UAVWayPoint_MouseMove);
             *  this.MouseLeftButtonUp -= new System.Windows.Input.MouseButtonEventHandler(this.UAVWayPoint_MouseLeftButtonUp);
             *  this.MouseLeftButtonDown -= new System.Windows.Input.MouseButtonEventHandler(this.UAVWayPoint_MouseLeftButtonDown);
             * }
             * else
             * {
             *
             *  this.MouseLeave += new System.Windows.Input.MouseEventHandler(this.MarkerControl_MouseLeave);
             *  this.MouseMove += new System.Windows.Input.MouseEventHandler(this.UAVWayPoint_MouseMove);
             *  this.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.UAVWayPoint_MouseLeftButtonUp);
             *  this.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.UAVWayPoint_MouseLeftButtonDown);
             *
             * }
             */
            this.MainWindow  = window;
            this.Marker      = marker;
            this.Marker.ID   = _no;
            this.Marker.Mode = 0;

            Popup = new Popup();    //ポップアップ表示
            Label = new Label();    //ポップアップのコメント表示

            Popup.Placement = PlacementMode.Mouse;
            {
                Label.Background      = Brushes.Blue;
                Label.Foreground      = Brushes.White;
                Label.BorderBrush     = Brushes.WhiteSmoke;
                Label.BorderThickness = new Thickness(2);
                Label.Padding         = new Thickness(5);
                Label.FontSize        = 12;
                Label.Content         = "ID/" + this.Marker.ID.ToString() +
                                        "\n纬度/" + this.Marker.Position.Lat.ToString("0.0000000") +
                                        "\n经度/" + this.Marker.Position.Lng.ToString("0.0000000");

                /*      Label.Content = "ID/" + this.Marker.ID.ToString() +
                 *                    "\n纬度/" + this.Marker.Position.Lat.ToString("0.0000000") +
                 *                    "\n经度/" + this.Marker.Position.Lng.ToString("0.0000000") +
                 *                    "\n角度/" + this.Marker.Azimuth.ToString("0.0000000") +
                 *                    "\n高度/" + this.Marker.Altitude.ToString("0.0000000") +
                 *                    "\n速度/" + this.Marker.Speed.ToString("0.0000000");*/
            }
            Popup.Child = Label;

            Number.Content = this.Marker.ID.ToString();

            //var task = Task.Factory.StartNew(() =>
            //{

            //    while (EndFlag)
            //    {
            //        if (UavAngSw && cnt > PushTime)   //cnt(長押し)
            //        {
            //            modeFlag = true;
            //        }
            //        else if (!UavAngSw)
            //        {
            //            modeFlag = false;
            //            cnt = 0;
            //        }

            //        Dispatcher.BeginInvoke(new Action<int>(Worker), ang);
            //        System.Threading.Thread.Sleep(10);   //1msec
            //        ++cnt;

            //    }
            //});
            if (First_Open_Timer == 0)
            {
                _Timer          = new DispatcherTimer();
                _Timer.Interval = TimeSpan.FromMilliseconds(_TimeDelay);
                _Timer.Tick    += _Timer_Tick; //1秒计时完成触发该事件
                _Timer.Start();                //这个可以放在按钮事件里执行
            }
        }
Esempio n. 41
0
 public TimingModel()
 {
     timer          = new DispatcherTimer();
     start_time     = 0;
     timer.Interval = TimeSpan.FromMilliseconds(1000);
 }
Esempio n. 42
0
 public EventTimer()
 {
     event_timer = new DispatcherTimer();
 }
Esempio n. 43
0
 static ThemeManager()
 {
     _ThemeUpdateTimer = new DispatcherTimer();
     _ThemeUpdateTimer.Interval = TimeSpan.FromSeconds(0.25);
     _ThemeUpdateTimer.Tick += UpdateTheme;
     _ThemeUpdateTimer.Start();
 }
Esempio n. 44
0
        void backTimer_Tick(object sender, EventArgs e)
        {
            //if (++countSquirrelMoving % 2 == 0)
            //{
            //changePicture Here

            txtDistance.Text = (++countSquirrelMoving / 10).ToString() + "m";
            if (countSquirrelMoving % 100 == 0)
            {
                txtNotice.Text       = (countSquirrelMoving / 10).ToString() + "m";
                txtNotice.Visibility = System.Windows.Visibility.Visible;
                DispatcherTimer tempTimer = new DispatcherTimer();
                tempTimer.Interval = TimeSpan.FromSeconds(2);
                tempTimer.Tick    += (sender1, event1) => {
                    txtNotice.Visibility = System.Windows.Visibility.Collapsed;
                    tempTimer.Stop();
                };
                tempTimer.Start();
            }
            if (countSquirrelMoving / 10 > 10 && countSquirrelMoving % 10 == 0 && countSquirrelMoving / 10 % 5 == 0)
            {
                nutAmount++;
                txtNuts.Text = nutAmount.ToString();
            }

            if (countSquirrelMoving / 10 == 10)
            {
                speedTimer.Stop();
                speedTimer.Interval = TimeSpan.FromSeconds(4);
                speedTimer.Start();
                rotateTimer.Stop();
                rotateTimer.Interval = TimeSpan.FromMilliseconds(100);
                rotateTimer.Start();
                backTimer.Stop();
                backTimer.Interval = TimeSpan.FromMilliseconds(100);
                backTimer.Start();
                Stream      stream00 = TitleContainer.OpenStream("Sound/LevelUp.wav");
                SoundEffect effect00 = SoundEffect.FromStream(stream00);
                FrameworkDispatcher.Update();

                effect00.Play();
                level.Text = "at 30m";

                img0.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L2/img01.png");
                img1.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L2/img11.png");
                img2.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L2/img21.png");
                img3.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L2/img31.png");
                img4.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L2/img41.png");
                img5.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L2/img51.png");
            }
            if (countSquirrelMoving / 10 == 30)
            {
                speedTimer.Stop();
                speedTimer.Interval = TimeSpan.FromSeconds(4);
                speedTimer.Start();
                rotateTimer.Stop();
                rotateTimer.Interval = TimeSpan.FromMilliseconds(50);
                rotateTimer.Start();
                backTimer.Stop();
                backTimer.Interval = TimeSpan.FromMilliseconds(80);
                backTimer.Start();
                Stream      stream11 = TitleContainer.OpenStream("Sound/LevelUp.wav");
                SoundEffect effect11 = SoundEffect.FromStream(stream11);
                FrameworkDispatcher.Update();

                effect11.Play();
                level.Text  = "at 60m";
                img0.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L3/img02.png");
                img1.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L3/img12.png");
                img2.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L3/img22.png");
                img3.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L3/img32.png");
                img4.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L3/img42.png");
                img5.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L3/img52.png");
                //change red background
            }
            if (countSquirrelMoving / 10 == 60)
            {
                speedTimer.Stop();
                speedTimer.Interval = TimeSpan.FromSeconds(2);
                speedTimer.Start();
                rotateTimer.Stop();
                rotateTimer.Interval = TimeSpan.FromMilliseconds(25);
                rotateTimer.Start();
                backTimer.Stop();
                backTimer.Interval = TimeSpan.FromMilliseconds(80);
                backTimer.Start();
                Stream      stream22 = TitleContainer.OpenStream("Sound/LevelUp.wav");
                SoundEffect effect22 = SoundEffect.FromStream(stream22);
                FrameworkDispatcher.Update();

                effect22.Play();
                level.Text  = "at 100m";
                img0.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L4/img03.png");
                img1.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L4/img13.png");
                img2.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L4/img23.png");
                img3.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L4/img33.png");
                img4.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L4/img43.png");
                img5.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L4/img53.png");
                //change red background
            }
            if (countSquirrelMoving / 10 == 100)
            {
                speedTimer.Stop();
                speedTimer.Interval = TimeSpan.FromSeconds(2);
                speedTimer.Start();
                rotateTimer.Stop();
                rotateTimer.Interval = TimeSpan.FromMilliseconds(10);
                rotateTimer.Start();
                backTimer.Stop();
                backTimer.Interval = TimeSpan.FromMilliseconds(40);
                backTimer.Start();
                Stream      stream33 = TitleContainer.OpenStream("Sound/LevelUp.wav");
                SoundEffect effect33 = SoundEffect.FromStream(stream33);
                FrameworkDispatcher.Update();

                effect33.Play();
                level.Text  = "at 150m";
                img0.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L5/img04.png");
                img1.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L5/img14.png");
                img2.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L5/img24.png");
                img3.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L5/img34.png");
                img4.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L5/img44.png");
                img5.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L5/img54.png");
                //change red background
            }
            if (countSquirrelMoving / 10 == 150)
            {
                speedTimer.Stop();
                speedTimer.Interval = TimeSpan.FromSeconds(1);
                speedTimer.Start();
                rotateTimer.Stop();
                rotateTimer.Interval = TimeSpan.FromMilliseconds(10);
                rotateTimer.Start();
                backTimer.Stop();
                backTimer.Interval = TimeSpan.FromMilliseconds(20);
                backTimer.Start();
                Stream      stream44 = TitleContainer.OpenStream("Sound/LevelUp.wav");
                SoundEffect effect44 = SoundEffect.FromStream(stream44);
                FrameworkDispatcher.Update();

                effect44.Play();
                level.Text  = "at 200m";
                img0.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L6/img05.png");
                img1.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L6/img15.png");
                img2.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L6/img25.png");
                img3.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L6/img35.png");
                img4.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L6/img45.png");
                img5.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L6/img55.png");
                //change red background
            }
            if (countSquirrelMoving / 10 == 200)
            {
                speedTimer.Stop();
                speedTimer.Interval = TimeSpan.FromSeconds(1);
                speedTimer.Start();
                rotateTimer.Stop();
                rotateTimer.Interval = TimeSpan.FromMilliseconds(1);
                rotateTimer.Start();
                backTimer.Stop();
                backTimer.Interval = TimeSpan.FromMilliseconds(10);
                backTimer.Start();
                Stream      stream55 = TitleContainer.OpenStream("Sound/LevelUp.wav");
                SoundEffect effect55 = SoundEffect.FromStream(stream55);
                FrameworkDispatcher.Update();

                effect55.Play();
                txtLevel.Text = "";
                level.Text    = "The Last Level!";
                img0.Source   = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L7/img06.png");
                img1.Source   = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L7/img16.png");
                img2.Source   = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L7/img26.png");
                img3.Source   = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L7/img36.png");
                img4.Source   = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L7/img46.png");
                img5.Source   = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/L7/img56.png");
                //change red background
            }
            imgSquirrel.Source = (ImageSource) new ImageSourceConverter().ConvertFromString("Img/CrazySquirrel" + (countSquirrelMoving / 2) % 4 + ".png");
            if (countSquirrelMoving % 4 == 0)
            {
                effect.Play();
            }
            //}
            for (int i = 0; i < imge.Length; i++)
            {
                Thickness temp = imge[i].Margin;
                temp.Top -= 16;
                if (temp.Top <= -96)
                {
                    temp.Top       = 480;
                    imge[i].Margin = temp;
                }
                else
                {
                    imge[i].Margin = temp;
                }
                //imge[i]. = imge[i].Margin.Top - 1;
            }
        }
Esempio n. 45
0
        /// <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; 
        }
Esempio n. 46
0
        public TileLayer(ITileImageLoader tileImageLoader)
        {
            Initialize();

            RenderTransform = new MatrixTransform();
            TileImageLoader = tileImageLoader;
            Tiles = new List<Tile>();
            TileZoomLevel = -1;

            updateTimer = new DispatcherTimer { Interval = UpdateInterval };
            updateTimer.Tick += (s, e) => UpdateTileRect();
        }
Esempio n. 47
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");
        }
Esempio n. 48
0
        private async void Setup()
        {
            this.hat = await GIS.FEZHAT.CreateAsync();

            //this.hat.S1.SetLimits(500, 2400, 0, 180);
            //this.hat.S2.SetLimits(500, 2400, 0, 180);

            this.timer          = new DispatcherTimer();
            this.timer.Interval = TimeSpan.FromMilliseconds(100);

            this.timer.Start();

            Mobil            = new MobilRemote();
            this.timer.Tick += (a, b) =>
            {
                /*
                 * double x, y, z;
                 *
                 * this.hat.GetAcceleration(out x, out y, out z);
                 *
                 * this.LightTextBox.Text = this.hat.GetLightLevel().ToString("P2");
                 * this.TempTextBox.Text = this.hat.GetTemperature().ToString("N2");
                 * this.AccelTextBox.Text = $"({x:N2}, {y:N2}, {z:N2})";
                 * this.Button18TextBox.Text = this.hat.IsDIO18Pressed().ToString();
                 * this.Button22TextBox.Text = this.hat.IsDIO22Pressed().ToString();
                 * this.AnalogTextBox.Text = this.hat.ReadAnalog(GIS.FEZHAT.AnalogPin.Ain1).ToString("N2");
                 */
                if (isNavigating)
                {
                    return;
                }
                isNavigating      = true;
                this.hat.D2.Color = GIS.FEZHAT.Color.Black;
                this.hat.D3.Color = GIS.FEZHAT.Color.Black;

                switch (Mobil.Arah)
                {
                case MobilRemote.ArahJalan.Maju:
                    this.hat.MotorA.Speed = 1.0;
                    this.hat.MotorB.Speed = 1.0;
                    this.hat.D2.Color     = GIS.FEZHAT.Color.Green;
                    this.hat.D3.Color     = GIS.FEZHAT.Color.Green;
                    break;

                case MobilRemote.ArahJalan.Mundur:
                    this.hat.MotorA.Speed = -1.0;
                    this.hat.MotorB.Speed = -1.0;
                    this.hat.D2.Color     = GIS.FEZHAT.Color.Yellow;
                    this.hat.D3.Color     = GIS.FEZHAT.Color.Yellow;
                    break;

                case MobilRemote.ArahJalan.Kiri:
                    this.hat.MotorA.Speed = -0.7;
                    this.hat.MotorB.Speed = 0.7;
                    this.hat.D2.Color     = GIS.FEZHAT.Color.Blue;
                    this.hat.D3.Color     = GIS.FEZHAT.Color.Blue;
                    break;

                case MobilRemote.ArahJalan.Kanan:
                    this.hat.MotorB.Speed = -0.7;
                    this.hat.MotorA.Speed = 0.7;
                    this.hat.D2.Color     = GIS.FEZHAT.Color.Cyan;
                    this.hat.D3.Color     = GIS.FEZHAT.Color.Cyan;
                    break;

                case MobilRemote.ArahJalan.Stop:
                    this.hat.MotorA.Speed = 0.0;
                    this.hat.MotorB.Speed = 0.0;
                    this.hat.D2.Color     = GIS.FEZHAT.Color.Red;
                    this.hat.D3.Color     = GIS.FEZHAT.Color.Red;
                    break;
                }
                isNavigating = false;
            };
            timer.Start();

            client = new MqttClient(MQTT_BROKER_ADDRESS);
            string clientId = Guid.NewGuid().ToString();

            client.Connect(clientId, "mifmasterz", "123qweasd");
            SubscribeMessage();
        }
Esempio n. 49
0
 private void CreateTimer(int interval)
 {
     _timer          = new DispatcherTimer();
     _timer.Tick    += OnTimerTick;
     _timer.Interval = new TimeSpan(0, 0, 0, 0, interval);
 }
Esempio n. 50
0
 public static void Refresh(this DispatcherTimer t)
 {
     t.Stop();
     t.Start();
 }
Esempio n. 51
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();
        }
Esempio n. 52
0
        /// <summary>
        /// Initializes the main window.
        /// </summary>
        private void InitializeMainWindow()
        {
            Loaded         += OnWindowLoaded;
            PreviewKeyDown += OnWindowKeyDown;
            MouseWheel     += OnMouseWheelChange;

            #region Notification MEssages

            var notificationsStoryboard = FindResource("ShowNotification") as Storyboard;
            ViewModel.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName != nameof(ViewModel.NotificationMessage))
                {
                    return;
                }

                Dispatcher.InvokeAsync(() =>
                {
                    if (string.IsNullOrWhiteSpace(ViewModel.NotificationMessage))
                    {
                        NotificationsGrid.Opacity = 0;
                        return;
                    }

                    Storyboard.SetTarget(notificationsStoryboard, NotificationsGrid);
                    notificationsStoryboard.Begin();
                });
            };

            #endregion

            #region Mouse Move Detection for Hiding the Controller Panel

            LastMouseMoveTime = DateTime.UtcNow;

            Loaded += (s, e) =>
            {
                Storyboard.SetTarget(HideControllerAnimation, ControllerPanel);
                Storyboard.SetTarget(ShowControllerAnimation, ControllerPanel);

                HideControllerAnimation.Completed += (es, ee) =>
                {
                    ControllerPanel.Visibility = Visibility.Hidden;
                    IsControllerHideCompleted  = true;
                };

                ShowControllerAnimation.Completed += (es, ee) =>
                {
                    IsControllerHideCompleted = false;
                };
            };

            MouseMove += (s, e) =>
            {
                var currentPosition = e.GetPosition(window);
                if (Math.Abs(currentPosition.X - LastMousePosition.X) > double.Epsilon ||
                    Math.Abs(currentPosition.Y - LastMousePosition.Y) > double.Epsilon)
                {
                    LastMouseMoveTime = DateTime.UtcNow;
                }

                LastMousePosition = currentPosition;
            };

            MouseLeave += (s, e) =>
            {
                LastMouseMoveTime = DateTime.UtcNow.Subtract(TimeSpan.FromSeconds(10));
            };

            MouseMoveTimer = new DispatcherTimer(DispatcherPriority.Background)
            {
                Interval  = TimeSpan.FromMilliseconds(150),
                IsEnabled = true
            };

            MouseMoveTimer.Tick += (s, e) =>
            {
                var elapsedSinceMouseMove = DateTime.UtcNow.Subtract(LastMouseMoveTime);
                if (elapsedSinceMouseMove.TotalMilliseconds >= 3000 && Media.IsOpen && ControllerPanel.IsMouseOver == false &&
                    PropertiesPanel.Visibility != Visibility.Visible && ControllerPanel.SoundMenuPopup.IsOpen == false)
                {
                    if (IsControllerHideCompleted)
                    {
                        return;
                    }
                    Cursor = Cursors.None;
                    HideControllerAnimation?.Begin();
                    IsControllerHideCompleted = false;
                }
                else
                {
                    Cursor = Cursors.Arrow;
                    ControllerPanel.Visibility = Visibility.Visible;
                    ShowControllerAnimation?.Begin();
                }
            };

            MouseMoveTimer.Start();

            #endregion
        }
		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);
				});
			});
		}
Esempio n. 54
0
        private void RelocatePanels(bool forShow, double?frontPanelPosition = null)
        {
            if (Container == null)
            {
                throw new NotImplementedException($"'{nameof(Container)}' must be implemented");
            }

            if (UseBackdrop && Backdrop == null)
            {
                throw new NotImplementedException($"'{nameof(Backdrop)}' must be implemented when '{nameof(UseBackdrop)}' is true");
            }

            if (forShow && frontPanelPosition == null)
            {
                throw new ArgumentNullException($"{nameof(ParentHeight)} cannot be null when forShow is enabled");
            }

            LogMe("Start sorting panels.");
            foreach (var panel in Container.Children.OfType <Border>())
            {
                var count  = Container.Children.Count;
                var number = Container.Children.IndexOf(panel) + 1;
                var index  = count - number;

                if (!(panel.Child is Frame frame))
                {
                    throw new Exception("Why frame is null ?");
                }

                double position;
                if (!forShow)
                {
                    frame.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                    position = ParentHeight - (frame.DesiredSize.Height + 16);
                }
                else
                {
                    position = (double)frontPanelPosition;
                }

                Thickness margin;
                var       opacity = (double)(100 - (index * 19)) / 100;
                switch (forShow)
                {
                case false when index == 0:
                    margin = new Thickness
                    {
                        Left   = 0,
                        Right  = 0,
                        Bottom = 0,
                        Top    = ParentHeight
                    };
                    break;

                case false when index > 0:
                    var newIndex = index - 1;
                    opacity = (double)(100 - (newIndex * 19)) / 100;
                    margin  = new Thickness
                    {
                        Left   = newIndex * 5,
                        Right  = newIndex * 5,
                        Bottom = 0,
                        Top    = position - (newIndex * 10)
                    };
                    break;

                default:
                    margin = new Thickness
                    {
                        Left   = index * 5,
                        Right  = index * 5,
                        Bottom = 0,
                        Top    = position - (index * 10)
                    };
                    break;
                }

                int animationDelayMilliseconds;
                if (count == 1)
                {
                    animationDelayMilliseconds = 0;
                }
                else if (forShow)
                {
                    animationDelayMilliseconds = number != count ? 0 : 400;
                }
                else
                {
                    animationDelayMilliseconds = number == count ? 0 : 400;
                }

                var duration         = TimeSpan.FromMilliseconds(150);
                var opacityAnimation = new DoubleAnimation
                {
                    From      = panel.Opacity,
                    To        = opacity,
                    Duration  = duration,
                    BeginTime = TimeSpan.FromMilliseconds(animationDelayMilliseconds)
                };
                panel.BeginAnimation(UIElement.OpacityProperty, opacityAnimation);

                var thicknessAnimation = new ThicknessAnimation
                {
                    From      = panel.Margin,
                    To        = margin,
                    Duration  = duration,
                    BeginTime = TimeSpan.FromMilliseconds(animationDelayMilliseconds),
                };
                panel.BeginAnimation(FrameworkElement.MarginProperty, thicknessAnimation);
            }

            ShowingPanels = Container.Children.Count;
            LogMe("Sort done.");
            if (forShow)
            {
                return;
            }

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(300)
            };

            timer.Start();
            timer.Tick += (sender, args) =>
            {
                timer.Stop();
                Container.Children.Remove(Container.Children[Container.Children.Count - 1]);
                ShowingPanels = Container.Children.Count;
            };
        }
Esempio n. 55
0
 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 Window_Loaded(object sender, RoutedEventArgs e)
 {
     timer          = new DispatcherTimer();
     timer.Interval = new TimeSpan(100000000);
     timer.Tick    += Timer_Tick;
 }
Esempio n. 57
0
        /// <summary>
        /// Loads songs from a specified folder into the library. <seealso cref="LoadCommand"/>
        /// </summary>
        public async void Load()
        {
            FolderPicker picker = new FolderPicker()
            {
                SuggestedStartLocation = PickerLocationId.MusicLibrary
            };
            CoreMethods Methods = new CoreMethods();

            picker.FileTypeFilter.Add(".mp3");
            StorageFolder folder = await picker.PickSingleFolderAsync();

            LibraryFoldersCollection.Add(folder);
            if (folder != null)
            {
                if (StorageApplicationPermissions.FutureAccessList.Entries.Count <= 999)
                {
                    StorageApplicationPermissions.FutureAccessList.Clear();
                }
                StorageApplicationPermissions.FutureAccessList.Add(folder);
                var filelist = await BreadPlayer.Common.DirectoryWalker.GetFiles(folder.Path); //folder.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName); //

                var             tempList = new List <Mediafile>();
                DispatcherTimer timer    = new DispatcherTimer();
                timer.Interval = TimeSpan.FromSeconds(2);
                timer.Start();
                var    stop  = System.Diagnostics.Stopwatch.StartNew();
                double i     = 0;
                var    count = filelist.Count();
                foreach (var x in filelist)
                {
                    i++;
                    double percent = (i / count) * 100;
                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { LibVM.Progress = percent; });

                    Mediafile   mp3file = null;
                    StorageFile file    = await StorageFile.GetFileFromPathAsync(x);

                    string path = file.Path;

                    if (LibVM.TracksCollection.Elements.All(t => t.Path != path))
                    {
                        try
                        {
                            mp3file = await CoreMethods.CreateMediafile(file);

                            tempList.Add(mp3file);
                        }
                        catch { }

                        timer.Tick += (sender, e) =>
                        {
                            LibVM.TracksCollection.AddRange(tempList);
                            LibVM.db.Insert(tempList);
                            tempList.Clear();
                        };
                    }
                }
                AlbumArtistVM.AddAlbums();
                stop.Stop();
                ShowMessage(stop.ElapsedMilliseconds.ToString() + "    " + LibVM.TracksCollection.Elements.Count.ToString());
            }
        }
Esempio n. 58
0
 public DoubleClickBehavior()
 {
     timer          = new DispatcherTimer();
     timer.Interval = new TimeSpan(0, 0, 0, 0, dblclickDelay);
     timer.Tick    += (sender, e) => timer.Stop();
 }
Esempio n. 59
0
        public XamlCanvas()
        {
            Background = new SolidColorBrush (NativeColors.Transparent);

            MinFps = 4;
            MaxFps = 30;
            Continuous = true;

            _drawTimer = new DispatcherTimer();
            _drawTimer.Tick += DrawTick;

            Unloaded += HandleUnloaded;
            Loaded += HandleLoaded;
            LayoutUpdated += delegate { HandleLayoutUpdated (); };
        }
Esempio n. 60
0
        private void glControl_Load(object sender, EventArgs e)
        {
            glControl.MakeCurrent();
            GL.Enable(EnableCap.DepthTest);
            GL.Disable(EnableCap.Lighting);
            GL.Disable(EnableCap.Texture2D);
            GL.Disable(EnableCap.CullFace);
            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
            GL.ClearColor(0.5f, 0.5f, 1.0f, 1.0f);

            plane      = new Physics.Plane(new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0, 1, 0));
            rigidBody1 = new RigidBody();

            Vector3 v3Gravity = new Vector3(0, -9.81f, 0);

            rigidBody1.m_fMass           = 1.0f;
            rigidBody1.m_v3Position      = new Vector3(0f, 1.0f, 0);
            rigidBody1.m_fGravity        = v3Gravity;
            rigidBody1.m_fRestitution    = 0.0f;
            rigidBody1.m_fFriction       = 1.0f;
            rigidBody1.m_v3Rotate        = new Vector3(0, 0, 0);
            rigidBody1.m_fLinearDamping  = 0.2f;
            rigidBody1.m_fAngularDamping = 0.2f;

            rigidBody1.m_listPoints.Add(new Vector3(-2.0f, -1.0f, -1.5f));
            rigidBody1.m_listPoints.Add(new Vector3(+2.0f, -1.0f, -1.5f));
            rigidBody1.m_listPoints.Add(new Vector3(-2.0f, +1.0f, -1.5f));
            rigidBody1.m_listPoints.Add(new Vector3(+2.0f, +1.0f, -1.5f));
            rigidBody1.m_listPoints.Add(new Vector3(-2.0f, -1.0f, +1.5f));
            rigidBody1.m_listPoints.Add(new Vector3(+2.0f, -1.0f, +1.5f));
            rigidBody1.m_listPoints.Add(new Vector3(-2.0f, +1.0f, +1.5f));
            rigidBody1.m_listPoints.Add(new Vector3(+2.0f, +1.0f, +1.5f));

            // back
            rigidBody1.m_listIndices.AddRange(new int[] { 3, 1, 0 });
            rigidBody1.m_listIndices.AddRange(new int[] { 0, 2, 3 });
            // front
            rigidBody1.m_listIndices.AddRange(new int[] { 4, 5, 7 });
            rigidBody1.m_listIndices.AddRange(new int[] { 7, 6, 4 });
            // left
            rigidBody1.m_listIndices.AddRange(new int[] { 6, 2, 0 });
            rigidBody1.m_listIndices.AddRange(new int[] { 0, 4, 6 });
            // right
            rigidBody1.m_listIndices.AddRange(new int[] { 1, 3, 7 });
            rigidBody1.m_listIndices.AddRange(new int[] { 7, 5, 1 });
            // bottom
            rigidBody1.m_listIndices.AddRange(new int[] { 0, 1, 5 });
            rigidBody1.m_listIndices.AddRange(new int[] { 5, 4, 0 });
            // top
            rigidBody1.m_listIndices.AddRange(new int[] { 7, 3, 2 });
            rigidBody1.m_listIndices.AddRange(new int[] { 2, 6, 7 });

            rigidBody1.Create();

            ;

            rigidBody2 = new RigidBody();

            rigidBody2.m_fMass           = 1.0f;
            rigidBody2.m_v3Position      = new Vector3(0.0f, 3.5f, 0);
            rigidBody2.m_fGravity        = v3Gravity;
            rigidBody2.m_fRestitution    = 0.0f;
            rigidBody2.m_fFriction       = 1.0f;
            rigidBody2.m_v3Rotate        = new Vector3(0, 0, 0);
            rigidBody2.m_fLinearDamping  = 0.2f;
            rigidBody2.m_fAngularDamping = 0.2f;

            float fScale = 1.0f;

            rigidBody2.m_listPoints.Add(new Vector3(-2.0f, -1.0f, -1.5f) * fScale);
            rigidBody2.m_listPoints.Add(new Vector3(+2.0f, -1.0f, -1.5f) * fScale);
            rigidBody2.m_listPoints.Add(new Vector3(-2.0f, +1.0f, -1.5f) * fScale);
            rigidBody2.m_listPoints.Add(new Vector3(+2.0f, +1.0f, -1.5f) * fScale);
            rigidBody2.m_listPoints.Add(new Vector3(-2.0f, -1.0f, +1.5f) * fScale);
            rigidBody2.m_listPoints.Add(new Vector3(+2.0f, -1.0f, +1.5f) * fScale);
            rigidBody2.m_listPoints.Add(new Vector3(-2.0f, +1.0f, +1.5f) * fScale);
            rigidBody2.m_listPoints.Add(new Vector3(+2.0f, +1.0f, +1.5f) * fScale);

            // back
            rigidBody2.m_listIndices.AddRange(new int[] { 3, 1, 0 });
            rigidBody2.m_listIndices.AddRange(new int[] { 0, 2, 3 });
            // front
            rigidBody2.m_listIndices.AddRange(new int[] { 4, 5, 7 });
            rigidBody2.m_listIndices.AddRange(new int[] { 7, 6, 4 });
            // left
            rigidBody2.m_listIndices.AddRange(new int[] { 6, 2, 0 });
            rigidBody2.m_listIndices.AddRange(new int[] { 0, 4, 6 });
            // right
            rigidBody2.m_listIndices.AddRange(new int[] { 1, 3, 7 });
            rigidBody2.m_listIndices.AddRange(new int[] { 7, 5, 1 });
            // bottom
            rigidBody2.m_listIndices.AddRange(new int[] { 0, 1, 5 });
            rigidBody2.m_listIndices.AddRange(new int[] { 5, 4, 0 });
            // top
            rigidBody2.m_listIndices.AddRange(new int[] { 7, 3, 2 });
            rigidBody2.m_listIndices.AddRange(new int[] { 2, 6, 7 });

            rigidBody2.Create();



            //rigidBody3 = new RigidBody();
            //
            //rigidBody3.m_fMass = 1.0f;
            //rigidBody3.m_v3Position = new Vector3(0f, 15.0f, 0);
            //rigidBody3.m_fGravity = v3Gravity;
            //rigidBody3.m_fRestitution = 0.1f;
            //rigidBody3.m_v3Rotate = new Vector3(ToRadian(0.0f), ToRadian(0.0f), ToRadian(0.0f));
            //rigidBody3.m_fLinearDamping = 0.01f;
            //rigidBody3.m_fAngularDamping = 0.01f;
            //
            //rigidBody3.m_listPoints.Add(new Vector3(-3.0f, -1.5f, -2.5f));
            //rigidBody3.m_listPoints.Add(new Vector3(+3.0f, -1.5f, -2.5f));
            //rigidBody3.m_listPoints.Add(new Vector3(-3.0f, +1.5f, -2.5f));
            //rigidBody3.m_listPoints.Add(new Vector3(+3.0f, +1.5f, -2.5f));
            //rigidBody3.m_listPoints.Add(new Vector3(-3.0f, -1.5f, +2.5f));
            //rigidBody3.m_listPoints.Add(new Vector3(+3.0f, -1.5f, +2.5f));
            //rigidBody3.m_listPoints.Add(new Vector3(-3.0f, +1.5f, +2.5f));
            //rigidBody3.m_listPoints.Add(new Vector3(+3.0f, +1.5f, +2.5f));
            //
            //// back
            //rigidBody3.m_listIndices.AddRange(new int[] { 3, 1, 0 });
            //rigidBody3.m_listIndices.AddRange(new int[] { 0, 2, 3 });
            //// front
            //rigidBody3.m_listIndices.AddRange(new int[] { 4, 5, 7 });
            //rigidBody3.m_listIndices.AddRange(new int[] { 7, 6, 4 });
            //// left
            //rigidBody3.m_listIndices.AddRange(new int[] { 6, 2, 0 });
            //rigidBody3.m_listIndices.AddRange(new int[] { 0, 4, 6 });
            //// right
            //rigidBody3.m_listIndices.AddRange(new int[] { 1, 3, 7 });
            //rigidBody3.m_listIndices.AddRange(new int[] { 7, 5, 1 });
            //// bottom
            //rigidBody3.m_listIndices.AddRange(new int[] { 0, 1, 5 });
            //rigidBody3.m_listIndices.AddRange(new int[] { 5, 4, 0 });
            //// top
            //rigidBody3.m_listIndices.AddRange(new int[] { 7, 3, 2 });
            //rigidBody3.m_listIndices.AddRange(new int[] { 2, 6, 7 });
            //
            //rigidBody3.CalculateNormals();

            DispatcherTimer timer = new DispatcherTimer();

            timer.Tick    += Timer_Tick;
            timer.Interval = TimeSpan.FromSeconds(0);
            timer.Start();
        }