コード例 #1
0
 /// <summary>
 /// This event is called when the user closes the window.Before closing
 /// the window the user is asked to confirm if he really wants to close the
 /// window.
 /// </summary>
 /// <param name="sender">Window instance.</param>
 /// <param name="e">Event data.</param>
 private void OnWindowClosed(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (MessageDialogResult.No == MessageDialogBox.Show(Properties.Resource.EXIT_APPLICATION, Properties.Resource.CAPTION, MessageDialogButton.YesNo))
     {
         e.Cancel = true;
     }
 }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: slogen/bio
 /// <summary>
 /// Display Exception Messages, if inner exception found then displays the inner exception.
 /// </summary>
 /// <param name="ex">The Exception.</param>
 private static void DisplayException(Exception ex)
 {
     if (ex.InnerException == null || string.IsNullOrEmpty(ex.InnerException.Message))
     {
         MessageDialogBox.Show(ex.Message, Resource.CAPTION,
                               MessageDialogButton.OK);
     }
     else
     {
         DisplayException(ex.InnerException);
     }
 }
コード例 #3
0
        /// <summary>
        /// Fired when user clicks the User Guide option in the Help menu
        /// </summary>
        private void OnMenuUserGuideClick(object sender, RoutedEventArgs e)
        {
            string userGuidePath = AppDomain.CurrentDomain.BaseDirectory + Properties.Resource.UserGuideRelativePath;

            if (File.Exists(userGuidePath))
            {
                Process.Start(userGuidePath);
            }
            else
            {
                MessageDialogBox.Show(Properties.Resource.NoUserGuidePresent, Properties.Resource.CAPTION, MessageDialogButton.OK);
            }
        }
コード例 #4
0
ファイル: AlignerDialog.xaml.cs プロジェクト: slogen/bio
        /// <summary>
        /// This method parses all the Textboxes and checks if the user
        /// has entered correct values.
        /// </summary>
        /// <returns>True in case parsing is successful, false if not.</returns>
        private bool ParseValues()
        {
            if (!ParseValue(this.txtMatchScore.Text, out this.matchScore))
            {
                MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources[MatchScoreKey] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                return(false);
            }

            if (!ParseValue(this.txtMisMatchScore.Text, out this.misMatchScore))
            {
                MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources[MisMatchScoreKey] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                return(false);
            }

            return(true);
        }
