void ReleaseDesignerOutlets() { if (AnalyzeButton != null) { AnalyzeButton.Dispose(); AnalyzeButton = null; } if (AnalyzedLabel != null) { AnalyzedLabel.Dispose(); AnalyzedLabel = null; } if (VoiceImageView != null) { VoiceImageView.Dispose(); VoiceImageView = null; } if (VoiceTextField != null) { VoiceTextField.Dispose(); VoiceTextField = null; } }
private void PrepareView() { _recordViewModel = new RecordViewModel(); _analyzeViewModel = new AnalyzeViewModel(); AnalyzeButton.TouchUpInside += async(object sender, EventArgs e) => { var analyzedInfoList = await _analyzeViewModel.AnalyzeTextAsync(VoiceTextField.Text); var attributedStringM = new NSMutableAttributedString(VoiceTextField.Text); foreach (var analyzedInfo in analyzedInfoList) { if (analyzedInfo.Item2 > 0.3) { continue; } var voiceText = VoiceTextField.Text; var foundIndex = voiceText.IndexOf(analyzedInfo.Item1, StringComparison.CurrentCultureIgnoreCase); if (foundIndex == -1) { continue; } var analyzedAttributes = new UIStringAttributes(); analyzedAttributes.ForegroundColor = UIColor.Red; analyzedAttributes.UnderlineStyle = NSUnderlineStyle.Thick; attributedStringM.SetAttributes(analyzedAttributes, new NSRange(foundIndex, analyzedInfo.Item1.Length)); } var attributedString = new NSAttributedString(attributedStringM); AnalyzedLabel.AttributedText = attributedString; }; var tapGesture = new UITapGestureRecognizer(async(UITapGestureRecognizer obj) => { VoiceTextField.Text = string.Empty; VoiceTextField.Text = await _recordViewModel.RecordVoice(); }); VoiceImageView.AddGestureRecognizer(tapGesture); }