private void UpdateButtonText(AssistantState state) { if (ButtonRecord.Dispatcher.CheckAccess()) { switch (state) { case AssistantState.Listening: ButtonRecordIcon.Text = "\xF12E"; ButtonRecordText.Text = state.ToString(); break; case AssistantState.Processing: ButtonRecordIcon.Text = "\xE9F5"; ButtonRecordText.Text = state.ToString(); break; case AssistantState.Speaking: ButtonRecordIcon.Text = "\xF5B0"; ButtonRecordText.Text = state.ToString(); break; case AssistantState.Inactive: ButtonRecordIcon.Text = "\xE720"; ButtonRecordText.Text = "Press"; break; } } else { ButtonRecord.Dispatcher.BeginInvoke(new Action(() => UpdateButtonText(state))); } }
public Assistant(Shop shop, EventHandler shopEvents) { Id = idCount++; this.shop = shop; this.shopEvents = shopEvents; state = AssistantState.Waiting; shop.Subscribe <Shop.CustomerEnter>(CustomerWalkin); }
private IEnumerator ChangeState(AssistantState newState, float delay) { CR_running = true; yield return(new WaitForSeconds(delay)); activated = false; currentState = newState; CR_running = false; }
private void UpdateButtonText(AssistantState state) { if (ButtonRecord.Dispatcher.CheckAccess()) { ButtonRecord.Content = state == AssistantState.Inactive ? "Press" : state.ToString(); } //else //ButtonRecord.Dispatcher.BeginInvoke(new Action(() => UpdateButtonText(state))); }
private void FinishedTreating() { lock (stateLock) { currentCustomer.Ready(); state = AssistantState.Waiting; shopEvents.Trigger <Shop.FinishedTreating>(currentCustomer); currentCustomer = null; shopEvents.Trigger <Shop.AssistantVacancy>(this); } }
public void AssignCustomer(Customer customer) { lock (stateLock) { if (customer != null && state == AssistantState.Waiting && customer.Treat()) { currentCustomer = customer; state = AssistantState.TreatingCustomer; var thread = new Thread(TreatCustomer); thread.Start(); } } }
private void OnAssistantStateChanged(AssistantState state) { _assistantState = state; UpdateButtonText(state); }