Example #1
0
        internal ViewBadGoodPairsDlg(CscProject project, ref KnownGoodWordList mapWhiteList,
                                     ref Bad2GoodMap mapBad2Good, Font font, bool bEditingWhiteList)
        {
            InitializeComponent();

            m_project           = project;
            m_mapWhiteList      = mapWhiteList;
            m_mapBad2Good       = mapBad2Good;
            m_bEditingWhiteList = bEditingWhiteList;

            this.dataGridView.RowsDefaultCellStyle.Font = font;
            dataGridView.RowTemplate.Height             = font.Height + 6; // 6 for padding

            if (bEditingWhiteList)
            {
                this.Text = "Edit Dictionary";
                this.helpProvider.SetHelpString(dataGridView, Properties.Resources.ViewBadGoodPairsDictionaryHelp);
                dataGridView.Columns[cnGoodSpelling].HeaderText = "Known Good Words";
                dataGridView.Columns[cnBadSpelling].Visible     = false;

                object[] ao = new object[2];
                ao[cnBadSpelling] = null;
                foreach (string strKey in mapWhiteList.Keys)
                {
                    ao[cnGoodSpelling] = strKey;
                    dataGridView.Rows.Add(ao);
                }
            }
            else
            {
                helpProvider.SetHelpString(dataGridView, Properties.Resources.ViewBadGoodPairsBad2GoodHelp);

                object[] ao = new object[2];
                foreach (KeyValuePair <string, string> kvp in mapBad2Good)
                {
                    ao[cnBadSpelling]  = kvp.Key;
                    ao[cnGoodSpelling] = kvp.Value;
                    dataGridView.Rows.Add(ao);
                }
            }
        }
Example #2
0
		internal ViewBadGoodPairsDlg(CscProject project, ref KnownGoodWordList mapWhiteList,
			ref Bad2GoodMap mapBad2Good, Font font, bool bEditingWhiteList)
		{
			InitializeComponent();

			m_project = project;
			m_mapWhiteList = mapWhiteList;
			m_mapBad2Good = mapBad2Good;
			m_bEditingWhiteList = bEditingWhiteList;

			this.dataGridView.RowsDefaultCellStyle.Font = font;
			dataGridView.RowTemplate.Height = font.Height + 6;   // 6 for padding

			if (bEditingWhiteList)
			{
				this.Text = "Edit Dictionary";
				this.helpProvider.SetHelpString(dataGridView, Properties.Resources.ViewBadGoodPairsDictionaryHelp);
				dataGridView.Columns[cnGoodSpelling].HeaderText = "Known Good Words";
				dataGridView.Columns[cnBadSpelling].Visible = false;

				object[] ao = new object[2];
				ao[cnBadSpelling] = null;
				foreach (string strKey in mapWhiteList.Keys)
				{
					ao[cnGoodSpelling] = strKey;
					dataGridView.Rows.Add(ao);
				}
			}
			else
			{
				helpProvider.SetHelpString(dataGridView, Properties.Resources.ViewBadGoodPairsBad2GoodHelp);

				object[] ao = new object[2];
				foreach (KeyValuePair<string,string> kvp in mapBad2Good)
				{
					ao[cnBadSpelling] = kvp.Key;
					ao[cnGoodSpelling] = kvp.Value;
					dataGridView.Rows.Add(ao);
				}
			}
		}
Example #3
0
		private void selectProjectToolStripMenuItem_Click(object sender, EventArgs e)
		{
			if (selectProjectToolStripMenuItem.Checked)
			{
				if (m_cscProject != null)   // might want to select a different project
					m_cscProject = null;

				if (!TrySelectProject())
					return;

				foreach (DataGridViewRow aRow in dataGridView.Rows)
				{
					string strSFM = (string)aRow.Cells[cnSfmMarkerColumn].Value;
					DirectableEncConverter aEC = GetConverter(strSFM);
					UpdateConverterCellValue(aRow.Cells[cnEncConverterColumn], aEC);
				}

				if (m_bBotherUser)
					MessageBox.Show("Now click on the buttons in the 'Converter' column for the " + Environment.NewLine +
						"SFM fields that you want to check spelling in", cstrCaption);
				m_bBotherUser = false;

				selectProjectToolStripMenuItem.Text = "&Turn off Consistent Spell Check mode";
				selectProjectToolStripMenuItem.ToolTipText = String.Format("Click to unload the '{0}' Consistent Spell Fixer project or right-click to choose another", m_cscProject.Name);
			}
			else
			{
				dataGridView.Rows.Clear();
				PopulateGrid();
				selectProjectToolStripMenuItem.Text = "&Select Project";
				selectProjectToolStripMenuItem.ToolTipText = "Click to load a Consistent Spell Fixer project";
			}
		}
Example #4
0
		protected void CscAddToCheckList(CscProject cscProject)
		{
			SetProgressMaximum();

			foreach (string strFileSpec in m_lstFilesOpen)
			{
				string[] aStrFileContents = m_mapFile2Contents[strFileSpec];
				for (int i = 0; i < aStrFileContents.Length; i++)
				{
					progressBarSpellingCheck.PerformStep();
					string strLine = aStrFileContents[i];
					if ((strLine.Length > 0) && (strLine[0] == '\\'))
					{
						int nIndex = strLine.IndexOf(' ');
						if (nIndex == -1)
							continue;

						string strSfm = strLine.Substring(0, nIndex);
						if (IsConverterDefined(strSfm))
						{
							string strData = strLine.Substring(nIndex + 1);
							string[] astrWords = strData.Split(caSplitChars, StringSplitOptions.RemoveEmptyEntries);
							int nNumWords = astrWords.Length;
							int nStartIndex = -1;
							int[] anStartIndices = new int[nNumWords];
							for (int j = 0; j < nNumWords; j++)
							{
								nStartIndex = strData.IndexOf(astrWords[j], ++nStartIndex);
								System.Diagnostics.Debug.Assert(nStartIndex != -1);
								anStartIndices[j] = nStartIndex;
							}

							const int cnNumContextWords = 3;
							for (int j = 0; j < nNumWords; j++)
							{
								if (j < cnNumContextWords)
									nStartIndex = 0;
								else
									nStartIndex = anStartIndices[j - cnNumContextWords];

								int nContextLength;
								if ((nNumWords - j) < cnNumContextWords)
									nContextLength = strData.Length - nStartIndex;
								else
								{
									int nArrIndex = j + cnNumContextWords - 1;
									nContextLength = anStartIndices[nArrIndex] + astrWords[nArrIndex].Length - nStartIndex;
								}

								string strContext = strData.Substring(nStartIndex, nContextLength);
								cscProject.AddWordToCheckList(astrWords[j], true, strContext);
							}
						}
					}
				}
			}
			progressBarSpellingCheck.Value = 0;
		}