コード例 #1
0
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            switch (index)
            {
            case 0:
                TextManager.SetTitle("Animation Events");
                TextManager.AddBulletAtLevel("SCNAnimationEvent", 0);
                TextManager.AddBulletAtLevel("Smooth transitions", 0);

                TextManager.AddCode("#var anEvent = #SCNAnimationEvent.Create# (0.2,  aBlock); \n"
                                    + "anAnimation.#AnimationEvents# = @[anEvent, anotherEvent];#");

                var path      = NSBundle.MainBundle.PathForResource("Sounds/bossaggro", "wav");
                var soundUrl  = NSUrl.FromFilename(path);
                var bossaggro = new NSSound(soundUrl, false);
                bossaggro.Play();
                break;

            case 1:
                // Trigger the attack animation
                HeroSkeletonNode.AddAnimation(Animations [(int)CharacterAnimation.Attack], new NSString("attack"));
                break;

            case 2:
                TextManager.FadeOutText(SlideTextManager.TextType.Code);
                TextManager.AddCode("#\n"
                                    + "\n"
                                    + "\n\n"
                                    + "anAnimation.FadeInDuration = #0.0#;\n"
                                    + "anAnimation.FadeOutDuration = #0.0#;#");
                break;

            case 3:
            case 4:
                Animations[(int)CharacterAnimation.Attack].FadeInDuration  = 0;
                Animations[(int)CharacterAnimation.Attack].FadeOutDuration = 0;
                // Trigger the attack animation
                HeroSkeletonNode.AddAnimation(Animations [(int)CharacterAnimation.Attack], new NSString("attack"));
                break;

            case 5:
                TextManager.FadeOutText(SlideTextManager.TextType.Code);
                TextManager.AddCode("#\n"
                                    + "\n"
                                    + "\n\n"
                                    + "anAnimation.FadeInDuration = #0.3#;\n"
                                    + "anAnimation.FadeOutDuration = #0.3#;#");
                break;

            case 6:
            case 7:
                Animations[(int)CharacterAnimation.Attack].FadeInDuration  = 0.3f;
                Animations[(int)CharacterAnimation.Attack].FadeOutDuration = 0.3f;
                // Trigger the attack animation
                HeroSkeletonNode.AddAnimation(Animations [(int)CharacterAnimation.Attack], new NSString("attack"));
                break;
            }
        }
コード例 #2
0
ファイル: GuiUtil.cs プロジェクト: xerohour/scsharp
        public static void PlaySound(Mpq mpq, string resourcePath)
        {
            Stream stream = (Stream)mpq.GetResource(resourcePath);

            if (stream == null)
            {
                return;
            }
            NSSound s = GuiUtil.SoundFromStream(stream);

            s.Play();
        }
コード例 #3
0
		public override void PresentStep (int index, PresentationViewController presentationViewController)
		{
			switch (index) {
			case 0:
				TextManager.SetTitle ("Animation Events");
				TextManager.AddBulletAtLevel ("SCNAnimationEvent", 0);
				TextManager.AddBulletAtLevel ("Smooth transitions", 0);

				TextManager.AddCode ("#var anEvent = #SCNAnimationEvent.Create# (0.2,  aBlock); \n"
				+ "anAnimation.#AnimationEvents# = @[anEvent, anotherEvent];#");

				var path = NSBundle.MainBundle.PathForResource ("Sounds/bossaggro", "wav");
				var soundUrl = NSUrl.FromFilename (path);
				var bossaggro = new NSSound (soundUrl, false);
				bossaggro.Play ();
				break;
			case 1:
				// Trigger the attack animation
				HeroSkeletonNode.AddAnimation (Animations [(int)CharacterAnimation.Attack], new NSString ("attack"));
				break;
			case 2:
				TextManager.FadeOutText (SlideTextManager.TextType.Code);
				TextManager.AddCode ("#\n"
				+ "\n"
				+ "\n\n"
				+ "anAnimation.FadeInDuration = #0.0#;\n"
				+ "anAnimation.FadeOutDuration = #0.0#;#");
				break;
			case 3:
			case 4:
				Animations[(int)CharacterAnimation.Attack].FadeInDuration = 0;
				Animations[(int)CharacterAnimation.Attack].FadeOutDuration = 0;
				// Trigger the attack animation
				HeroSkeletonNode.AddAnimation (Animations [(int)CharacterAnimation.Attack], new NSString ("attack"));
				break;
			case 5:
				TextManager.FadeOutText (SlideTextManager.TextType.Code);
				TextManager.AddCode ("#\n"
					+ "\n"
					+ "\n\n"
					+ "anAnimation.FadeInDuration = #0.3#;\n"
					+ "anAnimation.FadeOutDuration = #0.3#;#");
					break;
			case 6:
			case 7:
				Animations[(int)CharacterAnimation.Attack].FadeInDuration = 0.3f;
				Animations[(int)CharacterAnimation.Attack].FadeOutDuration = 0.3f;
				// Trigger the attack animation
				HeroSkeletonNode.AddAnimation (Animations [(int)CharacterAnimation.Attack], new NSString ("attack"));
				break;
			}
		}
