public static State Load() { State state; if (File.Exists(stateFilePath)) { XmlSerializer x = new XmlSerializer(typeof(State)); TextReader t = new StreamReader(stateFilePath); state = (State)x.Deserialize(t); t.Close(); } else { state = new State(); state.PaperInside = (App.Current as App).config.MaxPaper; state.MoneyInside = state.BanknotesInside = 0; } state.initialized = true; return state; }
/** * Transition to the given state. This involves enabling / disabling controls that do / don't make sense * in the new state. * * @param s The state to transition to **/ private void caTransition(State s) { // Do this on the dispatcher thread curCA.Dispatcher.BeginInvoke(new Action(() => { curCA.Content = s.ToString(); curState = s; switch (s) { case State.Running: caLoad.IsEnabled = false; caCreate.IsEnabled = false; stateLoad.IsEnabled = false; stateSave.IsEnabled = false; stateClear.IsEnabled = false; caPlay.IsEnabled = false; caStep.IsEnabled = false; caPause.IsEnabled = true; break; case State.UnInited: caLoad.IsEnabled = true; caCreate.IsEnabled = true; stateLoad.IsEnabled = false; stateSave.IsEnabled = false; stateClear.IsEnabled = false; caPlay.IsEnabled = false; caStep.IsEnabled = false; caPause.IsEnabled = false; break; case State.Stopped: caLoad.IsEnabled = true; caCreate.IsEnabled = true; stateLoad.IsEnabled = true; stateSave.IsEnabled = true; stateClear.IsEnabled = true; caPlay.IsEnabled = true; caStep.IsEnabled = true; caPause.IsEnabled = false; break; } })); }
public UserProgress(string firstName, string lastName, State state) { this.FirstName = firstName; this.LastName = lastName; switch (state) { case State.Da: IsDa = true; break; case State.Khong: IsKhong = true; break; case State.Chuahoi: default: IsNone = true; break; } }