Example #1
0
 void frmSearch.ISearchConnection.WinUnloaded()
 {
     if (this._searchForm != null)
     {
         this._searchForm.ClearAllData();
         this._searchForm = null;
     }
     this.tsiSearch.Checked = false;
 }
Example #2
0
 private void SwitchSearch()
 {
     if (!this.tsiSearch.Enabled)
         return;
     if (this.tsiSearch.Checked)
     {
         if (this._searchForm != null)
             this._searchForm.Hide();
         this.tsiSearch.Checked = false;
     }
     else
     {
         if (this._searchForm == null)
             this._searchForm = new frmSearch(this);
         this._searchForm.Show(this);
         this.tsiSearch.Checked = true;
     }
 }
Example #3
0
 void frmSearch.ISearchConnection.ShowResult(frmSearch.SearchResult result, Form formToActivate)
 {
     this.ShowSearchResult(result, formToActivate);
 }
Example #4
0
 private void ShowSearchResult(frmSearch.SearchResult result, Form formToActivate)
 {
     PO.Entry entry;
     if (result != null)
     {
         entry = result.Entry;
         if (!this.lbxEntries.Items.Contains(entry))
         {
             MessageBox.Show("Entry not found.");
             return;
         }
         this.lbxEntries.SelectedItem = entry;
     }
     else
     {
         entry = this.lbxEntries.SelectedItem as PO.Entry;
     }
     foreach (frmSearch.SearchPlace placeToReset in Enum.GetValues(typeof(frmSearch.SearchPlace)))
         this.ShowSearchResult(placeToReset, -1, 0, 0);
     if (result != null)
     {
         for (int n = 0; n < result.Places.Count; n++)
         {
             this.ShowSearchResult(result.Places[n], result.Indexes[n], result.Starts[n], result.Lengths[n]);
         }
     }
     if (formToActivate != null)
         formToActivate.Activate();
 }
Example #5
0
 private void ShowSearchResult(frmSearch.SearchPlace place, int? index, int? start, int? length)
 {
     bool isResetting = index.HasValue && (index.Value < 0);
     switch (place)
     {
         case frmSearch.SearchPlace.Context:
             ShowSearchResult(this.tbxSourceContext, isResetting ? 0 : start, isResetting ? 0 : length);
             break;
         case frmSearch.SearchPlace.Reference:
             for (int i = 0; i < this.flpReferences.Controls.Count; i++)
             {
                 if (isResetting || (index.Value == i))
                 {
                     LinkLabel link = (LinkLabel)this.flpReferences.Controls[i];
                     link.LinkColor = isResetting ? Color.FromArgb(0, 0, 255) : Color.Red;
                     if (!isResetting)
                         this.flpReferences.ScrollControlIntoView(link);
                 }
             }
             break;
         case frmSearch.SearchPlace.SourceComment:
             ShowSearchResult(this.tbxExtractedComment, isResetting ? 0 : start, isResetting ? 0 : length);
             break;
         case frmSearch.SearchPlace.TranslatorComment:
             ShowSearchResult(this.tbxTranslatorComment, isResetting ? 0 : start, isResetting ? 0 : length);
             break;
         case frmSearch.SearchPlace.Source:
             ShowSearchResult(this.TabbedTexts[TranslPlace.Source], index, start, length);
             break;
         case frmSearch.SearchPlace.Translated:
             ShowSearchResult(this.TabbedTexts[TranslPlace.Translated], index, start, length);
             break;
     }
 }
