1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using System.Windows.Threading;
  16. using System.IO;
  17. namespace TimeUpGoHome
  18. {
  19. /// <summary>
  20. /// MainWindow.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class MainWindow : Window
  23. {
  24. private string shouldGoHomeTime = "18:15";
  25. private string trueGoHomeTime = "";
  26. private DispatcherTimer ShowTimer;
  27. public MainWindow()
  28. {
  29. InitializeComponent();
  30. ShowTimer = new System.Windows.Threading.DispatcherTimer();
  31. ShowTimer.Tick += new EventHandler(ShowCurTimer);//起个Timer一直获取当前时间
  32. ShowTimer.Interval = new TimeSpan(0, 0, 0, 1, 0);
  33. ShowTimer.Start();
  34. this.MyText.Text = "";
  35. }
  36. public void ShowCurTimer(object sender, EventArgs e)
  37. {
  38. //"星期"+DateTime.Now.DayOfWeek.ToString(("d"))
  39. //获得星期几
  40. // this.Tt2.Text = DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("zh-cn"));
  41. //his.Tt.Text += " ";
  42. //获得年月日
  43. this.Tt2.Text = DateTime.Now.ToString("yyyy年MM月dd日"); //yyyy年MM月dd日
  44. // this.Tt.Text += " ";
  45. //获得时分
  46. this.Tt.Text = DateTime.Now.ToString("HH:mm");
  47. //System.Diagnostics.Debug.Print("this.ShowCurrentTime {0}", this.ShowCurrentTime);
  48. }
  49. private int[] GetHourAndMin(string _timer){
  50. int n = int.Parse(_timer.Substring(0, 2));
  51. int m = int.Parse(_timer.Substring(3,2));
  52. int[] to_back = new int[] { n,m};
  53. return to_back;
  54. }
  55. private int[] GetRemainHourAndMin(int smallMins1,int bigMins2){
  56. int remainMins= bigMins2-smallMins1;
  57. int remainHours=remainMins/60;
  58. int remainRemainMins=remainMins%60;
  59. int[] to_back=new int[]{remainHours,remainRemainMins};
  60. return to_back;
  61. }
  62. private int GetMins(int[] timeTable)
  63. {
  64. return timeTable[0] * 60 + timeTable[1];
  65. }
  66. private void Button_Click(object sender, RoutedEventArgs e)
  67. {
  68. string today_date = this.Tt2.Text;
  69. string trueBackHomeTime = this.Tt.Text;
  70. int[] shouldBackTimeTable = GetHourAndMin(shouldGoHomeTime);
  71. int[] trueBackTimeTable = GetHourAndMin(trueBackHomeTime);
  72. int shouldMins=GetMins(shouldBackTimeTable);
  73. int trueMins=GetMins(trueBackTimeTable);
  74. if (trueMins < shouldMins)
  75. {
  76. this.MyText.Text="时间还没到!!";
  77. }
  78. else
  79. {
  80. this.MyText.Text="";
  81. int[] remainTimes = GetRemainHourAndMin(shouldMins, trueMins);
  82. using
  83. (StreamWriter iFile = new StreamWriter("D:/AfterWorkLog/workLog.txt", true))
  84. iFile.WriteLine("加班时间:" + today_date+" "+ shouldGoHomeTime + " 到 " + trueBackHomeTime + "; 累计:" +remainTimes[0]+"小时 "+remainTimes[1]+ " 分钟");
  85. App.Current.Shutdown();
  86. }
  87. }
  88. }
  89. }
 