コード例 #4
0
ファイル: GuiUtil.cs プロジェクト: xerohour/scsharp
        public static void PlayMusic(Mpq mpq, string resourcePath, int numLoops)
        {
            Stream stream = (Stream)mpq.GetResource(resourcePath);

            if (stream == null)
            {
                return;
            }
            NSSound s = GuiUtil.SoundFromStream(stream);

            s.Loops = true;;
            s.Play();
        }
コード例 #5
0
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            switch (index)
            {
            case 0:
                TextManager.SetTitle("Animation Events");
                TextManager.AddBulletAtLevel("SCNAnimationEvent", 0);

                TextManager.AddCode("#var anEvent = #SCNAnimationEvent.Create# (0.2,  aBlock); \n"
                                    + "anAnimation.#AnimationEvents# = @[anEvent, anotherEvent];#");

                // Warm up NSSound by playing an empty sound.
                // Otherwise the first sound may take some time to start playing and will be desynchronised.
                var path       = NSBundle.MainBundle.PathForResource("Sounds/emptySound", "m4a");
                var soundUrl   = NSUrl.FromFilename(path);
                var emptySound = new NSSound(soundUrl, false);
                emptySound.Play();
                break;

            case 1:
            case 2:
                // Trigger the attack animation
                HeroSkeletonNode.AddAnimation(Animations [(int)CharacterAnimation.Attack], new NSString("attack"));
                break;

            case 3:
                // Trigger the walk animation
                HeroSkeletonNode.AddAnimation(Animations [(int)CharacterAnimation.Walk], new NSString("walk"));
                break;

            case 4:
                // Trigger the death animation
                // Make sure to remove the "idle" animation and prevent the model from intersecting with the floor.

                HeroSkeletonNode.RemoveAllAnimations();
                HeroSkeletonNode.AddAnimation(Animations [(int)CharacterAnimation.Die], new NSString("death"));

                SCNTransaction.Begin();
                //TODO heroSkeletonNode.ParentNode.Transform = SCNMatrix4.CreateTranslation (new SCNVector3 (0, 0, 40)); //CATransform3DTranslate(_heroSkeletonNode.parentNode.transform, 0, 0, 40);
                SCNTransaction.Commit();
                break;
            }
        }
コード例 #6
0
		public override void PresentStep (int index, PresentationViewController presentationViewController)
		{
			switch (index) {
			case 0:
				TextManager.SetTitle ("Animation Events");
				TextManager.AddBulletAtLevel ("SCNAnimationEvent", 0);

				TextManager.AddCode ("#var anEvent = #SCNAnimationEvent.Create# (0.2,  aBlock); \n"
				+ "anAnimation.#AnimationEvents# = @[anEvent, anotherEvent];#");

				// Warm up NSSound by playing an empty sound.
				// Otherwise the first sound may take some time to start playing and will be desynchronised.
				var path = NSBundle.MainBundle.PathForResource ("Sounds/emptySound", "m4a");
				var soundUrl = NSUrl.FromFilename (path);
				var emptySound = new NSSound (soundUrl, false);
				emptySound.Play ();
				break;
			case 1:
			case 2:
				// Trigger the attack animation
				HeroSkeletonNode.AddAnimation (Animations [(int)CharacterAnimation.Attack], new NSString ("attack"));
				break;
			case 3:
				// Trigger the walk animation
				HeroSkeletonNode.AddAnimation (Animations [(int)CharacterAnimation.Walk], new NSString ("walk"));
				break;
			case 4:
				// Trigger the death animation
				// Make sure to remove the "idle" animation and prevent the model from intersecting with the floor.

				HeroSkeletonNode.RemoveAllAnimations ();
				HeroSkeletonNode.AddAnimation (Animations [(int)CharacterAnimation.Die], new NSString ("death"));

				SCNTransaction.Begin ();
				//TODO heroSkeletonNode.ParentNode.Transform = SCNMatrix4.CreateTranslation (new SCNVector3 (0, 0, 40)); //CATransform3DTranslate(_heroSkeletonNode.parentNode.transform, 0, 0, 40);
				SCNTransaction.Commit ();
				break;
			}
		}