Example #6
0
 public static WorkDataSame Get(frmSearch frm)
 {
     List<PO.Entry> entries = frm._searchConnection.GetCurrentItems();
     if ((entries == null) || (entries.Count == 0))
     {
         MessageBox.Show("No search entries in the main form.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         return null;
     }
     return new WorkDataSame(entries, frm.chkSame_Case.Checked);
 }
Example #7
0
 public static WorkDataNumOccur Get(frmSearch frm)
 {
     List<PO.Entry> entries = frm._searchConnection.GetCurrentItems();
     if ((entries == null) || (entries.Count == 0))
     {
         MessageBox.Show("No search entries in the main form.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         return null;
     }
     string term = frm.tbxNumOccur_Text.Text;
     if (term.Length == 0)
     {
         MessageBox.Show("Please specify what to look for.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         frm.tbxNumOccur_Text.Focus();
         return null;
     }
     return new WorkDataNumOccur(entries, term);
 }
Example #8
0
 public static WorgDataStandard Get(frmSearch frm)
 {
     List<PO.Entry> entries = frm._searchConnection.GetCurrentItems();
     if ((entries == null) || (entries.Count == 0))
     {
         MessageBox.Show("No search entries in the main form.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         return null;
     }
     string searchTerm = frm.tbxStd_Term.Text;
     if (searchTerm.Length == 0)
     {
         MessageBox.Show("No search term specified.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         frm.tcPages.SelectedTab = frm.tpStandard;
         frm.tbxStd_Term.Focus();
         return null;
     }
     List<SearchPlace> searchPlaces = new List<SearchPlace>();
     if (frm.chkStd_WSource.Checked)
         searchPlaces.Add(SearchPlace.Source);
     if (frm.chkStd_WSourceComment.Checked)
         searchPlaces.Add(SearchPlace.SourceComment);
     if (frm.chkStd_WContext.Checked)
         searchPlaces.Add(SearchPlace.Context);
     if (frm.chkStd_WReference.Checked)
         searchPlaces.Add(SearchPlace.Reference);
     if (frm.chkStd_WTranslated.Checked)
         searchPlaces.Add(SearchPlace.Translated);
     if (frm.chkStd_WTranslatorComment.Checked)
         searchPlaces.Add(SearchPlace.TranslatorComment);
     if (searchPlaces.Count == 0)
     {
         MessageBox.Show("No search scope specified.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         frm.tcPages.SelectedTab = frm.tpStandard;
         frm.chkStd_WSource.Focus();
         return null;
     }
     return new WorgDataStandard(entries, searchTerm, frm.chkStd_Case.Checked, frm.chkStd_WholeWords.Checked, frm.chkStd_RegEx.Checked, searchPlaces);
 }
Example #9
0
            public static WorkDataTidy Get(frmSearch frm)
            {
                List<PO.Entry> entries = frm._searchConnection.GetCurrentItems();
                if ((entries == null) || (entries.Count == 0))
                {
                    MessageBox.Show("No search entries in the main form.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return null;
                }
                SearchPlace place;
                switch (frm.cbxTidy_Where.SelectedItem as string)
                {
                    case PLACE_SOURCE:
                        place = SearchPlace.Source;
                        break;
                    case PLACE_TRANSLATED:
                        place = SearchPlace.Translated;
                        break;
                    default:
                        MessageBox.Show("Please specify the search place.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        frm.cbxTidy_Where.Focus();
                        return null;
                }

                bool reportErrors = frm.chkTidy_Errs.Checked;
                bool reportWarnings = frm.chkTidy_Warns.Checked;
                if (!(reportErrors || reportWarnings))
                {
                    MessageBox.Show("Please specify at least one message kind to report.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    frm.chkTidy_Errs.Focus();
                    return null;
                }
                return new WorkDataTidy(entries, place, reportErrors, reportWarnings, frm.chkTidy_Unescape.Checked);
            }
Example #10
0
 public static WorkDataSpellCheck Get(frmSearch frm)
 {
     List<PO.Entry> entries = frm._searchConnection.GetCurrentItems();
     if ((entries == null) || (entries.Count == 0))
     {
         MessageBox.Show("No search entries in the main form.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         return null;
     }
     return new WorkDataSpellCheck(entries, SearchPlace.Translated, frm.chkSpellCheck_IgnoreAllCapsWords.Checked, frm.chkSpellCheck_IgnoreHtml.Checked, frm.chkSpellCheck_IgnoreWordsWithDigits.Checked);
 }