当前位置: 首页>>代码示例>>C#>>正文


C# Progress.Set方法代码示例

本文整理汇总了C#中Progress.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Progress.Set方法的具体用法?C# Progress.Set怎么用?C# Progress.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Progress的用法示例。


在下文中一共展示了Progress.Set方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Read

        /// <summary>
        /// Read data into the specified SnpCollection from the SnpCollection
        /// file having the specified filename (which may include a path). 
        /// The specified CancellationToken can be used to abort the read. 
        /// The progress parameter will be updated by this method with a 
        /// value of 0-100 to reflect the percent progress of the read.
        /// </summary>
        /// <param name="snps">The SnpCollection to receive the read data.</param>
        /// <param name="filename">The path and filename of the SnpCollection file.</param>
        /// <param name="cancel">The CancellationToken that can be used to abort the read.</param>
        /// <param name="progress">The progress parameter that will be updated to reflect 
        /// the percent progress of the read.</param>
        public static void Read(SnpCollection snps, string filename, CancellationToken cancel, Progress progress) {
            if (snps == null) throw new ArgumentNullException("The SnpCollection cannot be null.");
            if (filename == null) throw new ArgumentNullException("filename cannot be null.");
            if (String.IsNullOrWhiteSpace(filename)) throw new ArgumentOutOfRangeException("filename cannot be empty.");

            using (StreamReader reader = new StreamReader(filename)) {
                long length = 0;
                if (progress != null) length = reader.BaseStream.Length;
                string[] columns = new string[6];
                string line;
                while ((line = reader.ReadLine()) != null) {
                    cancel.ThrowIfCancellationRequested();
                    line.FastSplit(',', columns);
                    byte chr = Convert.ToByte(columns[2]);
                    if (chr == 0) chr = 23; // handles legacy use of 0 for X 
                    Snp snp;
                    if ((!String.IsNullOrWhiteSpace(columns[3]) && Char.IsDigit(columns[3][0]))) {
                        // new format snp file
                        snp = new Snp(columns[0], chr, Convert.ToInt32(columns[3]), Convert.ToSingle(columns[4]), columns[1], columns[5]);
                    } else {
                        // old SnpMap format snp file
                        snp = new Snp(columns[0], chr, -1, -1, columns[1], columns[3]);
                    }
                    snps.Add(snp);
                    if (progress != null) progress.Set(reader.BaseStream.Position, length);

                }
            }
        }
开发者ID:Bert6623,项目名称:Gedcom.Net,代码行数:41,代码来源:SnpFile.cs

示例2: Save

        public static Progress Save(int contractId,
            int projectId,
            int blockId,
            int workId,
            int groupId,
            int itemId,
            int subItemId,
            int initialProgress,
            int currentProgress,
            string user)
        {
            Progress progress = new Progress();

            using (IDataReader reader = DBProgress.Add(contractId, projectId, blockId, workId, groupId, itemId, subItemId, initialProgress, currentProgress, user))
            {
                if (reader.Read())
                {
                    progress.Set(Convert.ToInt32(reader["InitialProgress"]), Convert.ToInt32(reader["CurrentProgress"]));
                }
            }

            return progress;
        }
开发者ID:BackupTheBerlios,项目名称:buildingmonitor-svn,代码行数:23,代码来源:Progress.cs

示例3: btnSave_Click

        private void btnSave_Click(object sender, EventArgs e)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            List<Progress> progresses = new List<Progress>();

            foreach(RepeaterItem item in rptContractDetail.Items)
            {
                HiddenField hdnData = (HiddenField)item.FindControl("hdnData");
                Dictionary<string, object> data = (Dictionary<string, object>)serializer.DeserializeObject(hdnData.Value);

                if ((int)data["active"] == 0)
                    continue;
                if ((int)data["curr"] == (int)data["newp"])
                    continue;

                Progress progress = new Progress();

                progress.ContractDetail.ContractId = (int)data["cId"];
                progress.ContractDetail.ProjectId = (int)data["pId"];
                progress.ContractDetail.BlockId = (int)data["bId"];
                progress.ContractDetail.WorkId = (int)data["wId"];
                progress.ContractDetail.GroupId = (int)data["gId"];
                progress.ContractDetail.ItemId = (int)data["iId"];
                progress.ContractDetail.SubItemId = (int)data["sId"];
                progress.Set((int)data["curr"], (int)data["newp"]);

                progresses.Add(progress);
            }

            if (!Save(progresses))
                return;

            DisplaySavedSuccess();
            FillContractGrid();
        }