コード例 #7
0
        partial void OpenWavFile(NSObject sender)
        {
            var dlg = NSOpenPanel.OpenPanel;

            dlg.CanChooseFiles       = true;
            dlg.CanChooseDirectories = false;
            dlg.AllowedFileTypes     = new string[] { "mp3" };


            if (dlg.RunModal() == 1)
            {
                var url = dlg.Urls[0];
            }

            sound = new NSSound(dlg.Filename, byRef: false);
            var fil = new FileInfo(dlg.Filename);

            sound.Play();
            isPaused = false;
            string imagePath = "/Users/sansirajalingam/Desktop/bla.jpg";

            image = new NSImage(imagePath);
        }
コード例 #8
0
 public void Play()
 {
     _audioPlayer.Play();
 }
コード例 #9
0
        private void SetAnimation(CharacterAnimation index, string animationName, string sceneName)
        {
            // Load the DAE using SCNSceneSource in order to be able to retrieve the animation by its identifier
            var path        = NSBundle.MainBundle.PathForResource("Scenes/hero/" + sceneName, "dae");
            var sceneURL    = NSUrl.FromFilename(path);
            var sceneSource = SCNSceneSource.FromUrl(sceneURL, (NSDictionary)null);

            var animation = (CAAnimation)sceneSource.GetEntryWithIdentifier(animationName, new Class("CAAnimation"));

            Animations [(int)index] = animation;

            // Blend animations for smoother transitions
            animation.FadeInDuration  = 0.3f;
            animation.FadeOutDuration = 0.3f;

            if (index == CharacterAnimation.Die)
            {
                // We want the "death" animation to remain at its final state at the end of the animation
                animation.RemovedOnCompletion = false;
                animation.FillMode            = CAFillMode.Both;

                // Create animation events and set them to the animation
                var swipeSoundEventHandler = new SCNAnimationEventHandler((CAAnimation handlerAnimation, NSObject animatedObject, bool playingBackward) => {
                    InvokeOnMainThread(delegate {
                        var soundUrl = NSUrl.FromFilename(NSBundle.MainBundle.PathForResource("Sounds/swipe", "wav"));
                        new NSSound(soundUrl, false).Play();
                    });
                });

                var deathSoundEventBlock = new SCNAnimationEventHandler((CAAnimation handlerAnimation, NSObject animatedObject, bool playingBackward) => {
                    InvokeOnMainThread(delegate {
                        var soundUrl = NSUrl.FromFilename(NSBundle.MainBundle.PathForResource("Sounds/death", "wav"));
                        new NSSound(soundUrl, false).Play();
                    });
                });

                animation.AnimationEvents = new SCNAnimationEvent[] {
                    SCNAnimationEvent.Create(0.0f, swipeSoundEventHandler),
                    SCNAnimationEvent.Create(0.3f, deathSoundEventBlock)
                };
            }

            if (index == CharacterAnimation.Attack)
            {
                // Create an animation event and set it to the animation
                var swordSoundEventHandler = new SCNAnimationEventHandler((CAAnimation handlerAnimation, NSObject animatedObject, bool playingBackward) => {
                    InvokeOnMainThread(delegate {
                        var soundUrl    = NSUrl.FromFilename(NSBundle.MainBundle.PathForResource("Sounds/sword", "wav"));
                        var attackSound = new NSSound(soundUrl, false);
                        attackSound.Play();
                    });
                });

                animation.AnimationEvents = new SCNAnimationEvent[] { SCNAnimationEvent.Create(0.4f, swordSoundEventHandler) };
            }

            if (index == CharacterAnimation.Walk)
            {
                // Repeat the walk animation 3 times
                animation.RepeatCount = 3;

                // Create an animation event and set it to the animation
                var stepSoundEventHandler = new SCNAnimationEventHandler((CAAnimation handlerAnimation, NSObject animatedObject, bool playingBackward) => {
                    InvokeOnMainThread(delegate {
                        var soundUrl = NSUrl.FromFilename(NSBundle.MainBundle.PathForResource("Sounds/walk", "wav"));
                        new NSSound(soundUrl, false).Play();
                    });
                });

                animation.AnimationEvents = new SCNAnimationEvent[] {
                    SCNAnimationEvent.Create(0.2f, stepSoundEventHandler),
                    SCNAnimationEvent.Create(0.7f, stepSoundEventHandler)
                };
            }
        }
