public void UpdateStateSelectedRuleAudioClip(int selectedRule) { var audioClip = AudioClips.Where((x) => x.Label.Equals("State selected rule")).FirstOrDefault(); string audioDirectory = Path.Combine(DirectoryMgr.AudioClipsDirectory, "Ruleset"); if (audioClip == null) { audioClip = new AudioClip() { Category = "Ruleset", Label = "State selected rule", Tooltip = "State selected rule", ButtonColour = ColourHelper.StatementColour }; AudioClips.Add(audioClip); } List <string> clips = new List <string>(); StringBuilder sb = new StringBuilder(); string ruleText = TextHelper.GetRuleNumberText(selectedRule - 1); sb.Append(ruleText + ": "); clips.Add(Path.Combine(audioDirectory, ruleText)); sb.Append(Rules[selectedRule - 1].StateText); clips.Add(Rules[selectedRule - 1].TriggerClip.StateAudioFile); clips.Add(Rules[selectedRule - 1].ActionClip.StateAudioFile); audioClip.StateText = sb.ToString(); audioClip.StateAudioFile = AudioMgr.CombineAudioClips(clips); }
public string GetRuleAudioFile(string activity, int ruleNumber) { string ruleNumberText = TextHelper.GetNumberText(ruleNumber); string audioDirectory = Path.Combine(DirectoryMgr.AudioClipsDirectory, "Ruleset"); if (TriggerClip != null && ActionClip != null) { List <string> clips = new List <string>(); if (activity.Equals("State")) { if (ruleNumber == -1) // New rule { clips.Add(Path.Combine(audioDirectory, "New rule")); } else { clips.Add(Path.Combine(audioDirectory, "Rule " + ruleNumberText)); } clips.Add(TriggerClip.StateAudioFile); clips.Add(ActionClip.StateAudioFile); } else if (activity.Equals("Confirm")) { clips.Add(Path.Combine(audioDirectory, "OK")); if (ruleNumber == -1) { clips.Add(Path.Combine(audioDirectory, "New rule added")); } else { clips.Add(Path.Combine(audioDirectory, "Rule " + ruleNumberText + " changed")); } if (!ActionClip.Label.Equals("Generic New Rule")) { clips.Add(TriggerClip.StateAudioFile); clips.Add(ActionClip.StateAudioFile); } } else if (activity.Equals("Check")) { clips.Add(Path.Combine(audioDirectory, "Let me check I have understood")); if (ruleNumber == -1) { clips.Add(Path.Combine(audioDirectory, "Add new rule")); } else { clips.Add(Path.Combine(audioDirectory, "Change rule " + ruleNumberText)); } clips.Add(TriggerClip.StateAudioFile); clips.Add(ActionClip.StateAudioFile); clips.Add(Path.Combine(audioDirectory, "Is this correct_")); } return(AudioMgr.CombineAudioClips(clips)); } return(null); }
public void UpdateListRulesAudioClip() { var audioClip = AudioClips.Where((x) => x.Label.Equals("List rules")).FirstOrDefault(); string audioDirectory = Path.Combine(DirectoryMgr.AudioClipsDirectory, "Ruleset"); string deviceDirectory = Path.Combine(DirectoryMgr.AudioClipsDirectory, DeviceName); if (audioClip == null) { audioClip = new AudioClip() { Category = "Ruleset", Label = "List rules", Tooltip = "List rules", ButtonColour = ColourHelper.StatementColour }; AudioClips.Add(audioClip); } List <string> clips = new List <string>(); StringBuilder sb = new StringBuilder(); switch (Rules.Count) { case 0: sb.Append("Currently I have no rules for the " + DeviceName); clips.Add(Path.Combine(deviceDirectory, String.Format("Currently I have no rules for the {0}", DeviceName))); break; case 1: sb.Append("I have one rule for the " + DeviceName + ".\n"); sb.Append(Rules[0].StateText); clips.Add(Path.Combine(deviceDirectory, String.Format("I have one rule for the {0}", DeviceName))); clips.Add(Rules[0].TriggerClip.StateAudioFile); clips.Add(Rules[0].ActionClip.StateAudioFile); break; default: string numberTxt = TextHelper.GetNumberText(Rules.Count); sb.Append("I have " + numberTxt + " rules for the " + DeviceName + ".\n"); for (int i = 0; i < Rules.Count; i++) { sb.Append(TextHelper.GetRuleNumberText(i) + ": "); sb.Append(Rules[i].StateText + "\n"); } clips.Add(Path.Combine(deviceDirectory, String.Format("I have " + numberTxt + " rules for the {0}", DeviceName))); for (int i = 0; i < Rules.Count; i++) { clips.Add(Path.Combine(audioDirectory, TextHelper.GetRuleNumberText(i))); clips.Add(Rules[i].TriggerClip.StateAudioFile); clips.Add(Rules[i].ActionClip.StateAudioFile); } break; } audioClip.StateText = sb.ToString(); audioClip.StateAudioFile = AudioMgr.CombineAudioClips(clips); }
public void UpdateWhichRuleAudioClip() { StringBuilder sb = new StringBuilder(); var listRulesAudioClip = AudioClips.Where((x) => x.Label.Equals("List rules; which rule to change?")).FirstOrDefault(); var questionOnlyAudioClip = AudioClips.Where((x) => x.Label.Equals("Which rule to change?")).FirstOrDefault(); string audioDirectory = Path.Combine(DirectoryMgr.AudioClipsDirectory, "Ruleset"); string deviceDirectory = Path.Combine(DirectoryMgr.AudioClipsDirectory, DeviceName); if (listRulesAudioClip == null) { listRulesAudioClip = new AudioClip() { Category = "Ruleset", Label = "List rules; which rule to change?", Tooltip = "List rules; which rule to change?", ButtonColour = ColourHelper.QuestionColour }; AudioClips.Add(listRulesAudioClip); } if (questionOnlyAudioClip == null) { questionOnlyAudioClip = new AudioClip() { Category = "Ruleset", Label = "Which rule to change?", Tooltip = "Which rule to change?", ButtonColour = ColourHelper.QuestionColour }; AudioClips.Add(questionOnlyAudioClip); } List <string> clips = new List <string>(); switch (Rules.Count) { case 0: sb.Append("Currently I have no rules for the " + DeviceName + ".\n"); clips.Add(Path.Combine(deviceDirectory, String.Format("Currently I have no rules for the {0}", DeviceName))); break; case 1: sb.Append("OK, I have one rule for the " + DeviceName + ".\n"); sb.Append(Rules[0].StateText + "\n"); sb.Append("What would you like to change?"); clips.Add(Path.Combine(audioDirectory, "OK")); clips.Add(Path.Combine(deviceDirectory, String.Format("I have one rule for the {0}", DeviceName))); clips.Add(Rules[0].TriggerClip.StateAudioFile); clips.Add(Rules[0].ActionClip.StateAudioFile); clips.Add(Path.Combine(audioDirectory, "What would you like to change_")); break; default: string numberTxt = TextHelper.GetNumberText(Rules.Count); sb.Append("I have " + numberTxt + " rules for the " + DeviceName + ".\n"); sb.Append("Which rule would you like to change?"); questionOnlyAudioClip.StateText = sb.ToString(); questionOnlyAudioClip.StateAudioFile = AudioMgr.CombineAudioClips(clips); sb.Clear(); sb.Append("OK, I have " + numberTxt + " rules for the " + DeviceName + ".\n"); for (int i = 0; i < Rules.Count; i++) { sb.Append(TextHelper.GetRuleNumberText(i) + ": "); sb.Append(Rules[i].StateText + "\n"); } sb.Append("Which rule would you like to change?"); clips.Add(Path.Combine(audioDirectory, "OK")); clips.Add(Path.Combine(deviceDirectory, String.Format("I have " + numberTxt + " rules for the {0}", DeviceName))); for (int i = 0; i < Rules.Count; i++) { clips.Add(Path.Combine(audioDirectory, TextHelper.GetRuleNumberText(i))); clips.Add(Rules[i].TriggerClip.StateAudioFile); clips.Add(Rules[i].ActionClip.StateAudioFile); } clips.Add(Path.Combine(audioDirectory, "Which rule would you like to change_")); break; } listRulesAudioClip.StateText = sb.ToString(); listRulesAudioClip.StateAudioFile = AudioMgr.CombineAudioClips(clips); }