コード例 #5
0
        /// <summary>
        /// This method validates the gap cost input
        /// and on success adds the gap cost to the service parameters
        /// </summary>
        /// <param name="serviceParam">service param to add the param</param>
        /// <returns>whether the gap cost was valid and added or not</returns>
        private bool CheckNAddGapCostField(ref BlastParameters serviceParam)
        {
            int number;

            if (!Int32.TryParse(this.gapOpenTxt.Text, out number) && number != 0)
            {
                MessageDialogBox.Show(Resource.INVALID_TEXT + GAPCOSTS + Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                return(false);
            }

            if (!Int32.TryParse(this.gapOpenTxt.Text, out number) && number != 0)
            {
                MessageDialogBox.Show(Resource.INVALID_TEXT + GAPCOSTS + Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                return(false);
            }

            serviceParam.Add(GAPCOSTS, this.gapOpenTxt.Text + " " + this.gapExtendedTxt.Text);

            return(true);
        }
コード例 #6
0
        /// <summary>
        /// This method would validate and add the params to the service
        /// parameters for the requested search
        /// </summary>
        /// <param name="configuration">Configuration parameter</param>
        /// <param name="paramName">Param name</param>
        /// <param name="paramValue">Param value</param>
        /// <returns>whether the parameter was valid</returns>
        private static bool CheckNAddConfiguration(ConfigParameters configuration, string paramName, string paramValue)
        {
            if (URL == paramName)
            {
                if (!Uri.IsWellFormedUriString(paramValue, UriKind.Absolute))
                {
                    MessageDialogBox.Show(Resource.INVALID_TEXT + paramName + Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }
                else
                {
                    configuration.Connection = new Uri(paramValue);
                }
            }
            else if (EMAIL == paramName)
            {
                configuration.EmailAddress = paramValue;
            }

            return(true);
        }
コード例 #7
0
        /// <summary>
        /// This method would validate and add the params to the service
        /// parameters for the requested search
        /// </summary>
        /// <param name="serviceParam">Service parameter</param>
        /// <param name="paramName">Param name</param>
        /// <param name="paramValue">Param value</param>
        /// <returns>whether the parameter was valid</returns>
        private static bool CheckNAddServiceParams(ref BlastParameters serviceParam, string paramName, string paramValue)
        {
            RequestParameter param = BlastParameters.Parameters[paramName];

            if (string.IsNullOrEmpty(paramValue))
            {
                return(true);
            }
            else if (param.DataType == "int" && param.Validator == null)
            {
                int number;

                // Validate the int and double values which doesnot have validators.
                if (!Int32.TryParse(paramValue, out number))
                {
                    MessageDialogBox.Show(Resource.INVALID_TEXT + paramName + Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }
            }
            else if (param.DataType == "double" && param.Validator == null)
            {
                double number;
                if (!Double.TryParse(paramValue, out number))
                {
                    MessageDialogBox.Show(Resource.INVALID_TEXT + paramName + Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }
            }

            if (param.IsValid(paramValue))
            {
                serviceParam.Add(paramName, paramValue);
                return(true);
            }
            else
            {
                MessageDialogBox.Show(Resource.INVALID_TEXT + paramName + Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                return(false);
            }
        }
コード例 #8
0
ファイル: AlignerDialog.xaml.cs プロジェクト: slogen/bio
        /// <summary>
        /// Get the aligner input parameter from the controls in stack panel
        /// </summary>
        /// <param name="stkPanel">Stack panel object</param>
        /// <param name="assemblyInput">aligner input object</param>
        /// <param name="alphabet"> Alphabet of the Selected sequences.</param>
        /// <returns>Are parameters valid</returns>
        public bool GetAlignmentInput(
            StackPanel stkPanel,
            AlignerInputEventArgs alignerInput, IAlphabet alphabet)
        {
            TextBox textBox;
            int     intValue;
            float   floatValue;

            foreach (UIElement uiElement in stkPanel.Children)
            {
                if (uiElement is TextBox)
                {
                    textBox = uiElement as TextBox;

                    switch (textBox.Tag.ToString())
                    {
                    case PairwiseAlignmentAttributes.GapOpenCost:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.GapCost = intValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + PairwiseAlignmentAttributes.GapOpenCost
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    case PairwiseAlignmentAttributes.GapExtensionCost:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.GapExtensionCost = intValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + PairwiseAlignmentAttributes.GapExtensionCost
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    case MUMmerAttributes.LengthOfMUM:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.LengthOfMUM = intValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + NUCmerAttributes.LengthOfMUM
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    case NUCmerAttributes.FixedSeparation:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.FixedSeparation = intValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + NUCmerAttributes.FixedSeparation
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    case NUCmerAttributes.MaximumSeparation:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.MaximumSeparation = intValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + NUCmerAttributes.MaximumSeparation
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    case NUCmerAttributes.MinimumScore:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.MinimumScore = intValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + NUCmerAttributes.MinimumScore
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    case NUCmerAttributes.SeparationFactor:
                        if (float.TryParse(textBox.Text.Trim(), out floatValue))
                        {
                            alignerInput.SeparationFactor = floatValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + NUCmerAttributes.SeparationFactor
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    case NUCmerAttributes.BreakLength:
                        if (int.TryParse(textBox.Text.Trim(), out intValue))
                        {
                            alignerInput.BreakLength = intValue;
                        }
                        else
                        {
                            MessageDialogBox.Show(
                                Resource.INVALID_TEXT
                                + NUCmerAttributes.BreakLength
                                + Resource.VALUE_TEXT,
                                Properties.Resource.CAPTION,
                                MessageDialogButton.OK);

                            return(false);
                        }

                        break;

                    default:
                        break;
                    }
                }
                else if (uiElement is ComboBox)
                {
                    ComboBox comboBox = uiElement as ComboBox;

                    switch (comboBox.Tag.ToString())
                    {
                    case PairwiseAlignmentAttributes.SimilarityMatrix:

                        if (comboBox.SelectedValue != null && comboBox.SelectedIndex == 0)     // DSM
                        {
                            int matchScore     = 0;
                            int missmatchScore = 0;

                            int.TryParse(txtMatchScore.Text, out matchScore);
                            int.TryParse(txtMisMatchScore.Text, out missmatchScore);

                            alignerInput.SimilarityMatrix = new DiagonalSimilarityMatrix(matchScore, missmatchScore);
                        }

                        if (null != comboBox.SelectedValue && comboBox.SelectedIndex > 0)
                        {
                            string similarityMatrixOption = comboBox.SelectedValue.ToString();

                            if (Enum.IsDefined(
                                    typeof(SimilarityMatrix.StandardSimilarityMatrix),
                                    similarityMatrixOption))
                            {
                                SimilarityMatrix.StandardSimilarityMatrix matrix =
                                    (SimilarityMatrix.StandardSimilarityMatrix)Enum.Parse(
                                        typeof(SimilarityMatrix.StandardSimilarityMatrix),
                                        similarityMatrixOption,
                                        true);
                                alignerInput.SimilarityMatrix = new SimilarityMatrix(matrix);
                            }
                            else
                            {
                                MessageDialogBox.Show(
                                    Resource.INVALID_TEXT
                                    + PairwiseAlignmentAttributes.SimilarityMatrix
                                    + Resource.VALUE_TEXT,
                                    Properties.Resource.CAPTION,
                                    MessageDialogButton.OK);

                                return(false);
                            }
                        }

                        break;

                    default:
                        break;
                    }
                }
            }

            return(true);
        }
コード例 #9
0
ファイル: AlignerDialog.xaml.cs プロジェクト: slogen/bio
        public bool GetPamsamInput(
            StackPanel stkPanel,
            AlignerInputEventArgs alignerInput, IAlphabet alphabet)
        {
            TextBox textBox;
            int     intValue;

            try
            {
                foreach (UIElement uiElement in stkPanel.Children)
                {
                    if (uiElement is TextBox)
                    {
                        textBox = uiElement as TextBox;

                        switch (textBox.Tag.ToString())
                        {
                        case PamsamAlignmentAttributes.KmerLength:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.KmerLength = intValue;
                            }
                            else
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.KmerLength);
                            }
                            break;

                        case PamsamAlignmentAttributes.GapOpenPenalty:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.GapOpenPenalty = intValue;
                            }
                            else
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.GapOpenPenalty);
                            }
                            break;

                        case PamsamAlignmentAttributes.GapExtendPenalty:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.GapExtendPenalty = intValue;
                            }
                            else
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.GapExtendPenalty);
                            }
                            break;

                        case PamsamAlignmentAttributes.NumberOfPartitions:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.NumberOfPartitions = intValue;
                            }
                            else
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.NumberOfPartitions);
                            }
                            break;

                        case PamsamAlignmentAttributes.DegreeOfParallelism:
                            if (int.TryParse(textBox.Text.Trim(), out intValue))
                            {
                                alignerInput.DegreeOfParallelism = intValue;
                            }
                            else
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.DegreeOfParallelism);
                            }
                            break;
                        }
                    }
                    else if (uiElement is ComboBox)
                    {
                        ComboBox comboBox = uiElement as ComboBox;

                        switch (comboBox.Tag.ToString())
                        {
                        case PamsamAlignmentAttributes.SimilarityMatrix:
                            if (null != comboBox.SelectedValue)
                            {
                                string similarityMatrixOption = comboBox.SelectedValue.ToString();

                                if (Enum.IsDefined(
                                        typeof(SimilarityMatrix.StandardSimilarityMatrix),
                                        similarityMatrixOption))
                                {
                                    SimilarityMatrix.StandardSimilarityMatrix matrix =
                                        (SimilarityMatrix.StandardSimilarityMatrix)Enum.Parse(
                                            typeof(SimilarityMatrix.StandardSimilarityMatrix),
                                            similarityMatrixOption,
                                            true);
                                    alignerInput.SimilarityMatrix = new SimilarityMatrix(matrix);
                                }
                                else
                                {
                                    MessageDialogBox.Show(
                                        Resource.INVALID_TEXT
                                        + PairwiseAlignmentAttributes.SimilarityMatrix
                                        + Resource.VALUE_TEXT,
                                        Properties.Resource.CAPTION,
                                        MessageDialogButton.OK);

                                    return(false);
                                }
                            }
                            break;

                        case PamsamAlignmentAttributes.DistanceFunctionType:
                            if (!Enum.TryParse <DistanceFunctionTypes>(comboBox.Text, out alignerInput.DistanceFunctionName))
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.DistanceFunctionType);
                            }
                            break;

                        case PamsamAlignmentAttributes.UpdateDistanceMethodsType:
                            if (!Enum.TryParse <UpdateDistanceMethodsTypes>(comboBox.Text, out alignerInput.UpdateDistanceMethodsType))
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.UpdateDistanceMethodsType);
                            }
                            break;

                        case PamsamAlignmentAttributes.ProfileAlignerName:
                            if (!Enum.TryParse <ProfileAlignerNames>(comboBox.Text, out alignerInput.ProfileAlignerName))
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.ProfileAlignerName);
                            }
                            break;

                        case PamsamAlignmentAttributes.ProfileScoreFunctionName:
                            if (!Enum.TryParse <ProfileScoreFunctionNames>(comboBox.Text, out alignerInput.ProfileScoreFunctionName))
                            {
                                throw new ArgumentException(PamsamAlignmentAttributes.ProfileScoreFunctionName);
                            }
                            break;
                        }
                    }
                }
            }
            catch (ArgumentException ae)
            {
                MessageDialogBox.Show(Resource.INVALID_TEXT
                                      + ae.Message
                                      + Resource.VALUE_TEXT,
                                      Properties.Resource.CAPTION,
                                      MessageDialogButton.OK);

                return(false);
            }

            return(true);
        }