コード例 #10
0
ファイル: BowlSound.cs プロジェクト: vicenteherrera/awareness
 public override void Play(float volume = 100)
 {
     Sound.Volume = volume / 100;
     Sound.Play();
 }
コード例 #11
0
        public override void FinishedLaunching(NSObject notification)
        {
            // Configure logger
            string path = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "log4net.config");

            XmlConfigurator.ConfigureAndWatch(new FileInfo(path));
            logger.Info("Ventriliquest 1.0 Starting up...");

            // Get list of available audio out devices
            xamspeech ham = new xamspeech();

            OutputDevices = ham.GetDevices();

            // Setup UI
            statusMenu = new NSMenu();
            statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);

            var outputItem = new NSMenuItem("Output Device",
                                            (a, b) => {
            });

            var deviceList = new NSMenu();

            outputItem.Submenu = deviceList;

            OutputDeviceUID = "Built-in Output";

            foreach (var entry in OutputDevices)
            {
                var test = new NSMenuItem(entry.Key.ToString(),
                                          (a, b) => {
                    foreach (NSMenuItem item in deviceList.ItemArray())
                    {
                        item.State = NSCellStateValue.Off;
                    }
                    NSMenuItem theItem  = (NSMenuItem)a;
                    theItem.State       = NSCellStateValue.On;
                    config.OutputDevice = theItem.Title;
                    foreach (var e in OutputDevices)
                    {
                        if (e.Key.ToString().Equals(theItem.Title))
                        {
                            OutputDeviceUID = e.Value.ToString();
                        }
                    }
                });
                if (entry.Key.ToString().Equals(config.OutputDevice))
                {
                    test.State      = NSCellStateValue.On;
                    OutputDeviceUID = entry.Value.ToString();
                }
                deviceList.AddItem(test);
            }

            var daItem = new NSMenuItem("Local Connections Only",
                                        (a, b) => {
                NSMenuItem theItem = (NSMenuItem)a;
                if (theItem.State == NSCellStateValue.On)
                {
                    config.LocalOnly = false;
                    theItem.State    = NSCellStateValue.Off;
                }
                else
                {
                    config.LocalOnly = true;
                    theItem.State    = NSCellStateValue.On;
                }
            });

            if (config.LocalOnly)
            {
                daItem.State = NSCellStateValue.On;
            }

            var quitItem = new NSMenuItem("Quit",
                                          (a, b) => Shutdown());

            var voiceconfigItem = new NSMenuItem("Voice Configuration",
                                                 (a, b) => Process.Start("http://127.0.0.1:7888/config"));

            statusMenu.AddItem(new NSMenuItem("Version: 1.1"));
            statusMenu.AddItem(outputItem);
            statusMenu.AddItem(daItem);
            statusMenu.AddItem(voiceconfigItem);
            statusMenu.AddItem(quitItem);
            statusItem.Menu           = statusMenu;
            statusItem.Image          = NSImage.ImageNamed("tts-1.png");
            statusItem.AlternateImage = NSImage.ImageNamed("tts-2.png");
            statusItem.HighlightMode  = true;

            speechdelegate.DidComplete += delegate {
                synthesis.Set();
            };
            sounddelegate.DidComplete += delegate {
                playback.Set();
                IsSounding = false;
                IsSpeaking = false;
                sound.Dispose();
            };

            speech.Delegate = speechdelegate;

            queuetimer          = new System.Timers.Timer(250);
            queuetimer.Elapsed += (object sender, ElapsedEventArgs e) => {
                TTSRequest r;
                if (Queue.TryDequeue(out r))
                {
                    if (r.Interrupt)
                    {
                        // stop current TTS
                        NSApplication.SharedApplication.InvokeOnMainThread(delegate {
                            if (IsSpeaking)
                            {
                                speech.StopSpeaking();
                            }
                            if (IsSounding)
                            {
                                sound.Stop();
                            }
                        });
                        // clear queue
                        SpeechQueue.Clear();
                    }
                    if (!r.Reset)
                    {
                        SpeechQueue.Enqueue(r);
                    }
                    RequestCount++;
                }
                var eventdata = new Hashtable();
                eventdata.Add("ProcessedRequests", RequestCount);
                eventdata.Add("QueuedRequests", SpeechQueue.Count);
                eventdata.Add("IsSpeaking", IsSpeaking);
                InstrumentationEvent ev = new InstrumentationEvent();
                ev.EventName = "status";
                ev.Data      = eventdata;
                NotifyGui(ev.EventMessage());
            };

            // when this timer fires, it will pull off of the speech queue and speak it
            // the 1000ms delay also adds a little pause between tts requests.
            speechtimer          = new System.Timers.Timer(250);
            speechtimer.Elapsed += (object sender, ElapsedEventArgs e) => {
                if (IsSpeaking.Equals(false))
                {
                    if (SpeechQueue.Count > 0)
                    {
                        TTSRequest r = SpeechQueue.Dequeue();
                        IsSpeaking          = true;
                        speechtimer.Enabled = false;
                        var oink = Path.Combine(audiopath, "temp.aiff");
                        NSApplication.SharedApplication.InvokeOnMainThread(delegate {
                            ConfigureSpeechEngine(r);
                            speech.StartSpeakingStringtoURL(r.Text, new NSUrl(oink, false));
                        });
                        synthesis.WaitOne();
                        NSApplication.SharedApplication.InvokeOnMainThread(delegate {
                            IsSounding     = true;
                            sound          = new NSSound(Path.Combine(audiopath, "temp.aiff"), false);
                            sound.Delegate = sounddelegate;
                            //if(OutputDeviceUID != "Default") {
                            sound.PlaybackDeviceID = OutputDeviceUID;
                            //}
                            sound.Play();
                        });
                        playback.WaitOne();
                        IsSounding          = false;
                        speechtimer.Enabled = true;
                    }
                }
            };

            queuetimer.Enabled = true;
            queuetimer.Start();
            speechtimer.Enabled = true;
            speechtimer.Start();

            InitHTTPServer();
        }
