{"id":2252,"date":"2018-03-21T02:39:24","date_gmt":"2018-03-20T17:39:24","guid":{"rendered":"http:\/\/okamurax.com\/?p=2252"},"modified":"2020-05-05T23:02:23","modified_gmt":"2020-05-05T14:02:23","slug":"c-%e5%8d%b3%e5%b8%ad%e5%ad%a6%e7%bf%92%e3%82%bf%e3%82%a4%e3%83%9e%e3%83%bc","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=2252","title":{"rendered":"C# \u5373\u5e2d\u5b66\u7fd2\u30bf\u30a4\u30de\u30fc"},"content":{"rendered":"<p>\u30bd\u30d5\u30c8\u306e\u8d77\u52d5\u3067\u8a08\u6e2c\u3092\u958b\u59cb\u3001\u7d42\u4e86\u3067\u505c\u6b62\u3059\u308b\u3060\u3051\u306e\u5358\u7d14\u306a\u30bf\u30a4\u30de\u30fc\u3002\u81ea\u5206\u306e\u30e2\u30c1\u30d9\u30fc\u30b7\u30e7\u30f3\u30a2\u30c3\u30d7\u7528\u3002<br \/>\n\u6642\u9593\u306e\u30ea\u30bb\u30c3\u30c8\u306fdat.xml\u3092\u524a\u9664\u3002C\u30c9\u30e9\u30a4\u30d6\u306a\u3069\u3067\u5b9f\u884c\u3059\u308b\u3068\u843d\u3061\u308b\u3002<br \/>\n\u4ee5\u524d\u3082\u4f3c\u305f\u3088\u3046\u306a\u30bd\u30d5\u30c8\u3092\u4f5c\u308d\u3046\u3068\u3057\u3066\u3044\u305f\u304c\u3001\u9762\u5012\u306b\u306a\u3063\u305f\u306e\u3067\u30b7\u30f3\u30d7\u30eb\u306b\u3057\u305f\u3002<\/p>\n<pre class=\"lang:c# decode:true \">using System;\r\nusing System.Collections.Generic;\r\nusing System.ComponentModel;\r\nusing System.Data;\r\nusing System.Drawing;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\nusing System.Windows.Forms;\r\n\r\nnamespace study_timer_simple\r\n{\r\n    public partial class Form1 : Form\r\n    {\r\n        public Form1()\r\n        {\r\n            InitializeComponent();\r\n\r\n            string path = Application.StartupPath + @\"\\dat.xml\";\r\n            TimeSpan load_time_span = new TimeSpan();\r\n\r\n            if (System.IO.File.Exists(path))\r\n            {\r\n                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(int[]));\r\n                System.IO.StreamReader sr = new System.IO.StreamReader(path, new UTF8Encoding(false));\r\n                int[] ts = (int[])x.Deserialize(sr);\r\n                load_time_span = new TimeSpan(ts[0], ts[1], ts[2], ts[3]);\r\n                sr.Close();\r\n            }\r\n\r\n            TimeSpan current_time_span = new TimeSpan();\r\n\r\n            DateTime original_dt = DateTime.Now;\r\n            Timer t = new Timer();\r\n            t.Tick += new EventHandler((object t_sender, EventArgs t_e) =&gt; {\r\n            current_time_span = (DateTime.Now - original_dt);\r\n\r\n                int h = (load_time_span + current_time_span).Days * 24 + (load_time_span + current_time_span).Hours;\r\n                label1.Text = h.ToString() + \"\u6642\u9593\" + (load_time_span + current_time_span).ToString(@\"mm\\\u5206ss\\\u79d2\");\r\n            });\r\n            t.Start();\r\n\r\n            this.FormClosed += new FormClosedEventHandler((object sender, FormClosedEventArgs e) =&gt; {\r\n                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(int[]));\r\n                System.IO.StreamWriter sw = new System.IO.StreamWriter(path, false, new UTF8Encoding(false));\r\n\r\n                x.Serialize(sw, new int[] {\r\n                    (int)(load_time_span + current_time_span).Days,\r\n                    (int)(load_time_span + current_time_span).Hours,\r\n                    (int)(load_time_span + current_time_span).Minutes,\r\n                    (int)(load_time_span + current_time_span).Seconds\r\n                });\r\n                sw.Close();\r\n            });\r\n\r\n        }\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u30bd\u30d5\u30c8\u306e\u8d77\u52d5\u3067\u8a08\u6e2c\u3092\u958b\u59cb\u3001\u7d42\u4e86\u3067\u505c\u6b62\u3059\u308b\u3060\u3051\u306e\u5358\u7d14\u306a\u30bf\u30a4\u30de\u30fc\u3002\u81ea\u5206\u306e\u30e2\u30c1\u30d9\u30fc\u30b7\u30e7\u30f3\u30a2\u30c3\u30d7\u7528\u3002 \u6642\u9593\u306e\u30ea\u30bb\u30c3\u30c8\u306fdat.xml\u3092\u524a\u9664\u3002C\u30c9\u30e9\u30a4\u30d6\u306a\u3069\u3067\u5b9f\u884c\u3059\u308b\u3068\u843d\u3061\u308b\u3002 \u4ee5\u524d\u3082\u4f3c\u305f\u3088\u3046\u306a\u30bd\u30d5\u30c8\u3092\u4f5c\u308d\u3046\u3068\u3057\u3066\u3044\u305f\u304c\u3001\u9762\u5012\u306b\u306a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=2252\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# \u5373\u5e2d\u5b66\u7fd2\u30bf\u30a4\u30de\u30fc&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9],"class_list":["post-2252","post","type-post","status-publish","format-standard","hentry","category-1","tag-c-net"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2252"}],"version-history":[{"count":2,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2252\/revisions"}],"predecessor-version":[{"id":3416,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2252\/revisions\/3416"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}