zoukankan      html  css  js  c++  java
  • 应用程序在状态栏展示时间(C#)

      private DispatcherTimer _timer;

       private void SetTimeElaspInStatusBar()

            {

                try

                {

                   

                    _timer = new DispatcherTimer();

                    _timer.Tick += (sender, e) =>

                    {

                        DateTime dtNow = DateTime.Now;

                        TimeSpan interval = dtNow - _enterSystemTime;

     

                        this.barElapsedTime.Content = null;

     

                        #region

     

                        TimeZoneInfo currentTimeZone = TimeZoneUtil.GetLocalTimeZone();

                        if (currentTimeZone != null)

                        {

                            string str = currentTimeZone.Id;

     

                            this.barElapsedTime.Content += "     Local Time(" + str + " )"

                                + ": "

                                + dtNow.ToString("MM/dd/yyyy HH:mm:ss");

     

                            //DateTimeUtil.ConvertToUniversalTimeString(this._enterSystemTime, "MM/dd/yyyy HH:mm:ss");

                        }

     

                        //this.barElapsedTime.Content += "     UTC Time : "

                        //    + DateTimeUtil.ConvertToUniversalTimeString(dtNow, "MM/dd/yyyy HH:mm:ss");

     

                        DateTime? dtUTC =TimeZoneUtil.ConvertTimeToUTC(dtNow);

                    

                        if (dtUTC != null)

                        {

                            this.barElapsedTime.Content += "     UTC Time : "

                                +((DateTime)dtUTC).ToString("MM/dd/yyyy HH:mm:ss");

                        }

     

     

                        ////Convert To "Central America Standard Time"

                        //DateTime? dtUSCenter = TimeZoneUtil.ConvertFromUTC((DateTime)dtUTC, "Central America Standard Time");

     

                        //if (dtUSCenter != null)

                        //{

     

                        //    this.barElapsedTime.Content += "     UTC Time to  Central America Standard Time: "

                        //                               + ((DateTime)dtUSCenter).ToString("MM/dd/yyyy HH:mm:ss");

                        //}

     

                        #endregion

     

                        this.barElapsedTime.Content += "        Elapsed Time: " + (interval.Days > 0 ? interval.Days + " day(s) " : "") +

                           new DateTime(1900, 1, 1, interval.Hours, interval.Minutes, interval.Seconds).ToString("HH:mm:ss");

     

                        //

                        if (EventBinder.SystemTimeOutCheck.IsCheckTimeOut)

                        {

                            EventBinder.SystemTimeOutCheck.Check();

                        }

                       // SystemThreadStarter.StartGetUrlThread();

                    };

                    _timer.Interval = TimeSpan.FromSeconds(1);

                    _timer.Start();

                }

                catch (Exception ex)

                {

                    MessageBox.Show(ex.Message);

                }

            }

  • 相关阅读:
    VA对于开发QT是神器,VA自动补全QT
    64位下好神奇啊(增加了PatchGuard技术保护自己,SSDT是相对地址,参数通过寄存器与rdi来传递)
    贵在坚持
    VC程序查错之内存访问异常
    QT源码解析(一) QT创建窗口程序、消息循环和WinMain函数
    QTimer源码分析(以Windows下实现为例)
    Go语言的优点(oschina讨论)
    致诸位新程序员:来自Chuck Jazdzewski慈父般的忠告
    poj1483 It's not a Bug, It's a Feature!
    App应用与思考
  • 原文地址:https://www.cnblogs.com/quietwalk/p/3530955.html
Copyright © 2011-2022 走看看