Source code for MSQuant: frmMainForm.vb, MSQuant/msquant/src/GUI/forms/frmMainForm.vb.

Table of contents page.

Home page for MSQuant.

'****************************************************************************
'* Copyright (C) 2004 Peter Mortensen and Matthias Mann                     *
'* This file is part of MSQuant.                                            *
'*                                                                          *
'* MSQuant is distributed under the terms of                                *
'* the GNU General Public License. See src/COPYING.TXT or                   *
'* <http://www.gnu.org/licenses/gpl.txt> for details.                       *
'*                                                                          *
'* MSQuant is free software; you can redistribute it                        *
'* and/or modify it under the terms of the GNU                              *
'* General Public License as published by the Free                          *
'* Software Foundation; either version 2 of the                             *
'* License, or (at your option) any later version.                          *
'*                                                                          *
'* MSQuant is distributed in the hope that it will be                       *
'* useful, but WITHOUT ANY WARRANTY; without even the                       *
'* implied warranty of MERCHANTABILITY or FITNESS FOR                       *
'* A PARTICULAR PURPOSE.  See the GNU General Public                        *
'* License for more details.                                                *
'*                                                                          *
'* You should have received a copy of the GNU General                       *
'* Public License along with MSQuant; if not, write to                      *
'* the Free Software Foundation, Inc., 59 Temple                            *
'* Place, Suite 330, Boston, MA  02111-1307  USA                            *
'*                                                                          *
'* Purpose: Holds Class frmMainForm, see below for                          *
'*          documentation.                                                  *
'*                                                                          *
'****************************************************************************

'****************************************************************************
'*                               CEBI                                       *
'*                    Software Development Group                            *
'*                         Peter Mortensen                                  *
'*                E-mail: NUKESPAMMERSdrmortensen@get2netZZZZZZ.dk          *
'*                 WWW: http://www.cebi.sdu.dk/                             *
'*                                                                          *
'*  Program for post-processing of result from search in mass               *
'*    spectrometric data.                                                   *
'*                                                                          *
'*    FILENAME:   frmMainForm.vb                                            *
'*    TYPE:  VISUAL_BASIC                                                   *
'*                                                                          *
'* CREATED: PM 2002-02-13   Vrs 1.0. Estimated date...                      *
'* UPDATED: PM 2003-xx-xx                                                   *
'*                                                                          *
'****************************************************************************

Option Strict On
Option Explicit On  'Changed PM_OPTIONEXPLICIT 2003-02-13

Imports System.IO 'For File, Path, Directory, FileStream, etc.

Imports System.Windows.Forms

Imports System.Text  'For StringBuilder

Imports System.Collections.Generic 'For Dictionary.


Imports System.Runtime.Remoting.Channels 'For ChannelServices

Imports System.Runtime.Remoting.Channels.Tcp 'For TcpChannel
'  For this Import to work "system.runtime.remoting.dll" ***MUST*** be 
'  referenced in the project. Is ***NOT*** a physical DLL (at least not 
'  part of Visual Studio) but is in the
'  dialog box: menu Project/MSQcomputeServer Properties/References/Add.../tab .net/


'  Imports ExploreDataObjects 'Temp!!!!!!!!!



'Imports CEBI.Remoting

'Changed PM_FAST_SERIALISATION 2006-12-15
'Imports SimmoTech.Utils.Serialization 'For SerializationWriter

Imports App 'For class quantApplication
Imports massSpectrometryBase
Imports massSpectrometryBase.quantitation 'For QuantitationModes_moreGeneral
Imports SDUPutility


'Note: old start size of form: 976, 436


'****************************************************************************
'*    <placeholder for header>                                              *
'****************************************************************************
Public Class frmMainForm
    Inherits System.Windows.Forms.Form
    Private mOptions As OptionsStruct2
    Private mMascotOrWiffDir As String
    Private mSampleNum As Integer = 1

    'Changed PM_CORRELATION_DIALOG 2003-10-21
    Private mCorrSettings As massSpectrometryBase.correlationSettingsStructure

    Private mDefaultMascotWiffAssFileStr As String = _
      Application.StartupPath & "\FileAss.txt"

    'Changed PM_PERSIST_OPTIONS 2003-04-14
    Private mConfigurationFileName As String 'A constant string

    'Host it here for now
    'First and only global variable!!!. Even as many functions and classes
    'as possible should get it as a parameters....
    Public Shared gApplication As quantApplication

    Private mApplication As quantApplication

    'What are these doing here?????
    Friend WithEvents MenuItem8 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenAppFolder As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuTest1 As System.Windows.Forms.MenuItem 'A non-global version...

    'Changed PM_FINNIGAN_QUANTWINDOW_RELATIVE 2005-07-13
    Dim mForceClose2 As Boolean 'Used in frmMainForm_Closing() to not ask
    'for permission to exit if something went wrong during startup, e.g. presence
    'of an old .XML settings file.


    'Changed PM_COMMANDLINE 2006-11-15
    'Shared: one and only one for an application.
    Private Shared mTimer As System.Windows.Forms.Timer
    Private Shared mAlarmCounter As Integer
    Private Shared mMeShared As frmMainForm 'Sort of a global variable. Unfortunately
    '  it is the only way.
    Private Shared mCurrentInterval As Integer
    Const MAX_TIMER_INTERVAL As Integer = 5000
    Const MIN_TIMER_INTERVAL As Integer = 400

    'Changed PM_COMMANDLINE 2006-11-15
    Private mAutomator As AppAutomation.automator

    'What is this doing here???
    Friend WithEvents mnuCommandLineParameters As System.Windows.Forms.MenuItem

    Private mIdlesCount As Integer
    Friend WithEvents mnuZedGraph As System.Windows.Forms.MenuItem
    Private mCommands As String
    Friend WithEvents mnuFireAssert As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem9 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenPILGrinder As System.Windows.Forms.MenuItem
    Friend WithEvents mnuDimensions As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenMSRecal As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenMRL As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenDTASC As System.Windows.Forms.MenuItem
    Friend WithEvents mnuMGFcombiner As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenHelperApplicationsAppFolder As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenMascotResultViewer As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenMascotResultFileReductor As System.Windows.Forms.MenuItem
    Friend WithEvents mnuRawFileMapping As System.Windows.Forms.MenuItem

    'Changed PM_DOUBLE_RETURN_KEY 2007-09-08
    Private mKeyObserver As SDUPkeyObserver

    'Changed PM_HIGHER_LEVEL_PROCESSING 2008-09-02
    Private WithEvents mRawFileMappingDialog As frmRawFileMapping 'Member as we
    '  need a target for events from the dialog, e.g. when user OKs it.


    'Changed PM_HIGHER_LEVEL_PROCESSING 2008-09-02
    Private WithEvents mDimensionsDialog As frmDimensions
    Friend WithEvents mnuOpenFinniganNumberStripper As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenWithMascotResultViwerScript As System.Windows.Forms.MenuItem
    Friend WithEvents mnuRunFinniganNumberScript As System.Windows.Forms.MenuItem
    Friend WithEvents mnuRunMascotResultFileReductorScript As System.Windows.Forms.MenuItem
    Friend WithEvents someMenuItem7 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem10 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem11 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenMB3 As System.Windows.Forms.MenuItem


    'Changed PM_SAVE_RAWFILE_MAPPING_MB4 2008-11-18. Removed; after we 
    '  now store these settings in MBx files we let the application 
    '  handle the default values, e.g. for new parses.
    ' ''Changed PM_HIGHER_LEVEL_PROCESSING 2008-09-01
    ''Private mNpointkey2rawFileInfo As _
    ''  Dictionary(Of Integer, rawFileInfoStruct)
    'Private mExperimentSettings3 As experimentSettingsStruct


