private void OnEnable() { isFirstTouch = true; buttonState = StateButton.NONE; deltaOld = topSpacing; deltaTouch = 0; }
private void InitField() { try { N = int.Parse(countTextBox.Text); if (N > 30 || N < 2) { throw new FormatException("Поле должно быть от 2 до 20 клеток"); } } catch (Exception e) { MessageBox.Show(e.Message); return; } Buttons = new Button[N, N]; StateButtons = new StateButton[N, N]; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { int size = 30; Buttons[i, j] = new Button() { Location = new Point(i * size, j * size), Name = i.ToString() + " " + j.ToString(), Size = new Size(size, size), Font = new Font("Microsoft Sans Serif", 10F, FontStyle.Bold, GraphicsUnit.Point, 204) }; Buttons[i, j].MouseDown += new MouseEventHandler(CheckState); Controls.Add(Buttons[i, j]); StateButtons[i, j] = StateButton.Closed; } } GenerateMines(); countTextBox.Clear(); countTextBox.Visible = false; menuStrip1.Visible = false; }
/// <summary> /// 修改是否显示的状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void sbShow_Click(object sender, EventArgs e) { try { StateButton ub = (StateButton)sender; int index = ((GridViewRow)(ub.Parent.Parent)).RowIndex; int id = int.Parse(this.GridView1.DataKeys[index].Value.ToString()); //判断是否有员工 Song.Entities.EmpAccount[] acc = Business.Do <IPosition>().GetAllEmplyee(id); if (acc.Length > 0) { throw new WeiSha.Common.ExceptionForAlert("当前岗位下有员工,不得禁用!"); } // Song.Entities.Position entity = Business.Do <IPosition>().GetSingle(id); entity.Posi_IsUse = !entity.Posi_IsUse; Business.Do <IPosition>().Save(entity); BindData(null, null); } catch (Exception ex) { this.Alert(ex.Message); } }
private void Update() { if(!Input.mousePresent) { Touch[] touch = Input.touches; if(touch.Length <= 0) { if(!isFirstTouch) { deltaOld += deltaTouch; deltaTouch = 0; } isFirstTouch = true; return; } deltaTouch -= touch[0].deltaPosition.y; if( isFirstTouch ) { isFirstTouch = false; } } else { if(Input.GetMouseButtonDown(0)) { buttonState = StateButton.PRESSED; } if(Input.GetMouseButtonUp(0)) { buttonState = StateButton.RELEASED; } switch(buttonState) { case StateButton.PRESSED: if( isFirstTouch ) { beginTouch = Input.mousePosition; isFirstTouch = false; } Vector2 pos = Input.mousePosition; deltaTouch = -pos.y + beginTouch.y; break; case StateButton.RELEASED: if(!isFirstTouch) { deltaOld += deltaTouch; deltaTouch = 0; } isFirstTouch = true; break; case StateButton.NONE: break; } } }
private void MainMenu() { if (System.Environment.TickCount - LastTickCount > 100000) { LastTickCount = System.Environment.TickCount; MediaPlayer.Play(soundConvert); } MouseState mouse = Mouse.GetState(); if (sound) { if (btnUnmute.IsClicked) { sound = false; } btnUnmute.Update(mouse, sound); } else { if (btnMute.IsClicked) { sound = true; } btnMute.Update(mouse, sound); } switch (CurrentGameState) { case GameState.MainMenu: if (btnPlay.IsClicked) { CurrentGameState = GameState.Playing; } if (btnHowToPlay.IsClicked) { CurrentGameState = GameState.HowToPlay; } if (btnAbout.IsClicked) { CurrentGameState = GameState.About; } if (btnExit.IsClicked) { CurrentGameState = GameState.Exit; } btnPlay.Update(mouse, sound); btnHowToPlay.Update(mouse, sound); btnAbout.Update(mouse, sound); btnExit.Update(mouse, sound); break; case GameState.Playing: if (btnBack.IsClicked) { CurrentGameState = GameState.MainMenu; } if (btnEasy.IsClicked) { CurrentGameState = GameState.Easy; statebutton = StateButton.Playing; } if (btnHard.IsClicked) { CurrentGameState = GameState.Hard; statebutton = StateButton.Playing; } if (btnMedium.IsClicked) { CurrentGameState = GameState.Medium; statebutton = StateButton.Playing; } btnBack.Update(mouse, sound); btnMedium.Update(mouse, sound); btnHard.Update(mouse, sound); btnEasy.Update(mouse, sound); break; case GameState.HowToPlay: if (btnBack.IsClicked) { CurrentGameState = GameState.MainMenu; } btnBack.Update(mouse, sound); break; case GameState.About: if (btnBack.IsClicked) { CurrentGameState = GameState.MainMenu; } btnBack.Update(mouse, sound); break; case GameState.Hard: if (statebutton == StateButton.Playing) { startgame = true; Start(10, 33); statebutton = StateButton.Hard; } if (btnBack.IsClicked) { CurrentGameState = GameState.Back; } btnBack.Update(mouse, sound); if (winner == Winner.Playing) { player.Update(sound); } else { if (btnRestart.IsClicked) { statebutton = StateButton.Playing; } btnRestart.Update(mouse, sound); } if (stopped == false) { CheckCollision(10); } break; case GameState.Easy: if (statebutton == StateButton.Playing) { startgame = true; Start(4, 5); statebutton = StateButton.Easy; } if (btnBack.IsClicked) { CurrentGameState = GameState.Back; } btnBack.Update(mouse, sound); if (winner == Winner.Playing) { player.Update(sound); } else { if (btnRestart.IsClicked) { statebutton = StateButton.Playing; } btnRestart.Update(mouse, sound); } if (stopped == false) { CheckCollision(4); } break; case GameState.Medium: if (statebutton == StateButton.Playing) { startgame = true; Start(8, 21); statebutton = StateButton.Medium; } if (btnBack.IsClicked) { CurrentGameState = GameState.Back; } btnBack.Update(mouse, sound); if (winner == Winner.Playing) { player.Update(sound); } else { if (btnRestart.IsClicked) { statebutton = StateButton.Playing; } btnRestart.Update(mouse, sound); } if (stopped == false) { CheckCollision(8); } break; case GameState.Back: startgame = false; CurrentGameState = GameState.Playing; soundConvert = soundMainMenu; LastTickCount -= 100000; break; case GameState.Exit: break; } }
private void MainMenu() { MouseState mouse = Mouse.GetState(); switch (CurrentGameState) { case GameState.MainMenu: if (btnPlay.IsClicked) { CurrentGameState = GameState.Playing; } if (btnHowToPlay.IsClicked) { CurrentGameState = GameState.HowToPlay; } if (btnAbout.IsClicked) { CurrentGameState = GameState.About; } if (btnExit.IsClicked) { CurrentGameState = GameState.Exit; } btnPlay.Update(mouse); btnHowToPlay.Update(mouse); btnAbout.Update(mouse); btnExit.Update(mouse); break; case GameState.Playing: if (btnBack.IsClicked) { CurrentGameState = GameState.MainMenu; } if (btnEasy.IsClicked) { CurrentGameState = GameState.Easy; } if (btnHard.IsClicked) { CurrentGameState = GameState.Hard; } if (btnMedium.IsClicked) { CurrentGameState = GameState.Medium; } btnBack.Update(mouse); btnMedium.Update(mouse); btnHard.Update(mouse); btnEasy.Update(mouse); break; case GameState.HowToPlay: if (btnBack.IsClicked) { CurrentGameState = GameState.MainMenu; } btnBack.Update(mouse); break; case GameState.About: if (btnBack.IsClicked) { CurrentGameState = GameState.MainMenu; } btnBack.Update(mouse); break; case GameState.Hard: if (statebutton == StateButton.Playing) { Start(10, 33); statebutton = StateButton.Hard; } if (btnBack.IsClicked) { statebutton = StateButton.Playing; } btnWin.Update(mouse); btnLose.Update(mouse); btnBack.Update(mouse); if (winner == Winner.Playing) { player.Update(); } if (stopped == false) { CheckCollision(10); } break; case GameState.Easy: if (statebutton == StateButton.Playing) { Start(4, 5); statebutton = StateButton.Easy; } if (btnBack.IsClicked) { statebutton = StateButton.Playing; } btnWin.Update(mouse); btnLose.Update(mouse); btnBack.Update(mouse); if (winner == Winner.Playing) { player.Update(); } if (stopped == false) { CheckCollision(4); } break; case GameState.Medium: if (statebutton == StateButton.Playing) { Start(8, 21); statebutton = StateButton.Medium; } if (btnBack.IsClicked) { statebutton = StateButton.Playing; } btnWin.Update(mouse); btnLose.Update(mouse); btnBack.Update(mouse); if (winner == Winner.Playing) { player.Update(); } if (stopped == false) { CheckCollision(8); } break; case GameState.Exit: break; } }
void ReleaseDesignerOutlets() { if (CityButton != null) { CityButton.Dispose(); CityButton = null; } if (DivisionButton != null) { DivisionButton.Dispose(); DivisionButton = null; } if (OnlyMyButton != null) { OnlyMyButton.Dispose(); OnlyMyButton = null; } if (ServiceStateButton != null) { ServiceStateButton.Dispose(); ServiceStateButton = null; } if (ServiceStateImageButton != null) { ServiceStateImageButton.Dispose(); ServiceStateImageButton = null; } if (StateButton != null) { StateButton.Dispose(); StateButton = null; } if (StateImageButton != null) { StateImageButton.Dispose(); StateImageButton = null; } if (TypeButton != null) { TypeButton.Dispose(); TypeButton = null; } if (TypeImageButton != null) { TypeImageButton.Dispose(); TypeImageButton = null; } if (UserButton != null) { UserButton.Dispose(); UserButton = null; } }
/// <summary> /// Interpret this Input /// </summary> protected virtual void InterpretInput(bool inputValue, float flickAccumulationFactor, float dragThresholdMouse, float flickThreshold, float holdTime, float tapTime, float doubleTapTime) { if (!enabled) { return; } // Reset each frame, need to be triggered only once startedHold = false; endHold = false; isTapped = false; isDoubleTapped = false; if (inputValue) { switch (state) { case StateButton.UP: case StateButton.NONE: { state = StateButton.DOWN; startTime = Time.realtimeSinceStartup; } break; case StateButton.DOWN: case StateButton.HELD: { state = StateButton.HELD; // Stationary? (Hold) if (Time.realtimeSinceStartup - startTime >= holdTime) { startedHold = true; state = StateButton.HOLD; } } break; } } else { switch (state) { case StateButton.DOWN: case StateButton.HELD: { state = StateButton.UP; // Quick enough (with no drift) to be a tap? if (Time.realtimeSinceStartup - startTime < tapTime) { // Is a Double tap ? if (canDoubleTap && Time.realtimeSinceStartup - startDoubleTapTime <= doubleTapTime + tapTime) { isDoubleTapped = true; canDoubleTap = false; } else { isTapped = true; canDoubleTap = true; startDoubleTapTime = Time.realtimeSinceStartup; } } } break; case StateButton.HOLD: { state = StateButton.UP; endHold = true; } break; case StateButton.UP: { // Reset the state machine state = StateButton.NONE; startTime = 0; } break; } } }
public override void UpdateState() { if (!_IsInitialize) { GameScript.Instance._PressValidation.Play(); _IsInitialize = true; } StateButton state = _TurnNews ? StateButton.News : StateButton.FakeNews; if (!_ReleaseButton) { if (_WaitingNewTurn) { _CoordinateWaitingNews.Clear(); int nbButtonsToDisplay = GameScript.Instance.NbButtons(); nbButtonsToDisplay = nbButtonsToDisplay > _NbPressTouchPossible ? _NbPressTouchPossible : nbButtonsToDisplay; for (int i = 0; i < _NbPressTouchPossible; ++i) { _CoordinateWaitingNews.Add(GameScript.Instance.GetNextNewsButton()); GameScript.Instance.SwitchColor((int)_CoordinateWaitingNews[i].x, (int)_CoordinateWaitingNews[i].y, state); } _PreviousTimeDisplay = Time.time; _IsBlinking = true; _WaitingNewTurn = false; if (_TurnNews) { GameScript.Instance.LaunchTrigger("BLEU"); GameScript.Instance.SetNewNews(StateButton.News); GameScript.Instance._PressTrue.Play(); } else { GameScript.Instance.LaunchTrigger("ROUGE"); GameScript.Instance.SetNewNews(StateButton.FakeNews); GameScript.Instance._PressFake.Play(); } } if (Time.time > _PreviousTimeDisplay + 0.5f) { StateButton currentStateBlink = (_IsBlinking ? StateButton.None : state); for (int i = 0; i < _CoordinateWaitingNews.Count; ++i) { GameScript.Instance.SwitchColor((int)_CoordinateWaitingNews[i].x, (int)_CoordinateWaitingNews[i].y, currentStateBlink); } _PreviousTimeDisplay = Time.time; _IsBlinking = !_IsBlinking; } } else { if (_WaitingNewTurn) { _WaitingNewTurn = false; if (_TurnNews) { GameScript.Instance.LaunchTrigger("BLEU lache"); } else { GameScript.Instance.LaunchTrigger("ROUGE Lache"); } } } }
public InfoInputButton(string nameInput, StateButton stateButton) { this.nameInput = nameInput; this.stateButton = stateButton; }
public DelegateInfo(string inputName, StateButton stateButton) { this.inputActonString = inputName; this.stateButton = stateButton; }
/// <summary> /// 处理布局按钮的样式 /// </summary> /// <param name="action"></param> private void HandleLayoutStyle(IAction action) { try { StateButtons buttons = UserToolbarStateManager.ReportButtonState[this.ReportViewControl.ClientReportContext.GetReportId()]; StateButton layouts = buttons["Layouts"]; //foreach (StateButton bt in groupAndCross.Buttons) //{ //StateButton Layouts = new StateButton("Layouts", "布局", true, "布局", Properties.Resources.filterFormat, "Layouts"); //StateButton FixFilter = new StateButton("FixFilter", "显示固定条件", true, "显示固定条件", null, "Layouts"); //StateButton QuickFilter = new StateButton("QuickFilter", "显示快捷条件", true, "显示固定条件", null, "Layouts"); //StateButton line1 = new StateButton("line1", "-", true, "", null, "Layouts"); //StateButton OcxShowSchema = new StateButton("OcxShowSchema", "显示查询方案", true, "显示查询方案", null, "Layouts"); //StateButton OcxShowFilter = new StateButton("OcxShowFilter", "显示查询条件", true, "显示查询条件", null, "Layouts"); //StateButton line2 = new StateButton("line2", "-", true, "", null, "Layouts"); //StateButton LeftRightLayout = new StateButton("LeftRightLayout", "左右布局", true, "左右布局", null, "Layouts"); //StateButton TopBottomLayout = new StateButton("TopBottomLayout", "上下布局", true, "上下布局", null, "Layouts"); string reportId = this.ReportViewControl.ClientReportContext.GetReportId(); AbstractFormInput.ActionHashtable actions = UserToolbarStateManager.ReportActionsState[reportId]; NetAction layoutsbuttons = actions["Layouts"] as NetAction; IAction btnFixFilter = UserToolbarStateManager.FindActionByKey(reportId, "FixFilter"); IAction btnQuickFilter = UserToolbarStateManager.FindActionByKey(reportId, "QuickFilter"); IAction btnOcxShowSchema = UserToolbarStateManager.FindActionByKey(reportId, "OcxShowSchema"); IAction btnOcxShowFilter = UserToolbarStateManager.FindActionByKey(reportId, "OcxShowFilter"); IAction btnLeftRightLayout = UserToolbarStateManager.FindActionByKey(reportId, "LeftRightLayout"); IAction btnTopBottomLayout = UserToolbarStateManager.FindActionByKey(reportId, "TopBottomLayout"); //显示固定条件 if (action.Id == "FixFilter") { btnFixFilter.IsChecked = true; btnFixFilter.IsEnabled = true; this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.FilterFlag = FilterType.FixFilter; btnQuickFilter.IsChecked = false; btnQuickFilter.IsEnabled = true; btnOcxShowSchema.IsChecked = false; btnOcxShowSchema.IsEnabled = false; //this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.SolutionVisible = false; btnOcxShowFilter.IsChecked = false; btnOcxShowFilter.IsEnabled = false; //this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.ConditionVisible = false; btnLeftRightLayout.IsChecked = false; btnLeftRightLayout.IsEnabled = false; //this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.QuickFilterLayoutFlag = QuickFilterLayout.LeftRight; btnTopBottomLayout.IsChecked = false; btnTopBottomLayout.IsEnabled = false; } else if (action.Id == "QuickFilter") { btnQuickFilter.IsChecked = true; btnQuickFilter.IsEnabled = true; this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.FilterFlag = FilterType.QuickFilter; btnFixFilter.IsChecked = false; btnFixFilter.IsEnabled = true; btnQuickFilter.IsEnabled = true; btnOcxShowSchema.IsEnabled = true; //默认应该显示一个,现在默认显示solution //btnOcxShowSchema.IsChecked = this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.SolutionVisible; btnOcxShowSchema.IsChecked = true; btnOcxShowFilter.IsEnabled = true; btnOcxShowFilter.IsChecked = this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.ConditionVisible; btnLeftRightLayout.IsEnabled = true; btnTopBottomLayout.IsEnabled = true; if (this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.QuickFilterLayoutFlag == QuickFilterLayout.LeftRight) { btnLeftRightLayout.IsChecked = true; } else { btnTopBottomLayout.IsChecked = true; } if (this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.ConditionVisible == false && this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.SolutionVisible == false) { this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.SolutionVisible = true; } } else if (action.Id == "OcxShowSchema") { this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.SolutionVisible = action.IsChecked; } else if (action.Id == "OcxShowFilter") { this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.ConditionVisible = action.IsChecked; } else if (action.Id == "LeftRightLayout") { btnLeftRightLayout.IsChecked = true; btnTopBottomLayout.IsChecked = false; this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.QuickFilterLayoutFlag = QuickFilterLayout.LeftRight; this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.LayoutIsSetted = true; } else if (action.Id == "TopBottomLayout") { btnTopBottomLayout.IsChecked = true; btnLeftRightLayout.IsChecked = false; this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.QuickFilterLayoutFlag = QuickFilterLayout.TopBottom; this.ReportViewControl.ClientReportContext.ReportUIUserStateInfo.LayoutIsSetted = true; } this.ReportViewControl.HandlerLayout(action.Id, action.IsChecked); } catch (Exception ex) { Logger logger = Logger.GetLogger("ReportFacade"); logger.Error(ex); } }
private void Update() { if (!Input.mousePresent) { Touch[] touch = Input.touches; if (touch.Length <= 0) { if (!isFirstTouch) { deltaOld += deltaTouch; deltaTouch = 0; } isFirstTouch = true; return; } deltaTouch -= touch[0].deltaPosition.y; if (isFirstTouch) { isFirstTouch = false; } } else { if (Input.GetMouseButtonDown(0)) { buttonState = StateButton.PRESSED; } if (Input.GetMouseButtonUp(0)) { buttonState = StateButton.RELEASED; } switch (buttonState) { case StateButton.PRESSED: if (isFirstTouch) { beginTouch = Input.mousePosition; isFirstTouch = false; } Vector2 pos = Input.mousePosition; deltaTouch = -pos.y + beginTouch.y; break; case StateButton.RELEASED: if (!isFirstTouch) { deltaOld += deltaTouch; deltaTouch = 0; } isFirstTouch = true; break; case StateButton.NONE: break; } } }
void SetDisplayButton(int x, int y, StateButton parNewState) { _ButtonsState[x, y] = parNewState; SwitchColor(x, y, parNewState); }