加班计时App的更多相关文章

  1. 强制20天加班开发app后被集体解雇,象寻技术负责人公众号发文怒斥前领导

    5月16日下午三点,象寻官方公众号发了一篇<祝象寻早日倒闭的文章>文章,文章配一个竖中指的手势.如此劲爆的文章瞬间引爆了微信朋友圈,大家纷纷分享给好友和微信群,阅读量也达到了十万+. 当时 ...

  2. 蜗牛圈圈-时尚智能的运动计时App

    Duang! 各类运动爱好者的福音来啦! 蜗牛圈圈-最智能的圈速计时助手 扫描二维码下载体验 [产品简介] -蜗牛圈圈是一款专业的圈速计时工具,帮助您获得整个运动过程中的各项数据,保存记录,分享激情. ...

  3. C Primer Plus(第五版)7

    第 7 章 C 控制语句:分支和跳转 在本章中你将学习下列内容: · 关键字:if(如果),else(否则),switch(切换),continue(继续),break(中断), case(情况),d ...

  4. node.js报错throw err; // Rethrow non-MySQL errors e:\serverTest\node_modules\mysql\lib\protocol\Parser.js:79 解决方法

    今天在用node+angular做后台时,需要使用session保存登陆状态的时候,遇到了此问题,问题直译为非mysql问题,我也在后台取到的登陆用户名和密码,确实不是数据库问题.最后发现在使用ses ...

  5. 近期热门微信小程序demo源码下载汇总

    近期微信小程序demo源码下载汇总,乃小程序学习分析必备素材!点击标题即可下载: 即速应用首发!原创!电商商场Demo 优质微信小程序推荐 -秀人美女图 图片下载.滑动翻页 微信小程序 - 新词 GE ...

  6. Prism 4 文档 ---第7章 组成用户界面

    一个应用程序的用户界面(UI)可以通用以下几种模式之一来构建: 窗体所需要所有的控件都包含在一个单独的XAML文件中,在设计时组合这个窗体. 窗体的逻辑区域被分割到单独的部分中,通常指哟过户控件.这些 ...

  7. .Net语言 APP开发平台——Smobiler学习日志:如何快速实现Timer计时功能

    最前面的话:Smobiler是一个在VS环境中使用.Net语言来开发APP的开发平台,也许比Xamarin更方便 一.目标样式 我们要实现上图中的效果,需要如下的操作: 1.从工具栏上的”Smobil ...

  8. 带你实现开发者头条APP(三) 首页实现

    title: 带你实现开发者头条APP(三) 首页实现 tags: 轮播广告,ViewPager切换,圆形图片 grammar_cjkRuby: true --- 一.前言 今天实现开发者头条APP的 ...

  9. 2016年我们重新思考移动互联网创业的风险, 微信还是APP?

    感觉这两年前端开发又火起来了,很多做内容创业和做微电商创业的人,往往都选择了运营微信号.对于做纯技术开发的人来说,一般是看不上微信号的,感觉没什么技术含量,或者说没什么技术壁垒.也有另一批人观点相反的 ...

随机推荐

  1. Windbg找出死锁

    使用Windbg找出死锁,解决生产环境中运行的软件不响应请求的问题 前言 本文介绍本人的一次使用Windbg分析dump文件找出死锁的过程,并重点介绍如何确定线程所等待的锁及判断是否出现了死锁. 对于 ...

  2. 使用Entity Framework 4进行代码优先开发

    [原文地址]Code-First Development with Entity Framework 4   .NET 4随带发布了一个改进版的Entity Framework(EF)- 一个位于Sy ...

  3. TOGAF企业连续体和工具之架构资源库及架构工具的选择

    TOGAF企业连续体和工具之架构资源库及架构工具的选择 3. 架构资源库 在一个企业,尤其是在一个大型企业中,建设一个成熟的架构往往会产生大量的工作产品.为了很好地管理和利用这些工作产品,企业需要制定 ...

  4. ASP.NET Web API 2.0新特性:Attribute Routing1

    ASP.NET Web API 2.0新特性:Attribute Routing[上篇] 对于一个针对ASP.NET Web API的调用请求来说,请求的URL和对应的HTTP方法的组合最终决定了目标 ...

  5. Erasure Coding in WAS简单译文

    原文:<Erasure Coding in Windows Azure Storage.pdf>,地址:https://www.usenix.org/system/files/confer ...

  6. 简单使用JSON,通过JSON 字符串来创建对象(二)

    把 JSON 文本转换为 JavaScript 对象 JSON 最常见的用法之一,是从 web 服务器上读取 JSON 数据(作为文件或作为 HttpRequest),将 JSON 数据转换为 Jav ...

  7. Twitter Storm:单机环境的安装与配置

    Twitter Storm:单机环境的安装与配置 好久没写博客了,这一段时间一直被导师push着做毕业设计.由于目前的方向偏向于图像识别检索,毕设打算做一个基于分布式计算平台的图像检索系统,查阅相关资 ...

  8. grunt 上手

    grunt 上手 开始上手 Grunt 和 grunt 插件都是通过 npm 安装, Node.js 包管理器管理的. Grunt 0.4.x 版本需要Node.js 版本号不低于0.8.0. 一.安 ...

  9. spi数据KL25用SPI操作nor flash

    最近研究spi数据,稍微总结一下,以后继续补充: KL25的SPI连接一个nor flash.该flash型号为FM25F04,支撑SPI的模式0和模式3,要求高位先发送,在上升沿采集数据. 通常,S ...

  10. 我是实践派之mongo的一主多从

    mongo一主多从 为什么要做一主多从? mongodb天生就是为了分布式而生的,为了保证数据读写分离和数据安全,把数据放在不同的机子上,可以减少主节点的读压力,而让从节点去承受读请求压力. 主节点用 ...