'****************************************************************************
'* 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
Imports System.Windows.Forms
Imports System.Text 'For StringBuilder
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 MSQlib1 'For CEBI.Remoting.SampleObject
Imports CEBI.Remoting
'Changed PM_FAST_SERIALISATION 2006-12-15
'Imports SimmoTech.Utils.Serialization 'For SerializationWriter
Imports MSQuant 'For class quantApplication
Imports massSpectrometryBase
Imports massSpectrometryBase.quantitation 'For QuantitationModes_moreGeneral
Imports SDUPutility
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 MSQuantAutomation.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
'Changed PM_DOUBLE_RETURN_KEY 2007-09-08
Private mKeyObserver As SDUPkeyObserver
#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 Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 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.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.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.MenuItem2 = New System.Windows.Forms.MenuItem
Me.mnuTest1 = New System.Windows.Forms.MenuItem
Me.mnuZedGraph = 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.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.mnuOpenContainFolderForResultfile = New System.Windows.Forms.MenuItem
Me.mnuWiffFiles = New System.Windows.Forms.ContextMenu
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.mnuOpenContainFolderForRawfile = New System.Windows.Forms.MenuItem
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = 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
Me.mnuFireAssert = New System.Windows.Forms.MenuItem
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, 365)
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(968, 24)
Me.StatusBar1.TabIndex = 0
'
'StatusBarPanel1
'
Me.StatusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
Me.StatusBarPanel1.Name = "StatusBarPanel1"
Me.StatusBarPanel1.Width = 190
'
'StatusBarPanel2
'
Me.StatusBarPanel2.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
Me.StatusBarPanel2.Name = "StatusBarPanel2"
Me.StatusBarPanel2.Width = 190
'
'StatusBarPanel3
'
Me.StatusBarPanel3.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
Me.StatusBarPanel3.Name = "StatusBarPanel3"
Me.StatusBarPanel3.Width = 190
'
'StatusBarPanel4
'
Me.StatusBarPanel4.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
Me.StatusBarPanel4.Name = "StatusBarPanel4"
Me.StatusBarPanel4.Width = 190
'
'StatusBarPanel5
'
Me.StatusBarPanel5.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
Me.StatusBarPanel5.Name = "StatusBarPanel5"
Me.StatusBarPanel5.Width = 190
'
'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, 328)
Me.ProgressBar1.Name = "ProgressBar1"
Me.ProgressBar1.Size = New System.Drawing.Size(968, 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.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..."
'
'MenuItem3
'
Me.MenuItem3.Index = 1
Me.MenuItem3.Text = "-"
'
'mnuLoadDefFileAss
'
Me.mnuLoadDefFileAss.Enabled = False
Me.mnuLoadDefFileAss.Index = 2
Me.mnuLoadDefFileAss.Text = "Load defaut file associations"
'
'mnuOpenFileAss
'
Me.mnuOpenFileAss.Index = 3
Me.mnuOpenFileAss.Text = "Open file associations..."
'
'mnuSaveFileAssociations
'
Me.mnuSaveFileAssociations.Index = 4
Me.mnuSaveFileAssociations.Text = "&Save file associations"
'
'mnuSaveFileAssAs
'
Me.mnuSaveFileAssAs.Enabled = False
Me.mnuSaveFileAssAs.Index = 5
Me.mnuSaveFileAssAs.Text = "Save File Associations As..."
'
'mnuSetFileDirectoryMascotResults
'
Me.mnuSetFileDirectoryMascotResults.Index = 6
Me.mnuSetFileDirectoryMascotResults.Text = "Set Mascot or wiff/raw/idx folder"
'
'mnuExit
'
Me.mnuExit.Index = 7
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"
'
'mnuTools
'
Me.mnuTools.Index = 2
Me.mnuTools.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuQuantitateCheckedFiles, Me.mnuOpenHighlighted, Me.mnuGuessAllAss, Me.MenuItem1, Me.mnuCorrelationSettings, Me.mnuOptions})
Me.mnuTools.Text = "&Tools"
'
'mnuQuantitateCheckedFiles
'
Me.mnuQuantitateCheckedFiles.Enabled = False
Me.mnuQuantitateCheckedFiles.Index = 0
Me.mnuQuantitateCheckedFiles.Text = "Quantitate checked files"
'
'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 = "-"
'
'mnuCorrelationSettings
'
Me.mnuCorrelationSettings.Index = 4
Me.mnuCorrelationSettings.Text = "&Correlation settings..."
'
'mnuOptions
'
Me.mnuOptions.Index = 5
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.MenuItem2, Me.mnuTest1, Me.mnuZedGraph, Me.mnuFireAssert})
Me.MenuItem8.Text = "&Utility"
'
'mnuOpenAppFolder
'
Me.mnuOpenAppFolder.Index = 0
Me.mnuOpenAppFolder.Text = "Open &MSQuant 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)"
'
'MenuItem2
'
Me.MenuItem2.Index = 3
Me.MenuItem2.Text = "-"
'
'mnuTest1
'
Me.mnuTest1.Index = 4
Me.mnuTest1.Shortcut = System.Windows.Forms.Shortcut.F8
Me.mnuTest1.Text = "Test1 - remoting"
Me.mnuTest1.Visible = False
'
'mnuZedGraph
'
Me.mnuZedGraph.Index = 5
Me.mnuZedGraph.Text = "Test2 - ZedGraph"
'
'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 = "About MSQuant..."
'
'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, 274)
Me.chkLBMascotFiles.TabIndex = 2
Me.chkLBMascotFiles.ThreeDCheckBoxes = True
'
'mnuMascotFiles
'
Me.mnuMascotFiles.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuContSetFileDirMascot, Me.mnuAddEntryMascotFiles, Me.mnuFindInMascotFileList, Me.mnuRemoveEntryMascotFiles, Me.MenuItem6, Me.mnuAssociateWithHighlightedWiffFile, Me.mnuBreakMascotAssociation, Me.MenuItem7, Me.mnuOpenContainFolderForResultfile})
'
'mnuContSetFileDirMascot
'
Me.mnuContSetFileDirMascot.Index = 0
Me.mnuContSetFileDirMascot.Text = "Add Mascot result files in folder"
'
'mnuAddEntryMascotFiles
'
Me.mnuAddEntryMascotFiles.Index = 1
Me.mnuAddEntryMascotFiles.Text = "Add single Mascot result file"
'
'mnuFindInMascotFileList
'
Me.mnuFindInMascotFileList.Index = 2
Me.mnuFindInMascotFileList.Text = "Find entry"
'
'mnuRemoveEntryMascotFiles
'
Me.mnuRemoveEntryMascotFiles.Index = 3
Me.mnuRemoveEntryMascotFiles.Text = "Remove entry"
'
'MenuItem6
'
Me.MenuItem6.Index = 4
Me.MenuItem6.Text = "-"
'
'mnuAssociateWithHighlightedWiffFile
'
Me.mnuAssociateWithHighlightedWiffFile.Index = 5
Me.mnuAssociateWithHighlightedWiffFile.Text = "Associate with selected raw data file"
'
'mnuBreakMascotAssociation
'
Me.mnuBreakMascotAssociation.Index = 6
Me.mnuBreakMascotAssociation.Text = "Break association"
'
'MenuItem7
'
Me.MenuItem7.Index = 7
Me.MenuItem7.Text = "-"
'
'mnuOpenContainFolderForResultfile
'
Me.mnuOpenContainFolderForResultfile.Index = 8
Me.mnuOpenContainFolderForResultfile.Text = "Open Containing Folder"
'
'mnuWiffFiles
'
Me.mnuWiffFiles.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuAddWiffsInFolder, Me.mnuAddWiffFile, Me.mnuFindInWiffFileList, Me.mnuRemoveWiffFile, Me.MenuItem4, Me.mnuAssociateWithHighlightedMascotFile, Me.mnuBreakWiffAss, Me.MenuItem5, Me.mnuOpenContainFolderForRawfile})
'
'mnuAddWiffsInFolder
'
Me.mnuAddWiffsInFolder.Index = 0
Me.mnuAddWiffsInFolder.Text = "Add raw data files in folder"
'
'mnuAddWiffFile
'
Me.mnuAddWiffFile.Index = 1
Me.mnuAddWiffFile.Text = "Add single raw data file"
'
'mnuFindInWiffFileList
'
Me.mnuFindInWiffFileList.Index = 2
Me.mnuFindInWiffFileList.Text = "Find entry"
'
'mnuRemoveWiffFile
'
Me.mnuRemoveWiffFile.Index = 3
Me.mnuRemoveWiffFile.Text = "Remove entry"
'
'MenuItem4
'
Me.MenuItem4.Index = 4
Me.MenuItem4.Text = "-"
'
'mnuAssociateWithHighlightedMascotFile
'
Me.mnuAssociateWithHighlightedMascotFile.Index = 5
Me.mnuAssociateWithHighlightedMascotFile.Text = "Associate with selected Mascot result file"
'
'mnuBreakWiffAss
'
Me.mnuBreakWiffAss.Index = 6
Me.mnuBreakWiffAss.Text = "Break association"
'
'MenuItem5
'
Me.MenuItem5.Index = 7
Me.MenuItem5.Text = "-"
'
'mnuOpenContainFolderForRawfile
'
Me.mnuOpenContainFolderForRawfile.Index = 8
Me.mnuOpenContainFolderForRawfile.Text = "Open Containing Folder"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(0, 8)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(112, 16)
Me.Label1.TabIndex = 4
Me.Label1.Text = "Mascot htm files"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(488, 8)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(216, 16)
Me.Label2.TabIndex = 5
Me.Label2.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, 274)
Me.chkLBWiffFiles.TabIndex = 6
Me.chkLBWiffFiles.ThreeDCheckBoxes = True
'
'SaveFileDialog1
'
Me.SaveFileDialog1.FileName = "doc1"
Me.SaveFileDialog1.Filter = "text files (*.txt)|*.txt"
Me.SaveFileDialog1.ShowHelp = True
'
'mnuFireAssert
'
Me.mnuFireAssert.Index = 6
Me.mnuFireAssert.Text = "Test3 - Fire Assert"
'
'frmMainForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(968, 389)
Me.Controls.Add(Me.chkLBWiffFiles)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
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 = "MSQuant - www.cebi.sdu.dk & msquant.sourceforge.net"
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()
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
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
'Changed PM_REFACTOR 2007-08-02
Dim appName As String = "MSQuant"
'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 decimals 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 MSQuant. " & _
"MSQuant 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
MsgBox( _
"Could not start MSQuant. " & _
"The DLL file 'SqlInterface.dll' seems not " & _
"to have the correct version or it is absent.")
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 MSQuant. " & _
"Assembly SqlInterface (file ""SqlInterface.dll"") was not found. " & _
"Reinstall MSQuant.")
Me.doClose2(True, continueStartUp2)
End If
'Changed PM_RECALIB_VISUAL 2007-09-02
If Not ZedGraphFound Then
MsgBox( _
"Could not start MSQuant. " & _
"Assembly ZedGraph (file ""ZedGraph.dll"") was not found. " & _
"Reinstall MSQuant.")
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) = MSQconstants.OLD_QUANTMODES_FILENAME
oldFilesNames(1) = MSQconstants.OLD_MISCOPTIONS_FILENAME
oldFilesNames(2) = MSQconstants.OLD_CORRSETTINGS_FILENAME
oldFilesNames(3) = MSQconstants.OLD_SPECCLASSIFICATION_FILENAME
oldFilesNames(4) = MSQconstants.OLD_PARSER_SETTINGS_FILENAME
Dim newFilesNames(lastIndex) As String
newFilesNames(0) = MSQconstants.NEW_QUANTMODES_FILENAME
newFilesNames(1) = MSQconstants.NEW_MISCOPTIONS_FILENAME
newFilesNames(2) = MSQconstants.NEW_CORRSETTINGS_FILENAME
newFilesNames(3) = MSQconstants.NEW_SPECCLASSIFICATION_FILENAME
newFilesNames(4) = MSQconstants.NEW_PARSER_SETTINGS_FILENAME
If MSQuantCommon2.oldOptionFiles( _
oldFilesNames, newFilesNames, appName) 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 = MSQconstants.NEW_QUANTMODES_FILENAME
'Note: this must come before load of MascotParserOptions.xml.
Dim modificationsAccepted As Boolean
Dim errStr As String = Nothing
mApplication.appLoadQuantitationDefinitions( _
quantAndModFile, _
modificationsAccepted, _
errStr)
If Not modificationsAccepted Then
Dim msg As String = _
"Could not start " & appName & ". " & appName & _
" 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( _
MSQconstants.NEW_MISCOPTIONS_FILENAME)
End If
If continueStartUp2 Then
'Changed PM_COMVERSIONS 2007-07-24
''Changed PM_PERSIST_OPTIONS 2003-04-14
'mConfigurationFileName = "MascotParserOptions.xml" 'A constant string
mConfigurationFileName = MSQconstants.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( _
MSQconstants.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 MSQuantAutomation.automator(Me, mApplication)
'Changed PM_CMD_DISPLAY_PARAMETERS 2006-11-22
mCommands = Microsoft.VisualBasic.Interaction.Command()
'Sample command line:
' -bin "S:\temp2\LTQ-FTsampleDataSet1,1,QUANTMODE_No isotope.mb2" -quant 4-11 -maxPep 200
'
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()
' Adds the event and the event handler for the method that will
' process the timer event to the timer.
AddHandler mTimer.Tick, AddressOf TimerEventProcessor
' Sets the timer interval to 5 seconds.
mTimer.Interval = mCurrentInterval
mTimer.Start()
End If
End If
'Changed PM_PROCESS_PRIORITY 2005-04-27
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 sender As System.Object, ByVal e 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 sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuSetFileDirectoryMascotResults.Click
SetFileDirectoryMascotOrWiff(True, True)
End Sub 'mnuSetFileDirectoryMascotResults_Click
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Sub mnuContSetFileDirMascot_Click( _
ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuContSetFileDirMascot.Click
SetFileDirectoryMascotOrWiff(True, False)
End Sub 'mnuContSetFileDirMascot_Click
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Sub mnuAddWiffsInFolder_Click( _
ByVal sender As System.Object, ByVal e 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 sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuAddEntryMascotFiles.Click
AddFileToMascotOrWiffList(True)
End Sub 'mnuAddEntryMascotFiles_Click
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Sub mnuAddWiffFile_Click( _
ByVal sender As System.Object, ByVal e 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 sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuClearMascotHtmFileList.Click
chkLBMascotFiles.Items.Clear()
End Sub 'mnuClearMascotHtmFileList_Click
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Sub mnuClearWiffFileList_Click( _
ByVal sender As System.Object, ByVal e 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 sender As System.Object, ByVal e 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 sender As System.Object, ByVal e 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 sender As System.Object, ByVal e 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 sender As System.Object, ByVal e 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 sender As System.Object, ByVal e 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 sender As System.Object, ByVal e 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 sender As System.Object, ByVal e 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 sender As System.Object, ByVal e 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 sender As System.Object, ByVal e 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 sender As System.Object, ByVal e 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 sender As System.Object, ByVal e 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 new_MSQ_quantitationModes.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
'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)
'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 = _
' "MSQuant could not start parsing the Mascot result file. " & _
' "The current quantitation mode is not defined in the " & _
' "settings file " & _
' MSQconstants.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 corrSettingsForm As New frmCorrelationSettings(mCorrSettings, Me)
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 sender As System.Object, ByVal e 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 MSQuant?", _
"MSQuant", _
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) _
As Boolean
Dim msg As String = Nothing
Dim loadedDoc As MSQuantDocumentStructure
loadedDoc.parsedProts3 = Nothing 'Keep compiler happy.
loadedDoc.rawFiles = Nothing 'Keep compiler happy.
loadedDoc.mascotFileStr = Nothing 'Keep compiler happy.
loadedDoc.rawFileStr = Nothing 'Keep compiler happy.
Dim loadInfoStr As String = Nothing
Dim succeeded As Boolean = _
quantApplication.deserialiseDocumentDataStructures4( _
anInFileName, msg, loadedDoc, _
mApplication, loadInfoStr)
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.
'For now: use assoc pair for detection
If True Then
Dim resultFile As String = loadedDoc.mascotFileStr
Dim rawFile As String = loadedDoc.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( _
"MSQuant 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
End If
Else
'They exist!
end2 = True
End If
End While
If patchPaths Then
quantApplication.patchDocumentDataStructures( _
loadedDoc, resultFile, rawFile, onlyOneRawFile)
End If
End If
Dim mascotWiffAssoc As New MascotWiffAssociation( _
loadedDoc.mascotFileStr, loadedDoc.rawFileStr)
mascotWiffAssoc.setIsAssoc(True)
If OKtoOpenFiles2(mascotWiffAssoc) Then
anOutMascotResultForm2 = New frmProteinList( _
Me, mApplication, mOptions)
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, loadedDoc, _
loadInfoStr) 'What about mSampleNum and mCorrSettings?
anOutMascotResultForm2.ParserStatus.Text = msg '????
End If
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
End Function 'loadAndShowSavedParse
'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
'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) Then
Dim someMascotResultForm As frmProteinList = Nothing
Dim succeeded As Boolean = _
Me.loadAndShowSavedParse(loadFileName, someMascotResultForm)
End If
End Sub 'mnuOpenParsedProteinsEtc_Click
'To refactor: this function should be in a common location.
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Shared Sub showFileInWindowsExplorer( _
ByRef anInFilePath2 As String, _
ByRef anInFileNotExistMsg As String)
Dim effectivePath As String = anInFilePath2 'Default, if file exists...
Dim doOpen As Boolean = True
Dim fileExists As Boolean = File.Exists(anInFilePath2)
'Changed PM_CHECK_CONTAININGFOLDER_EXISTENCE 2008-01-14
If Not fileExists Then
'File/folder no longer exist. Open first
'existing ***containing*** folder that exists...
'Try to find a containing folder that exists.
Dim candidate As String = anInFilePath2
Dim rootDir As String = Path.GetPathRoot(anInFilePath2)
Dim done As Boolean = False
While Not done
If candidate = rootDir Then
candidate = "" 'No containing dir exists...
done = True
Else
candidate = Path.GetDirectoryName(candidate)
If Directory.Exists(candidate) Then
done = True
End If
End If
End While
effectivePath = candidate
Dim msgStr1 As String = _
"File does not exist: " & anInFilePath2 & ". "
Dim msgStr2 As String = Nothing
If effectivePath = "" Then
msgStr2 = "" 'None of the containing folders exists, not
' even the drive.
doOpen = False
Else
msgStr2 = _
"An existing containing folder, " & _
effectivePath & ", will be opened instead."
End If
MsgBox(msgStr1 & msgStr2)
End If 'File does not exist.
If doOpen Then
'Dim inputFolder As String = _
' Path.GetDirectoryName(aFilePath)
Dim explorerName As String = "explorer.exe"
Dim prefix3 As String = "/e,/select,""" 'To open Explorer.
If Not fileExists Then
prefix3 = "/e,""" 'To display the content of the
' first existing containing folder. It may or
' may not be empty.
End If
Dim postfix3 As String = """" 'To open Explorer.
Dim params3a As String = _
prefix3 & effectivePath & postfix3
Dim myProcess3 As Process = _
System.Diagnostics.Process.Start(explorerName, params3a)
End If
End Sub 'showFileInWindowsExplorer
'****************************************************************************
'* <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
showFileInWindowsExplorer( _
fileNamePath, "Opening the closest containing folder.")
Else
MsgBox("MSQuant could not proceed opening a containing folder. A " & _
anInFileTypeDescriptionShortString & _
" file was not selected. Please select a " & _
anInFileTypeDescriptionShortString & " file first.")
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
'****************************************************************************
'* <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_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_OPENMSQFOLDER 2006-08-25
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Sub mnuOpenAppFolder_Click( _
ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
Handles mnuOpenAppFolder.Click
Dim MSQfolderPath As String = MSQuantCommon2.appPath()
Dim someFileInMSQFolder As String = _
MSQfolderPath & Path.DirectorySeparatorChar & _
MSQconstants.NEW_QUANTMODES_FILENAME
Dim toOpen As String = someFileInMSQFolder
If Not File.Exists(toOpen) Then
'The file for some reason does not exist then the containing
'folder of MSQuant will be shown/selected instead - the user
'will then have to open that.
toOpen = MSQfolderPath
End If
'This should never fail; set 2nd parameter to empty string?
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 = "MSQuant could not open file. "
If Not anOutMascotWiffAssociation.getIsAssoc() Then
'Changed PM_VALIDATION_BEFOREOPEN 2006-09-01. Now
'always require association.
'If MsgBox( _
' "This item does not have an association with a " & _
' " data file. Continue?", _
' MsgBoxStyle.OkCancel, "No file association") = _
' MsgBoxResult.Cancel Then Exit Function
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 MSQuantCommon.SDUPcheckFileExists_withSearch( _
mascotFileStr, _
part1 & mascotFileStr & part2, _
realMascotFilePath) _
AndAlso _
MSQuantCommon.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 = _
"MSQuant could not start parsing the Mascot result file. " & _
"The current quantitation mode is not defined in the " & _
"settings file " & _
MSQconstants.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 = "MSQuant 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 sender As System.Object, ByVal e 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...
'MSQuantCommon2.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) _
As Boolean
Dim succeeded As Boolean = _
Me.loadAndShowSavedParse(anInBinPath, anOutMascotResultForm2)
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.exportSettings = 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
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
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 'ToString2
'??: Somehow intercept close of form. To do this:
' mTimer.Stop()
End Class 'MascotWiffAss
Generated by script codePublish.pl at 2008-09-23T11:59:18.