开发者ID:BackupTheBerlios,项目名称:buildingmonitor-svn,代码行数:35,代码来源:AdminProgressRecording.aspx.cs

示例4: Write

        public void Write(bool includePositions, char nullChar, CancellationToken cancel, Progress progress) {
            if (this.genome == null) throw new ArgumentNullException("The Genome cannot be null.");
            if (this.filename == null) throw new ArgumentNullException("filename cannot be null.");
            if (String.IsNullOrWhiteSpace(this.filename)) throw new ArgumentOutOfRangeException("filename cannot be empty.");

            using (StreamWriter writer = new StreamWriter(this.filename)) {
                if (this.comments != null) foreach (var str in this.comments) writer.WriteLine(str);
                writer.WriteLine(header);
                int count = 0;
                foreach (var snp in this.genome.Snps) {
                    cancel.ThrowIfCancellationRequested();
                    string line = snp.RsId + "\t";
                    if (includePositions) {
                        line += Snp.ChromosomeToString(snp.Chromosome) + "\t" + snp.Position + "\t";
                    }
                    byte alleles = genome[snp];
                    if (snp.Position == 892967) {
                        int xxx = 1;
                    }
                    if (alleles == Allele.Null) {
                        line += nullChar;
                    } else {
                        line += genome[snp].ToAllelesString();
                    }
                    writer.WriteLine(line);
                    if (progress != null) progress.Set(++count, genome.Count);
                }
            }
        }
开发者ID:Bert6623,项目名称:Gedcom.Net,代码行数:29,代码来源:GenomeFile.cs

示例5: ReadFtdnaGenome

        // FTDNA files are are made available by the Family Tree DNA testing 
        // service to their customers.

        /// <summary>
        /// Read data into the specified Genome from an individual's
        /// FTDNA personal genome file, using the specified filename (which 
        /// may include a path). The specified SnpCollection does not need
        /// to contain all the SNPs that may be present in the genome file.
        /// The SnpCollection is used as the source of physical and cM
        /// positional information. Centimorgan values for SNPs present in
        /// the genome but not in the SnpCollection are extrapolated.
        /// The specified CancellationToken can be used to abort the read. 
        /// The progress parameter will be updated by this method with a 
        /// value of 0-100 to reflect the percent progress of the read.
        /// </summary>
        /// <param name="genome">The Genome to receive the read data.</param>
        /// <param name="snps">The SnpCollection containing reference SNP positional data.</param>
        /// <param name="filename">The path and filename of the FTDNA genome file.</param>
        /// <param name="cancel">The CancellationToken that can be used to abort the read.</param>
        /// <param name="progress">The progress parameter that will be updated to reflect 
        /// the percent progress of the read.</param>
        private void ReadFtdnaGenome(SnpCollection snps, CancellationToken cancel, Progress progress) {
            using (StreamReader reader = new StreamReader(this.filename)) {
                long length = 0;
                if (progress != null) length = reader.BaseStream.Length;
                string[] columns = new string[4];
                string line;
                bool started = false;
                while ((line = reader.ReadLine()) != null) {
                    cancel.ThrowIfCancellationRequested();
                    if ((line.Length > 0) && (line[0] != '#') && (line[0] != '-')
                        && (started || !line.StartsWith("RSID,", StringComparison.Ordinal))) {
                        started = true;
                        line.Replace("\"", "").FastSplit(',', columns);
                        string rsId = columns[0];
                        Snp snp = snps[rsId];
                        if (snp == null) {
                            byte chr = Snp.ChromosomeToByte(columns[1]).Value;
                            if (chr > 23) continue;
                            int position = Convert.ToInt32(columns[2]);
                            snp = new Snp(rsId, chr, position, snps.ExtrapolateCentiMorganPosition(chr, position), null, "");
                        }
                        var alleles = columns[3];
                        if ((snp.Chromosome == 23) && (alleles.Length == 1)) alleles += alleles;
                        this.genome.Add(snp, Allele.ToAlleles(alleles));
                    } else if ((line.Length > 0) && (this.genome.Count == 0) && !line.StartsWith("# rsid\t")) {
                        this.comments.Add(line);
                    }
                    if (progress != null) progress.Set(reader.BaseStream.Position, length);
                }
            }
        }