コード例 #12
0
		void SetAnimation (CharacterAnimation index, string animationName, string sceneName)
		{
			// Load the DAE using SCNSceneSource in order to be able to retrieve the animation by its identifier
			var path = NSBundle.MainBundle.PathForResource ("Scenes/hero/" + sceneName, "dae");
			var sceneURL = NSUrl.FromFilename (path);
			var sceneSource = SCNSceneSource.FromUrl (sceneURL, (NSDictionary)null);

			var animation = (CAAnimation)sceneSource.GetEntryWithIdentifier (animationName, new Class ("CAAnimation"));
			Animations [(int)index] = animation;

			// Blend animations for smoother transitions
			animation.FadeInDuration = 0.3f;
			animation.FadeOutDuration = 0.3f;

			if (index == CharacterAnimation.Die) {
				// We want the "death" animation to remain at its final state at the end of the animation
				animation.RemovedOnCompletion = false;
				animation.FillMode = CAFillMode.Both;

				// Create animation events and set them to the animation
				var swipeSoundEventHandler = new SCNAnimationEventHandler ((CAAnimation handlerAnimation, NSObject animatedObject, bool playingBackward) => {
					InvokeOnMainThread (delegate {
						var soundUrl = NSUrl.FromFilename (NSBundle.MainBundle.PathForResource ("Sounds/swipe", "wav"));
						new NSSound (soundUrl, false).Play ();
					});
				});

				var deathSoundEventBlock = new SCNAnimationEventHandler ((CAAnimation handlerAnimation, NSObject animatedObject, bool playingBackward) => {
					InvokeOnMainThread (delegate {
						var soundUrl = NSUrl.FromFilename (NSBundle.MainBundle.PathForResource ("Sounds/death", "wav"));
						new NSSound (soundUrl, false).Play ();
					});
				});

				animation.AnimationEvents = new SCNAnimationEvent[] {
					SCNAnimationEvent.Create (0.0f, swipeSoundEventHandler),
					SCNAnimationEvent.Create (0.3f, deathSoundEventBlock)
				};
			}

			if (index == CharacterAnimation.Attack) {
				// Create an animation event and set it to the animation
				var swordSoundEventHandler = new SCNAnimationEventHandler ((CAAnimation handlerAnimation, NSObject animatedObject, bool playingBackward) => {
					InvokeOnMainThread (delegate {
						var soundUrl = NSUrl.FromFilename (NSBundle.MainBundle.PathForResource ("Sounds/sword", "wav"));
						var attackSound = new NSSound (soundUrl, false);
						attackSound.Play ();
					});
				});

				animation.AnimationEvents = new SCNAnimationEvent[] { SCNAnimationEvent.Create (0.4f, swordSoundEventHandler) };
			}

			if (index == CharacterAnimation.Walk) {
				// Repeat the walk animation 3 times
				animation.RepeatCount = 3;

				// Create an animation event and set it to the animation
				var stepSoundEventHandler = new SCNAnimationEventHandler ((CAAnimation handlerAnimation, NSObject animatedObject, bool playingBackward) => {
					InvokeOnMainThread (delegate {
						var soundUrl = NSUrl.FromFilename (NSBundle.MainBundle.PathForResource ("Sounds/walk", "wav"));
						new NSSound (soundUrl, false).Play ();
					});
				});

				animation.AnimationEvents = new SCNAnimationEvent[] {
					SCNAnimationEvent.Create (0.2f, stepSoundEventHandler),
					SCNAnimationEvent.Create (0.7f, stepSoundEventHandler)
				};
			}
		}
