Beispiel #1
0
    protected virtual void OnOpenActionActivated(object sender, System.EventArgs e)
    {
        m_dlgOpen.SelectFilename(m_LastDir);
        int res = m_dlgOpen.Run();

        m_dlgOpen.Hide();
        if (res != (int)ResponseType.Ok)
        {
            return;
        }
        m_LastDir = System.IO.Path.GetDirectoryName(m_dlgOpen.Filenames[0]);

        m_nFiles = 0;
        string title = " New Analysis ";
        int    tlen  = title.Length;

        Log.Text = title.PadLeft(40 + tlen / 2, '*').PadRight(80, '*');
        State    = States.LOADING;
        try {
            bool bThresholds = true;
            m_Mapper           = Mapper.Create(m_dlgOpen.Filename, m_Software);
            m_Mapper.OnNotify += WriteLog;
            foreach (string xmlpath in m_dlgOpen.Filenames)
            {
                m_Mapper.Load(xmlpath, true);
                if (m_Mapper.PlgsThreshold == Peptide.ConfidenceType.NoThreshold)
                {
                    bThresholds = false;
                }
                m_nFiles++;
            }
            m_Mapper.PlgsThreshold = bThresholds ? Peptide.ConfidenceType.Yellow : Peptide.ConfidenceType.NoThreshold;
        } catch (Exception ex) {
            WriteLog("Error loading XML: " + ex.Message);
            WriteLog("Stack trace:\n" + ex.StackTrace);
            State = States.EMPTY;
            return;
        }
        WriteLog("Completed!");
        if (m_Mapper.Spectra.Count != 0)
        {
            WriteLog("\tLoaded " + m_Mapper.Spectra.Count + " spectra");
            WriteLog("\tLoaded " + m_Mapper.PsmCount + " PSMs");
        }
        WriteLog("\tLoaded " + m_Mapper.Peptides.Count + " possible peptides");
        WriteLog("\tLoaded " + m_Mapper.Proteins.Count + " possible proteins");
        DisplayData();
        State = States.LOADED;
    }
		private void ConnectEventsMainWindow() {

			// ----------------------------------------------------------------------------------------------------
			m_imagemenuitemNew.Activated += delegate(object o, EventArgs args) {
				UpdateGui (m_defaultSettings);
			};

			m_imagemenuitemOpen.Activated += delegate(object o, EventArgs args) {
				Gtk.Application.Invoke(delegate {
					Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog ("Load configuration", m_mainWindow, FileChooserAction.Open,
						"_Cancel", ResponseType.Cancel,
						"_Open", ResponseType.Accept);
					fcd.LocalOnly = false;
					if(!String.IsNullOrWhiteSpace(m_currentPath)) fcd.SetFilename(m_currentPath);
					if ((Gtk.ResponseType)fcd.Run() == Gtk.ResponseType.Accept) {
						LoadSaveStateFromFile (fcd.Filename);
					}
					fcd.Destroy ();
				});
			};

			// ----------------------------------------------------------------------------------------------------
			EventHandler imagemenuItemSave = delegate(object o, EventArgs arg) {
				Gtk.Application.Invoke(delegate {
					Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog ("Save configuration to file", m_mainWindow, FileChooserAction.Save,
						"_Cancel", ResponseType.Cancel,
						"_Save", ResponseType.Accept);
					fcd.DoOverwriteConfirmation = true;
					fcd.LocalOnly = false;
					if(!String.IsNullOrWhiteSpace(m_currentPath)) fcd.SetFilename(m_currentPath);
					if ((Gtk.ResponseType)fcd.Run() == Gtk.ResponseType.Accept) {
						SaveStateToFile (fcd.Filename);
					}
					fcd.Destroy ();
				});
			};

			// ----------------------------------------------------------------------------------------------------
			m_imagemenuitemSave.Activated += imagemenuItemSave;
			m_imagemenuitemSaveAs.Activated += imagemenuItemSave;

			// ----------------------------------------------------------------------------------------------------
			m_imagemenuitemClose.Activated += delegate(object obj, EventArgs args) {
				Application.Quit ();
			};


			// ----------------------------------------------------------------------------------------------------
			m_buttonTargetLanguageChoose.Clicked += delegate(object o, EventArgs e) {
				// Open file dialog
				String[] filenames = OpenFileChooser ("Select subtitles file in target language");
				if (filenames == null)
					return;

				m_entryTargetLanguage.Text = AddFilesToEntry(m_entryTargetLanguage.Text, filenames, "Error in target language file entry field: ");
			};

			// ----------------------------------------------------------------------------------------------------
			m_buttonDirectoryChoose.Clicked += delegate(object o, EventArgs e) {

				Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog ("Select output folder", m_mainWindow, FileChooserAction.SelectFolder,
					"_Cancel", ResponseType.Cancel,
					"_Choose", ResponseType.Accept);
				fcd.DoOverwriteConfirmation = true;
				fcd.SelectMultiple = true;
				if(!String.IsNullOrWhiteSpace(m_currentPath)) fcd.SelectFilename(m_currentPath);
				if ((Gtk.ResponseType)fcd.Run () == Gtk.ResponseType.Accept) {
					m_entryOutputDirectory.Text = fcd.Filename;
					m_currentPath = fcd.Filename;
				}
				fcd.Destroy ();
			};

			// ----------------------------------------------------------------------------------------------------
			m_buttonNativeLanguageChoose.Clicked += delegate(object o, EventArgs e) {
				// Open file dialog
				String[] filenames = OpenFileChooser ("Select subtitles file in native language");
				if (filenames == null)
					return;

				m_entryNativeLanguage.Text = AddFilesToEntry(m_entryNativeLanguage.Text, filenames, "Error in native language file entry field: ");
			};

			// ----------------------------------------------------------------------------------------------------
			m_buttonVideoFileChoose.Clicked += delegate(object o, EventArgs e) {
				// Open file dialog
				String[] filenames = OpenFileChooser ("Select video files");
				if (filenames == null)
					return;

				m_entryVideoFile.Text = AddFilesToEntry(m_entryVideoFile.Text, filenames, "Error in video file entry field: ");
			};


			// ----------------------------------------------------------------------------------------------------
			m_buttonTargetLanguageOptions.Clicked += delegate(object o, EventArgs e) {
				OpenSubtitleWindow(0);
			};

			// ----------------------------------------------------------------------------------------------------
			m_buttonNativeLanguageOptions.Clicked += delegate(object o, EventArgs e) {
				OpenSubtitleWindow(1);
			};

			// ----------------------------------------------------------------------------------------------------
			m_buttonPreview.Clicked += delegate(object o, EventArgs args) {
				PreviewButtonClicked();
			};

			// ----------------------------------------------------------------------------------------------------
			m_mainWindow.DeleteEvent += delegate(object obj, DeleteEventArgs args) {
				Application.Quit ();
			};
		}