コード例 #1
0
 private void timerOdpoczynekHandler(object sender, EventArgs e)
 {
     if (Odpoczynek == 0)
     {
         timerOdpoczynek.stopTimer();
         widocznoscOdpoczynek = false;
         if ((Praca == 0 && Odpoczynek == 0 && Serie == 0) == true)
         {
             timerPraca.stopTimer();
             timerOdpoczynek.stopTimer();
             widocznoscSerie  = false;
             widocznoscKoniec = true;
             Textklawisz      = "OK Zakończ";
             { CrossTextToSpeech.Current.Speak("Trening zakończony"); }
         }
         else
         {
             Trening();
         }
     }
     else
     {
         Odpoczynek--;
         if (Odpoczynek <= 3)
         {
             CrossTextToSpeech.Current.Speak(Odpoczynek.ToString());
         }
     }
 }
コード例 #2
0
        private void SetTimer(int i)
        {
            switch (i)
            {
            case 0:    //"Begin cycles":
                CrossVibrate.Current.Vibration(1000);
                State.Text = "State: [25 min] Working!";
                onStart();
                TimerState();
                break;

            case 1:    //"pause"
                StartButton.Text = "Resume";
                timer.stopTimer();
                timerFlag = false;
                TimerState();
                break;

            case 2:    //"resume":
                StartButton.Text = "Pause";
                timer.startTimer();
                timerFlag = true;
                TimerState();
                break;

            case 3:    // "work":
                CrossVibrate.Current.Vibration(1000);
                TimeLeft.Text = "25:00";
                timerTime     = 25 * 60 * 1000;
                State.Text    = "State: [25 min] Working.";
                TimerState();
                break;

            case 4:    // "rest":
                CrossVibrate.Current.Vibration(1000);
                TimeLeft.Text = "5:00";
                timerTime     = 5 * 60 * 1000;
                State.Text    = "State: [5 min] Resting.";
                TimerState();
                break;

            case 5:    // "relax":
                CrossVibrate.Current.Vibration(1000);
                TimeLeft.Text = "35:00";
                timerTime     = 35 * 60 * 1000;
                State.Text    = "State: [35 min] Relaxing";
                TimerState();
                break;
            }
            return;
        }
コード例 #3
0
        public void  Trening()
        {
            Serie--;
            CrossTextToSpeech.Current.Speak("Work");

            Praca = pomP;
            if (Serie == 0)
            {
                Odpoczynek = 0;
            }
            else
            {
                Odpoczynek = pomO;
            }
            timerPraca.startTimer();
            Kolor           = "#e85151";
            widocznoscPraca = true;

            if (Praca == 0 && timerOdpoczynek.isTimerEnabled() == false)
            {
                timerPraca.stopTimer();
            }
        }
コード例 #4
0
ファイル: App.cs プロジェクト: systembugtj/AdvancedTimer
        public static Page GetMainPage()
        {
            timer = DependencyService.Get <IAdvancedTimer>();

            label = new Label
            {
                Text              = "Hello, Forms!",
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };

            Button button1 = new Button
            {
                Text              = String.Format("Start timer!"),
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };

            Button button2 = new Button
            {
                Text              = String.Format("Stop timer!"),
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };


            button1.Clicked += (sender, args) =>
            {
                label.Text = "Timer Started!";
                timer.initTimer(3000, timerElapsed, false);
                timer.startTimer();
            };

            button2.Clicked += (sender, args) =>
            {
                label.Text = "Timer Stopped!";
                timer.stopTimer();
            };

            return(new ContentPage
            {
                Content = new StackLayout
                {
                    Children = { label, button1, button2 }
                }
            });
        }
