示例#1
0
 /// <summary>
 /// Run task for a particular step. 
 /// </summary>
 /// <param name="task"></param>
 /// <returns></returns>
 private void RunTask(string task)
 {
     bool res = false;
     switch (task)
     {
         case "UserControl0":
             break;
         case "UserControl1":
             Util.SetupDirectories(Up.ProjectDir);
             break;
         case "UserControl2":
             if ((!File.Exists(Up.ProjectDir + "\\genes.fasta")) ||
                 (File.Exists(Up.ProjectDir + "\\genes.fasta") && (Up.FastaFile != "")))
             {
                 FastaParser parser = new FastaParser();
                 try
                 {
                     Up.QuerySequences = parser.Parse(Up.FastaFile).ToList();
                 }
                 catch
                 {
                     FatalErrorDialog("Error parsing FASTA file. Please confirm that the input file is in FASTA format. If the problem persists file a bug report at blip.codeplex.com.  The application will now be closed.");
                 }
                 File.Copy(Up.FastaFile, Up.ProjectDir + "\\genes.fasta", true);
             }
             break;
         case "UserControl3":
             break;
         case "UserControl4":
             UserControl4 uc4 = (CurrentControl as UserControl4);
             BlastUtil.RecordBlastThresholds(Up, uc4, ((ComboBoxItem)uc4.BlastProgram.SelectedItem).Content.ToString(), uc4.BlastDatabase.SelectedItem.ToString(), uc4.BlastAlgorithm.SelectedItem.ToString());
             /*
             MessageBox.Show(String.Format("Recorded Parameters:\n{0}\n{1}\n{2}\n{3}\n{4}\n{5}\n{6}\n{7}",
                     Up.BlastProgram,
                     Up.BlastDatabase,
                     Up.BlastGeneticCode, 
                     Up.BlastAlgorithm, 
                     Up.BlastMaxEvalue, 
                     Up.BlastMaxNumHits, 
                     Up.BlastMinPercentIdentity, 
                     Up.BlastMinPercentQueryCoverage
                     ));
             */
             LaunchBlastPipeline(Up.ProjectDir + "\\genes.fasta");
             break;
         case "UserControl5":
             LogMessage("Set Pivot parameters.\r\n");
             break;
         case "UserControl6":
             UserControl6 uc6 = (CurrentControl as UserControl6);
             //Pivot.RecordPivotParameters(Up, uc6.CollectionNameBox.Text, uc6.CollectionTitleBox.Text);
             Pivot.RecordPivotParameters(Up, "blip", uc6.CollectionTitleBox.Text);
             break;
         case "UserControl7":
             break;
         case "UserControl8":
             UserControl8 uc8 = (CurrentControl as UserControl8);
             // progressBar1.Maximum = Up.QuerySequences.Count();
             // progressBar1.Minimum = 0;
             // progressBar1.Value = 0;
             uc8.SaveImagePreviewState();
             res = WriteCollection();
             break;
         case "UserControl9":
             UserControl9 uc9 = (CurrentControl as UserControl9);
             if (uc9.createProject.IsChecked == true)
             {
                 Debug.WriteLine("NEW");
                 UserControls.Clear();
                 UserControl0 uc0 = new UserControl0(Up);
                 UserControls.Add(uc0);
                 UserControl9 c9 = new UserControl9(Up);
                 UserControls.Add(c9);
                 UserControl1 uc1 = new UserControl1(Up);
                 UserControls.Add(uc1);
                 UserControl2 uc2 = new UserControl2(Up);
                 UserControls.Add(uc2);
                 //UserControl3 uc3 = new UserControl3(Up);
                 //UserControls.Add(uc3);
                 UserControl6 c6 = new UserControl6(Up);
                 UserControls.Add(c6);
                 UserControl4 c4 = new UserControl4(Up);
                 UserControls.Add(c4);
                 UserControl5 uc5 = new UserControl5(Up);
                 UserControls.Add(uc5);
                 UserControl8 c8 = new UserControl8(Up);
                 UserControls.Add(c8);
                 UserControl7 uc7 = new UserControl7(Up);
                 UserControls.Add(uc7);
             }
             if (uc9.loadProject.IsChecked == true)
             {
                 UserControls.Clear();
                 UserControl0 uc0 = new UserControl0(Up);
                 UserControls.Add(uc0);
                 UserControl9 c9 = new UserControl9(Up);
                 UserControls.Add(c9);
                 UserControl10 c10 = new UserControl10(Up);
                 UserControls.Add(c10);
                 UserControl11 c11 = new UserControl11(Up);
                 UserControls.Add(c11);
             }
             break;
         case "UserControl10":
             UserControl10 uc10 = (CurrentControl as UserControl10);
             Debug.WriteLine("UC10");
             
             
             Action<object> action = (object obj) =>
             {
                 StartWebServer("/", Up.CxmlDir, Up.WebServerPort);
             };
             Task t1 = new Task(action, "BLiP_WS");
             t1.Start();
             Previous_Button.IsEnabled = false;
             Next_Button.IsEnabled = false;
             Finish_Button.IsEnabled = true;
             break;
         default:
             break;
     }
 }
