private void ToMainMenuButton_Click(object sender, EventArgs e) { FormStandartSize(); RefreshTimer.Stop(); _logic.LogicTimer.Stop(); PlatformTimer.Stop(); _gameState.GameStarted = false; MainMenuGroupBox.Visible = true; _gameState.Pause = false; GameGroupBox.Visible = false; }
protected override bool ProcessKeyPreview(ref Message m) { if (m.Msg == WM_KEYUP) { if (leftArrow) { PlatformTimer.Stop(); leftArrow = false; } else if (rightArrow) { PlatformTimer.Stop(); rightArrow = false; } } return(false); }
/// <summary> /// Остановка игры при выигрыше /// </summary> public void StopGameOnWin() { RefreshTimer.Stop(); _logic.LogicTimer.Stop(); PlatformTimer.Stop(); _gameState.WinGame = false; var result = MessageBox.Show("Выиграно!"); if (result == DialogResult.OK) { FormStandartSize(); MainMenuGroupBox.Visible = true; _gameState.GameStarted = false; GameGroupBox.Visible = false; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.CircleProgressLayout); var circleProgress = FindViewById <CircleProgress>(Resource.Id.circleProgress); var themeDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.themeDropDown); var colorDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.colorDropDown); var alternativeColorDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.alternativeColorDropDown); var fontDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.fontDropDown); var textSizeDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.textSizeDropDown); var fillColorDropDown = FindViewById <EOSSandboxDropDown>(Resource.Id.backgroundColorDropDown); var showProgressSwitch = FindViewById <Switch>(Resource.Id.showProgressSwitch); var resetButton = FindViewById <Button>(Resource.Id.buttonResetCustomization); var spinners = new List <EOSSandboxDropDown>() { themeDropDown, colorDropDown, fontDropDown, textSizeDropDown, alternativeColorDropDown, fillColorDropDown }; int percents = 0; var timer = new PlatformTimer(); timer.Setup(TimeSpan.FromMilliseconds(100), () => { percents += 1; circleProgress.Progress = percents; }); circleProgress.Started += (sender, e) => { if (percents == 100) { percents = 0; } timer.Start(); }; circleProgress.Stopped += (sender, e) => { timer.Stop(); percents = 0; circleProgress.Progress = 0; }; circleProgress.Finished += (sender, e) => { timer.Stop(); }; themeDropDown.Name = Fields.Theme; themeDropDown.SetupAdapter(ThemeTypes.ThemeCollection.Select(item => item.Key).ToList()); themeDropDown.ItemSelected += (position) => { if (position > 0) { circleProgress.GetThemeProvider().SetCurrentTheme(ThemeTypes.ThemeCollection.ElementAt(position).Value); circleProgress.ResetCustomization(); spinners.Except(new[] { themeDropDown }).ToList().ForEach(s => s.SetSpinnerSelection(0)); circleProgress.Progress = 0; showProgressSwitch.Checked = true; UpdateAppearance(); } }; var theme = circleProgress.GetThemeProvider().GetCurrentTheme(); if (theme is LightEOSTheme) { themeDropDown.SetSpinnerSelection(1); } if (theme is DarkEOSTheme) { themeDropDown.SetSpinnerSelection(2); } fontDropDown.Name = Fields.Font; fontDropDown.SetupAdapter(CircleProgressConstants.CircleProgressFonts.Select(item => item.Key).ToList()); fontDropDown.ItemSelected += (position) => { circleProgress.Typeface = Typeface.CreateFromAsset(Assets, CircleProgressConstants.CircleProgressFonts.ElementAt(position).Value); }; colorDropDown.Name = Fields.Color; colorDropDown.SetupAdapter(CircleProgressConstants.CircleProgressColors.Select(item => item.Key).ToList()); colorDropDown.ItemSelected += (position) => { circleProgress.Color = CircleProgressConstants.CircleProgressColors.ElementAt(position).Value; }; alternativeColorDropDown.Name = Fields.AlternativeColor; alternativeColorDropDown.SetupAdapter(CircleProgressConstants.AlternativeColors.Select(item => item.Key).ToList()); alternativeColorDropDown.ItemSelected += (position) => { circleProgress.AlternativeColor = CircleProgressConstants.AlternativeColors.ElementAt(position).Value; }; fillColorDropDown.Name = Fields.FillColor; fillColorDropDown.SetupAdapter(CircleProgressConstants.FillColors.Select(item => item.Key).ToList()); fillColorDropDown.ItemSelected += (position) => { circleProgress.FillColor = CircleProgressConstants.FillColors.ElementAt(position).Value; }; textSizeDropDown.Name = Fields.TextSize; textSizeDropDown.SetupAdapter(CircleProgressConstants.TextSizes.Select(item => item.Key).ToList()); textSizeDropDown.ItemSelected += (position) => { circleProgress.TextSize = CircleProgressConstants.TextSizes.ElementAt(position).Value; }; showProgressSwitch.CheckedChange += (sender, e) => { circleProgress.ShowProgress = showProgressSwitch.Checked; }; resetButton.Click += delegate { spinners.Except(new[] { themeDropDown }).ToList().ForEach(s => s.SetSpinnerSelection(0)); showProgressSwitch.Checked = true; circleProgress.ResetCustomization(); }; }
public override void ViewDidLoad() { base.ViewDidLoad(); _timer = new PlatformTimer(); _timer.Setup(TimeSpan.FromMilliseconds(100), TimerAction); _circleProgress = new CircleProgress(); _circleProgress.Frame = new CGRect(containerView.Frame.Width / 2 - _circleProgressSize / 2, containerView.Frame.Height / 2 - _circleProgressSize / 2, _circleProgressSize, _circleProgressSize); _circleProgress.Started += (sender, e) => { if (_percents == 100) { _percents = 0; } _timer.Start(); }; _circleProgress.Stopped += (sender, e) => { _timer.Stop(); _percents = 0; _circleProgress.Progress = 0; }; _circleProgress.Finished += (sender, e) => { _timer.Stop(); }; containerView.AddSubview(_circleProgress); _dropDowns = new List <EOSSandboxDropDown>() { themeDropDown, fontDropDown, colorDropDown, alternativeColorDropDown, textSizeDropDown, fillColorDropDown }; View.AddGestureRecognizer(new UITapGestureRecognizer(() => { _dropDowns.ForEach(dropDown => dropDown.CloseInputControl()); })); var frame = new CGRect(0, 0, 100, 100); InitThemeDropDown(frame); themeDropDown.SetTextFieldText(_circleProgress.GetThemeProvider().GetCurrentTheme() is LightEOSTheme ? "Light" : "Dark"); showProgressSwitch.ValueChanged += (sender, e) => { _circleProgress.ShowProgress = showProgressSwitch.On; }; resetButton.TouchUpInside += (sender, e) => { _dropDowns.Except(new[] { themeDropDown }).ToList().ForEach(dropDown => dropDown.ResetValue()); showProgressSwitch.On = true; _circleProgress.ResetCustomization(); }; InitSources(frame); }