开发者ID:Bert6623,项目名称:Gedcom.Net,代码行数:52,代码来源:GenomeFile.cs

示例6: Write23AndMe

 private void Write23AndMe(bool includePositions, char nullChar, CancellationToken cancel, Progress progress) {
     using (StreamWriter writer = new StreamWriter(this.filename)) {
         int count = 0;
         if (includePositions) {
             writer.WriteLine("# rsid\tchromosome\tposition\tgenotype");
         } else {
             writer.WriteLine("# rsid\tgenotype");
         }
         foreach (var snp in genome.Snps) {
             cancel.ThrowIfCancellationRequested();
             string line = snp.RsId + "\t";
             if (includePositions) {
                 line += Snp.ChromosomeToString(snp.Chromosome) + "\t" + snp.Position + "\t";
             }
             byte alleles = genome[snp];
             if (alleles == Allele.Null) {
                 line += nullChar;
             } else {
                 line += genome[snp].ToAllelesString();
             }
             writer.WriteLine(line);
             if (progress != null) progress.Set(++count, genome.Count);
         }
     }
 }
开发者ID:Bert6623,项目名称:Gedcom.Net,代码行数:25,代码来源:GenomeFile.cs

示例7: Read23AndMeGenome

        // 23AndMe files are are made available by the 23AndMe DNA testing service to
        // their customers.

        /// <summary>
        /// Read data into the specified Genome from an individual's
        /// 23AndMe personal genome file, using the specified filename (which 
        /// may include a path). The specified SnpCollection does not need
        /// to contain all the SNPs that may be present in the genome file.
        /// The SnpCollection is used as the source of physical and cM
        /// positional information. Centimorgan values for SNPs present in
        /// the genome but not in the SnpCollection are extrapolated.
        /// The specified CancellationToken can be used to abort the read. 
        /// The progress parameter will be updated by this method with a 
        /// value of 0-100 to reflect the percent progress of the read.
        /// </summary>
        /// <param name="genome">The Genome to receive the read data.</param>
        /// <param name="snps">The SnpCollection containing reference SNP positional data.</param>
        /// <param name="filename">The path and filename of the 23AndMe genome file.</param>
        /// <param name="cancel">The CancellationToken that can be used to abort the read.</param>
        /// <param name="progress">The progress parameter that will be updated to reflect 
        /// the percent progress of the read.</param>
        private void Read23AndMeGenome(SnpCollection snps, CancellationToken cancel, Progress progress) {
            using (StreamReader reader = new StreamReader(this.filename)) {
                long length = 0;
                if (progress != null) length = reader.BaseStream.Length;
                string line;
                string[] columns = new string[4];
                while ((line = reader.ReadLine()) != null) {
                    cancel.ThrowIfCancellationRequested();
                    if ((line.Length > 0) && (line[0] != '#') && (line[0] != '-')) {
                        int colCount = line.FastSplit('\t', columns);
                        if (colCount <= 1) throw new ApplicationException("Not 23andMe format.");
                        string rsId = columns[0];
                        Snp snp = snps[rsId];
                        if ((snp == null) && (colCount == 4)) {
                            byte chr = Snp.ChromosomeToByte(columns[1]).Value;
                            if (chr <= 23) {
                                int position = Convert.ToInt32(columns[2]);
                                snp = new Snp(rsId, chr, position, snps.ExtrapolateCentiMorganPosition(chr, position), null, "");
                            }
                        }
                        if (snp != null) {
                            var alleles = columns[colCount - 1];
                            if ((alleles != null) && (snp.Chromosome == 23) && (alleles.Length == 1)) alleles += alleles;
                            this.genome.Add(snp, Allele.ToAlleles(alleles));
                        }
                    } else if ((line.Length > 0) && (genome.Count == 0) && !line.StartsWith("# rsid\t")) {
                        this.comments.Add(line);
                    }
                    if (progress != null) progress.Set(reader.BaseStream.Position, length);
                }
            }
            if (this.genome.Count < 700000) {
                this.genome.GenomeTestType = Genome.GenomeType.MeAnd23v2;
            } else {
                this.genome.GenomeTestType = Genome.GenomeType.MeAnd23v3;
            }
        }