示例#2
0
        /// <summary>
        /// Controls behaviour when user clicks the Next button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Next_Click(object sender, RoutedEventArgs e)
        {


            Previous_Button.IsEnabled = true; // Previous button should always be enabled after clicking Next.
            RunTask(CurrentControl.Name); // Run the task assocaited with the current control step
            MainGrid.Children.Remove(CurrentControl); // Remove the current control from the UI. 
            
            // Update the current step and bound checking to decide which buttons to enable/disable.
            if (CurrentStep < (UserControls.Count() - 1))
            {
                CurrentStep += 1;
            }
            if (CurrentStep == (UserControls.Count() - 1))
            {
                //Next_Button.IsEnabled = false;
                //Finish_Button.IsEnabled = true;
            }
            else
            {
                Next_Button.IsEnabled = true;
                Finish_Button.IsEnabled = false;
            }

            // Load the user control for the updated current step into the UI
            UserControl uc = UserControls[CurrentStep];
            uc.VerticalAlignment = VerticalAlignment.Top;
            MainGrid.Children.Add(uc);
            Grid.SetRow(uc, 0);
            Grid.SetColumn(uc, 1);
            CurrentControl = uc;
            LogText.Text = Up.Log; // Update Log
            
            // SPECIAL CASE: If uploading file, disable Next button until user selects a file from RunkTask or the file already exists.

            if (uc.Name == "UserControl2")
            {

                UserControl2 uc2 = CurrentControl as UserControl2; 
                Next_Button.IsEnabled = false;
                //System.Windows.MessageBox.Show(String.Format("CHECK: {0}", Up.ProjectDir));
                
                if (File.Exists(Up.ProjectDir + "\\genes.fasta"))
                {
                    //System.Windows.MessageBox.Show("TRUE");
                    (CurrentControl as UserControl2).LoadFastaFileGrid.Children.Clear();
                    TextBlock txt1 = new TextBlock();
                    FastaParser parser = new FastaParser();
                    try
                    {
                        Up.QuerySequences = parser.Parse(Up.ProjectDir + "\\genes.fasta").ToList();
                    }
                    catch
                    {
                        FatalErrorDialog("Error parsing FASTA file. Please confirm that the input file is in FASTA format. If the problem persists file a bug report at blip.codeplex.com.  The application will now be closed.");
                    }
                    txt1.Text = ("A file with " + Up.QuerySequences.Count() + " gene sequences exists in this folder.\n\nIf you want to load a new file select an empty project folder instead.\r\n");
                    txt1.Margin = new Thickness(55);
                    (CurrentControl as UserControl2).LoadFastaFileGrid.Children.Add(txt1);
                    Next_Button.IsEnabled = true;
                }
                else
                {
                    //System.Windows.MessageBox.Show("FALSE");
                    MainGrid.Children.Remove(CurrentControl);
                    UserControls[CurrentStep] = new UserControl2(Up);
                    uc = UserControls[CurrentStep];
                    uc.VerticalAlignment = VerticalAlignment.Top;
                    MainGrid.Children.Add(uc);
                    Grid.SetRow(uc, 0);
                    Grid.SetColumn(uc, 1);
                    CurrentControl = uc; 
                }
                (uc as UserControl2).RunCompleted += delegate(object sender1, RoutedEventArgs arg)
                {
                    Next_Button.IsEnabled = true;
                    Previous_Button.IsEnabled = true;
                };
            }

            
            
            if (uc.Name == "UserControl7")
            {
                (CurrentControl as UserControl7).CollectionUrlBox.Text = Up.CollectionUrl;
            }
            
        }