{"id":1277,"date":"2017-04-27T02:52:29","date_gmt":"2017-04-26T17:52:29","guid":{"rendered":"http:\/\/okamurax.com\/?p=1277"},"modified":"2017-04-27T02:52:29","modified_gmt":"2017-04-26T17:52:29","slug":"c-%e5%8d%b3%e5%b8%ad%e3%82%bf%e3%82%a4%e3%83%9e%e3%83%bc","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=1277","title":{"rendered":"C# \u5373\u5e2d\u30bf\u30a4\u30de\u30fc"},"content":{"rendered":"<p>\u4f55\u304b\u52c9\u5f37\u3059\u308b\u3068\u304d\u6642\u9593\u3092\u8a18\u9332\u3059\u308b\u3068\u3044\u3044\u306e\u304b\u3082\u3068\u601d\u3063\u305f\u306e\u3067\u3002<\/p>\n<pre class=\"lang:c# decode:true \">using System;\r\nusing System.Windows.Forms;\r\n\r\nusing System.Xml.Serialization;\r\nusing System.IO;\r\n\r\nnamespace StudyTimer\r\n{\r\n    public partial class Form1 : Form\r\n    {\r\n        private DateTime Times;\r\n        \r\n        public Form1()\r\n        {\r\n            InitializeComponent();\r\n\r\n            this.label1.Text = \"00:00:00\";\r\n\r\n            if (this.textBox1.Text == \"\") this.textBox1.Text = \"0\";\r\n            if (this.textBox2.Text == \"\") this.textBox2.Text = \"0\";\r\n\r\n            timer1.Tick += new EventHandler((object sender, EventArgs e) =&gt; {\r\n                this.label1.Text = (DateTime.Now - Times).ToString(@\"hh\\:mm\\:ss\");\r\n            });\r\n\r\n            XmlSerializer xs = new XmlSerializer(typeof(int));\r\n            using (StreamReader sr = new StreamReader(Application.StartupPath + @\"\\dat\", new System.Text.UTF8Encoding(false)))\r\n            {\r\n                try\r\n                {\r\n                    this.textBox1.Text = xs.Deserialize(sr).ToString();\r\n                    this.textBox2.Text = (int.Parse(this.textBox1.Text) \/ 60).ToString();\r\n                }\r\n                catch\r\n                {\r\n                    MessageBox.Show(\"\u8aad\u8fbc\u5931\u6557\");\r\n                    return;\r\n                }\r\n                finally\r\n                {\r\n                    sr.Close();\r\n                }\r\n            }\r\n        }\r\n\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            timer1.Start();\r\n            Times = DateTime.Now;\r\n        }\r\n\r\n        private void button2_Click(object sender, EventArgs e)\r\n        {\r\n            if (timer1.Enabled)\r\n            {\r\n                timer1.Stop();\r\n            }\r\n        }\r\n\r\n        private void button3_Click(object sender, EventArgs e)\r\n        {\r\n            if (timer1.Enabled)\r\n            {\r\n                timer1.Stop();\r\n            }\r\n            this.label1.Text = \"00:00:00\";\r\n        }\r\n\r\n        private void Serialize()\r\n        {\r\n            XmlSerializer xs = new XmlSerializer(typeof(int));\r\n            using (StreamWriter sw = new StreamWriter(Application.StartupPath + @\"\\dat\", false, new System.Text.UTF8Encoding(false)))\r\n            {\r\n                try\r\n                {\r\n                    xs.Serialize(sw,int.Parse(this.textBox1.Text));\r\n                }\r\n                catch\r\n                {\r\n                    MessageBox.Show(\"\u4fdd\u5b58\u5931\u6557\");\r\n                    return;\r\n                }\r\n                finally\r\n                {\r\n                    sw.Close();\r\n                }\r\n            }\r\n        }\r\n\r\n        private void button4_Click(object sender, EventArgs e)\r\n        {\r\n            DateTime t = DateTime.Parse(label1.Text);\r\n            int m = t.Minute + int.Parse(this.textBox1.Text);\r\n            this.textBox1.Text = m.ToString();\r\n            this.textBox2.Text = (m \/ 60).ToString();\r\n\r\n            Serialize();\r\n        }\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4f55\u304b\u52c9\u5f37\u3059\u308b\u3068\u304d\u6642\u9593\u3092\u8a18\u9332\u3059\u308b\u3068\u3044\u3044\u306e\u304b\u3082\u3068\u601d\u3063\u305f\u306e\u3067\u3002 using System; using System.Windows.Forms; using System.Xml.Serialization; using S &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=1277\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# \u5373\u5e2d\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-1277","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\/1277","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=1277"}],"version-history":[{"count":1,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/1277\/revisions"}],"predecessor-version":[{"id":1278,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/1277\/revisions\/1278"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}