OSDN Git Service

Port bing.vb and Outputz.vb to C#
authorKimura Youichi <kim.upsilon@bucyou.net>
Sun, 4 Dec 2011 02:45:33 +0000 (11:45 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Wed, 22 Feb 2012 10:47:44 +0000 (19:47 +0900)
Tween/Outputz.vb [deleted file]
Tween/Tween.vbproj
Tween/bing.vb [deleted file]
TweenCS/Bing.cs [new file with mode: 0644]
TweenCS/Outputz.cs [new file with mode: 0644]
TweenCS/TweenCS.csproj

diff --git a/Tween/Outputz.vb b/Tween/Outputz.vb
deleted file mode 100644 (file)
index 6106855..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-' Tween - Client of Twitter
-' Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
-'           (c) 2008-2011 Moz (@syo68k)
-'           (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
-'           (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
-'           (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
-' All rights reserved.
-' 
-' This file is part of Tween.
-' 
-' This program is free software; you can redistribute it and/or modify it
-' under the terms of the GNU General Public License as published by the Free
-' Software Foundation; either version 3 of the License, or (at your option)
-' any later version.
-' 
-' This program is distributed in the hope that it will be useful, but
-' WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-' or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-' for more details. 
-' 
-' You should have received a copy of the GNU General Public License along
-' with this program. If not, see <http://www.gnu.org/licenses/>, or write to
-' the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
-' Boston, MA 02110-1301, USA.
-
-Imports System.Web
-Imports System.Net
-Imports System.Collections.Generic
-
-Public Class Outputz
-    Private Shared myOuturl As String
-    Private Shared myApikey As String
-
-    Private Shared state As Boolean
-
-    Public Shared Property OutUrl() As String
-        Get
-            Return myOuturl
-        End Get
-        Set(ByVal value As String)
-            myOuturl = value
-        End Set
-    End Property
-
-    Public Shared Property Key() As String
-        Get
-            Return myApikey
-        End Get
-        Set(ByVal value As String)
-            myApikey = value
-        End Set
-    End Property
-
-    Public Shared Property Enabled() As Boolean
-        Get
-            Return state
-        End Get
-        Set(ByVal value As Boolean)
-            state = value
-        End Set
-    End Property
-
-    Public Function Post(ByVal length As Integer) As Boolean
-
-        If state = False Then Return True
-
-        Dim content As String = ""
-        Dim output As String = "http://outputz.com/api/post"
-        Dim param As New Dictionary(Of String, String)
-        param.Add("key", myApikey)
-        param.Add("uri", myOuturl)
-        param.Add("size", length.ToString)
-
-        Return (New HttpVarious).PostData(output, param)
-    End Function
-End Class
index ebfe98c..797111b 100644 (file)
     <Compile Include="AuthBrowser.vb">
       <SubType>Form</SubType>
     </Compile>
-    <Compile Include="bing.vb" />
     <Compile Include="Connection\HttpConnectionOAuthEcho.vb" />
     <Compile Include="Connection\HttpOAuthApiProxy.vb" />
     <Compile Include="Connection\HttpConnectionOAuth.vb" />
     </Compile>
     <Compile Include="MySpecialPath.vb" />
     <Compile Include="nicoms.vb" />
-    <Compile Include="Outputz.vb" />
     <Compile Include="RadixConvert.vb" />
     <Compile Include="Setting\SettingAtIdList.vb" />
     <Compile Include="Setting\SettingLocal.vb" />
diff --git a/Tween/bing.vb b/Tween/bing.vb
deleted file mode 100644 (file)
index f94eba5..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-Public Class Bing
-
-    Private Const AppId As String = "ABD3DFF1AB47F3899A2203E0C5873CBE3E14E8D3"
-
-#Region "言語テーブル定義"
-    Private Shared ReadOnly LanguageTable As New List(Of String) From {
-        "af",
-        "sq",
-        "ar-sa",
-        "ar-iq",
-        "ar-eg",
-        "ar-ly",
-        "ar-dz",
-        "ar-ma",
-        "ar-tn",
-        "ar-om",
-        "ar-ye",
-        "ar-sy",
-        "ar-jo",
-        "ar-lb",
-        "ar-kw",
-        "ar-ae",
-        "ar-bh",
-        "ar-qa",
-        "eu",
-        "bg",
-        "be",
-        "ca",
-        "zh-tw",
-        "zh-cn",
-        "zh-hk",
-        "zh-sg",
-        "hr",
-        "cs",
-        "da",
-        "nl",
-        "nl-be",
-        "en",
-        "en-us",
-        "en-gb",
-        "en-au",
-        "en-ca",
-        "en-nz",
-        "en-ie",
-        "en-za",
-        "en-jm",
-        "en",
-        "en-bz",
-        "en-tt",
-        "et",
-        "fo",
-        "fa",
-        "fi",
-        "fr",
-        "fr-be",
-        "fr-ca",
-        "fr-ch",
-        "fr-lu",
-        "gd",
-        "ga",
-        "de",
-        "de-ch",
-        "de-at",
-        "de-lu",
-        "de-li",
-        "el",
-        "he",
-        "hi",
-        "hu",
-        "is",
-        "id",
-        "it",
-        "it-ch",
-        "ja",
-        "ko",
-        "ko",
-        "lv",
-        "lt",
-        "mk",
-        "ms",
-        "mt",
-        "no",
-        "no",
-        "pl",
-        "pt-br",
-        "pt",
-        "rm",
-        "ro",
-        "ro-mo",
-        "ru",
-        "ru-mo",
-        "sz",
-        "sr",
-        "sr",
-        "sk",
-        "sl",
-        "sb",
-        "es",
-        "es-mx",
-        "es-gt",
-        "es-cr",
-        "es-pa",
-        "es-do",
-        "es-ve",
-        "es-co",
-        "es-pe",
-        "es-ar",
-        "es-ec",
-        "es-cl",
-        "es-uy",
-        "es-py",
-        "es-bo",
-        "es-sv",
-        "es-hn",
-        "es-ni",
-        "es-pr",
-        "sx",
-        "sv",
-        "sv-fi",
-        "th",
-        "ts",
-        "tn",
-        "tr",
-        "uk",
-        "ur",
-        "ve",
-        "vi",
-        "xh",
-        "ji",
-        "zu"
-    }
-#End Region
-
-#Region "Translation"
-
-    Private Const TranslateUri As String = "http://api.microsofttranslator.com/v2/Http.svc/Translate?appId=" + AppId
-
-    Public Function Translate(ByVal _from As String,
-                                ByVal _to As String,
-                                ByVal _text As String,
-                                ByRef buf As String) As Boolean
-
-        Dim http As New HttpVarious()
-        Dim apiurl As String = TranslateUri + "&text=" + System.Web.HttpUtility.UrlEncode(_text) + "&to=" + _to
-        Dim content As String = ""
-        If http.GetData(apiurl, Nothing, content) Then
-            buf = String.Copy(content)
-            Return True
-        End If
-        Return False
-    End Function
-
-    Public Function GetLanguageEnumFromIndex(ByVal index As Integer) As String
-        Return LanguageTable(index)
-    End Function
-
-    Public Function GetIndexFromLanguageEnum(ByVal lang As String) As Integer
-        Return LanguageTable.IndexOf(lang)
-    End Function
-#End Region
-End Class
diff --git a/TweenCS/Bing.cs b/TweenCS/Bing.cs
new file mode 100644 (file)
index 0000000..271c705
--- /dev/null
@@ -0,0 +1,196 @@
+// Tween - Client of Twitter
+// Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
+//           (c) 2008-2011 Moz (@syo68k)
+//           (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
+//           (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
+//           (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
+//           (c) 2011      kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// All rights reserved.
+// 
+// This file is part of Tween.
+// 
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+// 
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details. 
+// 
+// You should have received a copy of the GNU General Public License along
+// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Tween
+{
+    public class Bing
+    {
+        private const string AppId = "ABD3DFF1AB47F3899A2203E0C5873CBE3E14E8D3";
+
+#region "言語テーブル定義"
+        private static readonly List<string> LanguageTable = new List<string>() {
+        "af",
+        "sq",
+        "ar-sa",
+        "ar-iq",
+        "ar-eg",
+        "ar-ly",
+        "ar-dz",
+        "ar-ma",
+        "ar-tn",
+        "ar-om",
+        "ar-ye",
+        "ar-sy",
+        "ar-jo",
+        "ar-lb",
+        "ar-kw",
+        "ar-ae",
+        "ar-bh",
+        "ar-qa",
+        "eu",
+        "bg",
+        "be",
+        "ca",
+        "zh-tw",
+        "zh-cn",
+        "zh-hk",
+        "zh-sg",
+        "hr",
+        "cs",
+        "da",
+        "nl",
+        "nl-be",
+        "en",
+        "en-us",
+        "en-gb",
+        "en-au",
+        "en-ca",
+        "en-nz",
+        "en-ie",
+        "en-za",
+        "en-jm",
+        "en",
+        "en-bz",
+        "en-tt",
+        "et",
+        "fo",
+        "fa",
+        "fi",
+        "fr",
+        "fr-be",
+        "fr-ca",
+        "fr-ch",
+        "fr-lu",
+        "gd",
+        "ga",
+        "de",
+        "de-ch",
+        "de-at",
+        "de-lu",
+        "de-li",
+        "el",
+        "he",
+        "hi",
+        "hu",
+        "is",
+        "id",
+        "it",
+        "it-ch",
+        "ja",
+        "ko",
+        "ko",
+        "lv",
+        "lt",
+        "mk",
+        "ms",
+        "mt",
+        "no",
+        "no",
+        "pl",
+        "pt-br",
+        "pt",
+        "rm",
+        "ro",
+        "ro-mo",
+        "ru",
+        "ru-mo",
+        "sz",
+        "sr",
+        "sr",
+        "sk",
+        "sl",
+        "sb",
+        "es",
+        "es-mx",
+        "es-gt",
+        "es-cr",
+        "es-pa",
+        "es-do",
+        "es-ve",
+        "es-co",
+        "es-pe",
+        "es-ar",
+        "es-ec",
+        "es-cl",
+        "es-uy",
+        "es-py",
+        "es-bo",
+        "es-sv",
+        "es-hn",
+        "es-ni",
+        "es-pr",
+        "sx",
+        "sv",
+        "sv-fi",
+        "th",
+        "ts",
+        "tn",
+        "tr",
+        "uk",
+        "ur",
+        "ve",
+        "vi",
+        "xh",
+        "ji",
+        "zu"
+    };
+#endregion
+
+#region "Translation"
+
+        private const string TranslateUri = "http://api.microsofttranslator.com/v2/Http.svc/Translate?appId=" + AppId;
+
+        public bool Translate(string _from, string _to, string _text, out string buf)
+        {
+            HttpVarious http = new HttpVarious();
+            string apiurl = TranslateUri + "&text=" + System.Web.HttpUtility.UrlEncode(_text) + "&to=" + _to;
+            string content = "";
+            if (http.GetData(apiurl, null, out content))
+            {
+                buf = string.Copy(content);
+                return true;
+            }
+            buf = null;
+            return false;
+        }
+
+        public string GetLanguageEnumFromIndex(int index)
+        {
+            return LanguageTable[index];
+        }
+
+        public int GetIndexFromLanguageEnum(string lang)
+        {
+            return LanguageTable.IndexOf(lang);
+        }
+#endregion
+    }
+}
diff --git a/TweenCS/Outputz.cs b/TweenCS/Outputz.cs
new file mode 100644 (file)
index 0000000..fad6888
--- /dev/null
@@ -0,0 +1,72 @@
+// Tween - Client of Twitter
+// Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
+//           (c) 2008-2011 Moz (@syo68k)
+//           (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
+//           (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
+//           (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
+//           (c) 2011      kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// All rights reserved.
+// 
+// This file is part of Tween.
+// 
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+// 
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details. 
+// 
+// You should have received a copy of the GNU General Public License along
+// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Tween
+{
+    public class Outputz
+    {
+        private static string myOuturl;
+        private static string myApikey;
+
+        private static bool state;
+
+        public static string OutUrl
+        {
+            get { return myOuturl; }
+            set { myOuturl = value; }
+        }
+
+        public static string Key
+        {
+            get { return myApikey; }
+            set { myApikey = value; }
+        }
+
+        public static bool Enabled
+        {
+            get { return state; }
+            set { state = value; }
+        }
+
+        public bool Post(int length)
+        {
+            if (state == false) return true;
+
+            string output = "http://outputz.com/api/post";
+            Dictionary<string, string> param = new Dictionary<string, string>();
+            param.Add("key", myApikey);
+            param.Add("uri", myOuturl);
+            param.Add("size", length.ToString());
+
+            return (new HttpVarious()).PostData(output, param);
+        }
+    }
+}
index ca9f06c..f81db8d 100644 (file)
@@ -49,6 +49,7 @@
       <SubType>Component</SubType>
     </Compile>
     <Compile Include="ApiInformation.cs" />
+    <Compile Include="Bing.cs" />
     <Compile Include="Connection\HttpVarious.cs" />
     <Compile Include="Connection\IHttpConnection.cs" />
     <Compile Include="Connection\IMultimediaShareService.cs" />
@@ -63,6 +64,7 @@
     <Compile Include="OpenURL.Designer.cs">
       <DependentUpon>OpenURL.cs</DependentUpon>
     </Compile>
+    <Compile Include="Outputz.cs" />
     <Compile Include="PictureBoxEx.cs">
       <SubType>Component</SubType>
     </Compile>