{"id":2242,"date":"2018-03-14T16:32:31","date_gmt":"2018-03-14T07:32:31","guid":{"rendered":"http:\/\/okamurax.com\/?p=2242"},"modified":"2020-05-05T23:02:43","modified_gmt":"2020-05-05T14:02:43","slug":"c-%e3%83%87%e3%82%b9%e3%82%af%e3%83%88%e3%83%83%e3%83%97%e3%81%ab%e6%a4%9c%e7%b4%a2%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=2242","title":{"rendered":"C# \u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u306b\u691c\u7d22\u30dc\u30c3\u30af\u30b9"},"content":{"rendered":"<p>\u6614\u3001\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u306b\u691c\u7d22\u30dc\u30c3\u30af\u30b9\u3092\u8868\u793a\u3059\u308b\u30a2\u30d7\u30ea\u304c\u3042\u3063\u305f\u6c17\u304c\u3057\u3066\u3001\u540c\u3058\u3088\u3046\u306a\u3082\u306e\u3092\u4f5c\u308a\u306f\u3058\u3081\u3066\u307f\u305f\u304c\u3001\u3069\u3046\u3082\u4f7f\u308f\u306a\u305d\u3046\u306a\u306e\u3067\u4e2d\u6b62\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 \u691c\u7d22\u30dc\u30c3\u30af\u30b9\r\n{\r\n    public partial class Form1 : Form\r\n    {\r\n        private Point mouse_point;\r\n        public Form1()\r\n        {\r\n            InitializeComponent();\r\n\r\n            load_xml();\r\n\r\n            NotifyIcon ic = new NotifyIcon();\r\n            ic.Visible = true;\r\n            ic.Icon = Icon;\r\n            ic.MouseDoubleClick += new MouseEventHandler((object sender, MouseEventArgs e) =&gt; {\r\n                this.Close();\r\n            });\r\n\r\n            this.ShowInTaskbar = false;\r\n\r\n            this.FormBorderStyle = FormBorderStyle.None;\r\n            this.TransparencyKey = this.BackColor;\r\n\r\n            this.comboBox1.AutoCompleteMode = AutoCompleteMode.Append;\r\n            this.comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;\r\n\r\n            this.comboBox1.MouseDown += new MouseEventHandler((object sender, MouseEventArgs e)=&gt; {\r\n                if(e.Button == MouseButtons.Left)\r\n                {\r\n                    mouse_point = new Point(e.X, e.Y);\r\n                }\r\n            });\r\n            this.comboBox1.MouseMove += new MouseEventHandler((object sender, MouseEventArgs e)=&gt; {\r\n                if(e.Button == MouseButtons.Left)\r\n                {\r\n                    this.Left += e.X - mouse_point.X;\r\n                    this.Top += e.Y - mouse_point.Y;\r\n                }\r\n            });\r\n            this.comboBox1.KeyDown  += new KeyEventHandler((object sender, KeyEventArgs e) =&gt; {\r\n                if(e.KeyCode == Keys.Enter)\r\n                {\r\n                    string tmp = Uri.EscapeDataString(comboBox1.Text);\r\n                    System.Diagnostics.Process.Start(@\"https:\/\/www.google.co.jp\/search?q=\" + tmp);\r\n                    comboBox1.Items.Add(comboBox1.Text);\r\n                    save_xml();\r\n                }\r\n            });\r\n        }\r\n        private void load_xml()\r\n        {\r\n            if (!System.IO.File.Exists(Application.StartupPath + @\"\\dat.xml\")) return;\r\n\r\n            System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(string[]));\r\n            System.IO.StreamReader sr = new System.IO.StreamReader(Application.StartupPath + @\"\\dat.xml\", new UTF8Encoding(false));\r\n            string[] items = (string[])xs.Deserialize(sr);\r\n            comboBox1.Items.AddRange(items);\r\n            sr.Close();\r\n        }\r\n\r\n        private void save_xml()\r\n        {\r\n            System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(string[]));\r\n            System.IO.StreamWriter sw = new System.IO.StreamWriter(Application.StartupPath + @\"\\dat.xml\", false, new UTF8Encoding(false));\r\n            List&lt;string&gt; items = comboBox1.Items.Cast&lt;string&gt;().ToList();\r\n            xs.Serialize(sw, items.ToArray());\r\n            sw.Close();\r\n        }\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6614\u3001\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u306b\u691c\u7d22\u30dc\u30c3\u30af\u30b9\u3092\u8868\u793a\u3059\u308b\u30a2\u30d7\u30ea\u304c\u3042\u3063\u305f\u6c17\u304c\u3057\u3066\u3001\u540c\u3058\u3088\u3046\u306a\u3082\u306e\u3092\u4f5c\u308a\u306f\u3058\u3081\u3066\u307f\u305f\u304c\u3001\u3069\u3046\u3082\u4f7f\u308f\u306a\u305d\u3046\u306a\u306e\u3067\u4e2d\u6b62\u3002 using System; using System.Collections.Generi &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=2242\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# \u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u306b\u691c\u7d22\u30dc\u30c3\u30af\u30b9&#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-2242","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\/2242","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=2242"}],"version-history":[{"count":6,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2242\/revisions"}],"predecessor-version":[{"id":3417,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2242\/revisions\/3417"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}