コード例 #5
0
ファイル: App.cs プロジェクト: powerdude/AdvancedTimer
        public static Page GetMainPage()
        {
            timer = DependencyService.Get<IAdvancedTimer>();

            label = new Label
            {
                Text = "Hello, Forms!",
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };

            Button button1 = new Button
            {
                Text = String.Format("Start timer!"),
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };

            Button button2 = new Button
            {
                Text = String.Format("Stop timer!"),
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };

            button1.Clicked += (sender, args) =>
            {
                label.Text = "Timer Started!";
                timer.initTimer(3000, timerElapsed, false);
                timer.startTimer();
            };

            button2.Clicked += (sender, args) =>
            {
                label.Text = "Timer Stopped!";
                timer.stopTimer();
            };

            return new ContentPage
            {
                Content = new StackLayout
                {
                    Children = { label, button1, button2 }
                }
            };
        }
コード例 #6
0
 private void timerElapsed(object sender, EventArgs e)
 {
     timer.stopTimer();
     try
     {
         Device.BeginInvokeOnMainThread(() =>
         {
             Application.Current.MainPage = new NavigationPage(new MainPage())
             {
                 BarBackgroundColor = Color.FromHex("#263763"),
                 BarTextColor       = Color.White,
             };
             Navigation.PushAsync(new MainPage());
         });
     }
     catch (Exception ex)
     {
         Debug.WriteLine(@"ERROR {0}", ex.Message);
     }
 }
コード例 #7
0
ファイル: Timer.cs プロジェクト: pieriv/HP32SII
 public void StartWithInactivityInterval()
 {
     timer.stopTimer();
     timer.setInterval(InactivityIntervalInMs);
     timer.startTimer();
 }
コード例 #8
0
ファイル: LockPage.cs プロジェクト: xlent-bi/XlentLock
        public LockPage()
        {
            NavigationPage.SetHasNavigationBar(this, false);
            BindingContext = new LockViewModel();
            sec = 30;
            rest = 00;
            milliSec = 30000;

            _advancedTimer = Resolver.Resolve<IAdvancedTimer>();
            _advancedTimer.initTimer(1000, (sender, args) =>
            {
                sec--;
                Device.BeginInvokeOnMainThread(() => { SecLabel.Text = sec.ToString(); });
                if (sec == 5)
                    Device.BeginInvokeOnMainThread(() => { SecLabel.TextColor = Color.Red; });


                Debug.WriteLine(milliSec);
                if (sec == 0)
                {
                    _advancedTimer.stopTimer();
                    GameCompleted();
                }
            }, true);


            NumberGrid = new Grid
            {
                VerticalOptions = LayoutOptions.CenterAndExpand,
                RowSpacing = 10,
                ColumnSpacing = 10
            };


            _lockService = new LockService();


            NumberGrid.Children.Add(Buttons[0], 0, 1);

            NumberGrid.Children.Add(Buttons[1], 1, 1);

            NumberGrid.Children.Add(Buttons[2], 2, 1);


            NumberGrid.Children.Add(Buttons[3], 0, 2);


            NumberGrid.Children.Add(Buttons[4], 1, 2);


            NumberGrid.Children.Add(Buttons[5], 2, 2);

            NumberGrid.Children.Add(Buttons[6], 0, 3);


            NumberGrid.Children.Add(Buttons[7], 1, 3);

            NumberGrid.Children.Add(Buttons[8], 2, 3);

            NumberGrid.Children.Add(Buttons[9], 0, 4);

            NumberGrid.Children.Add(Buttons[10], 1, 4);
            NumberGrid.Children.Add(Buttons[11], 2, 4);

            // Accomodate iPhone status bar.
            Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

            ClockStackLayout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Children =
                {
                    SecLabel
                }
            };

            if (Device.Idiom == TargetIdiom.Phone)
                MainStackLayout = new StackLayout
                {
                    VerticalOptions = LayoutOptions.End,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Children =
                    {
                        ClockStackLayout,
                        ResponsLabel,
                        LabelAndEraseLayout,
                        NumberGrid
                    },
                    Padding = new Thickness(0, 0, 0, 10)
                };
            if (Device.Idiom == TargetIdiom.Tablet)
            {
                var rightStack = new StackLayout
                {
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    Children =
                    {
                        ClockStackLayout,
                        ResponsLabel,
                        LabelAndEraseLayout,
                        NumberGrid
                    },
                    Padding = new Thickness(0, 0, 0, 10)
                };

                var width = Resolver.Resolve<IDevice>().Display.Width;


                var leftImage = new Image
                {
                    Source = "iconlogo1024x500.png",
                    Aspect = Aspect.AspectFill,
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    WidthRequest = width/2
                };

                var leftContentView = new ContentView
                {
                    Content = leftImage,
                    MinimumWidthRequest = Width/2,
                    BackgroundColor = Color.White
                };
                var leftStackLayout = new StackLayout
                {
                    Orientation = StackOrientation.Vertical,
                    Children =
                    {
                        leftContentView,
                        new Button
                        {
                            Text = "Reset",
                            BorderColor = Color.Green,
                            BorderRadius = 5,
                            Command = new Command(() => { Reset(); }),
                            VerticalOptions = LayoutOptions.End
                        }
                    },
                    VerticalOptions = LayoutOptions.FillAndExpand
                };


                MainStackLayout = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    Children =
                    {
                        // leftStackLayout,
                        rightStack
                    }
                };
            }


            Content = MainStackLayout;
            //_advancedTimer.startTimer();
        }
