<commit_before>// --------------------------------------------------------------------------------------------
#region // Copyright (c) 2022, SIL International. All Rights Reserved.
// <copyright from='2020' to='2022' company='SIL International'>
//		Copyright (c) 2022, SIL International. All Rights Reserved.
//
//		Distributable under the terms of the MIT License (http://sil.mit-license.org/)
// </copyright>
#endregion
// --------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
using HearThis.Script;
using HearThis.StringDifferences;
using L10NSharp;
using SIL.Reporting;
using static System.String;
using DateTime = System.DateTime;

namespace HearThis.UI
{
	/// <summary>
	/// This class holds the text that the user is supposed to be reading (the main pane on the bottom left of the UI).
	/// </summary>
	public partial class ScriptTextHasChangedControl : UserControl, ILocalizable
	{
		private Project _project;
		private bool _updatingDisplay;
		private static float s_zoomFactor;
		private string _standardProblemText;
		private string _okayResolutionText;
		private string _standardDeleteExplanationText;
		private string _fmtRecordedDate;
		private ScriptLine _lastNullScriptLineIgnored;
		private ScriptLine CurrentScriptLine { get; set; }
		private StringDifferenceFinder _currentThenNowDifferences;
		public event EventHandler ProblemIgnoreStateChanged;
		public event EventHandler NextClick;
		public delegate void DisplayUpdatedHandler(ScriptTextHasChangedControl sender, bool displayingOptions);
		public event DisplayUpdatedHandler DisplayUpdated;
		public delegate void DisplayedWithClippedControlsHandler(ScriptTextHasChangedControl sender, ushort increasedVerticalSizeNeeded);
		public event DisplayedWithClippedControlsHandler DisplayedWithClippedControls;
		private ShiftClipsViewModel _shiftClipsViewModel;
		private Dictionary<Control, Action<Control>> _actionsToSetLocalizedTextForCtrls;

		public ScriptTextHasChangedControl()
		{
			InitializeComponent();

			Program.RegisterLocalizable(this);
			HandleStringsLocalized();

			_txtThen.BackColor = AppPalette.Background;
			_txtNow.BackColor = AppPalette.Background;
			_txtThen.ForeColor = AppPalette.TitleColor;
			_txtNow.ForeColor = AppPalette.TitleColor;
			_lblProblemSummary.ForeColor = _tableProblem.ForeColor =
				_nextButton.RoundedBorderColor = AppPalette.HilightColor;
			_btnPlayClip.SetUnconditionalFlatBackgroundColor(AppPalette.Background);

			_btnAskLater.CorrespondingRadioButton = _rdoAskLater;
			_btnUseExisting.CorrespondingRadioButton = _rdoUseExisting;
			_btnDelete.CorrespondingRadioButton = _rdoReRecord;
		}

		public void HandleStringsLocalized()
		{
			_standardProblemText = _lblProblemSummary.Text;
			_okayResolutionText = _lblResolution.Text;
			_standardDeleteExplanationText = _btnDelete.Text;
			_fmtRecordedDate = _lblBefore.Text;
			if (_actionsToSetLocalizedTextForCtrls != null)
			{
				foreach (var action in _actionsToSetLocalizedTextForCtrls)
					action.Value(action.Key);
			}
		}

		protected override void OnVisibleChanged(EventArgs e)
		{
			base.OnVisibleChanged(e);
			if (Visible)
			{
				if (!_updatingDisplay)
					UpdateState();
			}
		}

		private void OnNextButton(object sender, EventArgs e)
		{
			NextClick?.Invoke(this, e);
		}

		public void SetData(Project project)
		{<commit_msg>HT-359: Stop playing audio when ScriptTextHasChangedControl is hidden, so that the user can re-record in the other view without getting an error.<commit_after>// --------------------------------------------------------------------------------------------
#region // Copyright (c) 2022, SIL International. All Rights Reserved.
// <copyright from='2020' to='2022' company='SIL International'>
//		Copyright (c) 2022, SIL International. All Rights Reserved.
//
//		Distributable under the terms of the MIT License (http://sil.mit-license.org/)
// </copyright>
#endregion
// --------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
using HearThis.Script;
using HearThis.StringDifferences;
using L10NSharp;
using SIL.Reporting;
using static System.String;
using DateTime = System.DateTime;

namespace HearThis.UI
{
	/// <summary>
	/// This class holds the text that the user is supposed to be reading (the main pane on the bottom left of the UI).
	/// </summary>
	public partial class ScriptTextHasChangedControl : UserControl, ILocalizable
	{
		private Project _project;
		private bool _updatingDisplay;
		private static float s_zoomFactor;
		private string _standardProblemText;
		private string _okayResolutionText;
		private string _standardDeleteExplanationText;
		private string _fmtRecordedDate;
		private ScriptLine _lastNullScriptLineIgnored;
		private ScriptLine CurrentScriptLine { get; set; }
		private StringDifferenceFinder _currentThenNowDifferences;
		public event EventHandler ProblemIgnoreStateChanged;
		public event EventHandler NextClick;
		public delegate void DisplayUpdatedHandler(ScriptTextHasChangedControl sender, bool displayingOptions);
		public event DisplayUpdatedHandler DisplayUpdated;
		public delegate void DisplayedWithClippedControlsHandler(ScriptTextHasChangedControl sender, ushort increasedVerticalSizeNeeded);
		public event DisplayedWithClippedControlsHandler DisplayedWithClippedControls;
		private ShiftClipsViewModel _shiftClipsViewModel;
		private Dictionary<Control, Action<Control>> _actionsToSetLocalizedTextForCtrls;

		public ScriptTextHasChangedControl()
		{
			InitializeComponent();

			Program.RegisterLocalizable(this);
			HandleStringsLocalized();

			_txtThen.BackColor = AppPalette.Background;
			_txtNow.BackColor = AppPalette.Background;
			_txtThen.ForeColor = AppPalette.TitleColor;
			_txtNow.ForeColor = AppPalette.TitleColor;
			_lblProblemSummary.ForeColor = _tableProblem.ForeColor =
				_nextButton.RoundedBorderColor = AppPalette.HilightColor;
			_btnPlayClip.SetUnconditionalFlatBackgroundColor(AppPalette.Background);

			_btnAskLater.CorrespondingRadioButton = _rdoAskLater;
			_btnUseExisting.CorrespondingRadioButton = _rdoUseExisting;
			_btnDelete.CorrespondingRadioButton = _rdoReRecord;
		}

		public void HandleStringsLocalized()
		{
			_standardProblemText = _lblProblemSummary.Text;
			_okayResolutionText = _lblResolution.Text;
			_standardDeleteExplanationText = _btnDelete.Text;
			_fmtRecordedDate = _lblBefore.Text;
			if (_actionsToSetLocalizedTextForCtrls != null)
			{
				foreach (var action in _actionsToSetLocalizedTextForCtrls)
					action.Value(action.Key);
			}
		}

		protected override void OnVisibleChanged(EventArgs e)
		{
			base.OnVisibleChanged(e);
			if (Visible)
			{
				if (!_updatingDisplay)
					UpdateState();
			}
			else
			{
				_audioButtonsControl.StopPlaying();
			}
		}

		private void OnNextButton(object sender, EventArgs e)
		{
			NextClick?.Invoke(this, e);
		}

		public void SetData(Project project)
		{
{'fraction_non_alphanumeric': 0.12071349557522124, 'fraction_numerical': 0.0053926991150442475, 'mean_word_length': 3.9372013651877134, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '817064', 'n_tokens_mistral': 2225, 'n_tokens_neox': 1943, 'n_words': 483}