#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

        Me.init()
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
    Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
    Friend WithEvents StatusBarPanel1 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents StatusBarPanel2 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents StatusBarPanel3 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents StatusBarPanel4 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents StatusBarPanel5 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar
    Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
    Friend WithEvents mnuFile As System.Windows.Forms.MenuItem
    Friend WithEvents mnuEdit As System.Windows.Forms.MenuItem
    Friend WithEvents mnuTools As System.Windows.Forms.MenuItem
    Friend WithEvents mnuHelp As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOptions As System.Windows.Forms.MenuItem
    Friend WithEvents chkLBMascotFiles As System.Windows.Forms.CheckedListBox
    Friend WithEvents mnuSetFileDirectoryMascotResults As System.Windows.Forms.MenuItem
    Friend WithEvents mnuQuantitateCheckedFiles As System.Windows.Forms.MenuItem
    Friend WithEvents lblHTMLheader As System.Windows.Forms.Label
    Friend WithEvents lblRAWheader As System.Windows.Forms.Label
    Friend WithEvents mnuExit As System.Windows.Forms.MenuItem
    Friend WithEvents mnuAbout As System.Windows.Forms.MenuItem
    Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip
    Friend WithEvents mnuClearMascotHtmFileList As System.Windows.Forms.MenuItem
    Friend WithEvents mnuClearWiffFileList As System.Windows.Forms.MenuItem
    Friend WithEvents mnuSaveFileAssociations As System.Windows.Forms.MenuItem
    Friend WithEvents mnuMascotFiles As System.Windows.Forms.ContextMenu
    Friend WithEvents mnuWiffFiles As System.Windows.Forms.ContextMenu
    Friend WithEvents mnuRemoveEntryMascotFiles As System.Windows.Forms.MenuItem
    Friend WithEvents mnuAddEntryMascotFiles As System.Windows.Forms.MenuItem
    Friend WithEvents mnuRemoveWiffFile As System.Windows.Forms.MenuItem
    Friend WithEvents mnuAddWiffFile As System.Windows.Forms.MenuItem
    Friend WithEvents mnuAssociateWithHighlightedMascotFile As System.Windows.Forms.MenuItem
    Friend WithEvents mnuAddWiffsInFolder As System.Windows.Forms.MenuItem
    Friend WithEvents mnuContSetFileDirMascot As System.Windows.Forms.MenuItem
    Friend WithEvents mnuAssociateWithHighlightedWiffFile As System.Windows.Forms.MenuItem
    Friend WithEvents chkLBWiffFiles As System.Windows.Forms.CheckedListBox
    Friend WithEvents mnuFindInMascotFileList As System.Windows.Forms.MenuItem
    Friend WithEvents mnuFindInWiffFileList As System.Windows.Forms.MenuItem
    Friend WithEvents mnuBreakMascotAssociation As System.Windows.Forms.MenuItem
    Friend WithEvents mnuBreakWiffAss As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenHighlighted As System.Windows.Forms.MenuItem
    Friend WithEvents mnuLoadDefFileAss As System.Windows.Forms.MenuItem
    Friend WithEvents mnuSaveFileAssAs As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenFileAss As System.Windows.Forms.MenuItem
    Friend WithEvents mnuGuessAllAss As System.Windows.Forms.MenuItem
    Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog
    Friend WithEvents mnuSetSampleNum As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuCorrelationSettings As System.Windows.Forms.MenuItem
    Friend WithEvents mnunGarbageCollect As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenParsedProteinsEtc As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenContainFolderForRawfile As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem6 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem7 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpenContainFolderForResultfile As System.Windows.Forms.MenuItem
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMainForm))
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
        Me.StatusBar1 = New System.Windows.Forms.StatusBar
        Me.StatusBarPanel1 = New System.Windows.Forms.StatusBarPanel
        Me.StatusBarPanel2 = New System.Windows.Forms.StatusBarPanel
        Me.StatusBarPanel3 = New System.Windows.Forms.StatusBarPanel
        Me.StatusBarPanel4 = New System.Windows.Forms.StatusBarPanel
        Me.StatusBarPanel5 = New System.Windows.Forms.StatusBarPanel
        Me.ProgressBar1 = New System.Windows.Forms.ProgressBar
        Me.MainMenu1 = New System.Windows.Forms.MainMenu(Me.components)
        Me.mnuFile = New System.Windows.Forms.MenuItem
        Me.mnuOpenParsedProteinsEtc = New System.Windows.Forms.MenuItem
        Me.someMenuItem7 = New System.Windows.Forms.MenuItem
        Me.mnuOpenMB3 = New System.Windows.Forms.MenuItem
        Me.MenuItem3 = New System.Windows.Forms.MenuItem
        Me.mnuLoadDefFileAss = New System.Windows.Forms.MenuItem
        Me.mnuOpenFileAss = New System.Windows.Forms.MenuItem
        Me.mnuSaveFileAssociations = New System.Windows.Forms.MenuItem
        Me.mnuSaveFileAssAs = New System.Windows.Forms.MenuItem
        Me.mnuSetFileDirectoryMascotResults = New System.Windows.Forms.MenuItem
        Me.mnuExit = New System.Windows.Forms.MenuItem
        Me.mnuEdit = New System.Windows.Forms.MenuItem
        Me.mnuClearMascotHtmFileList = New System.Windows.Forms.MenuItem
        Me.mnuClearWiffFileList = New System.Windows.Forms.MenuItem
        Me.mnuSetSampleNum = New System.Windows.Forms.MenuItem
        Me.mnuTools = New System.Windows.Forms.MenuItem
        Me.mnuQuantitateCheckedFiles = New System.Windows.Forms.MenuItem
        Me.mnuOpenHighlighted = New System.Windows.Forms.MenuItem
        Me.mnuGuessAllAss = New System.Windows.Forms.MenuItem
        Me.MenuItem1 = New System.Windows.Forms.MenuItem
        Me.mnuDimensions = New System.Windows.Forms.MenuItem
        Me.mnuRawFileMapping = New System.Windows.Forms.MenuItem
        Me.mnuCorrelationSettings = New System.Windows.Forms.MenuItem
        Me.mnuOptions = New System.Windows.Forms.MenuItem
        Me.MenuItem8 = New System.Windows.Forms.MenuItem
        Me.mnuOpenAppFolder = New System.Windows.Forms.MenuItem
        Me.mnuCommandLineParameters = New System.Windows.Forms.MenuItem
        Me.mnunGarbageCollect = New System.Windows.Forms.MenuItem
        Me.MenuItem9 = New System.Windows.Forms.MenuItem
        Me.mnuOpenHelperApplicationsAppFolder = New System.Windows.Forms.MenuItem
        Me.mnuOpenPILGrinder = New System.Windows.Forms.MenuItem
        Me.mnuOpenDTASC = New System.Windows.Forms.MenuItem
        Me.mnuOpenMRL = New System.Windows.Forms.MenuItem
        Me.mnuOpenMascotResultViewer = New System.Windows.Forms.MenuItem
        Me.mnuOpenFinniganNumberStripper = New System.Windows.Forms.MenuItem
        Me.mnuOpenMascotResultFileReductor = New System.Windows.Forms.MenuItem
        Me.mnuMGFcombiner = New System.Windows.Forms.MenuItem
        Me.mnuOpenMSRecal = New System.Windows.Forms.MenuItem
        Me.MenuItem2 = New System.Windows.Forms.MenuItem
        Me.mnuTest1 = New System.Windows.Forms.MenuItem
        Me.mnuZedGraph = New System.Windows.Forms.MenuItem
        Me.mnuFireAssert = New System.Windows.Forms.MenuItem
        Me.mnuHelp = New System.Windows.Forms.MenuItem
        Me.mnuAbout = New System.Windows.Forms.MenuItem
        Me.chkLBMascotFiles = New System.Windows.Forms.CheckedListBox
        Me.mnuMascotFiles = New System.Windows.Forms.ContextMenu
        Me.mnuOpenContainFolderForResultfile = New System.Windows.Forms.MenuItem
        Me.MenuItem10 = New System.Windows.Forms.MenuItem
        Me.mnuContSetFileDirMascot = New System.Windows.Forms.MenuItem
        Me.mnuAddEntryMascotFiles = New System.Windows.Forms.MenuItem
        Me.mnuFindInMascotFileList = New System.Windows.Forms.MenuItem
        Me.mnuRemoveEntryMascotFiles = New System.Windows.Forms.MenuItem
        Me.MenuItem6 = New System.Windows.Forms.MenuItem
        Me.mnuAssociateWithHighlightedWiffFile = New System.Windows.Forms.MenuItem
        Me.mnuBreakMascotAssociation = New System.Windows.Forms.MenuItem
        Me.MenuItem7 = New System.Windows.Forms.MenuItem
        Me.mnuOpenWithMascotResultViwerScript = New System.Windows.Forms.MenuItem
        Me.mnuRunFinniganNumberScript = New System.Windows.Forms.MenuItem
        Me.mnuRunMascotResultFileReductorScript = New System.Windows.Forms.MenuItem
        Me.mnuWiffFiles = New System.Windows.Forms.ContextMenu
        Me.mnuOpenContainFolderForRawfile = New System.Windows.Forms.MenuItem
        Me.MenuItem11 = New System.Windows.Forms.MenuItem
        Me.mnuAddWiffsInFolder = New System.Windows.Forms.MenuItem
        Me.mnuAddWiffFile = New System.Windows.Forms.MenuItem
        Me.mnuFindInWiffFileList = New System.Windows.Forms.MenuItem
        Me.mnuRemoveWiffFile = New System.Windows.Forms.MenuItem
        Me.MenuItem4 = New System.Windows.Forms.MenuItem
        Me.mnuAssociateWithHighlightedMascotFile = New System.Windows.Forms.MenuItem
        Me.mnuBreakWiffAss = New System.Windows.Forms.MenuItem
        Me.MenuItem5 = New System.Windows.Forms.MenuItem
        Me.lblHTMLheader = New System.Windows.Forms.Label
        Me.lblRAWheader = New System.Windows.Forms.Label
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.chkLBWiffFiles = New System.Windows.Forms.CheckedListBox
        Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog
        CType(Me.StatusBarPanel1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.StatusBarPanel2, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.StatusBarPanel3, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.StatusBarPanel4, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.StatusBarPanel5, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'StatusBar1
        '
        Me.StatusBar1.Location = New System.Drawing.Point(0, 156)
        Me.StatusBar1.Name = "StatusBar1"
        Me.StatusBar1.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() {Me.StatusBarPanel1, Me.StatusBarPanel2, Me.StatusBarPanel3, Me.StatusBarPanel4, Me.StatusBarPanel5})
        Me.StatusBar1.ShowPanels = True
        Me.StatusBar1.Size = New System.Drawing.Size(1155, 24)
        Me.StatusBar1.TabIndex = 0
        '
        'StatusBarPanel1
        '
        Me.StatusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
        Me.StatusBarPanel1.Name = "StatusBarPanel1"
        Me.StatusBarPanel1.Width = 227
        '
        'StatusBarPanel2
        '
        Me.StatusBarPanel2.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
        Me.StatusBarPanel2.Name = "StatusBarPanel2"
        Me.StatusBarPanel2.Width = 227
        '
        'StatusBarPanel3
        '
        Me.StatusBarPanel3.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
        Me.StatusBarPanel3.Name = "StatusBarPanel3"
        Me.StatusBarPanel3.Width = 227
        '
        'StatusBarPanel4
        '
        Me.StatusBarPanel4.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
        Me.StatusBarPanel4.Name = "StatusBarPanel4"
        Me.StatusBarPanel4.Width = 227
        '
        'StatusBarPanel5
        '
        Me.StatusBarPanel5.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
        Me.StatusBarPanel5.Name = "StatusBarPanel5"
        Me.StatusBarPanel5.Width = 227
        '
        'ProgressBar1
        '
        Me.ProgressBar1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.ProgressBar1.Location = New System.Drawing.Point(0, 79)
        Me.ProgressBar1.Name = "ProgressBar1"
        Me.ProgressBar1.Size = New System.Drawing.Size(1155, 14)
        Me.ProgressBar1.TabIndex = 1
        '
        'MainMenu1
        '
        Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile, Me.mnuEdit, Me.mnuTools, Me.MenuItem8, Me.mnuHelp})
        '
        'mnuFile
        '
        Me.mnuFile.Index = 0
        Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuOpenParsedProteinsEtc, Me.someMenuItem7, Me.MenuItem3, Me.mnuLoadDefFileAss, Me.mnuOpenFileAss, Me.mnuSaveFileAssociations, Me.mnuSaveFileAssAs, Me.mnuSetFileDirectoryMascotResults, Me.mnuExit})
        Me.mnuFile.Text = "&File"
        '
        'mnuOpenParsedProteinsEtc
        '
        Me.mnuOpenParsedProteinsEtc.Index = 0
        Me.mnuOpenParsedProteinsEtc.Text = "&Open..."
        '
        'someMenuItem7
        '
        Me.someMenuItem7.Index = 1
        Me.someMenuItem7.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuOpenMB3})
        Me.someMenuItem7.Text = "Legacy"
        '
        'mnuOpenMB3
        '
        Me.mnuOpenMB3.Index = 0
        Me.mnuOpenMB3.Text = "Open older format (MB3)"
        '
        'MenuItem3
        '
        Me.MenuItem3.Index = 2
        Me.MenuItem3.Text = "-"
        '
        'mnuLoadDefFileAss
        '
        Me.mnuLoadDefFileAss.Enabled = False
        Me.mnuLoadDefFileAss.Index = 3
        Me.mnuLoadDefFileAss.Text = "Load defaut file associations"
        '
        'mnuOpenFileAss
        '
        Me.mnuOpenFileAss.Index = 4
        Me.mnuOpenFileAss.Text = "Open file associations..."
        '
        'mnuSaveFileAssociations
        '
        Me.mnuSaveFileAssociations.Index = 5
        Me.mnuSaveFileAssociations.Text = "&Save file associations"
        '
        'mnuSaveFileAssAs
        '
        Me.mnuSaveFileAssAs.Enabled = False
        Me.mnuSaveFileAssAs.Index = 6
        Me.mnuSaveFileAssAs.Text = "Save File Associations As..."
        '
        'mnuSetFileDirectoryMascotResults
        '
        Me.mnuSetFileDirectoryMascotResults.Index = 7
        Me.mnuSetFileDirectoryMascotResults.Text = "Set  Mascot or wiff/raw/idx folder"
        '
        'mnuExit
        '
        Me.mnuExit.Index = 8
        Me.mnuExit.Text = "E&xit"
        '
        'mnuEdit
        '
        Me.mnuEdit.Index = 1
        Me.mnuEdit.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuClearMascotHtmFileList, Me.mnuClearWiffFileList, Me.mnuSetSampleNum})
        Me.mnuEdit.Text = "&Edit"
        '
        'mnuClearMascotHtmFileList
        '
        Me.mnuClearMascotHtmFileList.Index = 0
        Me.mnuClearMascotHtmFileList.Text = "Clear Mascot htm files"
        '
        'mnuClearWiffFileList
        '
        Me.mnuClearWiffFileList.Index = 1
        Me.mnuClearWiffFileList.Text = "Clear raw data files"
        '
        'mnuSetSampleNum
        '
        Me.mnuSetSampleNum.Index = 2
        Me.mnuSetSampleNum.Text = "Set sample number (QSTAR only)"
        '
        'mnuTools
        '
        Me.mnuTools.Index = 2
        Me.mnuTools.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuQuantitateCheckedFiles, Me.mnuOpenHighlighted, Me.mnuGuessAllAss, Me.MenuItem1, Me.mnuDimensions, Me.mnuRawFileMapping, Me.mnuCorrelationSettings, Me.mnuOptions})
        Me.mnuTools.Text = "&Tools"
        '
        'mnuQuantitateCheckedFiles
        '
        Me.mnuQuantitateCheckedFiles.Enabled = False
        Me.mnuQuantitateCheckedFiles.Index = 0
        Me.mnuQuantitateCheckedFiles.Text = "Quantitate checked files"
        Me.mnuQuantitateCheckedFiles.Visible = False
        '
        'mnuOpenHighlighted
        '
        Me.mnuOpenHighlighted.Enabled = False
        Me.mnuOpenHighlighted.Index = 1
        Me.mnuOpenHighlighted.Text = "Open highlighted file"
        Me.mnuOpenHighlighted.Visible = False
        '
        'mnuGuessAllAss
        '
        Me.mnuGuessAllAss.Index = 2
        Me.mnuGuessAllAss.Text = "Guess all associations"
        '
        'MenuItem1
        '
        Me.MenuItem1.Index = 3
        Me.MenuItem1.Text = "-"
        '
        'mnuDimensions
        '
        Me.mnuDimensions.Index = 4
        Me.mnuDimensions.Shortcut = System.Windows.Forms.Shortcut.CtrlF12
        Me.mnuDimensions.Text = "Experiment Dimensions..."
        '
        'mnuRawFileMapping
        '
        Me.mnuRawFileMapping.Index = 5
        Me.mnuRawFileMapping.Shortcut = System.Windows.Forms.Shortcut.F12
        Me.mnuRawFileMapping.Text = "Experiment Raw File Mapping..."
        '
        'mnuCorrelationSettings
        '
        Me.mnuCorrelationSettings.Index = 6
        Me.mnuCorrelationSettings.Text = "&Correlation settings..."
        '
        'mnuOptions
        '
        Me.mnuOptions.Index = 7
        Me.mnuOptions.Shortcut = System.Windows.Forms.Shortcut.F10
        Me.mnuOptions.Text = "&Options..."
        '
        'MenuItem8
        '
        Me.MenuItem8.Index = 3
        Me.MenuItem8.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuOpenAppFolder, Me.mnuCommandLineParameters, Me.mnunGarbageCollect, Me.MenuItem9, Me.mnuOpenHelperApplicationsAppFolder, Me.mnuOpenPILGrinder, Me.mnuOpenDTASC, Me.mnuOpenMRL, Me.mnuOpenMascotResultViewer, Me.mnuOpenFinniganNumberStripper, Me.mnuOpenMascotResultFileReductor, Me.mnuMGFcombiner, Me.mnuOpenMSRecal, Me.MenuItem2, Me.mnuTest1, Me.mnuZedGraph, Me.mnuFireAssert})
        Me.MenuItem8.Text = "&Utility"
        '
        'mnuOpenAppFolder
        '
        Me.mnuOpenAppFolder.Index = 0
        Me.mnuOpenAppFolder.Shortcut = System.Windows.Forms.Shortcut.CtrlF2
        Me.mnuOpenAppFolder.Text = "Open MS&Quant folder"
        '
        'mnuCommandLineParameters
        '
        Me.mnuCommandLineParameters.Index = 1
        Me.mnuCommandLineParameters.Text = "Current Command Line Parameters"
        '
        'mnunGarbageCollect
        '
        Me.mnunGarbageCollect.Index = 2
        Me.mnunGarbageCollect.Shortcut = System.Windows.Forms.Shortcut.F2
        Me.mnunGarbageCollect.Text = "Don't Panic: Garbage Collect (experimental)"
        '
        'MenuItem9
        '
        Me.MenuItem9.Index = 3
        Me.MenuItem9.Text = "-"
        '
        'mnuOpenHelperApplicationsAppFolder
        '
        Me.mnuOpenHelperApplicationsAppFolder.Index = 4
        Me.mnuOpenHelperApplicationsAppFolder.Text = "Open &Helper Applications folder"
        '
        'mnuOpenPILGrinder
        '
        Me.mnuOpenPILGrinder.Index = 5
        Me.mnuOpenPILGrinder.Shortcut = System.Windows.Forms.Shortcut.F5
        Me.mnuOpenPILGrinder.Text = "Open PIL&Grinder"
        '
        'mnuOpenDTASC
        '
        Me.mnuOpenDTASC.Index = 6
        Me.mnuOpenDTASC.Shortcut = System.Windows.Forms.Shortcut.F6
        Me.mnuOpenDTASC.Text = "Open &DTASuperCharge"
        '
        'mnuOpenMRL
        '
        Me.mnuOpenMRL.Index = 7
        Me.mnuOpenMRL.Shortcut = System.Windows.Forms.Shortcut.F7
        Me.mnuOpenMRL.Text = "Open &Mascot Result Launcher"
        '
        'mnuOpenMascotResultViewer
        '
        Me.mnuOpenMascotResultViewer.Index = 8
        Me.mnuOpenMascotResultViewer.Text = "Open Mascot Result Viewer (script)"
        '
        'mnuOpenFinniganNumberStripper
        '
        Me.mnuOpenFinniganNumberStripper.Index = 9
        Me.mnuOpenFinniganNumberStripper.Text = "Open Finnigan Number Stripper (script)"
        '
        'mnuOpenMascotResultFileReductor
        '
        Me.mnuOpenMascotResultFileReductor.Index = 10
        Me.mnuOpenMascotResultFileReductor.Text = "Open Mascot Result File Reductor (script)"
        '
        'mnuMGFcombiner
        '
        Me.mnuMGFcombiner.Index = 11
        Me.mnuMGFcombiner.Shortcut = System.Windows.Forms.Shortcut.F8
        Me.mnuMGFcombiner.Text = "Open MGF&combiner"
        '
        'mnuOpenMSRecal
        '
        Me.mnuOpenMSRecal.Index = 12
        Me.mnuOpenMSRecal.Shortcut = System.Windows.Forms.Shortcut.F9
        Me.mnuOpenMSRecal.Text = "Open MS&Recal"
        '
        'MenuItem2
        '
        Me.MenuItem2.Index = 13
        Me.MenuItem2.Text = "-"
        '
        'mnuTest1
        '
        Me.mnuTest1.Enabled = False
        Me.mnuTest1.Index = 14
        Me.mnuTest1.Shortcut = System.Windows.Forms.Shortcut.F8
        Me.mnuTest1.Text = "Test1 - remoting"
        Me.mnuTest1.Visible = False
        '
        'mnuZedGraph
        '
        Me.mnuZedGraph.Enabled = False
        Me.mnuZedGraph.Index = 15
        Me.mnuZedGraph.Text = "Test2 - ZedGraph"
        Me.mnuZedGraph.Visible = False
        '
        'mnuFireAssert
        '
        Me.mnuFireAssert.Enabled = False
        Me.mnuFireAssert.Index = 16
        Me.mnuFireAssert.Text = "Test3 - Fire Assert"
        Me.mnuFireAssert.Visible = False
        '
        'mnuHelp
        '
        Me.mnuHelp.Index = 4
        Me.mnuHelp.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuAbout})
        Me.mnuHelp.Text = "&Help"
        '
        'mnuAbout
        '
        Me.mnuAbout.Index = 0
        Me.mnuAbout.Text = "xyz"
        '
        'chkLBMascotFiles
        '
        Me.chkLBMascotFiles.ContextMenu = Me.mnuMascotFiles
        Me.chkLBMascotFiles.HorizontalScrollbar = True
        Me.chkLBMascotFiles.Location = New System.Drawing.Point(0, 24)
        Me.chkLBMascotFiles.Name = "chkLBMascotFiles"
        Me.chkLBMascotFiles.Size = New System.Drawing.Size(480, 49)
        Me.chkLBMascotFiles.TabIndex = 2
        Me.chkLBMascotFiles.ThreeDCheckBoxes = True
        '
        'mnuMascotFiles
        '
        Me.mnuMascotFiles.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuOpenContainFolderForResultfile, Me.MenuItem10, Me.mnuContSetFileDirMascot, Me.mnuAddEntryMascotFiles, Me.mnuFindInMascotFileList, Me.mnuRemoveEntryMascotFiles, Me.MenuItem6, Me.mnuAssociateWithHighlightedWiffFile, Me.mnuBreakMascotAssociation, Me.MenuItem7, Me.mnuOpenWithMascotResultViwerScript, Me.mnuRunFinniganNumberScript, Me.mnuRunMascotResultFileReductorScript})
        '
        'mnuOpenContainFolderForResultfile
        '
        Me.mnuOpenContainFolderForResultfile.Index = 0
        Me.mnuOpenContainFolderForResultfile.Text = "Open Containing Folder"
        '
        'MenuItem10
        '
        Me.MenuItem10.Index = 1
        Me.MenuItem10.Text = "-"
        '
        'mnuContSetFileDirMascot
        '
        Me.mnuContSetFileDirMascot.Index = 2
        Me.mnuContSetFileDirMascot.Text = "Add Mascot result files in folder"
        '
        'mnuAddEntryMascotFiles
        '
        Me.mnuAddEntryMascotFiles.Index = 3
        Me.mnuAddEntryMascotFiles.Text = "Add single Mascot result file"
        '
        'mnuFindInMascotFileList
        '
        Me.mnuFindInMascotFileList.Index = 4
        Me.mnuFindInMascotFileList.Text = "Find entry"
        '
        'mnuRemoveEntryMascotFiles
        '
        Me.mnuRemoveEntryMascotFiles.Index = 5
        Me.mnuRemoveEntryMascotFiles.Text = "Remove entry"
        '
        'MenuItem6
        '
        Me.MenuItem6.Index = 6
        Me.MenuItem6.Text = "-"
        '
        'mnuAssociateWithHighlightedWiffFile
        '
        Me.mnuAssociateWithHighlightedWiffFile.Index = 7
        Me.mnuAssociateWithHighlightedWiffFile.Text = "Associate with selected raw data file"
        '
        'mnuBreakMascotAssociation
        '
        Me.mnuBreakMascotAssociation.Index = 8
        Me.mnuBreakMascotAssociation.Text = "Break association"
        '
        'MenuItem7
        '
        Me.MenuItem7.Index = 9
        Me.MenuItem7.Text = "-"
        '
        'mnuOpenWithMascotResultViwerScript
        '
        Me.mnuOpenWithMascotResultViwerScript.Index = 10
        Me.mnuOpenWithMascotResultViwerScript.Text = "View with Mascot Result Viewer - opens in web-browser (e.g. Opera)"
        '
        'mnuRunFinniganNumberScript
        '
        Me.mnuRunFinniganNumberScript.Index = 11
        Me.mnuRunFinniganNumberScript.Text = "Generate parse-only Mascot result file ( Finnigan Number Stripper)"
        '
        'mnuRunMascotResultFileReductorScript
        '
        Me.mnuRunMascotResultFileReductorScript.Index = 12
        Me.mnuRunMascotResultFileReductorScript.Text = "Generate smaller Mascot result file (Mascot Result File Reductor)"
        '
        'mnuWiffFiles
        '
        Me.mnuWiffFiles.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuOpenContainFolderForRawfile, Me.MenuItem11, Me.mnuAddWiffsInFolder, Me.mnuAddWiffFile, Me.mnuFindInWiffFileList, Me.mnuRemoveWiffFile, Me.MenuItem4, Me.mnuAssociateWithHighlightedMascotFile, Me.mnuBreakWiffAss, Me.MenuItem5})
        '
        'mnuOpenContainFolderForRawfile
        '
        Me.mnuOpenContainFolderForRawfile.Index = 0
        Me.mnuOpenContainFolderForRawfile.Text = "Open Containing Folder"
        '
        'MenuItem11
        '
        Me.MenuItem11.Index = 1
        Me.MenuItem11.Text = "-"
        '
        'mnuAddWiffsInFolder
        '
        Me.mnuAddWiffsInFolder.Index = 2
        Me.mnuAddWiffsInFolder.Text = "Add raw data files in folder"
        '
        'mnuAddWiffFile
        '
        Me.mnuAddWiffFile.Index = 3
        Me.mnuAddWiffFile.Text = "Add single raw data file"
        '
        'mnuFindInWiffFileList
        '
        Me.mnuFindInWiffFileList.Index = 4
        Me.mnuFindInWiffFileList.Text = "Find entry"
        '
        'mnuRemoveWiffFile
        '
        Me.mnuRemoveWiffFile.Index = 5
        Me.mnuRemoveWiffFile.Text = "Remove entry"
        '
        'MenuItem4
        '
        Me.MenuItem4.Index = 6
        Me.MenuItem4.Text = "-"
        '
        'mnuAssociateWithHighlightedMascotFile
        '
        Me.mnuAssociateWithHighlightedMascotFile.Index = 7
        Me.mnuAssociateWithHighlightedMascotFile.Text = "Associate with selected Mascot result file"
        '
        'mnuBreakWiffAss
        '
        Me.mnuBreakWiffAss.Index = 8
        Me.mnuBreakWiffAss.Text = "Break association"
        '
        'MenuItem5
        '
        Me.MenuItem5.Index = 9
        Me.MenuItem5.Text = "-"
        '
        'lblHTMLheader
        '
        Me.lblHTMLheader.Location = New System.Drawing.Point(0, 8)
        Me.lblHTMLheader.Name = "lblHTMLheader"
        Me.lblHTMLheader.Size = New System.Drawing.Size(141, 16)
        Me.lblHTMLheader.TabIndex = 4
        Me.lblHTMLheader.Text = "Mascot result files (HTML)"
        '
        'lblRAWheader
        '
        Me.lblRAWheader.Location = New System.Drawing.Point(488, 8)
        Me.lblRAWheader.Name = "lblRAWheader"
        Me.lblRAWheader.Size = New System.Drawing.Size(113, 16)
        Me.lblRAWheader.TabIndex = 5
        Me.lblRAWheader.Text = "Raw data files"
        '
        'chkLBWiffFiles
        '
        Me.chkLBWiffFiles.ContextMenu = Me.mnuWiffFiles
        Me.chkLBWiffFiles.HorizontalScrollbar = True
        Me.chkLBWiffFiles.Location = New System.Drawing.Point(488, 24)
        Me.chkLBWiffFiles.Name = "chkLBWiffFiles"
        Me.chkLBWiffFiles.Size = New System.Drawing.Size(472, 49)
        Me.chkLBWiffFiles.TabIndex = 6
        Me.chkLBWiffFiles.ThreeDCheckBoxes = True
        '
        'SaveFileDialog1
        '
        Me.SaveFileDialog1.FileName = "doc1"
        Me.SaveFileDialog1.Filter = "text files (*.txt)|*.txt"
        Me.SaveFileDialog1.ShowHelp = True
        '
        'frmMainForm
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(1155, 180)
        Me.Controls.Add(Me.chkLBWiffFiles)
        Me.Controls.Add(Me.lblRAWheader)
        Me.Controls.Add(Me.lblHTMLheader)
        Me.Controls.Add(Me.chkLBMascotFiles)
        Me.Controls.Add(Me.ProgressBar1)
        Me.Controls.Add(Me.StatusBar1)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Menu = Me.MainMenu1
        Me.MinimumSize = New System.Drawing.Size(400, 200)
        Me.Name = "frmMainForm"
        Me.Text = "xyz"
        CType(Me.StatusBarPanel1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.StatusBarPanel2, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.StatusBarPanel3, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.StatusBarPanel4, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.StatusBarPanel5, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub init()
        'Note: second-level initialisation is in frmMainForm_Load()...

        mForceClose2 = False
        mCommands = ""

        'Changed PM_DOUBLE_RETURN_KEY 2007-09-08
        mKeyObserver = New SDUPkeyObserver

        'Test...
        If True Then
            'Dim sw As SimmoTech.Utils.Serialization=
            'Dim sw As SerializationWriter = New SerializationWriter()
        End If

        'Changed PM_REFACTOR 2008-12-12. Override anything set in the
        '  designer.
        Me.mnuAbout.Text = "About " & AppConstants.LONG_APP & "..."
        Me.Text = _
          AppConstants.LONG_APP & _
          " - www.cebi.sdu.dk & " & _
          AppConstants.APP_HOMEPAGE
    End Sub 'init()


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub frmMainForm_Load( _
      ByVal sender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles MyBase.Load

        Dim continueStartUp2 As Boolean = True

        gApplication = New quantApplication
        mApplication = gApplication

        'Move all of this to the application!!!


        'Changed PM_BAD_QUANTITATION_MASSSCALE 2006-04-04. Moved up here to be detected
        '  first. Otherwise we will write out XML files with bad output, e.g. "0,2" in
        '  file new_MiscOptions.xml ...
        '
        'Changed PM_DETECT_PROPER_REGIONALSETTINGS 2003-03-13
        'Detect whether the decimal point (for numbers) is ".").
        If True Then
            Dim failed As Boolean = False

            Dim numStr As String = "1.9"

            Dim conNum As Double = -1000.0
            Try
                conNum = CDbl(numStr)
                'Note: this conversion fails (exception) for
                '      systems with "," as decimal point.
                '
                '      And where "Digit grouping symbol" is 
                '      not ","... E.g. for Norwegian Bokmal
                '      where it is a space !
            Catch ex As Exception
                failed = True
            End Try

            If conNum > 1.89 And conNum < 1.91 Then
                Dim peter3 As Integer = 3
            Else
                failed = True
            End If

            If failed Then
                MsgBox( _
                  "Could not start " & AppConstants.LONG_APP & ". " & _
                  AppConstants.LONG_APP & " only works if the decimal point is '.' (dot). " & _
                  "For instance set regional settings to English " & _
                  "(in Start menu/Settings/Control Panel/Regional Options/General/Your locale).")

                Me.doClose2(True, continueStartUp2)
            End If

            'One could use this function everywhere a conversion from string to double is required:
            '
            '    'Will covert crazy number strings to proper number even in the
            '    'presence of crazy regional settings like Danish.
            '    Private Function MyToDouble(inValue As String) As Double
            '        Dim dotString As String
            '        dotString = ReplaceCommaWithDot(inValue)
            '        MyToDouble = CDbl(Val(dotString))
            '
            '        'Stub
            '        'MyToDouble = 1.3
            '    End Function
        End If

        'Changed PM_BAD_QUANTITATION_MASSSCALE 2006-04-04. Moved up here to be
        '  detected early. To remove risk that creation of default XML files
        '  will be affected by an old version of SqlInterface.dll.
        'Changed PM_DLL_VERSIONING_CHECK_PEPTIDEHITSTRUCTURE 2003-10-08
        If continueStartUp2 Then
            'Check to see if new fields in PeptideHitStructure are in
            'the DLL, "SqlInterface.dll"....

            'Will this force load assembly ZedGraph?? Yes, positively! But we will 
            'probably get an exception if ZedGraph is not present.
            'How does it work for "SqlInterface" then??
            Try
                Dim someZedGraph As ZedGraph.ZedGraphControl = New ZedGraph.ZedGraphControl
                Dim myPane As ZedGraph.GraphPane = someZedGraph.GraphPane

            Catch exceptionObject As Exception
                'Ignore exception. This problem will be reported below.
            End Try

            'Force load of SqlInterface.dll, otherwise it will not found
            'in the code below.

            Dim curApp As System.AppDomain = AppDomain.CurrentDomain()
            Dim assemblies As System.Reflection.Assembly() = _
              curApp.GetAssemblies()

            Dim sqlInterfaceFound As Boolean = False

            'Changed PM_RECALIB_VISUAL 2007-09-02
            Dim ZedGraphFound As Boolean = False

            Dim str4 As String = ""
            Dim t2 As System.Reflection.Assembly
            For Each t2 In assemblies
                str4 &= "Assembly: " & t2.FullName & vbCr & vbLf
                Dim aName As System.Reflection.AssemblyName = _
                  t2.GetName()
                Dim aNameStr As String = aName.Name

                'Changed PM_QUANT_MODE_REORG 2004-01-05. Note: is
                'NOT MolecularSharedStructures, it is the name of the assembly (file name?)
                If aNameStr = "SqlInterface" Then
                    sqlInterfaceFound = True
                    Dim str5 As String = ""
                    Dim t3 As Type
                    For Each t3 In t2.GetTypes()
                        str5 &= "Type: " & t3.Name & vbCr & vbLf
                        If t3.Name = "PeptideHitStructure" Then
                            'Changed PM_DLL_CHECK_PEPTIDEHITSTRUCTURE 2003-10-28
                            Dim fieldTypeNew2 As System.Reflection.FieldInfo = _
                                t3.GetField( _
                                  "LCprofilesProperties")
                            'Older: "AASequencePlusMods"
                            '       "usedForQuantitation_maxWTintensity_LCtime"
                            '       "evenHigherLCpeakProfile"
                            '       "uncalibratedMSCentroidMass"
                            '       "rawFileFullPath"
                            '       "modHits"
                            '       "MascotScorePlusMS3Score"
                            '       "measuredMass" 

                            'Changed PM_STARTUPCHECK_DELETED_FIELDS 2005-08-08
                            'Note: this field must NOT exist....
                            Dim fieldTypeOld2 As System.Reflection.FieldInfo = _
                                t3.GetField( _
                                  "totalLCPeakArea_Isotope")
                            'Older:
                            '   "lowerMZuncalib"

                            If fieldTypeNew2 Is Nothing Or _
                               Not fieldTypeOld2 Is Nothing Then

                                Dim msgStr As String = _
                                  "Could not start " & _
                                  AppConstants.LONG_APP & ". " & _
                                  "The DLL file 'SqlInterface.dll' seems not " & _
                                  "to have the correct version or it is absent."
                                MsgBox(msgStr)

                                Me.doClose2(True, continueStartUp2)
                                Exit Sub
                            Else
                                Dim peter20 As Integer = 20
                            End If
                        End If
                    Next
                End If 'SqlInterface assembly

                'Changed PM_RECALIB_VISUAL 2007-09-02
                If aNameStr = "ZedGraph" Then
                    ZedGraphFound = True
                End If
            Next 'Through assemblies of this application.

            If Not sqlInterfaceFound Then
                MsgBox( _
                  "Could not start " & AppConstants.LONG_APP & ". " & _
                  "Assembly SqlInterface (file ""SqlInterface.dll"") was " & _
                  "not found. " & _
                  "Reinstall " & AppConstants.LONG_APP & ".")
                Me.doClose2(True, continueStartUp2)
            End If

            'Changed PM_RECALIB_VISUAL 2007-09-02
            If Not ZedGraphFound Then
                MsgBox( _
                  "Could not start " & AppConstants.LONG_APP & _
                  ". " & _
                  "Assembly ZedGraph (file ""ZedGraph.dll"") was not found. " & _
                  "Reinstall " & AppConstants.LONG_APP & ".")
                Me.doClose2(True, continueStartUp2) 'This will change continueStartUp2...
            End If

        End If 'Check to see if new fields in PeptideHitStructure/old version
        '  of SqlInterface.dll.

        'Changed PM_REFACTOR 2006-06-21
        'Refuse to start if configuration file(s) in old format(s) exist.
        If continueStartUp2 Then
            Dim numberOfFiles As Integer = 5
            Dim lastIndex As Integer = numberOfFiles - 1
            Dim oldFilesNames(lastIndex) As String
            oldFilesNames(0) = AppConstants.OLD_QUANTMODES_FILENAME
            oldFilesNames(1) = AppConstants.OLD_MISCOPTIONS_FILENAME
            oldFilesNames(2) = AppConstants.OLD_CORRSETTINGS_FILENAME
            oldFilesNames(3) = AppConstants.OLD_SPECCLASSIFICATION_FILENAME
            oldFilesNames(4) = AppConstants.OLD_PARSER_SETTINGS_FILENAME

            Dim newFilesNames(lastIndex) As String
            newFilesNames(0) = AppConstants.NEW_QUANTMODES_FILENAME
            newFilesNames(1) = AppConstants.NEW_MISCOPTIONS_FILENAME2
            newFilesNames(2) = AppConstants.NEW_CORRSETTINGS_FILENAME
            newFilesNames(3) = AppConstants.NEW_SPECCLASSIFICATION_FILENAME
            newFilesNames(4) = AppConstants.NEW_PARSER_SETTINGS_FILENAME

            If AppCommon2.oldOptionFiles( _
              oldFilesNames, newFilesNames, AppConstants.LONG_APP) Then
                Me.doClose2(True, continueStartUp2)
            End If
        End If

        If continueStartUp2 Then
            'Changed PM_RESIZE_MAINWINDOW 2008-01-14
            Me.adjustGUIsizes()

            'We load the default association stored in the bin directory.
            If File.Exists(mDefaultMascotWiffAssFileStr) Then
                Me.loadFileAssociations(mDefaultMascotWiffAssFileStr)
            End If

            Dim quantAndModFile As String = AppConstants.NEW_QUANTMODES_FILENAME

            'Note: this must come before load of MascotParserOptions.xml.
            Dim modificationsAccepted As Boolean
            Dim errStr As String = Nothing
            'E.g. loading "... quantitationModes.xml".
            mApplication.appLoadQuantitationDefinitions( _
              quantAndModFile, _
              modificationsAccepted, _
              errStr)

            If Not modificationsAccepted Then
                Dim msg As String = _
                  "Could not start " & AppConstants.LONG_APP & ". " _
                  & AppConstants.LONG_APP & _
                  " will not start due to problems with the modification " & _
                  "definitions in the settings file " & _
                  quantAndModFile & _
                  " (details below). " & _
                  "Please edit this file. Extra information: " & _
                  ControlChars.NewLine & ControlChars.NewLine & _
                  errStr
                MsgBox(msg)

                Me.doClose2(True, continueStartUp2)
            End If
        End If

        'Changed PM_TITLELINEPARSING 2007-06-08. Moved before loading of 
        '  user settings, loadOptions().
        If continueStartUp2 Then
            mApplication.loadMiscSettings( _
              AppConstants.NEW_MISCOPTIONS_FILENAME2)
        End If

        If continueStartUp2 Then
            mApplication.loadExperimentSettings( _
              AppConstants.EXPERIMENT_SETTINGS_FILENAME)

            'Delete at any time.
            ''To keep it the same as before...
            ' ''Changed PM_HIGHER_LEVEL_PROCESSING 2008-09-01
            ' ''For now: no load from XML file...
            ' ''mNpointkey2rawFileInfo = _
            ' ''  New Dictionary(Of Integer, rawFileInfoStruct)
            ' ''Changed PM_HIGHER_LEVEL_PROCESSING 2008-09-02
            ''mExperimentSettings.rawFileMapping3 = _
            ''  New Dictionary(Of Integer, rawFileStruct)
            ''mExperimentSettings.JAspace = mApplication.getExperimentSpaces()
            'mExperimentSettings2 = mApplication.getExperimentSettings()
        End If

        If continueStartUp2 Then
            mConfigurationFileName = AppConstants.NEW_PARSER_SETTINGS_FILENAME

            'Note: this must be ***after*** loadQuantitationDefinitions()....
            mApplication.loadOptions(mConfigurationFileName, mOptions)
        End If

        'For menu Tools/Correlation settings
        If continueStartUp2 Then
            'Changed PM_REFACTOR 2003-12-17
            mApplication.loadCorrSettings( _
              AppConstants.NEW_CORRSETTINGS_FILENAME, mCorrSettings)

            'Error detection: this field must stay constant
            Trace.Assert(mOptions.checkSum = 8893, _
              "PIL ASSERT. Bad configuration file, " & mConfigurationFileName & _
              ". Delete it and restart the program.")
        End If

        'Changed PM_WEAKLY_TYPED_SPECTRUMCLASSIFICATION 2006-02-16
        If continueStartUp2 Then
            'Do nothing at this point. Spectrum classifications are
            'loaded on demand.
        End If

        'Changed PM_COMMANDLINE 2006-11-15
        'Wait until here to set up the automation/timer. In any
        'case mApplication must have been set - is done in the beginning
        'of this function; does not exit when New() and init() are
        'executed.
        If continueStartUp2 Then
            'Changed PM_COMMANDLINE 2006-11-15
            mAutomator = New AppAutomation.automator(Me, mApplication)

            'Changed PM_CMD_DISPLAY_PARAMETERS 2006-11-22
            mCommands = Microsoft.VisualBasic.Interaction.Command()

            'Sample command lines:
            '  1st (with TABs):
            '    -bin "S:\temp2\LTQ-FTsampleDataSet1,1,QUANTMODE_No isotope.mb2" -quant 4-11 -maxPep 200
            '
            '  In VS environment, 2008-08-20, with multiple TABs:
            '    -zbin	"D:\temp2\LTQ-FTsampleDataSet1,QUANTMODE_No isotope,2007-01-07.mb3"	-PTM	2-3
            '
            '  Testing export function, 2008-08-22:
            '    -bin "S:\temp2\LTQ-FTsampleDataSet1,1,QUANTMODE_No isotope,export test.mb3" -export 2-5 -quant 4-11
            '
            '  As of 2008-09-14:
            '    -zbin "S:\temp2\LTQ-FTsampleDataSet1,1,QUANTMODE_No isotope,export test.mb3" -quant 4-11 
            '
            '  JH trouble, 2008-09-15:
            '
            '    -bin "U:\tempCollection\temp202,JEA automation trouble\Relocated on MORTENSEN.mb3" -export 9995-9995 -quant 9995-9995  -maxPep 500000
            '
            '    Using sample data set with all raw files availalbe:
            '
            '      -bin "S:\temp2\quant speed test,2.mb3" -quant 10-10  -maxPep 500000

            Dim commandsAccepted As Boolean = mApplication.setCommands(mCommands)

            If commandsAccepted Then
                Dim params1 As automationInfoStructure = _
                  mApplication.getAutomationInfo()
                If params1.binPath.Length > 0 Then
                    mAutomator.initTask1(params1)
                Else
                    Dim peter2 As Integer = 2 'No command parameters to
                    '  consider - there may be some but they are not proper.
                End If
            Else
                Dim peter1 As Integer = 1 'Some problem... Or no
                '  command line parameters...
            End If

            'Timer/command line processing.
            If True Then
                mMeShared = Me
                mCurrentInterval = MAX_TIMER_INTERVAL
                mAlarmCounter = 0
                mIdlesCount = 0

                'Changed PM_COMMANDLINE 2006-11-15
                mTimer = New System.Windows.Forms.Timer()

                AddHandler mTimer.Tick, AddressOf TimerEventProcessor

                mTimer.Interval = mCurrentInterval
                mTimer.Start()
            End If
        End If

        'Changed PM_PROCESS_PRIORITY 2005-04-27
        'Be nice: lower this application's priority.
        If True Then
            Dim currProc As Process = Process.GetCurrentProcess
            currProc.PriorityClass = ProcessPriorityClass.BelowNormal
        End If
    End Sub 'frmMainForm_Load()


    'Changed PM_REFACTOR 2006-11-15
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Sub doClose2( _
      ByVal aForceClose As Boolean, _
      ByRef anOutContinueStartup As Boolean)

        mForceClose2 = aForceClose

        'Changed PM_REFACTOR 2007-08-02
        anOutContinueStartup = False

        Me.Close()
    End Sub 'doClose2


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuExit_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuExit.Click

        Dim dummy As Boolean
        Me.doClose2(False, dummy)
    End Sub 'mnuExit_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuSetFileDirectoryMascotResults_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuSetFileDirectoryMascotResults.Click

        SetFileDirectoryMascotOrWiff(True, True)
    End Sub 'mnuSetFileDirectoryMascotResults_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuContSetFileDirMascot_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuContSetFileDirMascot.Click

        SetFileDirectoryMascotOrWiff(True, False)
    End Sub 'mnuContSetFileDirMascot_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuAddWiffsInFolder_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuAddWiffsInFolder.Click

        SetFileDirectoryMascotOrWiff(False, True)
    End Sub 'mnuAddWiffsInFolder_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub SetFileDirectoryMascotOrWiff( _
      ByVal addMascothtmFiles As Boolean, ByVal addWiffFiles As Boolean)

        Try
            OpenFileDialog1.RestoreDirectory() = False 'Do not restore directory.
            OpenFileDialog1.Title = "Select any file in Mascot result or raw data file folder" 'Maybe change name
            OpenFileDialog1.DereferenceLinks = True

            'Changed PM_ACCEPT_HTML_FILEEXTENSION 2005-06-10
            OpenFileDialog1.Filter = _
              "Mascot results or raw data files " & _
              "(*.htm)(*.html)(*.wiff)(*.raw)(*.idx)|*.htm;*.html;*.wiff;*.raw;*.idx"

            OpenFileDialog1.FileName = ""
            If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                mMascotOrWiffDir = Directory.GetCurrentDirectory
                If addMascothtmFiles Then
                    PopulateMascotHtmList(mMascotOrWiffDir)
                End If
                If addWiffFiles Then
                    PopulateWiffFileList(mMascotOrWiffDir, "*.wiff")
                    PopulateWiffFileList(mMascotOrWiffDir, "*.raw")
                    PopulateWiffFileList(mMascotOrWiffDir, "*.idx")
                End If
            End If
        Catch exceptionObject As Exception
            StatusBar1.Panels(0).Text = "Error in listing files"
        End Try
    End Sub 'SetFileDirectoryMascotOrWiff


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuAddEntryMascotFiles_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuAddEntryMascotFiles.Click

        AddFileToMascotOrWiffList(True)
    End Sub 'mnuAddEntryMascotFiles_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuAddWiffFile_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuAddWiffFile.Click

        AddFileToMascotOrWiffList(False)
    End Sub 'mnuAddWiffFile_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    'File selection in this method. The actual adding is done
    'in AddItemToMasWiffAss().
    Private Sub AddFileToMascotOrWiffList(ByVal isMascot As Boolean)

        Try
            OpenFileDialog1.RestoreDirectory() = False 'do not restore directory
            If isMascot Then
                OpenFileDialog1.Title = "Select a Mascot htm file"
                'filter syntax: "Text files (*.txt)|*.txt|All files (*.*)|*.*"

                'Changed PM_ACCEPT_HTML_FILEEXTENSION 2005-06-10
                OpenFileDialog1.Filter = _
                  "Mascot result files (*.htm)(*.html)|*.htm;*.html"
            Else
                OpenFileDialog1.Title = "Select Analyst wiff files, Finnegan raw files or Micromass idx file"
                OpenFileDialog1.Filter = "Raw data files (*.wiff)(*.raw)(*.idx)|*.wiff;*.raw;*.idx"
            End If
            OpenFileDialog1.DereferenceLinks = True
            OpenFileDialog1.FileName = ""
            If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK And _
               OpenFileDialog1.FileName <> "" Then

                AddItemToMasWiffAss(OpenFileDialog1.FileName, isMascot)
            End If
        Catch exceptionObject As Exception
            StatusBar1.Panels(0).Text = "Error selecting a file"
        End Try
    End Sub 'AddFileToMascotOrWiffList


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Friend Sub AddItemToMasWiffAss( _
      ByVal aFileName As String, ByVal isMascot As Boolean)

        'declare friend so that we can test from test rig ???
        If isMascot Then
            If Not MakeTempMascotFileArrayList().Contains(aFileName) Then
                Dim mascotWiffAssoc As New MascotWiffAssociation( _
                  aFileName, "")
                chkLBMascotFiles.Items.Add(mascotWiffAssoc)
            End If
        Else
            If Not chkLBWiffFiles.Items.Contains(aFileName) Then
                chkLBWiffFiles.Items.Add(aFileName)
            End If
        End If
    End Sub 'AddItemToMasWiffAss


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuClearMascotHtmFileList_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuClearMascotHtmFileList.Click

        chkLBMascotFiles.Items.Clear()
    End Sub 'mnuClearMascotHtmFileList_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuClearWiffFileList_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuClearWiffFileList.Click

        chkLBWiffFiles.Items.Clear()
    End Sub 'mnuClearWiffFileList_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuAssociateWithHighlightedWiffFile_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuAssociateWithHighlightedWiffFile.Click

        AssociateHighlightedFiles()
        DisplaySortedByAssociation()
    End Sub 'mnuAssociateWithHighlightedWiffFile_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuAssociateWithHighlightedMascotFile_Click( _
      ByVal aSender As System.Object, _
      ByVal anEvent As System.EventArgs) _
      Handles mnuAssociateWithHighlightedMascotFile.Click

        AssociateHighlightedFiles()
        DisplaySortedByAssociation()
    End Sub 'mnuAssociateWithHighlightedMascotFile_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub DisplaySortedByAssociation()
        SortByAssociation()
        chkLBMascotFiles.Refresh() 'Invalidate only the selected item rectangle?
    End Sub 'DisplaySortedByAssociation


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub AssociateHighlightedFiles()

        'Todo:  give them the same background colour. That is pretty
        'complicated, see Balena book.

        Dim selMascotFileIdx As Integer = chkLBMascotFiles.SelectedIndex()
        Dim selWiffFileIdx As Integer = chkLBWiffFiles.SelectedIndex()

        '-1 is flag for no selection association is by means of the collection
        'in Mascot file list box.
        If Not (selMascotFileIdx = -1 Or selWiffFileIdx = -1) Then
            Dim selMascotItem As MascotWiffAssociation = _
              CType(chkLBMascotFiles.SelectedItem, MascotWiffAssociation)
            selMascotItem.setIsAssoc(True)

            selMascotItem.setWiffFileStr( _
              CStr(chkLBWiffFiles.Items.Item(selWiffFileIdx)))
        End If
    End Sub 'AssociateHighlightedFiles


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub PopulateMascotHtmList(ByVal aMascotDirStr As String)
        'Mascot files have a .htm or .html file extension.

        'Changed PM_ACCEPT_HTML_FILEEXTENSION 2005-06-10
        'Dim filePath() As String = Directory.GetFiles(aMascotDirStr, "*.htm")
        Dim filePath() As String = Directory.GetFiles(aMascotDirStr, "*.htm*")

        Dim filePathStr As String

        'Make a collection of mascot file result strings so that we can
        'check if a file already exists.
        Dim tempMascFileStrCol As ArrayList = MakeTempMascotFileArrayList()

        'Now add if it doesn't already exist.
        For Each filePathStr In filePath
            'OrElse shortcircuits and makes this safe.
            If tempMascFileStrCol Is Nothing OrElse _
               tempMascFileStrCol.Contains(filePathStr) = False Then

                Dim association As New MascotWiffAssociation(filePathStr, "")
                chkLBMascotFiles.Items.Add(association)
            End If
        Next
    End Sub 'PopulateMascotHtmList


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Function MakeTempMascotFileArrayList() As ArrayList
        Dim tempMascFileStrCol As New ArrayList
        Dim obj As Object
        For Each obj In chkLBMascotFiles.Items
            Dim tempStr As String = _
              CType(obj, MascotWiffAssociation).getMascotFileStr()
            tempMascFileStrCol.Add(tempStr)
        Next
        Return tempMascFileStrCol
    End Function 'MakeTempMascotFileArrayList


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub PopulateWiffFileList( _
      ByVal wiffDirStr As String, _
      ByVal aSearchPattern As String)
        'Dim filePath() As String = Directory.GetFiles(wiffDirStr, "*.wiff")
        Dim filePath() As String = Directory.GetFiles(wiffDirStr, aSearchPattern)

        Dim filePathStr As String
        For Each filePathStr In filePath
            If chkLBWiffFiles.Items Is Nothing OrElse _
               chkLBWiffFiles.Items.Contains(filePathStr) = False Then

                chkLBWiffFiles.Items.Add(filePathStr)
            End If
        Next
    End Sub 'PopulateWiffFileList


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuFindInMascotFileList_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuFindInMascotFileList.Click

        'Changed PM_STRUCTURED_PROGRAMMING 2005-12-05
        If chkLBMascotFiles.Items.Count <> 0 Then

            'Better name??
            Dim someStr As String = _
              InputBox("Type text to search", "Find in Mascot file list", "")
            Dim i As Integer
            Dim fullPathStr As String
            For i = 0 To chkLBMascotFiles.Items.Count - 1
                fullPathStr = CType(chkLBMascotFiles.Items.Item(i), _
                  MascotWiffAssociation).getMascotFileStr()
                If fullPathStr.ToUpper.IndexOf(someStr.ToUpper) > -1 Then
                    StatusBar1.Panels(0).Text = "Match found"
                    chkLBMascotFiles.SetSelected(i, True)
                    Exit For 'we want only the first occurance
                End If
            Next
            If i = chkLBMascotFiles.Items.Count Then
                StatusBar1.Panels(0).Text = "No match"
                If chkLBMascotFiles.SelectedIndex > -1 Then
                    chkLBMascotFiles.SetSelected( _
                      chkLBMascotFiles.SelectedIndex, False)
                End If
            End If
        End If
    End Sub 'mnuFindInMascotFileList_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub FindInMascotFileList()
        'Why is it empty?????????????
    End Sub 'FindInMascotFileList


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuFindInWiffFileList_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuFindInWiffFileList.Click

        Dim userStr As String = _
          InputBox("Type text to search", "Find in wiff file list", "")

        Dim i As Integer
        For i = 0 To chkLBWiffFiles.Items.Count - 1
            Dim fullPathStr As String = _
              CType(chkLBWiffFiles.Items.Item(i), String)
            If fullPathStr.ToUpper.IndexOf(userStr.ToUpper) > -1 Then
                StatusBar1.Panels(0).Text = "Match found"
                chkLBWiffFiles.SetSelected(i, True)
                Exit For 'we want the first occurance
            End If
        Next
        If i = chkLBWiffFiles.Items.Count Then
            StatusBar1.Panels(0).Text = "No match"
            If chkLBWiffFiles.SelectedIndex > -1 Then
                chkLBWiffFiles.SetSelected(chkLBWiffFiles.SelectedIndex, False)
            End If
        End If
    End Sub 'mnuFindInWiffFileList_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub chkLBMascotFiles_SelectedIndexChanged( _
      ByVal sender As Object, ByVal e As System.EventArgs) _
      Handles chkLBMascotFiles.SelectedIndexChanged

        Dim selIdx As Integer = chkLBMascotFiles.SelectedIndex
        If selIdx < 0 Then
            StatusBar1.Panels(0).Text = "Error: selected index < 0"
        Else
            Dim someItem As MascotWiffAssociation = _
              CType(chkLBMascotFiles.Items.Item(selIdx), MascotWiffAssociation)

            Dim wiffFile As String = someItem.getWiffFileStr()
            If someItem.getIsAssoc() And _
               chkLBWiffFiles.Items.Contains(wiffFile) Then 'Test this.

                chkLBWiffFiles.SetSelected( _
                  chkLBWiffFiles.Items.IndexOf(wiffFile), True)
            Else
                Dim guessedIdx As Integer = GuessAssociation(someItem)
                If guessedIdx > -1 Then
                    chkLBWiffFiles.SetSelected(guessedIdx, True)
                End If
            End If
            StatusBar1.Panels(0).Text = "Selected Index: " & selIdx.ToString()
        End If
    End Sub 'chkLBMascotFiles_SelectedIndexChanged


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuGuessAllAss_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuGuessAllAss.Click

        AssociateAll()
    End Sub 'mnuGuessAllAss_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub AssociateAll()

        If Not (chkLBMascotFiles.Items.Count < 1) Then
            Dim i As Integer
            Dim mascWiffAssItem As MascotWiffAssociation
            'chkLBMascotFiles.BeginUpdate() 'Don't avoid flickering - looks
            '  more interesting like this
            '  Can't use enumerator because the list changes.
            For i = 0 To chkLBMascotFiles.Items.Count - 1
                mascWiffAssItem = _
                  CType(chkLBMascotFiles.Items(i), MascotWiffAssociation)
                If Not mascWiffAssItem.getIsAssoc() Then
                    Dim associatedIdx As Integer
                    associatedIdx = GuessAssociation(mascWiffAssItem)
                    If associatedIdx > -1 Then
                        chkLBMascotFiles.SelectedItem = mascWiffAssItem
                        chkLBWiffFiles.SelectedIndex = associatedIdx
                        'If Not chkLBMascotFiles.SelectedItem = chkLBMascotFiles.SelectedIndex Then
                        '    MsgBox("selected item not equal selected index)
                        'End If
                        AssociateHighlightedFiles()
                    End If
                End If
            Next
            SortByAssociation()
            DisplaySortedByAssociation()
        End If
    End Sub 'AssociateAll


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Function GuessAssociation( _
      ByRef aItem As MascotWiffAssociation) _
      As Integer

        Dim toReturn As Integer = -1

        'This function returns the index of the associated item 
        'in the wiff file (list Or -1).

        Dim wiffFileName As String
        Dim MascotFileName As String = _
          Path.GetFileNameWithoutExtension(aItem.getMascotFileStr())

        Dim found As Boolean = False
        Dim i As Integer
        For i = 0 To chkLBWiffFiles.Items.Count - 1

            wiffFileName = CStr(chkLBWiffFiles.Items.Item(i))

            'Why is it overwritten??
            wiffFileName = Path.GetFileNameWithoutExtension(wiffFileName)

            'Does the wiff file name occur in the Mascot file name?
            If MascotFileName.IndexOf(wiffFileName) > -1 Then

                toReturn = i
                found = True
                Exit For
            End If
        Next

        If Not found Then
            'Try once more without the last two letters in wiff file name in
            'case these are initials.
            For i = 0 To chkLBWiffFiles.Items.Count - 1
                wiffFileName = CStr(chkLBWiffFiles.Items.Item(i))

                'Why is it overwritten??
                wiffFileName = Path.GetFileNameWithoutExtension(wiffFileName)

                With wiffFileName
                    If .Length > 2 AndAlso _
                       Char.IsLetter(.Chars(.Length - 1)) AndAlso _
                       Char.IsLetter(.Chars(.Length - 2)) Then
                        'Does the trunctated wiff file name occur
                        'in the Mascot file name?
                        Dim theTruncStr As String = .Remove(.Length - 2, 2)
                        If MascotFileName.IndexOf(theTruncStr) > -1 Then
                            toReturn = i
                            Exit For
                        End If
                    End If
                End With
            Next
        End If

        Return toReturn
    End Function 'GuessAssociation


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub SortByAssociation()
        'Sort the two listBoxes such that the files with associations
        ' are on top (low index) and associated files are next to each other.
        Dim i As Integer
        Dim done As Boolean = False
        Dim tempItem As Object
        'We use something similar to bubble sort. Efficiency is not an issue.
        While Not done
            done = True
            For i = 0 To chkLBMascotFiles.Items.Count - 2
                If CType( _
                  chkLBMascotFiles.Items.Item(i), _
                    MascotWiffAssociation).getIsAssoc() = False And _
                   CType( _
                     chkLBMascotFiles.Items.Item(i + 1), _
                       MascotWiffAssociation).getIsAssoc() Then 'we need to flip them
                    tempItem = chkLBMascotFiles.Items.Item(i)
                    chkLBMascotFiles.Items.Item(i) = _
                      chkLBMascotFiles.Items.Item(i + 1)
                    chkLBMascotFiles.Items.Item(i + 1) = tempItem
                    done = False
                End If
            Next i
        End While

        'All the associated files are at the top. Now we need to sort
        'their associated wiff.
        Dim tempWiffItem As Object
        Dim currItem As MascotWiffAssociation
        For i = 0 To chkLBMascotFiles.Items.Count - 1
            currItem = CType(chkLBMascotFiles.Items.Item(i), MascotWiffAssociation)
            If currItem.getIsAssoc() Then
                'We need to move the associated wiff file to the same index.
                Dim currWiffIdx As Integer = _
                  chkLBWiffFiles.Items.IndexOf(currItem.getWiffFileStr())
                If currWiffIdx > -1 Then
                    tempWiffItem = chkLBWiffFiles.Items.Item(i)
                    chkLBWiffFiles.Items.Item(i) = _
                      chkLBWiffFiles.Items.Item(currWiffIdx)
                    chkLBWiffFiles.Items.Item(currWiffIdx) = tempWiffItem
                    chkLBMascotFiles.SetSelected(i, True)
                    chkLBWiffFiles.SetSelected(i, True)
                End If
            End If
        Next i
    End Sub 'SortByAssociation


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuRemoveEntryMascotFiles_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuRemoveEntryMascotFiles.Click

        'Remove the highlighted entry from the list.
        Dim theSelIdx As Integer = chkLBMascotFiles.SelectedIndex

        'Changed PM_STRUCTURED_PROGRAMMING 2005-12-05
        If theSelIdx >= 0 Then
            chkLBMascotFiles.Items.RemoveAt(theSelIdx)
        End If
    End Sub 'mnuRemoveEntryMascotFiles_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuRemoveWiffFile_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuRemoveWiffFile.Click

        'Remove the highlighted entry from the list.
        Dim theSelIdx As Integer = chkLBWiffFiles.SelectedIndex
        If theSelIdx >= 0 Then
            chkLBWiffFiles.Items.RemoveAt(theSelIdx)
        End If
    End Sub 'mnuRemoveWiffFile_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuBreakWiffAss_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuBreakWiffAss.Click

        If chkLBWiffFiles.SelectedIndex >= 0 Then
            Dim wiffStr As String = CStr(chkLBWiffFiles.SelectedItem)
            Dim mascotWiffAss As MascotWiffAssociation = _
              GetMascotWiffAssByWiffStr(wiffStr)
            BreakMascotWiffAss(mascotWiffAss)
            SortByAssociation()
            chkLBMascotFiles.Refresh()
        End If
    End Sub 'mnuBreakWiffAss_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Function GetMascotWiffAssByWiffStr( _
      ByVal aWiffString As String) _
      As MascotWiffAssociation

        Dim toReturn As MascotWiffAssociation = Nothing

        Dim obj As Object
        For Each obj In chkLBMascotFiles.Items
            If aWiffString = _
               CType(obj, MascotWiffAssociation).getWiffFileStr() Then

                toReturn = CType(obj, MascotWiffAssociation)
                'Why not exit the loop at this point??
            End If
        Next
        Return toReturn
    End Function 'GetMascotWiffAssByWiffStr


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuBreakMascotAssociation_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuBreakMascotAssociation.Click

        If Not (chkLBMascotFiles.SelectedIndex < 0) Then
            Dim mascotWiffAss As MascotWiffAssociation = _
              CType(chkLBMascotFiles.SelectedItem, MascotWiffAssociation)
            BreakMascotWiffAss(mascotWiffAss)
            SortByAssociation()
            chkLBMascotFiles.Refresh()
        End If
    End Sub 'mnuBreakMascotAssociation_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub BreakMascotWiffAss(ByRef aMascotWiffAss As MascotWiffAssociation)
        aMascotWiffAss.setIsAssoc(False)
        aMascotWiffAss.setWiffFileStr("")
    End Sub 'BreakMascotWiffAss


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuSaveFileAssociations_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuSaveFileAssociations.Click

        'Save only associated files.
        'Give choice of save append or save overwrite?
        If MsgBox("Overwrite previous file association?", MsgBoxStyle.OkCancel, _
          "Saving file associations to default file") = MsgBoxResult.Ok Then

            Me.SaveFileAss(mDefaultMascotWiffAssFileStr, True)
        End If
    End Sub 'mnuSaveFileAssociations_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuSaveFileAssAs_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuSaveFileAssAs.Click

        SaveFileDialog1.DefaultExt = ".txt" 'Note: only works if ValidateNames is True!!!!
        '  ".txt" should probably be "txt"

        SaveFileDialog1.ValidateNames = True
        SaveFileDialog1.ShowHelp = True

        SaveFileDialog1.DereferenceLinks = True
        SaveFileDialog1.OverwritePrompt = True
        SaveFileDialog1.Title = "Save Mascot wiff file associations as..."
        If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            SaveFileAss(SaveFileDialog1.FileName, True)
        End If
    End Sub 'mnuSaveFileAssAs_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub SaveFileAss(ByVal aSaveFileStr As String, _
      ByVal fOverwrite As Boolean)

        Dim stream As FileStream
        Try
            If Not File.Exists(aSaveFileStr) Then
                stream = New FileStream(aSaveFileStr, FileMode.CreateNew)
            Else
                stream = New FileStream(aSaveFileStr, FileMode.Open)
            End If
        Catch exceptionObject As Exception
            MsgBox("Could not save the data", _
              MsgBoxStyle.Exclamation, "File save error")
            Exit Sub
        End Try
        If fOverwrite Then
            stream.SetLength(0)
        End If
        Dim writer As New StreamWriter(stream)
        Dim count As Integer = 0
        Try
            writer.BaseStream.Seek(0, SeekOrigin.End) 'Append.
            Dim MWiffAss As MascotWiffAssociation
            For Each MWiffAss In chkLBMascotFiles.Items
                With MWiffAss
                    If .getIsAssoc() Then
                        writer.WriteLine(.getMascotFileStr())
                        writer.WriteLine(.getWiffFileStr())
                        count += 1
                    End If
                End With
            Next
        Catch exceptionObject As Exception
            '???????
        Finally
            writer.Flush()
            writer.Close()
            stream.Close()
        End Try

        StatusBar1.Panels(1).Text = "Saved " & count.ToString & " file associations"

        If count = 0 Then
            'Using the 3 W's: What happend? Why did it happen?
            'What can be done about it?
            Dim msgStr As String = "No associations were saved - " & _
                "because no associations were defined! " & _
                "To associate: 1) menu File/""set Mascot or " & _
                  "wiff folder"" to add items to the two panels." & _
                " 2) select 1 file in each panel 3) " & _
                "Right-click on the selected Mascot htm file and " & _
                  "choose ""Associate with highlighted wiff file""."
            MsgBox(msgStr)
        End If
    End Sub


    'note misleading mnu command below (correct in 'Handles...'
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenFileAssociations_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuLoadDefFileAss.Click

        'Changed PM_STRUCTURED_PROGRAMMING 2005-12-05

        'read in the two associated file strings. Check for alternating .htm and .wiff file designations
        If Not File.Exists(mDefaultMascotWiffAssFileStr) Then
            MsgBox("No saved file associations.")
        Else
            loadFileAssociations(mDefaultMascotWiffAssFileStr)
        End If
    End Sub 'mnuOpenFileAssociations_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenFileAss_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenFileAss.Click

        OpenFileDialog1.FileName = ""
        OpenFileDialog1.Title = "Select an Analyst wiff file"
        OpenFileDialog1.Filter = "text files (*.txt)|*.txt"
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            loadFileAssociations(OpenFileDialog1.FileName)
        End If
    End Sub 'mnuOpenFileAss_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub loadFileAssociations(ByVal aFileSting As String)

        Dim stream As FileStream = Nothing 'Keep compiler happy.
        Try
            stream = New FileStream(aFileSting, FileMode.Open) 'Will open
            '  in ReadWrite mode. Is that what we want?
        Catch exceptionObject As Exception
            MsgBox("Error opening the association file")
        End Try
        Dim reader As StreamReader = Nothing 'Keep compiler happy.
        Try
            reader = New StreamReader(stream)
            reader.BaseStream.Seek(0, SeekOrigin.Begin)
            Dim mascotFileStr As String
            Dim wiffFileStr As String
            Dim errStrSB As StringBuilder = Nothing
            While reader.Peek <> -1
                mascotFileStr = reader.ReadLine()
                If Not reader.Peek <> -1 Then
                    MsgBox("A file association is missing")
                End If
                wiffFileStr = reader.ReadLine()
                InstantiateMascotWiffFileAssociation( _
                  mascotFileStr, wiffFileStr, errStrSB)
            End While

            'Changed PM_EMPTYFILESDLG_FOR_NOMISSING 2006-07-26
            'Assume the error string is empty (no fixed part) if all files exist.
            If errStrSB.Length <> 0 Then
                'Changed PM_SINGLE_MISSING_FILES_ERRMSG 2006-06-16
                Dim errStr As String = errStrSB.ToString()

                MsgBox( _
                  "These files do not exist:" & ControlChars.NewLine & _
                  ControlChars.NewLine & _
                  errStr)
            End If

        Catch exceptionObject As Exception
            MsgBox("Error reading from the association file")
        Finally
            reader.Close()
            stream.Close()
        End Try
    End Sub 'loadFileAssociations


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub InstantiateMascotWiffFileAssociation( _
      ByVal aMascotFileStr As String, _
      ByVal aWiffFileStr As String, _
      ByRef anInOutErrorMsgStr As StringBuilder)

        'Lazy instantiation....
        If anInOutErrorMsgStr Is Nothing Then
            anInOutErrorMsgStr = New StringBuilder(200)
        End If
        Dim existErrors As Boolean = False

        If Not File.Exists(aMascotFileStr) Then

            'Changed PM_SINGLE_MISSING_FILES_ERRMSG 2006-06-16
            'MsgBox("This file doesn't exist: " & aMascotFileStr)
            anInOutErrorMsgStr.Append("")
            anInOutErrorMsgStr.Append(aMascotFileStr)
            anInOutErrorMsgStr.Append(ControlChars.NewLine)

            existErrors = True
        End If

        'Changed PM_ACCEPT_HTML_FILEEXTENSION 2005-06-10
        Dim resExt As String = Path.GetExtension(aMascotFileStr)
        If Not (resExt = ".htm" Or resExt = ".html") Then
            MsgBox("This file has the wrong extension (should be .htm or .html): " & _
              aMascotFileStr)
        End If

        If Not File.Exists(aWiffFileStr) Then
            'Changed PM_SINGLE_MISSING_FILES_ERRMSG 2006-06-16
            'MsgBox("This file doesn't exist: " & aWiffFileStr)
            anInOutErrorMsgStr.Append("")
            anInOutErrorMsgStr.Append(aWiffFileStr)
            anInOutErrorMsgStr.Append(ControlChars.NewLine)
            existErrors = True
        End If

        Dim rawExt As String = Path.GetExtension(aWiffFileStr)
        'Changed PM_ASSOC_UPPEREXT_ERRMSG 2004-01-26
        'If Not (ext = ".wiff" Or ext = ".raw") Then
        If Not (rawExt = ".wiff" Or rawExt = ".raw" Or rawExt = ".idx" Or _
                rawExt = ".WIFF" Or rawExt = ".RAW" Or rawExt = ".IDX") Then
            MsgBox( _
              "This file has the wrong extension (should be .wiff or .raw or .idx): " & _
              aWiffFileStr)
        End If
        Dim MWFileAss As New MascotWiffAssociation(aMascotFileStr, aWiffFileStr)
        chkLBMascotFiles.Items.Add(MWFileAss)
        chkLBWiffFiles.Items.Add(aWiffFileStr)
        With MWFileAss
            .setIsAssoc(True)
            .setWiffFileStr(aWiffFileStr)
        End With

        'Changed PM_SINGLE_MISSING_FILES_ERRMSG 2006-06-16
        If existErrors Then
            'Empty line to separate from next pair.
            anInOutErrorMsgStr.Append(ControlChars.NewLine)
        End If
    End Sub 'InstantiateMascotWiffFileAssociation


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenHighlighted_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenHighlighted.Click

        OpenHighlighted()
    End Sub 'mnuOpenHighlighted_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub chkLBMascotFiles_DoubleClick( _
      ByVal sender As Object, ByVal e As System.EventArgs) _
      Handles chkLBMascotFiles.DoubleClick

        OpenHighlighted()
    End Sub 'chkLBMascotFiles_DoubleClick


    'Changed PM_MOUSE_IS_BAD 2004-05-04
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub chkLBMascotFiles_Enter( _
      ByVal aSender As Object, ByVal anEvent As System.EventArgs) _
      Handles chkLBMascotFiles.Enter

        'No!!!!  It is not the Enter key, but getting focus to a control/form....
    End Sub 'chkLBMascotFiles_Enter


    'Changed PM_DOUBLE_RETURN_KEY 2007-08-31. No longer used. It has the 
    '  problem with being fired if the file dialog is dismissed with Enter.
    ' 'Changed PM_MOUSE_IS_BAD 2004-05-04
    ' '****************************************************************************
    ' '*    <placeholder for header>                                              *
    ' '****************************************************************************
    ' Private Sub chkLBMascotFiles_KeyUp( _
    '   ByVal aSender As Object, ByVal anEvent As System.Windows.Forms.KeyEventArgs) _
    '   Handles chkLBMascotFiles.KeyUp
    ' 
    '     If anEvent.KeyCode = Keys.Enter Or anEvent.KeyCode = Keys.Return Then
    '         If chkLBMascotFiles.SelectedIndices.Count > 0 Then
    '             OpenHighlighted()
    '         Else
    '             Dim peter63 As Integer = 63
    '         End If
    '     Else
    '         Dim peter92 As Integer = 92
    '     End If
    ' End Sub 'chkLBMascotFiles_KeyUp


    'Changed PM_DOUBLE_RETURN_KEY 2007-08-31
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub chkLBMascotFiles_KeyDown( _
      ByVal aSender As Object, _
      ByVal anEvent As System.Windows.Forms.KeyEventArgs) _
      Handles chkLBMascotFiles.KeyDown

        mKeyObserver.keyDown(anEvent.KeyCode)
    End Sub 'chkLBMascotFiles_KeyDown


    'Changed PM_DOUBLE_RETURN_KEY 2007-08-31
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub chkLBMascotFiles_KeyUp1( _
      ByVal aSender As Object, _
      ByVal anEvent As System.Windows.Forms.KeyEventArgs) _
      Handles chkLBMascotFiles.KeyUp

        'Changed PM_DOUBLE_RETURN_KEY 2007-09-08
        If mKeyObserver.keyUp(anEvent.KeyCode) Then
            OpenHighlighted()
        End If
    End Sub 'chkLBMascotFiles_KeyUp1


    ''****************************************************************************
    ''*    <placeholder for header>                                              *
    ''****************************************************************************
    'Private Sub frmMainForm_KeyPress( _
    '  ByVal aSender As Object, _
    '  ByVal anEvent As System.Windows.Forms.KeyPressEventArgs) _
    '  Handles Me.KeyPress
    'End Sub 'frmMainForm_KeyPress


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub OpenHighlighted()

        'Changed PM_PARSESPEED_INTERNAL 2006-11-28
        mApplication.startStopWatch()

        'Old. Delete at any time.
        ' 'the highlighted item will be opened in a frmProteinList window
        ' Dim selItem As MascotWiffAss = _
        '   CType(chkLBMascotFiles.SelectedItem, MascotWiffAss)
        '
        ' 'Changed PM_STRUCTURED_PROGRAMMING 2005-12-05
        ' If selItem Is Nothing Then
        '     MsgBox("Please select an item first")
        ' Else
        '     If Not selItem.getIsAssoc() Then
        '         If MsgBox("This item does not have an association with a data file. Continue?", MsgBoxStyle.OkCancel, "No file association") = MsgBoxResult.Cancel Then Exit Sub
        '     End If
        '     OpenAndProcessMascotFile(selItem)
        ' End If

        'Changed PM_VALIDATION_BEFOREOPEN 2006-09-01
        Dim selItem As MascotWiffAssociation = Nothing
        Dim dummy As Boolean = False
        If OKtoOpenFiles(selItem, dummy) Then
            OpenAndProcessMascotFile(selItem)
        End If
    End Sub 'OpenHighlighted


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '*  Returns true if the file exists, otherwise false                        *
    '****************************************************************************
    Private Shared Function SDUPcheckFileExists( _
      ByVal aFileNameFullPath As String, _
      ByVal anErrorMsg As String) _
      As Boolean

        Dim toReturn As Boolean = True
        If Not File.Exists(aFileNameFullPath) Then
            toReturn = False
            MsgBox(anErrorMsg)
        End If
        Return toReturn
    End Function 'SDUPcheckFileExists


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub OpenAndProcessMascotFile( _
      ByVal aMascotWiffAssociation As MascotWiffAssociation)

        'Changed PM_VALIDATION_BEFOREOPEN 2006-09-01
        'Moved to OKtoOpenFiles().
        ' Dim part1 As String = "Mascot could not proceed. The file "
        ' Dim part2 As String = _
        '   " does not exist on disk (this can happen if raw and/or " & _
        '   "Mascot result files are moved after being added to the " & _
        '   "associtation window). "
        '
        ' 'Changed PM_AVOID_EXCEPTION_FILE_NOT_EXIST 2003-10-14
        ' If SDUPcheckFileExists(aMasWiffAss.getMascotFileStr(), _
        '        part1 & aMasWiffAss.getMascotFileStr() & part2) _
        '   AndAlso _
        '    SDUPcheckFileExists(aMasWiffAss.getWiffFileStr(), _
        '      part1 & aMasWiffAss.getWiffFileStr() & part2) Then
        '
        '
        '    'Changed PM_XMLFILE_SWITCH_BUG 2006-07-26
        '    '  Avoid ASSERT, check first if quantitation code exists.
        '    '  This can happen if ...quaZZntitationModes.xml is
        '    '  replaced with somethingthat does not contain a
        '    '  quantiation mode code equal to the current
        '    '  (stored in MascotParserOptions.xml).
        '
        '    Dim quantitationModesObject As _
        '      massSpectrometryBase.quantitation.QuantitationModes_moreGeneral = _
        '        mApplication.getQuantModes()
        '
        '
        '    'Changed PM_UNKNOWN_QUANTCODE_BUG 2006-07-26
        '    If quantitationModesObject.quantitationCodeExists( _
        '      mOptions.quantModeCode) Then


        'Changed PM_SAVE_RAWFILE_MAPPING_MB4 2008-11-18
        'Now use defaults that the application keeps track of - no matter
        'if they were changed in this dialog or if the defaults are from the
        'last loaded MBx file.
        Dim someExperimentSettings As experimentSettingsStruct = _
          mApplication.getDefaultExperimentSettings()

        'Now open the file form just like we used to do except already
        'with Mascot and data file association
        'and the form will start to parse immediately.
        Dim mascotResultForm As _
          New frmProteinList(Me, mApplication, mOptions, someExperimentSettings)

        'Add Mascot result file name to title of Protein List Window...
        If True Then
            Dim mascotResultFileName As String = _
              aMascotWiffAssociation.getMascotFileStr()
            Dim newTitle As String = _
              mascotResultForm.Text & " " & mascotResultFileName
            mascotResultForm.Text = newTitle
        End If

        mascotResultForm.Show()
        Application.DoEvents() 'Give it time to show the form correctly.

        mascotResultForm.ParseMascotFile( _
          aMascotWiffAssociation, mSampleNum, mCorrSettings)

        'Changed PM_VALIDATION_BEFOREOPEN 2006-09-01
        'Moved to OKtoOpenFiles().
        '    Else
        '
        '        'Changed PM_UNKNOWN_QUANTCODE_BUG 2006-07-26
        '        Dim msgStr As String = _
        '          AppConstants.LONG_APP " could not start parsing the Mascot result file. " & _
        '          "The current quantitation mode is not defined in the " & _
        '          "settings file " & _
        '          AppConstants.NEW_QUANTMODES_FILENAME & _
        '          ". This can happen if the settings file was replaced by a " & _
        '          " another file. " & _
        '          "What to do: select a quantitation mode in " & _
        '          "the settings dialog, menu Tools/Options/Quantitation mode." & _
        '          "Then restart the parsing."
        '
        '        MsgBox(msgStr)
        '    End If 'Quant mode code exists
        '
        'End If 'Both associated files exist.

        'PM: dim "Options" in menu "Tools" while it is
        '    executing ParseMascotFile()?


        'Changed PM_PARSESPEED_INTERNAL 2006-11-28
        'Only for internal use for now.
        Dim memDiff_MB As Double
        Dim parseTimeSecs As Double = mApplication.stopStopWatch(memDiff_MB)
    End Sub 'OpenAndProcessMascotFile


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuQuantitateCheckedFiles_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuQuantitateCheckedFiles.Click

        ShowNotImplementedMsg()
    End Sub 'mnuQuantitateCheckedFiles_Click


    'Called when menu Tools/Options is chosen.
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOptions_Click( _
      ByVal aSender As System.Object, _
      ByVal anEvent As System.EventArgs) _
      Handles mnuOptions.Click

        'Changed PM_RAWFILE_PEPFILTER 2007-11-17
        Dim noRawFilesFilter() As fileSpecStructure = Nothing 'We do not know
        '  about the raw files yet. Not until after parsing...

        Dim optionsForm As frmOptions = _
          New frmOptions( _
            mOptions, Me, mApplication, noRawFilesFilter)

        optionsForm.Show()
    End Sub 'mnuOptions_Click


    'Changed PM_REPORTS 2006-08-15
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Function getOptions() _
      As OptionsStruct2

        Return mOptions
    End Function 'getOptions


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Friend Sub setOptions(ByRef anOptions As OptionsStruct2)

        mOptions = anOptions

        'Changed PM_PERSIST_OPTIONS 2003-04-14
        'Persist new options

        'BinaryFormatter class,  class

        'Test
        'Dim sc As New StreamingContext(StreamingContextStates.File)
        '
        ''Dim myBinFormatter As New BinaryFormatter(Nothing, sc)
        '
        'Dim myXMLFormatter As New SoapFormatter()
        'Dim FS As New System.IO.FileStream(mConfigurationFileName, _
        '    IO.FileMode.Create)
        'myXMLFormatter.Serialize(FS, mOptions)
        'Dim test1 As OptionsStruct2 = _
        '  CType(LoadObject(mConfigurationFileName), OptionsStruct2)

        'Changed PM_LOAD_OPTIONS_AGAIN 2003-12-12
        'mApplication.PIL_PersistObject( _
        '  mConfigurationFileName, mOptions)
        mApplication.newOptions2(mOptions) 'Will save the settings...
    End Sub 'setOptions


    'Changed PM_CORRELATION_DIALOG 2003-10-21
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuCorrelationSettings_Click( _
      ByVal aSender As System.Object, _
      ByVal anEvent As System.EventArgs) _
      Handles mnuCorrelationSettings.Click


        Dim quantitationModesObject As _
          massSpectrometryBase.quantitation.QuantitationModes_moreGeneral = _
            mApplication.getQuantModes()
        Dim curQuantMode As generalisedQuantModeStructure = _
          quantitationModesObject.getQuantitationMode( _
            mOptions.quantModeCode)
        Dim dishes As Integer = _
          curQuantMode.dishes_StartingFromDish2.Count + 1

        Dim corrSettingsForm As frmCorrelationSettings = _
          New frmCorrelationSettings(mCorrSettings, Me, dishes)
        corrSettingsForm.Show()
    End Sub 'mnuCorrelationSettings_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub ShowNotImplementedMsg()
        MsgBox("Can't do this yet. Sorry", _
          MsgBoxStyle.Information, "Not implemented")
    End Sub


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuAbout_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuAbout.Click

        Dim aboutForm As formAbout = New formAbout
        aboutForm.Show()
    End Sub 'mnuAbout_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Sub setCorrSettings( _
      ByVal aFileName4 As String, _
      ByRef aCorrSettings As massSpectrometryBase.correlationSettingsStructure)

        mCorrSettings = aCorrSettings
        mApplication.newCorrelationSettings(aFileName4, mCorrSettings)
    End Sub 'setCorrSettings()


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuSetSampleNum_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuSetSampleNum.Click

        'ask for sample number to use in opening Analyst file
        Dim response As String = InputBox("Please enter a sample number", _
          "Analyst sample number", 1.ToString)
        If response <> "" AndAlso IsNumeric(response) Then
            Dim newSampleNum As Integer = CInt(response)
            If newSampleNum > 0 Then
                mSampleNum = newSampleNum
            Else
                MsgBox("Sample number must be 1 or higher")
            End If
        End If
    End Sub 'mnuSetSampleNum_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub frmMainForm_Closing( _
      ByVal aSender As Object, _
      ByVal anEvent As System.ComponentModel.CancelEventArgs) _
      Handles MyBase.Closing

        If Not mForceClose2 Then

            If MessageBox.Show( _
                "Exit " & AppConstants.LONG_APP & "?", _
                AppConstants.LONG_APP, _
                MessageBoxButtons.YesNo, _
                MessageBoxIcon.Warning, _
                MessageBoxDefaultButton.Button2) = _
              Windows.Forms.DialogResult.Yes Then

                'OK to close
                Dim peter92 As Integer = 92
            Else
                ' Cancel the Closing event from closing the form.
                anEvent.Cancel = True
            End If 'Call method to save file...
        End If
    End Sub 'frmMainForm_Closing


    'Changed PM_DONT_PANIC 2004-08-26
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnunGarbageCollect_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnunGarbageCollect.Click

        Dim memDiffMB As Double
        Dim tickTimeSecs As Double
        quantApplication.GarbageCollect(Nothing, memDiffMB, tickTimeSecs)
        MsgBox("Memory garbage collection performed. Saved " & _
          memDiffMB.ToString("0.00") & " MB in " & tickTimeSecs & " seconds.")
    End Sub 'mnunGarbageCollect_Click


    'Changed PM_REFACTOR 2006-11-15
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Function loadAndShowSavedParse( _
      ByRef anInFileName As String, _
      ByRef anOutMascotResultForm2 As frmProteinList, _
      ByVal aMBfileVersion As Integer) _
      As Boolean

        Dim msg As String = Nothing
        Dim loadedDoc2 As MSQuantDocumentStructure
        loadedDoc2.parsedProts3 = Nothing 'Keep compiler happy.
        loadedDoc2.rawFiles2 = Nothing 'Keep compiler happy.
        loadedDoc2.mascotFileStr = Nothing 'Keep compiler happy.
        loadedDoc2.rawFileStr = Nothing 'Keep compiler happy.

        loadedDoc2.experimentSettings2.JAspace = Nothing 'Keep compiler happy.
        loadedDoc2.experimentSettings2.rawFileMapping3 = Nothing 'Keep compiler happy.

        loadedDoc2.recalibrator = Nothing 'Keep compiler happy.

        Dim loadInfoStr As String = Nothing
        Dim succeeded As Boolean = _
          quantApplication.deserialiseDocumentDataStructures4( _
            anInFileName, msg, loadedDoc2, _
            mApplication, loadInfoStr, _
            aMBfileVersion)

        If succeeded Then

            'Changed PM_MB3_RELOCATION 2008-05-23
            'Check that the referenced Mascot result file and raw files
            'exists (this can happen if a MB3 file is moved to another
            'computer and the files are not copied to the exact same
            'place). Otherwise let the user specify new locatios.

            'Changed PM_RELOCATEDIALOG_NOEXTRADIALOGS 2008-07-30
            Dim continue2 As Boolean = True

            'For now: use assoc pair for detection
            If True Then 'Block.
                Dim resultFile As String = loadedDoc2.mascotFileStr
                Dim rawFile As String = loadedDoc2.rawFileStr

                'Only true when used with folder with not all the
                'required RAW files and a script that has stripped
                'the raw file references from the Mascot result file.
                Dim onlyOneRawFile As Boolean = False

                'Loop to ask for location until the files exist (e.g. user
                'may paste in folders that do not exist) or the user cancels.
                Dim patchPaths As Boolean = False 'Default if files already exist.
                Dim end2 As Boolean = False
                While Not end2

                    Dim resultFileExists As Boolean = File.Exists(resultFile)
                    Dim rawFileExists As Boolean = File.Exists(rawFile)

                    If Not resultFileExists Or _
                       Not rawFileExists Then

                        System.Windows.Forms.MessageBox.Show( _
                          AppConstants.LONG_APP & _
                          " can not proceed. Mascot result file or " & _
                          "raw file does not exist (" & _
                          resultFile & " or " & rawFile & _
                          "). Locate file(s) (next dialog).")

                        Me.Visible = True
                        Dim modalform As frmFilesRelocation = _
                          New frmFilesRelocation(resultFile, rawFile)
                        modalform.ShowDialog(Me) 'Note: ShowDialog() makes it
                        '  modal. Show() makes it non-modal (mode-less)...

                        If modalform.wasOKed Then
                            'Take another round in the loop - to check the
                            'existence of the two files
                            patchPaths = True
                            resultFile = modalform.getResultFile()
                            rawFile = modalform.getRawFile()
                            onlyOneRawFile = modalform.getOnlyOneRawFile()
                        Else
                            'User canceled or clicked the close cross.
                            'This correspond to old times, opening the
                            'protein list window will be refused.
                            end2 = True
                            patchPaths = False

                            'Changed PM_RELOCATEDIALOG_NOEXTRADIALOGS 2008-07-30
                            continue2 = False 'User opted out, prevent any
                            '  attempt to open the Protein List window - 
                            '  this would create extra error dialogs after
                            '  the user cancel.
                        End If
                    Else
                        'They exist!
                        end2 = True
                    End If
                End While

                If patchPaths Then
                    quantApplication.patchDocumentDataStructures( _
                      loadedDoc2, resultFile, rawFile, onlyOneRawFile)
                End If
            End If 'Block.

            'Changed PM_RELOCATEDIALOG_NOEXTRADIALOGS 2008-07-30
            If continue2 Then
                Dim mascotWiffAssoc As MascotWiffAssociation = _
                  New MascotWiffAssociation( _
                    loadedDoc2.mascotFileStr, loadedDoc2.rawFileStr)
                mascotWiffAssoc.setIsAssoc(True)

                If OKtoOpenFiles2(mascotWiffAssoc) Then

                    anOutMascotResultForm2 = _
                      New frmProteinList( _
                        Me, mApplication, mOptions, _
                        loadedDoc2.experimentSettings2)

                    anOutMascotResultForm2.Show()
                    Application.DoEvents()

                    'Notes for debugging:
                    '  The user dialog for asking about the file to load from is
                    '  started down in:
                    '    OpenParsedProteinsEtc()/DeserialiseDocumentDataStructures().
                    '
                    '  How to make it work:
                    '    1. Use breakpoint before ShowDialog()
                    '       in DeserialiseDocumentDataStructures().
                    '
                    '    2. Use F5 to really show the user dialog - stepping
                    '       over the call below will hang!!!!!
                    '
                    anOutMascotResultForm2.OpenParsedProteinsEtc( _
                      mascotWiffAssoc, mSampleNum, loadedDoc2, _
                      loadInfoStr) 'What about mSampleNum and mCorrSettings?

                    anOutMascotResultForm2.ParserStatus.Text = msg '????
                End If 'If the files exist, quantitation mode exists, etc.
            End If 'User did not cancel.
        Else
            Dim peter2 As Integer = 2 'Loading the binary file failed. Perhaps
            '  we should handle the error here instead of down
            '  in deserialiseDocumentDataStructures4 ??
        End If

        Return succeeded 'Used for error handling when the application
        '  is started with command line parameters.
    End Function 'loadAndShowSavedParse


    'Changed PM_REFACTOR 2008-11-12
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub userSelectAndOpenProteinList(ByVal aMBfileVersion As Integer)

        'Changed PM_REFACTOR 2006-09-01
        'Dim selItem As MascotWiffAss = _
        '  CType(chkLBMascotFiles.SelectedItem, MascotWiffAss)
        'If selItem Is Nothing Then
        '    MsgBox("Please select an item first")
        'Else
        'End If

        Dim loadFileName As String = Nothing
        If frmProteinList.dialogLoad( _
             OpenFileDialog1, loadFileName, aMBfileVersion) Then

            Dim someMascotResultForm As frmProteinList = Nothing
            Dim succeeded As Boolean = _
              Me.loadAndShowSavedParse( _
                loadFileName, someMascotResultForm, aMBfileVersion)
        End If
    End Sub 'userSelectAndOpenProteinList()


    'Changed PM_MORE_MEMORY_WORKAROUND 2004-09-07
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenParsedProteinsEtc_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenParsedProteinsEtc.Click

        userSelectAndOpenProteinList(AppConstants.CURRENT_SAVEDFILEVERSION)
    End Sub 'mnuOpenParsedProteinsEtc_Click


    'Changed PM_MB4_VERSIONING 2008-11-12
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenMB3_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenMB3.Click

        userSelectAndOpenProteinList(AppConstants.SAVEDFILEVERSION_MB3)
    End Sub 'mnuOpenMB3_Click()


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub openContainingFolderForSelectedFileInList( _
      ByRef anInSomeCheckedListBox As System.Windows.Forms.CheckedListBox, _
      ByRef anInFileTypeDescriptionShortString As String, _
      ByVal anInIsSimpleString As Boolean)

        If anInSomeCheckedListBox.SelectedIndex >= 0 Then
            Trace.Assert(anInSomeCheckedListBox.SelectedIndices.Count = 1, _
              "PIL ASSERT. Only single item selection supported.")
            Dim fileNamePath As String
            If anInIsSimpleString Then
                fileNamePath = CStr(anInSomeCheckedListBox.SelectedItem)
            Else
                fileNamePath = _
                  CType(anInSomeCheckedListBox.SelectedItem, _
                    MascotWiffAssociation).getMascotFileStr()
            End If

            AppCommon2.showFileInWindowsExplorer( _
              fileNamePath, "Opening the closest containing folder.")
        Else
            Dim msgStr As String = _
              AppConstants.LONG_APP & _
              " could not proceed opening a containing folder. A " & _
              anInFileTypeDescriptionShortString & _
              " file was not selected. Please select a " & _
              anInFileTypeDescriptionShortString & " file first."
            MsgBox(msgStr)
        End If
    End Sub 'openContainingFolderForSelectedFileInList


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenContainFolderForRawfile_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenContainFolderForRawfile.Click

        openContainingFolderForSelectedFileInList(chkLBWiffFiles, "raw", True)
    End Sub 'mnuOpenContainFolderForRawfile_Click


    'Changed PM_PEPTIDEFILTER_GENERALISED 2007-08-24. Moved to
    '    sub-dialog, under the options dialog.
    ' '****************************************************************************
    ' '*    <placeholder for header>                                              *
    ' '****************************************************************************
    ' Private Sub mnuPeptideFilters_Click( _
    '   ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
    '   Handles mnuPeptideFilters.Click
    '
    '     'Changed PM_PEPTIDEFILTER_GENERALISED 2007-08-24
    '     'Dim peptideFilter As peptideFilterSpecificationStructure = _
    '     '  mOptions.peptideFilterSpecification
    '     Dim peptideFilter As peptideFilterSpecificationStructure = _
    '       mOptions.peptideFilters(peptideFilterEnum.enumParsing)
    '
    '     Dim filterForm As New frmPeptideFilters( _
    '       peptideFilter, Me, mApplication)
    '
    '     filterForm.Show()
    ' End Sub 'mnuPeptideFilters_Click


    'Changed PM_PEPTIDEFILTER_GENERALISED 2007-08-24. Moved to
    '    sub-dialog, under the options dialog.
    ' '****************************************************************************
    ' '*    <placeholder for header>                                              *
    ' '****************************************************************************
    ' Public Sub setPeptideFilterSpecification( _
    '   ByVal anInPeptideFilterSpecification As _
    '     peptideFilterSpecificationStructure)
    ' 
    '     'mOptions.peptideFilterSpecification = anInPeptideFilterSpecification
    '     mOptions.peptideFilters(peptideFilterEnum.enumParsing) = _
    '       anInPeptideFilterSpecification
    ' End Sub 'setPeptideFilterSpecification


    'Changed PM_OPEN_APP_FOLDER 2006-08-25
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenAppFolder_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenAppFolder.Click

        Dim AppFolderPath As String = AppCommon2.appPath()

        Dim someFileInAppFolder As String = _
          AppFolderPath & Path.DirectorySeparatorChar & _
          AppConstants.NEW_QUANTMODES_FILENAME

        Dim toOpen As String = someFileInAppFolder
        If Not File.Exists(toOpen) Then
            'The file for some reason does not exist then the containing
            'folder of the application will be shown/selected instead - 
            'the user will then have to open that.
            toOpen = AppFolderPath
        End If

        'This should never fail; set 2nd parameter to empty string?
        AppCommon2.showFileInWindowsExplorer( _
          toOpen, "Opening the closest containing folder.")
    End Sub 'mnuOpenAppFolder_Click()


    'Changed PM_REFACTOR 2006-11-15
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Function OKtoOpenFiles2( _
      ByRef anOutMascotWiffAssociation As MascotWiffAssociation) _
      As Boolean

        Dim toReturn As Boolean = True
        Dim msgPrefix As String = _
          AppConstants.LONG_APP & " could not open file. "

        If Not anOutMascotWiffAssociation.getIsAssoc() Then
            MsgBox( _
              msgPrefix & _
              "This item does not have an association with a data file. " & _
              "Associate the result file to a raw file first.")
            toReturn = False
        End If

        If toReturn Then 'Condition really means: "continue?"
            Dim mascotFileStr As String = _
              anOutMascotWiffAssociation.getMascotFileStr()
            Dim rawFileStr As String = _
              anOutMascotWiffAssociation.getWiffFileStr()

            Dim realMascotFilePath As String = Nothing
            Dim realRawFilePath As String = Nothing
            Dim part1 As String = "Mascot could not proceed. The file "
            Dim part2 As String = _
              " does not exist on disk (this can happen if raw and/or " & _
              "Mascot result files are moved after being added to the " & _
              "associtation window). " & _
              " Select and associate existing files."
            If AppCommon.SDUPcheckFileExists_withSearch( _
                mascotFileStr, _
                part1 & mascotFileStr & part2, _
                realMascotFilePath) _
                  AndAlso _
               AppCommon.SDUPcheckFileExists_withSearch( _
                 rawFileStr, _
                 part1 & rawFileStr & part2, _
                 realRawFilePath) Then

                Dim peter7 As Integer = 7 'OK. The files exist!

                'Changed PM_FLEXIBLE_RAWFILE_LOC 2007-06-12
                'Patch with real paths, if any.
                Dim patched As MascotWiffAssociation = _
                  New MascotWiffAssociation(realMascotFilePath, realRawFilePath)
                anOutMascotWiffAssociation = patched
            Else
                MsgBox( _
                  msgPrefix & _
                  "The result file, " & mascotFileStr & _
                  ", and/or the raw file, " & rawFileStr & _
                  ",  does not exist. " & _
                  "Select and associate existing files.")
                toReturn = False
            End If
        End If

        If toReturn Then
            Dim quantitationModesObject As _
              massSpectrometryBase.quantitation.QuantitationModes_moreGeneral = _
                mApplication.getQuantModes()

            'Changed PM_UNKNOWN_QUANTCODE_BUG 2006-07-26
            If quantitationModesObject.quantitationCodeExists( _
              mOptions.quantModeCode) Then

                'OK
            Else
                'Changed PM_UNKNOWN_QUANTCODE_BUG 2006-07-26
                Dim msgStr As String = _
                  AppConstants.LONG_APP & _
                  " could not start parsing the Mascot result file. " & _
                  "The current quantitation mode is not defined in the " & _
                  "settings file " & _
                  AppConstants.NEW_QUANTMODES_FILENAME & _
                  ". This can happen if the settings file was replaced by" & _
                  " another file. " & _
                  "What to do: select a quantitation mode in " & _
                  "the settings dialog, menu Tools/Options/Quantitation mode." & _
                  "Then restart the parsing."
                MsgBox(msgStr)
                toReturn = False
            End If
        End If
        Return toReturn
    End Function 'OKtoOpenFiles2


    'Changed PM_REFACTOR 2006-09-01
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Function OKtoOpenFiles( _
      ByRef anOutMascotWiffAssociation As MascotWiffAssociation, _
      ByVal aDummy As Boolean) _
      As Boolean

        Dim toReturn As Boolean = True

        'Do we have a selection?
        Dim msgPrefix As String = _
          AppConstants.LONG_APP & " could not open file. "
        anOutMascotWiffAssociation = _
          CType(chkLBMascotFiles.SelectedItem, MascotWiffAssociation)
        If anOutMascotWiffAssociation Is Nothing Then
            MsgBox( _
              msgPrefix & _
              "An associated result file/raw file pair was not selected. " & _
              "Please select an item first.")
            toReturn = False
        End If

        If toReturn Then
            toReturn = OKtoOpenFiles2(anOutMascotWiffAssociation)
        End If

        Return toReturn
    End Function 'OKtoOpenFiles


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuTest1_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuTest1.Click

        Me.DotNetRemotingTest()
    End Sub 'mnuTest1_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub DotNetRemotingTest()

        ' Create a channel for communicating w/ the remote object.
        ' Notice no port is specified on the client.
        Dim chan As TcpChannel = New TcpChannel 'Requires
        '  import "System.Runtime.Remoting.Channels.Tcp", see above.

        Dim secure As Boolean = False

        Try
            'Should probably only be done once, at program startup...
            ChannelServices.RegisterChannel(chan, secure)
        Catch exceptionObject As Exception
            'Ignore it...
            'AppCommon2.displayStandardExceptionInfo( _
            '  exceptionObject, _
            '  "Could not register TCP channel...")
            'Exit Sub
        End Try

        ' Create an instance of the remote object.
        Dim obj As CEBI.Remoting.SampleObject = DirectCast( _
          Activator.GetObject( _
            GetType(CEBI.Remoting.SampleObject), _
            "tcp://localhost:8090/quant"), _
            CEBI.Remoting.SampleObject)

        ' Use the object.
        If obj Is Nothing Then
            System.Console.WriteLine( _
              "Error: unable to locate server.")
        Else
            Dim res1 As String = obj.HelloWorld(7, 8)
            Console.WriteLine(res1) 'Not very useful.

            Dim res2 As String = obj.HelloWorld(7, 8)
            Dim res3 As String = obj.HelloWorld(987, 0)
            Dim res4 As String = obj.HelloWorld(-29, 3)

            Dim someParams As CEBI.Remoting.quantParametersStruct
            someParams.rawFileName = _
              "U:\toDelete\temp19,LyrisYeast\2005-03-04,LGYeastSILACtest\" & _
              "Lyris-YeastSILAC_Lys8-MS3.RAW"

            obj.setQuantitationParameters(someParams)
        End If
    End Sub 'DotNetRemotingTest


    'Changed PM_COMMANDLINE 2006-11-15
    '****************************************************************************
    '*    doIdle2. Drive the automation (a state machine); cooperative          *
    '*             multitasking.                                                *
    '****************************************************************************
    Public Function doIdle2() As Boolean

        Dim result As Boolean = False
        If Not mForceClose2 Then
            result = mAutomator.doIdle() 'Drive it!

            If Not mForceClose2 Then
                mIdlesCount += 1
                Dim msgStr As String = "Idles: " & mIdlesCount
                StatusBar1.Panels(4).Text = msgStr
            Else
                'We are closing down. Attempt to stop timer.
                mTimer.Stop()
            End If
        Else
            'We are closing down. Attempt to stop timer.
            mTimer.Stop()
        End If

        Return result
    End Function 'doIdle2


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    ' This is the method to run when the timer is raised.
    Private Shared Sub TimerEventProcessor( _
      ByVal aSomeObject As Object, _
      ByVal myEventArgs As EventArgs)

        mAlarmCounter += 1

        Dim newInterval As Integer = -1
        Dim busy As Boolean = mMeShared.doIdle2()

        If busy Then
            'newInterval = MIN_TIMER_INTERVAL

            newInterval = (mCurrentInterval * 2) \ 3
            If newInterval < MIN_TIMER_INTERVAL Then
                newInterval = MIN_TIMER_INTERVAL
            End If
        Else
            If mCurrentInterval = MAX_TIMER_INTERVAL Then
                'Nothing to change.
                Dim peter2 As Integer = 2
            Else
                'Worker just stopped working. We assume that work
                'will not resume soon and it is acceptable to take
                'a relatively long break (the alternative would
                'be to ramp up to MAX_TIMER_INTERVAL).
                newInterval = MAX_TIMER_INTERVAL
            End If
        End If

        If newInterval >= 0 Then
            mCurrentInterval = newInterval
            mTimer.Interval = newInterval
        Else
            Dim peter5 As Integer = 5
        End If
    End Sub 'TimerEventProcessor


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Function externalControl_loadBinFile2( _
      ByRef anInBinPath As String, _
      ByRef anOutMascotResultForm2 As frmProteinList, _
      ByVal aFileVersion As Integer) _
      As Boolean

        Dim succeeded As Boolean = _
          Me.loadAndShowSavedParse( _
            anInBinPath, anOutMascotResultForm2, aFileVersion)
        Return succeeded
    End Function 'externalControl_loadBinFile


    'Changed PM_CMD_DISPLAY_PARAMETERS 2006-11-22
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuCommandLineParameters_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuCommandLineParameters.Click

        Dim msg As String = Nothing
        If mCommands.Length > 0 Then
            msg = _
              "Command line parameters: " & ControlChars.NewLine & _
              ControlChars.NewLine & _
              mCommands
        Else
            msg = "No command line parameters were specified!"
        End If

        Trace.Assert(Not msg Is Nothing, "PIL ASSERT. msg not set...")
        MsgBox(msg)
    End Sub 'mnuCommandLineParameters_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuZedGraph_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuZedGraph.Click

        '  frmZedGraphTryout
        Dim zForm As frmZedGraphTryout = New frmZedGraphTryout
        zForm.Show()
    End Sub 'mnuZedGraph_Click


    'Changed PM_PEPTIDEFILTER_GENERALISED 2007-08-28
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '*    Note: this function is for the export filter.                         *
    '****************************************************************************
    Public Sub setProteinAndPeptidesFilter2( _
      ByVal aInProteinAndPeptidesFilter2 As proteinAndPeptidesFilterStructure2, _
      ByVal aPeptideFilter As peptideFilterStructure)

        'Note: this is for export.

        'Changed PM_PEPTIDEFILTER_GENERALISED 2007-08-29
        'Stuff aInProteinAndPeptidesFilter2 into mOptions and
        '  persist.
        mOptions.proteinAndPeptidesFilter = aInProteinAndPeptidesFilter2

        'Changed PM_REFACTOR 2007-09-04
        'mOptions.peptideFilters(peptideFilterEnum.enumExport2) = _
        '  aPeptideFilter
        'Me.setOptions(mOptions) 'Will save the settings...
        Me.setApeptideFilter(aPeptideFilter, peptideFilterEnum.enumExport2)
    End Sub 'setProteinAndPeptidesFilter


    'Changed PM_REFACTOR 2007-09-04
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Sub setApeptideFilter( _
      ByVal aPeptideFilter As peptideFilterStructure, _
      ByVal aPeptideFilterSelector As peptideFilterEnum)

        mOptions.peptideFilters(aPeptideFilterSelector) = _
          aPeptideFilter
        Me.setOptions(mOptions) 'Will save the settings...
    End Sub 'setApeptideFilter


    'Changed PM_RESIZE_MAINWINDOW 2008-01-14
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub adjustGUIsizes()

        Dim xOffset As Integer = 0
        Dim yOffset As Integer = 24

        Dim rightMargin As Integer = 16
        Dim bottomMargin As Integer = 118 - 46

        Dim xSeparation As Integer = 8

        Dim xSizeAll As Integer = _
          ClientRectangle.Width - rightMargin - xOffset + 8

        'ClientRectangle.Height is expected to be 416 when first called.
        Dim ySize As Integer = _
          ClientRectangle.Height - yOffset - bottomMargin

        Dim xSize As Integer = (xSizeAll - xSeparation) \ 2 '476 for start size.

        Dim xLoc1 As Integer = xOffset
        Dim xLoc2 As Integer = xLoc1 + xSize + xSeparation

        Dim sizeBoth As System.Drawing.Size = New System.Drawing.Size(xSize, ySize)

        Dim loc1 As System.Drawing.Point = New System.Drawing.Point(xLoc1, yOffset)
        Dim loc2 As System.Drawing.Point = New System.Drawing.Point(xLoc2, yOffset)

        chkLBMascotFiles.Location = loc1
        chkLBMascotFiles.Size = sizeBoth

        chkLBWiffFiles.Location = loc2
        chkLBWiffFiles.Size = sizeBoth

        'Changed PM_MAIN_ZOOM_MOVE_RAWFILELABEL 2008-09-14
        'Move the label above the raw file list in X-direction.
        Dim rawX As Integer = loc2.X 'Raw file list's X.
        Dim loc3 As System.Drawing.Point = lblRAWheader.Location
        loc3.X = rawX
        lblRAWheader.Location = loc3

    End Sub 'adjustGUIsizes


    'Changed PM_RESIZE_MAINWINDOW 2008-01-14
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub frmMainForm_Resize( _
      ByVal aSender As Object, ByVal anEvent As System.EventArgs) _
      Handles Me.Resize

        Me.adjustGUIsizes()
    End Sub 'frmMainForm_Resize


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuFireAssert_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuFireAssert.Click

        Trace.Assert(False, _
          "Stop!", "PIL ASSERT. Internal/development assert for stopping execution......")
    End Sub 'mnuFireAssert_Click


    'Changed PM_HELPER_APPLICATIONS 2008-07-30
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub openHelperApplication( _
      ByRef anInExeName As String, _
      ByRef anSubFolderName As String, _
      ByRef aEnvironmentVariables2 As Dictionary(Of String, String), _
      ByRef aInPerlOutputFolder As String _
      )
        '  aEnvironmentVariables is Nothing if not used/specified. If
        '  it is specified then we assume it should run under CMD.EXE.
        '
        '  aInPerlOutputFolder: only used if environment variables are specified.
        '
        '  Return value is the folder the helper application is in.


        Dim AppFolderPath As String = AppCommon2.appPath()

        Dim helperFolder As String = _
          AppFolderPath & Path.DirectorySeparatorChar & _
          AppConstants.HELPER_APPLICATIONS_TOPFOLDER & _
            Path.DirectorySeparatorChar & _
          anSubFolderName

        Dim helperAppPath As String = _
          helperFolder & Path.DirectorySeparatorChar & _
          anInExeName

        Dim toOpen As String = helperAppPath
        If Not File.Exists(toOpen) Then
            'The file for some reason does not exist then the containing
            'folder of the application will be shown/selected instead - 
            'the user will then have to open that.
            toOpen = AppFolderPath
        End If

        'External process start.
        If True Then 'False for the old method (that does not
            '  work for the Perl scripts).
            Dim psInfo As System.Diagnostics.ProcessStartInfo = _
              New System.Diagnostics.ProcessStartInfo()

            'psInfo.WindowStyle = 
            '  System.Diagnostics.ProcessWindowStyle.Normal;

            Dim specifiedEnvVars As Boolean = _
              Not aEnvironmentVariables2 Is Nothing

            'Currently implied:
            Dim CMDrun As Boolean = specifiedEnvVars
            Dim waitExit As Boolean = specifiedEnvVars

            If specifiedEnvVars Then
                psInfo.UseShellExecute = False 'Required if
                '  field EnvironmentVariables is set, apparently.

                Dim hashEnumerator2 As Dictionary( _
                  Of String, String).Enumerator = _
                    aEnvironmentVariables2.GetEnumerator()

                While hashEnumerator2.MoveNext()
                    Dim curKey As String = hashEnumerator2.Current.Key
                    Dim curValue As String = _
                       hashEnumerator2.Current.Value

                    psInfo.EnvironmentVariables(curKey) = curValue
                End While 'Hash iteration.
            End If 'Environment variables specified.

            Dim effectiveProcessFileName As String = Nothing
            Dim args As String = Nothing
            Dim workingFolder As String = Nothing
            If CMDrun Then
                'Assume CMD run if environment variables are specified.
                effectiveProcessFileName = "cmd.exe"

                '  /C      Carries out the command specified by string and 
                '          then terminates
                '
                '  /K      Carries out the command specified by string but 
                '          remains
                'Dim CMDmode As String = "/K" 'For testing
                Dim CMDmode As String = "/C" 'Normal. Otherwise the
                '  application will hang..

                args = _
                  CMDmode & _
                  " """ & toOpen & """" 'Quote as there
                '  can be spaces in the full path, e.g.
                '    \bin\helper applications\MRV\MascotResultViewer.pl

                workingFolder = aInPerlOutputFolder 'Needed as some Perl scripts
                '  don't use absolute paths for output files.

                'Perhaps later: invisible run.
                '
                '  <http://www.thescarms.com/dotnet/Process.aspx>:
                '  
                '    Start the process in a hidden window.
                '    '
                '    myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
                '    myProcess.StartInfo.CreateNoWindow = True
                '    myProcess.Start()
                '    '
                '    ' Kill the process if it doesn't finish in one minute.
                '    '
                '    myProcess.WaitForExit(1000)
                '    If Not myProcess.HasExited Then
                '        myProcess.Kill()
                '    End If
            Else
                'Normal run. E.g. starting PILGrinder.

                effectiveProcessFileName = toOpen
                args = ""
                workingFolder = helperFolder 'The folder that the helper
                '  application is living in.
            End If 'Environment variables specified or not.

            psInfo.Arguments = args
            psInfo.FileName = effectiveProcessFileName
            psInfo.WorkingDirectory = workingFolder

            Dim myProcess As Process = _
              System.Diagnostics.Process.Start(psInfo)

            If waitExit Then
                myProcess.WaitForExit()
            End If
        Else
            'Old method. From the time before opening Perl scripts
            'in this function.
            Dim myProcess3 As Process = _
              System.Diagnostics.Process.Start(toOpen, "")
        End If

        'Return helperFolder
    End Sub 'openHelperApplication()


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenPILGrinder_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenPILGrinder.Click

        'Note: the open helper applications folder menu command depends on
        '      the second parameter to not change...
        openHelperApplication( _
          "PILGrinderWindowsApplication.exe", "PILGrinder", Nothing, "")
    End Sub 'mnuOpenPILGrinder_Click()


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenDTASC_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenDTASC.Click

        openHelperApplication("DTASuperCharge.exe", "DTASC", Nothing, "")
    End Sub 'mnuOpenDTASC_Click()


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenMRL_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenMRL.Click

        openHelperApplication("MascotResultLauncher.exe", "MRL", Nothing, "")
    End Sub 'mnuOpenMRL_Click


    'Changed PM_HELPER_APPLICATIONS 2008-08-21
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenMascotResultViewer_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenMascotResultViewer.Click

        'Note: for now just open the folder with the script.
        Dim MRVscriptPath As String = _
          getHelperAppRootFodler() & _
            Path.DirectorySeparatorChar & _
          "MRV" & Path.DirectorySeparatorChar & _
          "MascotResultViewer.bat"
        AppCommon2.showFileInWindowsExplorer(MRVscriptPath, "")
    End Sub 'mnuOpenMascotResultViewer_Click()


    'Changed PM_HELPER_APPLICATIONS 2008-09-15
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenFinniganNumberStripper_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenFinniganNumberStripper.Click

        'Note: for now just open the folder with the script.
        Dim FNSscriptPath As String = _
          getHelperAppRootFodler() & _
            Path.DirectorySeparatorChar & _
          "FNS" & Path.DirectorySeparatorChar & _
          "FinneganNumberStripper.bat"
        AppCommon2.showFileInWindowsExplorer(FNSscriptPath, "")
    End Sub 'mnuOpenFinniganNumberStripper_Click()


    'Changed PM_HELPER_APPLICATIONS 2008-08-21
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenMascotResultFileReductor_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenMascotResultFileReductor.Click

        'Note: for now just open the folder with the script.
        Dim MRFRscriptPath As String = _
          getHelperAppRootFodler() & _
            Path.DirectorySeparatorChar & _
          "MRFR" & Path.DirectorySeparatorChar & _
          "MascotResultFileReductor.bat"
        AppCommon2.showFileInWindowsExplorer(MRFRscriptPath, "")
    End Sub 'mnuOpenMascotResultFileReductor_Click()


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuMGFcombiner_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuMGFcombiner.Click

        openHelperApplication("MGFcombiner.exe", "MGFcombiner", Nothing, "")
    End Sub 'mnuMGFcombiner_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenMSRecal_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenMSRecal.Click

        openHelperApplication("MSRecal2.exe", "MSRecal", Nothing, "")
    End Sub 'mnuOpenMSRecal_Click


    'Changed PM_HELPER_APPLICATIONS 2008-08-21
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Function getHelperAppRootFodler() _
      As String

        Dim AppFolderPath As String = AppCommon2.appPath()
        Dim toReturn As String = _
          AppFolderPath & Path.DirectorySeparatorChar & _
          AppConstants.HELPER_APPLICATIONS_TOPFOLDER

        Return toReturn
    End Function 'getHelperAppRootFodler()


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenHelperApplicationsAppFolder_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenHelperApplicationsAppFolder.Click

        Dim someFolderInHelpAppFolder As String = _
          getHelperAppRootFodler() & _
            Path.DirectorySeparatorChar & _
          "PILGrinder" & Path.DirectorySeparatorChar & _
          ""

        AppCommon2.showFileInWindowsExplorer( _
          someFolderInHelpAppFolder, "")
    End Sub 'mnuOpenHelperApplicationsAppFolder_Click()


    'Changed PM_HIGHER_LEVEL_PROCESSING 2008-07-29
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuDimensions_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuDimensions.Click

        'Dim JAspace As CEBIspaces = mApplication.getExperimentSpaces()

        'Changed PM_SAVE_RAWFILE_MAPPING_MB4 2008-11-18
        'Dim experimentSettings As experimentSettingsStruct = mExperimentSettings2
        Dim experimentSettings As experimentSettingsStruct = _
          mApplication.getDefaultExperimentSettings()

        mDimensionsDialog = New frmDimensions(experimentSettings.JAspace)

        mDimensionsDialog.Show() 'When the dialog
        '  is OK'ed mDimensionsDialog_dialogDismissed() will be called.
    End Sub 'mnuDimensions_Click()


    'From dialog, dimensions dialog.
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '*    Call-back from dimensions form.                                       *
    '****************************************************************************
    Private Sub mDimensionsDialog_dialogDismissed( _
      ByVal aSender As Object, _
      ByVal anEvent As dimensionsEventArgs) _
      Handles mDimensionsDialog.dimensionsDismissed

        Dim newDimensions As List(Of CEBIdimension) = anEvent.getDimensions()

        'Changed PM_SHARED_DIMENSIONSETTINGS_BUG 2008-11-20
        ''Changed PM_SAVE_RAWFILE_MAPPING_MB4 2008-11-18. In the
        ''  dialogs for this class we are handling the defaults (in contrast
        ''  to stored settings in MBx files). 
        ' ''Dim JAspace As CEBIspaces = mApplication.getExperimentSpaces()
        ''Dim JAspace As CEBIspaces = mExperimentSettings2.JAspace
        'Dim experimentSettings As experimentSettingsStruct = _
        '  mApplication.getDefaultExperimentSettings()
        'Dim JAspace2 As CEBIspaces = experimentSettings.JAspace
        Dim experimentSettings As experimentSettingsStruct = _
          mApplication.getDefaultExperimentSettings()
        experimentSettings.JAspace = New CEBIspaces() 'Replace
        '  existing. Actually: will not effectively happen until
        '  written back to the application object.

        experimentSettings.JAspace.setDimensionDefinitions(newDimensions)

        mApplication.experimentSettingsChanged(experimentSettings) 'Persist it!
    End Sub 'mDimensionsDialog_dialogDismissed()


    'Changed PM_HIGHER_LEVEL_PROCESSING 2008-08-30
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuRawFileMapping_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuRawFileMapping.Click

        'Changed PM_SAVE_RAWFILE_MAPPING_MB4 2008-11-18
        'Dim experimentSettings As experimentSettingsStruct = mExperimentSettings2
        Dim experimentSettings As experimentSettingsStruct = _
          mApplication.getDefaultExperimentSettings()

        'Changed PM_ASKFOR_EXPORTTARGET_FIRSTTIME 2008-12-18
        'Note: we are using the settings for the proteins and
        '      peptide export. Essentially these are currently
        '      global for all kinds of exports.
        Dim exportTargetSettings As exportTargetSettingsStruct = _
          mOptions.proteinAndPeptidesFilter.exportTargetSettings4

        'Changed PM_ASKFOR_EXPORTTARGET_FIRSTTIME 2008-12-18
        quantApplication.checkExportSettings(exportTargetSettings)
        '  This will present the target dialog to the user if
        '  the setting has not been persisted yet.

        mRawFileMappingDialog = _
          New frmRawFileMapping( _
            experimentSettings.JAspace.getVectorSet(), _
            experimentSettings.rawFileMapping3, _
            exportTargetSettings)
        mRawFileMappingDialog.Show()
    End Sub 'mnuRawFileMapping_Click()


    'From dialog, raw file mapping dialog.
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '*    Call-back from raw files mapping form.                                *
    '****************************************************************************
    Private Sub mRawFileMappingDialog_dialogDismissed( _
      ByVal aSender As Object, _
      ByVal anEvent As rawFileMappingEventArgs) _
      Handles mRawFileMappingDialog.rawFileMappingDismissed

        Dim experimentSettings As experimentSettingsStruct = _
          mApplication.getDefaultExperimentSettings()

        experimentSettings.rawFileMapping3 = anEvent.getMapping()

        mApplication.experimentSettingsChanged( _
          experimentSettings) 'Persist it!
    End Sub 'mRawFileMappingDialog_dialogDismissed()


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenContainFolderForResultfile_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenContainFolderForResultfile.Click

        openContainingFolderForSelectedFileInList( _
          chkLBMascotFiles, "Mascot HTML result", False)
    End Sub 'mnuOpenContainFolderForResultfile_Click()


    'Changed PM_RESULT_VIEWER_INTEGRATION 2008-10-21
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub perlRunOnSelectedMascotFile( _
      ByRef anInExeName As String, _
      ByRef anSubFolderName As String, _
      ByRef anInEnvVarForMascotFile As String, _
      ByRef aPartlyEnvironmentVariables As Dictionary(Of String, String), _
      ByVal aOpenResultFile As Boolean, ByVal aOpenOutputFolder As Boolean)

        Dim selItem As MascotWiffAssociation = Nothing
        Dim dummy As Boolean = False
        If OKtoOpenFiles(selItem, dummy) Then
            Dim mascotResultFileName As String = _
              selItem.getMascotFileStr()

            aPartlyEnvironmentVariables.Add( _
              anInEnvVarForMascotFile, mascotResultFileName)

            Dim outputFolder As String = _
              Path.GetDirectoryName(mascotResultFileName)

            'Dim outputFolder As String = _
            openHelperApplication( _
              anInExeName, anSubFolderName, _
              aPartlyEnvironmentVariables, outputFolder)

            If aOpenOutputFolder Then
                AppCommon2.showFileInWindowsExplorer( _
                  mascotResultFileName, "")
            End If

            If aOpenResultFile Then
                'Find youngest file in the MascotResultViewer script
                'folder - this is what the Perl script has generated.
                'And open this file using Windows settings. E.g. opening
                'it in Opera.

                Dim dir As DirectoryInfo = New DirectoryInfo(outputFolder)

                'Dim files As FileInfo() = dir.GetFiles(".html") 'Does not work. Why?
                Dim files As FileInfo() = dir.GetFiles()

                Dim len As Integer = files.Length
                Dim lastIndex As Integer = len - 1

                Dim youngestDate As Date = New Date(2007, 1, 1)
                Dim youngestFile As FileInfo
                Dim j As Integer
                For j = 0 To lastIndex Step 1
                    Dim someFile As FileInfo = files(j)

                    Dim modTime As Date = someFile.LastWriteTime
                    If modTime > youngestDate Then
                        youngestDate = modTime
                        youngestFile = someFile
                    End If
                Next j

                Dim resultFile As String = youngestFile.FullName
                Dim myProcess3 As Process = _
                  System.Diagnostics.Process.Start(resultFile, "")
            End If

        End If 'If OK to process the Mascot result file.

    End Sub 'perlRunOnSelectedMascotFile()


    'Changed PM_RESULT_VIEWER_INTEGRATION 2008-10-21
    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuOpenWithMascotResultViwerScript_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuOpenWithMascotResultViwerScript.Click

        Dim envVars As Dictionary(Of String, String) = _
          New Dictionary(Of String, String)
        envVars.Add("START_PROTEIN_HIT", "1")
        envVars.Add("END_PROTEIN_HIT", "10")
        'envVars.Add("MASCOTRESULT", mascotResultFileName)

        perlRunOnSelectedMascotFile( _
          "MascotResultViewer.pl", "MRV", _
          "MASCOTRESULT", envVars, _
           True, True)
    End Sub 'mnuOpenWithMascotResultViwerScript_Click()


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuRunFinniganNumberScript_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuRunFinniganNumberScript.Click

        Dim envVars As Dictionary(Of String, String) = _
          New Dictionary(Of String, String)
        envVars.Add("STRIP_PERIOD", "")
        envVars.Add("MAXSPECTRUMNUMBER", "")
        envVars.Add("OUTFILE", "stripped.html") 'Fixed name for now.

        perlRunOnSelectedMascotFile( _
          "FinneganNumberStripper.pl", "FNS", _
          "INFILE", envVars, _
           False, True)

    End Sub 'mnuRunFinniganNumberScript_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub mnuRunMascotResultFileReductorScript_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles mnuRunMascotResultFileReductorScript.Click

        Dim envVars As Dictionary(Of String, String) = _
          New Dictionary(Of String, String)
        envVars.Add("START_PROTEIN_HIT", "1")
        envVars.Add("END_PROTEIN_HIT", "999999")
        envVars.Add("OUTFILE", "reducted.html") 'Fixed name for now.

        perlRunOnSelectedMascotFile( _
          "MascotResultFileReductor.pl", "MRFR", _
          "INFILE", envVars, _
           False, True)

    End Sub 'mnuRunMascotResultFileReductorScript_Click


End Class 'frmMainForm


'****************************************************************************
'*    <placeholder for header>                                              *
'****************************************************************************
'Object for associating Mascot and wiff files and displaying them
'in the list box.
<Serializable()> _
Public Class MascotWiffAssociation

    Private mMascotFileStr As String
    Private mWiffFileStr As String
    Private mIsAssoc As Boolean


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Sub New(ByVal aMascotFileStr As String, ByVal aWiffFileStr As String)
        mMascotFileStr = aMascotFileStr
        mWiffFileStr = aWiffFileStr
    End Sub 'New


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Function getMascotFileStr() As String
        Return mMascotFileStr
    End Function 'getMascotFileStr


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Sub setWiffFileStr(ByRef anInWiffFileStr As String)
        mWiffFileStr = anInWiffFileStr
    End Sub 'setWiffFileStr


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Function getWiffFileStr() As String
        Return mWiffFileStr
    End Function 'getWiffFileStr


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Sub setIsAssoc(ByRef anInIsAssoc As Boolean)
        mIsAssoc = anInIsAssoc
    End Sub 'setIsAssoc


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Function getIsAssoc() As Boolean
        Return mIsAssoc
    End Function 'getIsAssoc


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Public Overrides Function ToString() As String
        '  Note: override. Why?

        'ToDo: shortened file name here.

        Dim toReturn As String = ""
        If Not mIsAssoc Then
            toReturn = mMascotFileStr
        Else
            toReturn = "<asso.> " & mMascotFileStr
        End If
        Return toReturn
    End Function 'ToString


    '??: Somehow intercept close of form. To do this:
    '  mTimer.Stop()


End Class 'MascotWiffAss




    

    

Generated by script codePublish.pl at 2009-01-05T15:20:59.