开发者ID:Bert6623,项目名称:Gedcom.Net,代码行数:58,代码来源:GenomeFile.cs

示例8: ReadMatchWeights

        public static void ReadMatchWeights(SnpMap<MatchWeight> matchWeights, SnpCollection snps, string filename, 
            CancellationToken cancel, Progress progress) {
            if (matchWeights == null) throw new ArgumentNullException("The MatchWeights cannot be null.");
            if (snps == null) throw new ArgumentNullException("The SnpCollection cannot be null.");
            if (filename == null) throw new ArgumentNullException("filename cannot be null.");
            if (String.IsNullOrWhiteSpace(filename)) throw new ArgumentOutOfRangeException("filename cannot be empty.");

            using (StreamReader reader = new StreamReader(filename)) {
                long length = 0;
                if (progress != null) length = reader.BaseStream.Length;
                string line;
                string[] columns = new string[5];
                while ((line = reader.ReadLine()) != null) {
                    cancel.ThrowIfCancellationRequested();
                    if (line.Length > 0) {
                        line.FastSplit('\t', columns);
                        string rsId = columns[0];
                        string majorAllele = columns[1];
                        double majorWeight, minorWeight;
                        double.TryParse(columns[2], out majorWeight);
                        double.TryParse(columns[4], out minorWeight);
                        if (snps.Contains(rsId)) {
                            Snp snp = snps[rsId];
                            MatchWeight matchWeight = new MatchWeight(Convert.ToInt32(10*majorWeight), Convert.ToInt32(10*minorWeight));
                            matchWeights.Add(snp, matchWeight);
                        }
                    }
                    if (progress != null) progress.Set(reader.BaseStream.Position, length);
                }
            }
        }
开发者ID:Bert6623,项目名称:Gedcom.Net,代码行数:31,代码来源:SnpFile.cs

示例9: ReadRutgers

        /// <summary>
        /// Read data into the specified SnpCollection from the Rutgers SNP
        /// map file having the specified filename (which may include a path). 
        /// The specified CancellationToken can be used to abort the read. 
        /// The progress parameter will be updated by this method with a 
        /// value of 0-100 to reflect the percent progress of the read.
        /// </summary>
        /// </summary>
        /// <remarks>See http://compgen.rutgers.edu/RutgersMap/AffymetrixIllumina.aspx </remarks>
        /// <param name="snps">The SnpCollection to receive the read data.</param>
        /// <param name="filename">The path and filename of the Rutgers SNP map file.</param>
        /// <param name="cancel">The CancellationToken that can be used to abort the read.</param>
        /// <param name="progress">The progress parameter that will be updated to reflect 
        /// the percent progress of the read.</param>
        public static void ReadRutgers(SnpCollection snps, string filename, CancellationToken cancel, Progress progress) {
            if (snps == null) throw new ArgumentNullException("The SnpCollection cannot be null.");
            if (filename == null) throw new ArgumentNullException("filename cannot be null.");
            if (String.IsNullOrWhiteSpace(filename)) throw new ArgumentOutOfRangeException("filename cannot be empty.");

            using (StreamReader reader = new StreamReader(filename)) {
                long length = 0;
                if (progress != null) length = reader.BaseStream.Length;
                string[] columns = new string[4];
                string line;
                reader.ReadLine(); // skip header
                while ((line = reader.ReadLine()) != null) {
                    cancel.ThrowIfCancellationRequested();
                    line.FastSplit(',', columns);
                    byte? chr = Snp.ChromosomeToByte(columns[1]);
                    if (chr.HasValue && (chr.Value >= 1) && (chr.Value <= 23)) {
                        float cM;
                        Snp snp;
                        if (float.TryParse(columns[3], out cM)) {
                            snp = new Snp(columns[0], chr.Value, Convert.ToInt32(columns[2]), cM, null, null);
                        } else {
                            snp = new Snp(columns[0], chr.Value, Convert.ToInt32(columns[2]));
                        }
                        snps.Add(snp);
                    }
                    if (progress != null) progress.Set(reader.BaseStream.Position, length);
                }
            }
        }
