public bool SetToken(UIToken token) { try { mCurrentToken = token; mTokenActions[token][CurrentState](); return(true); } catch (Exception e) { Debug.Log(String.Format("Invalid Change from {0} with {1}", CurrentState, token)); return(false); } }
public void RegisterState(UIToken token, UIState[] fromStates, UIState toState, Action @event) { if (!mTokenActions.ContainsKey(token)) { mTokenActions.Add(token, new Dictionary <UIState, Action>()); } foreach (UIState item in fromStates) { mTokenActions[token].Add(item, delegate { CurrentState = toState; @event?.Invoke(); }); } }
// Use this for initialization void Start() { var canvasRoot = GameObject.Find("CanvasMain"); uiText_inputVoice = UIToken.FindToken <UnityEngine.UI.Text>(CanvasRoot, "inputVoiceText"); uiText_transVoice = UIToken.FindToken <UnityEngine.UI.Text>(CanvasRoot, "transVoiceText"); uiText_inputVoiceRealtime = UIToken.FindToken <UnityEngine.UI.Text>(CanvasRoot, "inputVoiceRtText"); uiText_transVoiceRealtime = UIToken.FindToken <UnityEngine.UI.Text>(CanvasRoot, "transVoiceRtText"); foreach (var dev in Microphone.devices) { int test; int test2; Microphone.GetDeviceCaps(dev, out test, out test2); System.Diagnostics.Debug.WriteLine(dev + " " + test + " " + test2); } btnHonyaku.onClick.AddListener(onclick_actHonyaku); btnVoiceTest.onClick.AddListener(onclick_actVoiceInpuChange); tts_ = GetComponent <TextToSpeech>(); #if WINDOWS_UWP { uwpSpeechReco_.DictationHypothesis += DictationRecognizer_DictationHypothesis; uwpSpeechReco_.DictationResult += DictationRecognizer_DictationResult; uwpSpeechReco_.DictationComplete += DictationRecognizer_DictationComplete; uwpSpeechReco_.DictationError += DictationRecognizer_DictationError; } #else { MyDictationInputManager.DictationRecognizer.DictationHypothesis += DictationRecognizer_DictationHypothesis; MyDictationInputManager.DictationRecognizer.DictationResult += DictationRecognizer_DictationResult; MyDictationInputManager.DictationRecognizer.DictationComplete += DictationRecognizer_DictationComplete; MyDictationInputManager.DictationRecognizer.DictationError += DictationRecognizer_DictationError; } #endif StartUWP(); tryDictationStart_(); }
/// <summary> /// 绑定列表数据到容器 /// </summary> private void BindContainer() { MenuTabItem _MenuTabItem = MenuTabCollection.Exists(r => r.Token.ToLower() == UIToken.ToLower()) ? MenuTabCollection.Find(r => r.Token.ToLower() == UIToken.ToLower()) : new MenuTabItem(); if (_MenuTabItem != null && !String.IsNullOrEmpty(_MenuTabItem.Token) && !this.DesignMode) { //加载相应的控件 BaseModule ManageContent = new BaseModule(); string ContentSrc = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, _MenuTabItem.Src)); if (System.IO.File.Exists(MapPath(ContentSrc))) { ManageContent = (BaseModule)LoadControl(ContentSrc); ManageContent.ModuleConfiguration = ModuleConfiguration; ManageContent.ID = _MenuTabItem.Token; ManageContent.LocalResourceFile = Localization.GetResourceFile(this, string.Format("{0}.resx", _MenuTabItem.Src)); phContainer.Controls.Add(ManageContent); } } else if (!String.IsNullOrEmpty(Token) && Token.ToLower() == "error") { //加载相应的控件 BaseModule ManageContent = new BaseModule(); string ContentSrc = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, "Manager_ErrorCatch.ascx")); if (System.IO.File.Exists(MapPath(ContentSrc))) { ManageContent = (BaseModule)LoadControl(ContentSrc); ManageContent.ModuleConfiguration = ModuleConfiguration; ManageContent.ID = "ErrorCatch"; ManageContent.LocalResourceFile = Localization.GetResourceFile(this, string.Format("{0}.resx", "Manager_ErrorCatch.ascx")); phContainer.Controls.Add(ManageContent); } //标题 Page.Title = String.Format("{0} - {1}", "Error", ModuleConfiguration.ModuleTitle); } }