コード例 #10
0
        /// <summary>
        /// This method parses all the Textboxes and checks if the user
        /// has entered correct values.
        /// </summary>
        /// <returns>True in case parsing is successful, false if not.</returns>
        private bool ParseValues()
        {
            if (simpleSequenceAssemblerOptionButton.IsChecked == true)
            {
                if (!ParseValue(this.txtMatchScore.Text, out this.matchScore))
                {
                    MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources[MatchScoreKey] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }

                if (!ParseValue(this.txtMergeThreshold.Text, out this.mergeThreshold))
                {
                    MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources[MergeThresholdKey] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }

                if (!ParseValue(this.txtMisMatchScore.Text, out this.misMatchScore))
                {
                    MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources[MisMatchScoreKey] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }

                if (!ParseValue(this.txtConsensusThreshold.Text, out this.consensusThreshold))
                {
                    MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources[ConsensusThresholdKey] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }

                return(true);
            }
            else
            {
                if (!ParseValue(this.txtKmerLength.Text, out this.kmerLength) || kmerLength < 0)
                {
                    MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_KmerLength"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }

                if (!ParseValue(this.txtRedundantThreshold.Text, out this.redundantThreshold) || redundantThreshold < 0)
                {
                    MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_RedundantThreshold"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }

                if (!ParseValue(this.txtDangleThreshold.Text, out this.dangleThreshold) || dangleThreshold < 0)
                {
                    MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_DangleThreshold"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }

                if (chkErosion.IsChecked == true)
                {
                    if (!ParseValue(txtErosionThreshold.Text, out erosionThreshold) || (erosionThreshold != -1 && erosionThreshold < 0))
                    {
                        MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_Erosion"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                        return(false);
                    }
                }

                if (chkLowCoverageRemoval.IsChecked == true)
                {
                    if (!ParseValue(txtLowCoverageRemovalThreshold.Text, out lowCoverageContigRemovalThreshold) || (lowCoverageContigRemovalThreshold != -1 && lowCoverageContigRemovalThreshold < 0))
                    {
                        MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_LowCoverageContigRemoval"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                        return(false);
                    }
                }

                if (scaffoldGenerationParameters.IsChecked == true)
                {
                    if (!ParseValue(this.txtScaffoldRedundancy.Text, out this.scaffoldRedundancy) || scaffoldRedundancy < 0)
                    {
                        MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_ScaffoldRedundancy"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                        return(false);
                    }

                    if (!ParseValue(this.txtDepth.Text, out this.depth) || depth < 0)
                    {
                        MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_ContigGraphTraversalDepth"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                        return(false);
                    }

                    if (!ParseValue(this.txtLibraryMean.Text, out cloneLibraryMean))
                    {
                        MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_LibraryMean"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                        return(false);
                    }

                    if (!ParseValue(this.txtLibraryStandardDeviation.Text, out cloneLibrarySd) || cloneLibrarySd < 0)
                    {
                        MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_LibrarySd"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                        return(false);
                    }

                    if (string.IsNullOrEmpty(this.txtLibraryName.Text))
                    {
                        MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_LibraryNames"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                        return(false);
                    }

                    CloneLibrary.Instance.AddLibrary(this.txtLibraryName.Text, (float)cloneLibraryMean, (float)cloneLibrarySd);
                }

                return(true);
            }
        }
コード例 #11
0
        /// <summary>
        /// Launches the File Dialog, creates the selected filenames list,
        /// also validates the selected file name for import.
        /// </summary>
        /// <param name="fileDialog">OpenFiledialog instance to be launched</param>
        private void LaunchWindowFileDialog()
        {
            //// Create and launch the Windows File Dialog, Set various validations
            using (System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog())
            {
                fileDialog.Multiselect     = true;
                fileDialog.CheckFileExists = true;
                fileDialog.CheckPathExists = true;
                fileDialog.Filter          = Resource.AllFilesFilter;

                // On SuccessFull selection of the files.
                if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    // Reset the file name collection
                    this.fileNames = new Collection <string>();
                    this.fileNameList.Items.Clear();

                    string autoParser = null;
                    string prevParser = null;

                    bool chooseParserManually = false;

                    //// Validate the file type and create a list of file names to be displayed on the screen.
                    foreach (string file in fileDialog.FileNames)
                    {
                        if (!this.CheckDuplicateFile(file))
                        {
                            MessageDialogBox.Show(Resource.DUPLICATE_FILE, Resource.CAPTION, MessageDialogButton.OK);
                            return;
                        }

                        ISequenceParser parser = SequenceParsers.FindParserByFileName(file);

                        autoParser = parser == null ? null : parser.Name;

                        if (fileDialog.FileNames[0].Equals(file))
                        {
                            prevParser = autoParser;
                        }

                        if (autoParser == null || prevParser == null || !autoParser.Equals(prevParser))
                        {
                            chooseParserManually = true;
                        }

                        prevParser = autoParser;
                    }

                    //// Creates the collection of the File names.
                    foreach (string file in fileDialog.FileNames)
                    {
                        if (!this.fileNames.Contains(file))
                        {
                            this.fileNames.Add(file);
                            this.fileNameList.Items.Add(new ListViewItem {
                                Content = new FileInfo(file).Name, ToolTip = file
                            });
                        }
                    }

                    //// Enables the Molecule type.
                    this.comboMoleculeType.IsEnabled     = true;
                    this.comboMoleculeType.SelectedIndex = 0;

                    //// Enables the Parser selection.
                    this.cmbParserType.IsEnabled = true;

                    if (chooseParserManually == true)
                    {
                        this.cmbParserType.SelectedIndex = 0;
                        this.btnImport.IsEnabled         = false;
                    }
                    else
                    {
                        foreach (ComboBoxItem item in this.cmbParserType.Items)
                        {
                            string parser = item.Content as string;

                            if (parser != null && autoParser != null)
                            {
                                if (parser.Equals(autoParser))
                                {
                                    this.cmbParserType.SelectedItem = item;
                                    break;
                                }
                            }
                        }

                        this.btnImport.IsEnabled = true;
                    }

                    this.btnImport.Focus();
                }
                else
                {
                    this.btnBrowse.Focus();
                    this.dialogEscaped = true;
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// This method parses all the Textboxes and checks if the user
        /// has entered correct values.
        /// </summary>
        /// <returns>True in case parsing is successful, false if not.</returns>
        private bool ParseValues()
        {
            if (simpleSequenceAssemblerOptionButton.IsChecked == true)
            {
                if (!ParseValue(this.txtMatchScore.Text, out this.matchScore))
                {
                    MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources[MatchScoreKey] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }

                if (!ParseValue(this.txtMergeThreshold.Text, out this.mergeThreshold))
                {
                    MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources[MergeThresholdKey] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }

                if (!ParseValue(this.txtMisMatchScore.Text, out this.misMatchScore))
                {
                    MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources[MisMatchScoreKey] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }

                if (!ParseValue(this.txtConsensusThreshold.Text, out this.consensusThreshold))
                {
                    MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources[ConsensusThresholdKey] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }

                return(true);
            }
            else
            {
                if (!ParseValue(this.txtKmerLength.Text, out this.kmerLength) || kmerLength < 0)
                {
                    MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_KmerLength"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }

                if (!ParseValue(this.txtRedundantThreshold.Text, out this.redundantThreshold) || redundantThreshold < 0)
                {
                    MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_RedundantThreshold"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }

                if (!ParseValue(this.txtDangleThreshold.Text, out this.dangleThreshold) || dangleThreshold < 0)
                {
                    MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_DangleThreshold"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                    return(false);
                }

                if (scaffoldGenerationParameters.IsChecked == true)
                {
                    if (!ParseValue(this.txtScaffoldRedundancy.Text, out this.scaffoldRedundancy) || scaffoldRedundancy < 0)
                    {
                        MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_ScaffoldRedundancy"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                        return(false);
                    }

                    if (!ParseValue(this.txtDepth.Text, out this.depth) || depth < 0)
                    {
                        MessageDialogBox.Show(Properties.Resource.INVALID_TEXT + Application.Current.Resources["AssemblerDialog_ContigGraphTraversalDepth"] + Properties.Resource.VALUE_TEXT, Properties.Resource.CAPTION, MessageDialogButton.OK);
                        return(false);
                    }
                }

                return(true);
            }
        }