开发者ID:Bert6623,项目名称:Gedcom.Net,代码行数:43,代码来源:SnpFile.cs

示例10: Write

 /// <summary>
 /// Write all data from the specified SnpCollection into the SnpCollection
 /// file having the specified filename (which may include a path). Any
 /// existing contents of the file will be overwritten.
 /// The specified CancellationToken can be used to abort the read. 
 /// The progress parameter will be updated by this method with a 
 /// value of 0-100 to reflect the percent progress of the read.
 /// </summary>
 /// <param name="snps">The SnpCollection containing the data to be written.</param>
 /// <param name="filename">The path and filename of the SnpCollection file.</param>
 /// <param name="cancel">The CancellationToken that can be used to abort the write.</param>
 /// <param name="progress">The progress parameter that will be updated to reflect 
 /// the percent progress of the write.</param>
 public static void Write(SnpCollection snps, string filename, CancellationToken cancel, Progress progress) {
     if (snps == null) throw new ArgumentNullException("The SnpCollection cannot be null.");
     if (filename == null) throw new ArgumentNullException("filename cannot be null.");
     if (String.IsNullOrWhiteSpace(filename)) throw new ArgumentOutOfRangeException("filename cannot be empty.");
  
     using (StreamWriter writer = new StreamWriter(filename)) {
         int count = 0;
         foreach (var snp in snps) {
             string rsid = snp.RsId;
             cancel.ThrowIfCancellationRequested();
             writer.WriteLine(rsid + "," + snp.AlfredId + "," + Snp.ChromosomeToString(snp.Chromosome)
                 + "," + snp.Position + "," + snp.cM.ToString("0.######") + "," + snp.Alleles.ToAllelesString());
             count++;
             if (progress != null) progress.Set(count, snps.Count);
         }
     }
 }
开发者ID:Bert6623,项目名称:Gedcom.Net,代码行数:30,代码来源:SnpFile.cs

示例11: Read

        public void Read(SnpCollection snps, CancellationToken cancel, Progress progress) {
            if (snps == null) throw new ArgumentNullException("The SnpCollection cannot be null.");
            if (this.filename == null) throw new ArgumentNullException("filename cannot be null.");
            if (String.IsNullOrWhiteSpace(filename)) throw new ArgumentOutOfRangeException("filename cannot be empty.");

            if (this.genome == null) {
                this.genome = new PhasedGenome(1, 23);
            } else {
                this.genome.Clear();
            }
            this.comments.Clear();
            using (StreamReader reader = new StreamReader(this.filename)) {
                long length = 0;
                if (progress != null) length = reader.BaseStream.Length;
                string line;
                string[] columns = new string[4];
                while ((line = reader.ReadLine()) != null) {
                    cancel.ThrowIfCancellationRequested();
                    if ((line.Length > 0) && (line[0] != '#')) {
                        int colCount = line.FastSplit('\t', columns);
                        if ((colCount != 2) && (colCount != 4)) throw new ApplicationException("Not phased genome format.");
                        string rsId = columns[0];
                        Snp snp = snps[rsId];
                        if (snp != null) {
                            var alleles = columns[colCount - 1];
                            var phased = new PhasedGenome.Phasing(alleles[0].ToAllele(), alleles[1].ToAllele());
                            this.genome.Add(snp, phased);
                        }
                    } else if ((line.Length > 0) && (genome.Count == 0) && (line != header)) {
                        this.comments.Add(line);
                    }
                    if (progress != null) progress.Set(reader.BaseStream.Position, length);
                }
            }
            if (String.IsNullOrWhiteSpace(genome.Name)) this.genome.Name = Path.GetFileNameWithoutExtension(filename);
        }
开发者ID:Bert6623,项目名称:Gedcom.Net,代码行数:36,代码来源:PhasedGenomeFile.cs


注:本文中的Progress.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。