コード例 #9
0
		public ChatDetailsPage ( ObservableCollection<ChatDetails> chats,string tosusrID, string userImageUrl, string toUserName )
		{


			App.CurrentChatUserID = tosusrID;
			NavigationPage.SetHasNavigationBar(this, false);

			chatList = chats;
			touserID = tosusrID;
			currentuser = App.Settings.GetUser ();

		    timer = DependencyService.Get<IAdvancedTimer>();
			timer.initTimer (30000, SyncChatHistoryFromServer, true);
			timer.startTimer ();
			//Xamarin.Forms.Device.StartTimer ( TimeSpan.FromSeconds( 1 ), SyncChatHistoryFromServer );


			string chatTouser = toUserName;

			if (chatTouser.Length > 30)
			{
				chatTouser = chatTouser.Substring(0, 30);
				chatTouser += "...";
			}


			progressBar = DependencyService.Get< IProgressBar > ();
			mainTitleBar = new PurposeColorTitleBar(Color.FromRgb(8, 135, 224), chatTouser, Color.Black, userImageUrl, true);
			mainTitleBar.imageAreaTapGestureRecognizer.Tapped += (object sender, EventArgs e) => 
			{
				App.masterPage.IsPresented = true;
			};
			subTitleBar = new CommunityGemChatTitleBar(Constants.SUB_TITLE_BG_COLOR, chatTouser, userImageUrl, false);
			subTitleBar.BackButtonTapRecognizer.Tapped += async (object sender, EventArgs e) => 
			{
				timer.stopTimer ();
				App.CurrentChatUserID = null;
				await Navigation.PopAsync();
			};

			masterLayout = new CustomLayout ();
			masterLayout.WidthRequest = App.screenWidth;
			masterLayout.HeightRequest = App.screenHeight - 50;
			masterLayout.BackgroundColor = Color.FromRgb(45, 62, 80);

			chatHistoryListView = new ListView();
			chatHistoryListView.ItemTemplate = new DataTemplate(typeof(ChatHistoryListCell));
			chatHistoryListView.SeparatorVisibility = SeparatorVisibility.None;
			chatHistoryListView.HeightRequest = App.screenHeight * 70 / 100;
			chatHistoryListView.HasUnevenRows = true;
			chatHistoryListView.BackgroundColor =  Color.FromRgb(54, 79, 120);
			chatHistoryListView.ItemsSource = chatList;
			if( chatList != null && chatList.Count > 1 )
				chatHistoryListView.ScrollTo( chatList[ chatList.Count -1 ], ScrollToPosition.End, true );
			
			chatHistoryListView.ItemTapped += (object sender, ItemTappedEventArgs e) => 
			{
				chatHistoryListView.SelectedItem = null;
			};
			chatHistoryListView.ItemSelected += (object sender, SelectedItemChangedEventArgs e) => 
			{
				chatHistoryListView.SelectedItem = null;
			};


		

			ExtendedEntry chatEntry = new ExtendedEntry
			{
				Placeholder = "Enter your chat...",
				BackgroundColor = Color.White,//Color.White,
				WidthRequest = App.screenWidth * .80,
				HorizontalOptions = LayoutOptions.Start,
				TextColor = Color.Black
			};
			chatEntry.TextChanged += ChatEntry_TextChanged;

			Image postChatButton = new Image();
			postChatButton.Source = Device.OnPlatform("icon_send.png", "icon_send.png", "//Assets//icon_send.png");

			postChatButton.VerticalOptions = LayoutOptions.Center;
			postChatButton.HorizontalOptions = LayoutOptions.Center;
			TapGestureRecognizer postChatButtonTap = new TapGestureRecognizer();

			postChatButton.GestureRecognizers.Add(postChatButtonTap);

			StackLayout inputCountainer = new StackLayout
			{
				Spacing = Device.OnPlatform(5, 5, 1),
				Padding = Device.OnPlatform(5, 5, 5),
				Orientation = StackOrientation.Horizontal,
				BackgroundColor = Color.FromRgb( 45, 62, 80 ),
				Children = { chatEntry, postChatButton },
				WidthRequest = App.screenWidth
			};


			masterLayout.AddChildToLayout(mainTitleBar, 0, 0);
			masterLayout.AddChildToLayout(subTitleBar, 0, Device.OnPlatform(9, 10, 10));
			masterLayout.AddChildToLayout ( chatHistoryListView, 0, 17 );
			masterLayout.AddChildToLayout ( inputCountainer, 0, 85 );

			ScrollView masterScroll = new ScrollView ();
			masterScroll.Orientation = ScrollOrientation.Vertical;
			masterScroll.Content = masterLayout;
			masterScroll.IsClippedToBounds = true;

			postChatButtonTap.Tapped += async (object sender, EventArgs e) => 
			{
				ChatDetails detail = new ChatDetails();
				detail.AuthorName = "prvn";
				detail.Message = chatEntry.Text;
				detail.FromUserID = currentuser.UserId.ToString();
				detail.CurrentUserid = currentuser.UserId.ToString();
				chatList.Add( detail );
				chatEntry.Text = "";
				chatHistoryListView.ScrollTo( chatList[ chatList.Count -1 ], ScrollToPosition.End, true );

				if(!string.IsNullOrEmpty( detail.Message ))
					await ServiceHelper.SendChatMessage( currentuser.UserId.ToString(), touserID, detail.Message );
			};



			/*	this.Appearing += async (object sender, EventArgs e) => 
			{

				progressBar.ShowProgressbar( "Preparing chat window..." );
				masterScroll.IsVisible = true;

				chatUsersList = await ServiceHelper.GetAllChatUsers ();



				progressBar.HideProgressbar();

			};*/


			MessagingCenter.Subscribe<CrossPushNotificationListener, string>(this, "boom", (page, message) =>
				{
					string pushResult = message;
					string[] delimiters = { "&&" };
					string[] clasIDArray = pushResult.Split(delimiters, StringSplitOptions.None);
					string chatMessage = clasIDArray [0];
					string fromUser = clasIDArray [1];


					if( touserID == fromUser )
					{
						ChatDetails detail = new ChatDetails();
						detail.AuthorName = fromUser;
						detail.Message = chatMessage;
						detail.FromUserID = fromUser;
						detail.CurrentUserid = currentuser.UserId.ToString();
						chatList.Add( detail );

						if( chatList != null && chatList.Count > 1 )
						chatHistoryListView.ScrollTo( chatList[ chatList.Count -1 ], ScrollToPosition.End, true );
					}


				});


			Content = masterScroll;

		}