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


C# TimeSpan.Format方法代码示例

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


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

示例1: toTimeMedia

        public static string toTimeMedia(this FileInfo file)
        {
            ShellFile so = ShellFile.FromFilePath(file.FullName);
            double nanoseconds;
            double.TryParse(so.Properties.System.Media.Duration.Value.ToString(), out nanoseconds);
            TimeSpan tmp = new TimeSpan();
            if (nanoseconds > 0)
            {
                double seconds = nanoseconds / 10000000;
                tmp = seconds.secondToTimeSpan();

            }
            return tmp.Format();
        }
开发者ID:iceriver102,项目名称:alta-mtc-version-2,代码行数:14,代码来源:FileExtensions.cs

示例2: MultipleConfigurationProgressHandler

        public void MultipleConfigurationProgressHandler(object o, ProgressCallbackEventArgs progressArgs)
        {
            if (this.m_FormClosed)
            {
                // if form is closed we have no access to controls
                this.MasterInterpreter.Cancel();
                return;
            }

            this.m_stopwatch.Start();

            this.progressBarMultiple.Value = Math.Min((int)progressArgs.Percent, 100);

            if (progressArgs.Configuration == null)
            {
                this.lblMultiple.Text = string.Format("{0} - {1}", progressArgs.Context, progressArgs.Title);
            }
            else
            {
                this.lblMultiple.Text = string.Format("{0} - [{1}] - {2}", progressArgs.Context, progressArgs.Configuration, progressArgs.Title);
            }

            if (progressArgs.Percent == 0)
            {
                this.lblTimeEstimate.Text = "Calculating remaining time...";
            }
            else
            {
                TimeSpan remaining = new TimeSpan(this.m_stopwatch.Elapsed.Ticks * (long)((100 - progressArgs.Percent) / progressArgs.Percent));
                // TODO: make this label more user friendly
                this.lblTimeEstimate.Text = string.Format("Estimated remaining time: {0}.", remaining.Format());
            }

            if (progressArgs.Percent == 100)
            {
                if (this.IsDisposed == false)
                {
                    this.m_RaiseExceptionOnClose = false;
                    this.m_UserCancelled = false;
                    this.Close();
                }
            }
        }
开发者ID:neemask,项目名称:meta-core,代码行数:43,代码来源:ProgressDialog.cs

示例3: ExtractHeightfield

        /// <summary>
        ///  Extracts all heightfields of the given map
        /// </summary>
        public static bool ExtractHeightfield(MapId mapId)
        {
            var name = TileIdentifier.GetName(mapId);
            if (string.IsNullOrEmpty(name))
            {
                Console.WriteLine(@"No ADT for map {0}.", mapId);
                return false;
            }

            // get started
            var mpqFinder = WCellTerrainSettings.GetDefaultMPQFinder();

            // Create WDT
            var wdt = new WDT(mapId);

            var startTime = DateTime.Now;

            // compute total size
            Console.Write(@"Estimating workload... ");
            var totalAmount = 0;
            var archives = new HashSet<string>();
            for (var tileX = 0; tileX < TerrainConstants.TilesPerMapSide; tileX++)
            {
                for (var tileY = 0; tileY < TerrainConstants.TilesPerMapSide; tileY++)
                {
                    var fname = ADTReader.GetFilename(mapId, tileX, tileY);
                    var archive = mpqFinder.GetArchive(fname);
                    if (archive != null && archive.GetFileSize(fname) > 0)
                    {
                        //totalSize += archive.GetFileSize(fname);
                        ++totalAmount;
                        archives.Add(archive.Path);
                    }
                }
            }
            Console.WriteLine(@"Done - Found {0} tiles in {1} files.", totalAmount, archives.Count);

            // Get cooking:
            Console.WriteLine();
            Console.WriteLine("Extracting...");

            // Load all ADTs and write them to file
            var processedTiles = 0;
            for (var tileX = 0; tileX < TerrainConstants.TilesPerMapSide; tileX++)
            {
                for (var tileY = 0; tileY < TerrainConstants.TilesPerMapSide; tileY++)
                {
                    try
                    {
                        var fname = ADTReader.GetFilename(mapId, tileX, tileY);
                        long fsize;
                        var archive = mpqFinder.GetArchive(fname);
                        if (archive != null && (fsize = archive.GetFileSize(fname)) > 0)
                        {
                            //processedSize += fsize;

                            var adt = ADTReader.ReadADT(wdt, tileX, tileY, false);
                            Console.Write(@"Tile ({0}, {1}) in Map {2} has been read from {3}. Writing... ",
                                tileX, tileY, mapId, Path.GetFileName(archive.Path));

                            // write to file
                            WriteHeightfield(adt);

                            // stats
                            ++processedTiles;
                            var timePassed = DateTime.Now - startTime;
                            var timePerTile = timePassed.Ticks / processedTiles;
                            var progress = processedTiles / (float)totalAmount;
                            var timeRemaining = new TimeSpan((totalAmount - processedTiles) * timePerTile);
                            Console.WriteLine(@"Done. [{0}/{1} {2:F2}% - {3} (Remaining: {4})]",
                                processedTiles,
                                totalAmount,
                                100 * progress,
                                timePassed.Format(),
                                timeRemaining.Format());
                            continue;
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine();
                        LogUtil.ErrorException(e, @"Extraction FAILED: Tile ({0}, {1}) in Map {2} could not be loaded", tileX, tileY, mapId);
                        return false;
                    }
                }
            }
            return true;
        }
开发者ID:KroneckerX,项目名称:WCell,代码行数:91,代码来源:HeightfieldExtractor.cs

示例4: drawScaleText

        private void drawScaleText(Graphics gc)
        {
            bool colHangOver = (LeftColumn > 0 && LeftColumn + DisplayedColumnCount > ColumnCount);
            int xLeft = colHangOver ? (ViewRectangle.Width - DisplayedColumnCount * _colWidth) : 0;

            double ticksPerInterval = _sched.TicksPerSec * _scaleInterval.TotalSeconds;
            int colLeft = (colHangOver ? LeftColumn - 1 : LeftColumn);
            int firstInterval = (int)Math.Ceiling(colLeft / ticksPerInterval);
            double pixPerInterval = ticksPerInterval * _colWidth;
            double xFirst = (pixPerInterval * firstInterval) - (colLeft * _colWidth);
            int nInterval = firstInterval;
            for (double x = xFirst + xLeft; x < ViewRectangle.Width; x += pixPerInterval, nInterval++)
            {
                TimeSpan interval = new TimeSpan(_scaleInterval.Ticks * (long)nInterval);
                gc.DrawString(interval.Format((int)_sched.TicksPerSec, _scaleFormat), _scaleFont, _scaleColor,
                    new RectangleF((int)x + 2, 2, _colWidth - 4, _scaleHeight - 4));
            }
        }
开发者ID:Veggie13,项目名称:Genesis,代码行数:18,代码来源:ScheduleView.cs


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