예제 #1
0
 /// <summary>
 /// Checks for a ctrl+T shortcut and opens a new tab if found.  Also restores selction state for
 /// combo boxes and text boxes.
 /// </summary>
 private void checkForNewTab(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.T && e.Control)
     {
         int      selectionStart  = 0;
         int      selectionLength = 0;
         ComboBox combo           = sender as ComboBox;
         TextBox  textbox         = sender as TextBox;
         if (combo != null)
         {
             selectionStart  = combo.SelectionStart;
             selectionLength = combo.SelectionLength;
         }
         else if (textbox != null)
         {
             selectionLength = textbox.SelectionLength;
             selectionStart  = textbox.SelectionStart;
         }
         TabManager.get().AddTab();
         e.Handled = true;
         ((Control)sender).Focus();
         if (combo != null)
         {
             combo.SelectionStart  = selectionStart;
             combo.SelectionLength = selectionLength;
         }
         else if (textbox != null)
         {
             textbox.SelectionStart  = selectionStart;
             textbox.SelectionLength = selectionLength;
         }
     }
 }
예제 #2
0
 /// <summary>
 /// Get the single instance of the tab manager.
 /// </summary>
 /// <returns>The single instance of the tab manager.</returns>
 public static TabManager get()
 {
     if (sTabManager == null)
     {
         sTabManager = new TabManager();
     }
     return(sTabManager);
 }
예제 #3
0
 /// <summary>
 /// Construction, set up some defaults and initialize other components.
 /// </summary>
 /// <param name="startDirectory">Allows the program to be opened with a start directory given.</param>
 /// <param name="startPattern">Allows the program to be opened with a start search pattern given.</param>
 public Form1(String startDirectory, String startPattern)
 {
     InitializeComponent();
     Logger.get();
     mShouldCheckForUpdate = false;
     #if UPDATER_SUPPORTED
     Updater.Check();
     this.Text += " - " + Updater.getUpdateInfo().Version.ToString("F2");
     #endif
     checkSettings();
     TabManager.get().init(tabControl1);
     NamedPipes.SearchPatternReceived += new NamedPipes.SearchPatternCallback(mNamedPipe_SearchPatternReceived);
     writePathToAppData();
     TabManager.get().connectKeyShortcuts(this);
     // This looks unecessary (and really is), but it will speed up the very first search
     // after the program is opened.  It seems like .NET doesn't load something in PLINQ
     // until it is first needed.
     List <String> unecessary = new List <string>();
     unecessary.AsParallel().ForAll(res => { res = String.Empty; });
 }
예제 #4
0
        /// <summary>
        /// Starts a search.  Gets the search parameters and creates a new file searcher.  Connects
        /// up with the results control.
        /// </summary>
        public void startSearch()
        {
            searchInit();
            mUiUpdateThrottle.Enabled = true;
            RtfUtility.WriteFileHeader(mStreamWriter);
            mStreamWriter.Flush();
            mInitialStreamLength = mMemoryStream.Position;

            if (Logger.get().LoggingEnabled)
            {
                Logger.get().AddData(new SearchParameters(Settings.get().SearchParams), "SearchParameters", "Search Parameters");
            }
            Settings.get().SearchParams.SearchInProgress = true;
            mResults = TabManager.get().getControlForNewResults();
            if (mFileSearcher != null)
            {
                mFileSearcher.HandleResults -= fileSearcher_HandleResults;
                mFileSearcher = null;
            }
            mFileSearcher = new Grep.FileSearcher(Settings.get().SearchParams);
            mFileSearcher.HandleResults += new Grep.FileSearcher.SearchResults(fileSearcher_HandleResults);
            mFileSearcher.search();
        }