コード例 #13
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.labeltime.Alignment       = NSTextAlignment.Center;
            this.txtRemain.StringValue     = "";
            this.txtRemain.BackgroundColor = NSColor.FromRgb(135 / 255f, 206 / 255f, 250 / 255f);
            this.txtRemain.Alignment       = NSTextAlignment.Center;
            this.txtminutes.Alignment      = NSTextAlignment.Right;

            SecondTimer          = new Timer(1000);
            SecondTimer.Elapsed += (sender, e) =>
            {
                TimeLeft--;
                TimeSpan time = TimeSpan.FromSeconds(TimeLeft);

                InvokeOnMainThread(() =>
                {
                    this.txtRemain.StringValue = $"剩:{TimeLeft / 60} 分鐘 ";
                });

                if (TimeLeft == 0)
                {
                    // Stop the timer and reset
                    //SecondTimer.Stop();
                    TimeLeft = this.orignTimeLeft;

                    InvokeOnMainThread(() =>
                    {
                        String path = NSBundle.MainBundle.PathForResource("fb", "mp3");

                        NSSound sound = new NSSound(path, true);

                        sound.Play();

                        NSAlert alert = new NSAlert();
                        // Set the style and message text
                        alert.AlertStyle  = NSAlertStyle.Informational;
                        alert.MessageText = "起來休息啦!!";
                        //NSImage image = NSImage.ImageNamed("clock.ico");
                        // Display the NSAlert from the current view
                        alert.BeginSheet(View.Window);
                        NSTimer.CreateScheduledTimer(TimeSpan.FromSeconds(5), (a) => {
                            this.View.Window.EndSheet(alert.Window);
                        });
                    });
                }
            };


            MainTimer          = new Timer(1000);
            MainTimer.Elapsed += (sender, e) =>
            {
                DateTime time       = DateTime.Now;
                string   timeString = time.ToString(@"HH\:mm\:ss");
                InvokeOnMainThread(() =>
                {
                    this.labeltime.StringValue = timeString;
                });
            };

            MainTimer.Start();

            thirdTimer          = new Timer(3000);
            thirdTimer.Elapsed += (sender, e) =>
            {
                imagenumber++;

                InvokeOnMainThread(() =>
                {
                    ChangeBackground((imagenumber));

                    NextSnowStartPosition();
                    //this.HideLayer();
                });


                if (imagenumber == 6)
                {
                    imagenumber = 1;
                }
            };

            thirdTimer.Start();
        }