Пример #1
0
 public static string ToChinese(string text, bool Is2Simple)
 {
     try
     {
         if (string.IsNullOrEmpty(text))
         {
             return(string.Empty);
         }
         if (string.IsNullOrEmpty(text.Trim()))
         {
             return(string.Empty);
         }
         string ctext = string.Empty;
         if (Is2Simple == false)
         {
             ctext = ChineseConverter.Convert(text, ChineseConversionDirection.SimplifiedToTraditional);
         }
         else
         {
             ctext = ChineseConverter.Convert(text, ChineseConversionDirection.TraditionalToSimplified);
         }
         return(ctext);
     }
     catch
     {
         return(string.Empty);
     }
 }
Пример #2
0
        private void GenerateFm2()
        {
            string where = String.Format("WHERE Type ='FM2' AND CONVERT(VARCHAR(25), InsertDbDate , 126) LIKE '{0}%'", DateTime.Now.AddDays(-9).ToString("yyyy-MM-dd"));
            var nda1 = new Nda();
            var fm2  = ManagerBase.Select(tableName, new string[] { "*" }, where);

            foreach (DataRow row in fm2.Rows)
            {
                Dictionary <string, string> newInfos = new Dictionary <string, string>
                {
                    { "englishname", row["EnglishName"].ToString() },
                    { "fullname", row["FullName"].ToString() },
                    { "shortname", row["ShortName"].ToString() },
                    { "price", row["Price"].ToString() },
                    { "listingshares", row["ListingShares"].ToString() },
                    { "effectivedate", ((DateTime)row["EffectiveDate"]).ToString("dd-MMM-yyyy") },
                    { "offeringdate", row["OfferingDate"].ToString() },
                    { "insertdbdate", row["InsertDbDate"].ToString() },
                    { "type", row["Type"].ToString() },
                    { "code", row["Code"].ToString() },
                    { "market", row["Market"].ToString() }
                };
                newInfos.Add("traditionalname", ChineseConverter.Convert(newInfos["shortname"], ChineseConversionDirection.SimplifiedToTraditional));
                nda1.AddProp(newInfos);
            }
            if (fm2.Rows.Count > 0)
            {
                nda1.GenerateAndSave("CnIaAddFutDat", String.Format("{0}IaAddFutDat_{1}.csv", configObj.ResultFolderPath, DateTime.Now.ToString("ddMM")));
                nda1.GenerateAndSave("CnLotAdd", String.Format("{0}LotAdd_{1}.csv", configObj.ResultFolderPath, DateTime.Now.ToString("ddMM")));
                nda1.GenerateAndSave("CnQaAddFutDat", String.Format("{0}QaAddFutDat_{1}.csv", configObj.ResultFolderPath, DateTime.Now.ToString("ddMM")));
                nda1.GenerateAndSave("CnQaChgFtd", String.Format("{0}QaChgFtd_{1}.csv", configObj.ResultFolderPath, DateTime.Now.ToString("ddMM")));
                nda1.GenerateAndSave("CnTickAdd", String.Format("{0}TickAdd_{1}.csv", configObj.ResultFolderPath, DateTime.Now.ToString("ddMM")));
            }
        }
Пример #3
0
        public RewardGiftInfo(HttpRequest request)
        {
            //_RewardVerify = -1;
            try
            {
                int     anchorid   = int.TryParse(request.Form["AnchorId"], out anchorid) ? anchorid : 0;
                int     combocount = int.TryParse(request.Form["ComboCount"], out combocount) ? combocount : 0;
                decimal giftprice  = decimal.TryParse(request.Form["GiftPrice"], out giftprice) ? giftprice : 0;
                int     userid     = int.TryParse(request.Form["UserId"], out userid) ? userid : 0;
                int     userlevel  = int.TryParse(request.Form["UserLevel"], out userlevel) ? userlevel : 0;

                GameId       = request.Form["GameId"] ?? "";
                AnchorId     = anchorid;
                AnchorName   = request.Form["AnchorName"] ?? "";
                ComboCount   = combocount;
                GiftName     = request.Form["GiftName"] ?? "";
                GiftPrice    = giftprice;
                UserId       = userid;
                UserName     = request.Form["UserName"] ?? "";
                UserNickName = ChineseConverter.ToSimplified(request.Form["UserNickName"] ?? "");
                UserLevel    = userlevel;
                UserAvatar   = request.Form["UserAvatar"] ?? "";
                Identityid   = request.Form["Identityid"] ?? "";
                ClientSource = request.Form["ClientSource"] ?? "";
            }
            catch
            { }
        }
        public LiveChatMessageInfo(HttpRequest request)
        {
            _SensitiveWordsVerify = -1;
            try
            {
                Identityid  = request.Form["Identityid"] ?? "";
                Target      = request.Form["Target"] ?? "";
                GameID      = request.Form["GameID"] ?? "";
                Type        = request.Form["Type"] ?? "";
                ChatMessage = Regex.Replace(ChineseConverter.ToSimplified(request.Form["ChatMessage"] ?? ""), @"[,, \t]+", "");
                int userGroup       = int.TryParse(request.Form["UserGroup"], out userGroup) ? userGroup : -32768;
                int minSendInterval = int.TryParse(request.Form["MinSendInterval"], out minSendInterval) ? minSendInterval : -32768;
                MinSendInterval = minSendInterval;
                UserGroup       = userGroup;
                AllowUserGroups = request.Form["AllowUserGroups"] ?? "";
                UserName        = request.Form["UserName"] ?? "";
                UserNickName    = ChineseConverter.ToSimplified(request.Form["UserNickName"] ?? "");
                UserAvatar      = request.Form["UserAvatar"] ?? "";
                CountryName     = request.Form["CountryName"] ?? "";
                RegionName      = request.Form["RegionName"] ?? "";
                CityName        = request.Form["CityName"] ?? "";
                ClientIp        = request.Form["ClientIp"] ?? "";
                IspDomain       = request.Form["IspDomain"] ?? "";

                Log.Info("request", "request", request.Form.ToString());
            }
            catch
            { }
        }
    private void Button_Translate_Click(object sender, RoutedEventArgs e)
    {
        AudioUtil.ClickSound();

        try
        {
            if (TextBox_InputMessage.Text != "")
            {
                var str = (e.OriginalSource as Button).Content.ToString();

                switch (str)
                {
                case "中英互译":
                    Translation();
                    break;

                case "简转繁":
                    TextBox_InputMessage.Text = ChineseConverter.ToTraditional(TextBox_InputMessage.Text);
                    break;

                case "繁转简":
                    TextBox_InputMessage.Text = ChineseConverter.ToSimplified(TextBox_InputMessage.Text);
                    break;

                case "转拼音":
                    TextBox_InputMessage.Text = Pinyin.GetString(TextBox_InputMessage.Text, PinyinFormat.WithoutTone);
                    break;
                }
            }
        }
        catch (Exception ex)
        {
            MsgBoxUtil.Exception(ex);
        }
    }
Пример #6
0
 public void UpdateResxInfo()
 {
     try
     {
         String _strSql = String.Format(@" select a.FKey,a.FValue from Resx_Info a with(nolock) left join Resx_DetailInfo  b with(nolock) 
             on a.FKey=b.FKey where a.Sys_Name='TAOS' and isnull(b.FKey,'')='' order by b.FKey ");
         dbConnect();
         DataSet _DS = runSql.GetDataBySql(_strSql);
         foreach (DataRow row in _DS.Tables[0].Rows)
         {
             _strSql = string.Empty;
             string strFkey    = row["fkey"].ToString().Trim();
             string strValue   = row["FValue"].ToString().Trim();
             String _txtWordCN = ChineseConverter.Convert(strValue, ChineseConversionDirection.TraditionalToSimplified);
             String _txtWordTW = ChineseConverter.Convert(strValue, ChineseConversionDirection.SimplifiedToTraditional);
             _strSql = _strSql + string.Format(@" insert into Resx_DetailInfo (FKey,Resx_Type,Resx_Text,Sys_Name,CUser,CTime) 
             values(N'{0}',N'{1}',N'{2}',N'{3}',N'{4}',GETDATE()) ", strFkey, "zh-CN", _txtWordCN, "TAOS", "admin");
             _strSql = _strSql + string.Format(@" insert into Resx_DetailInfo (FKey,Resx_Type,Resx_Text,Sys_Name,CUser,CTime) 
             values(N'{0}',N'{1}',N'{2}',N'{3}',N'{4}',GETDATE()) ", strFkey, "zh-TW", _txtWordTW, "TAOS", "admin");
             runSql.ExecSql(_strSql, "");
         }
     }
     catch (Exception ex)
     {
     }
 }
Пример #7
0
        /// <summary>
        /// 简体转换为繁体
        /// </summary>
        /// <param name="str">简体字</param>
        /// <returns>繁体字</returns>
        public static string GetTraditional(string str)
        {
            string r = string.Empty;

            r = ChineseConverter.Convert(str, ChineseConversionDirection.SimplifiedToTraditional);
            return(r);
        }
Пример #8
0
        private void RecursivelyReplaceText(HtmlNode innernode, bool toTraditional, bool doTransfer)
        {
            foreach (HtmlNode childinnenode in innernode.ChildNodes)
            {
                if (childinnenode.ChildNodes.Count == 0)
                {
                    //Logger.logger.Debug($"To translate Xpath { childinnenode.XPath}");
                    string tempinnertext = childinnenode.InnerHtml;

                    // tempinnertext = HttpUtility.HtmlDecode(tempinnertext);

                    if (doTransfer)
                    {
                        if (toTraditional)
                        {
                            childinnenode.InnerHtml = ChineseConverter.Convert(tempinnertext, ChineseConversionDirection.SimplifiedToTraditional);
                        }
                        else
                        {
                            childinnenode.InnerHtml = ChineseConverter.Convert(tempinnertext, ChineseConversionDirection.TraditionalToSimplified);
                        }
                    }
                    childinnenode.InnerHtml = EscapeCharacterReplacement(childinnenode.InnerHtml);
                }
                else
                {
                    RecursivelyReplaceText(childinnenode, toTraditional, doTransfer);
                }
            }
        }
Пример #9
0
        /// <summary>
        /// list多项目添加
        /// </summary>
        /// <param name="cameraDtos"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <CameraDto> > PostList(List <UpdateCameraDto> cameraDtos)
        {
            if (cameraDtos == null)
            {
                return(null);
            }
            List <Camera> cameras = new List <Camera>();
            var           data    = ObjectMapper.Map <List <UpdateCameraDto>, List <Camera> >(cameraDtos);
            //简繁转换
            string simplifieddata  = Newtonsoft.Json.JsonConvert.SerializeObject(data);
            string traditionaldata = ChineseConverter.Convert(simplifieddata, ChineseConversionDirection.SimplifiedToTraditional);
            var    data2           = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Camera> >(traditionaldata);



            foreach (var item in data2)
            {
                var camera = _repository.InsertAsync(item);
                cameras.Add(camera.Result);
            }
            var camerasdto = ObjectMapper.Map <List <Camera>, List <CameraDto> >(cameras);

            return(new PagedResultDto <CameraDto> {
                TotalCount = camerasdto.Count, Items = camerasdto
            });
        }
Пример #10
0
        /// <summary>
        /// 轉換文字
        /// </summary>
        /// <param name="origin">原始文字</param>
        /// <param name="ToChinese">0: 不轉換 1: 簡體轉繁體 2:繁體轉簡體</param>
        /// <param name="VocabularyCorrection">-1: 依照設定值變動 0:不使用辭典轉換 1:使用辭典轉換</param>
        /// <returns></returns>
        public static string Convert(string origin, int ToChinese, int VocabularyCorrection = -1)
        {
            if (String.IsNullOrWhiteSpace(origin))
            {
                return(origin);
            }
            if (!App.DicLoaded)
            {
                System.Threading.SpinWait.SpinUntil(() => App.DicLoaded, 10000);
                if (!App.DicLoaded)
                {
                    throw new Exception("詞彙修正的Dictionary載入失敗");
                }
            }
            switch (ToChinese)
            {
            case 1:
                if ((App.Settings.VocabularyCorrection && VocabularyCorrection != 0) || VocabularyCorrection == 1)
                {
                    origin = App.ChineseConverter.Convert(origin, true);
                }
                origin = ChineseConverter.ToTraditional(origin);
                break;

            case 2:
                if ((App.Settings.VocabularyCorrection && VocabularyCorrection != 0) || VocabularyCorrection == 1)
                {
                    origin = App.ChineseConverter.Convert(origin, false);
                }
                origin = ChineseConverter.ToSimplified(origin);
                break;
            }
            return(origin);
        }
Пример #11
0
        /// <summary>
        /// 繁体转换为简体
        /// </summary>
        /// <param name="str">繁体字</param>
        /// <returns>简体字</returns>
        public string GetSimplified(string str)
        {
            string r = string.Empty;

            r = ChineseConverter.Convert(str, ChineseConversionDirection.TraditionalToSimplified);
            return(r);
        }
Пример #12
0
 public static string FileConvert(string origin, Encoding[] encoding, int ToChinese, int VocabularyCorrection = -1)
 {
     if (ToChinese == 0)
     {
         //經研究,ConvertZ在轉檔案時,做了一些小動作,他會先把原本big5顯示不出來的字轉成繁體,證據是'软'都變成'軟'了
         StringBuilder sb = new StringBuilder(origin.Length);
         foreach (char c in origin.ToCharArray())
         {
             if (encoding[1].GetChars(encoding[1].GetBytes(new char[] { c }))[0] != c)
             {
                 sb.Append(ChineseConverter.ToTraditional(new String(c, 1)));
             }
             else
             {
                 sb.Append(c);
             }
         }
         origin = sb.ToString();
     }
     if (encoding[1] == Encoding.Default || encoding[1] == Encoding.UTF8 || encoding[1] == Encoding.Unicode || encoding[1] == Encoding.GetEncoding("UnicodeFFFE") || encoding[0] == encoding[1])
     {
         return(Convert(origin, ToChinese, VocabularyCorrection));
     }
     else
     {
         return(Convert(origin, new Encoding[2] {
             Encoding.Default, encoding[1]
         }, ToChinese, VocabularyCorrection));
     }
 }
Пример #13
0
        private async Task Traditional(HttpContext context)
        {
            var accept = context.Request.Headers["Accept"].ToString();

            if (accept.StartsWith("text") || accept.Contains(ContentType.Json))
            {
                //设置stream存放ResponseBody
                var responseOriginalBody = context.Response.Body;
                var memStream            = new MemoryStream();
                context.Response.Body = memStream;

                // 执行其他中间件
                await _next(context);

                //处理执行其他中间件后的ResponseBody
                memStream.Position = 0;
                var responseReader = new StreamReader(memStream, Encoding.UTF8);
                var responseBody   = await responseReader.ReadToEndAsync();

                memStream = new MemoryStream(Encoding.UTF8.GetBytes(ChineseConverter.Convert(responseBody, ChineseConversionDirection.SimplifiedToTraditional)));
                await memStream.CopyToAsync(responseOriginalBody);

                context.Response.Body = responseOriginalBody;
            }
            else
            {
                await _next(context);
            }
        }
Пример #14
0
 private void ButtonOK_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(textBoxLyrics.Text))
     {
         listBoxWord.Items.Clear();
         textBoxLyrics.Text = ChineseConverter.Convert(textBoxLyrics.Text, ChineseConversionDirection.TraditionalToSimplified);
         textBoxLyrics.Text = RemoveFormat(textBoxLyrics.Text);
         string[] sentence = textBoxLyrics.Text.Split('|');
         foreach (var itemSen in sentence)
         {
             if (checkBoxDisV.Checked)
             {
                 listBoxWord.Items.AddRange(ToPinyinDisV(itemSen));
             }
             else
             {
                 foreach (char itemWord in itemSen.Replace("\n", "").Replace("\r", "").Replace(" ", ""))
                 {
                     if (nPinyinRBox.Checked)
                     {
                         listBoxWord.Items.Add(ToPinyin.ByNPingyin(itemWord));
                     }
                     else
                     {
                         listBoxWord.Items.Add(ToPinyin.ByMsIntPinyin(itemWord));
                     }
                 }
             }
         }
     }
     else
     {
         MessageBox.Show(@"歌词不能为空。");
     }
 }
Пример #15
0
        /// <summary>
        /// 模糊匹配词条信息
        /// </summary>
        /// <param name="_Word"></param>
        public DataSet CheckItemInfo(String _SysName, String _Word)
        {
            String _txtWordCN = ChineseConverter.Convert(_Word, ChineseConversionDirection.TraditionalToSimplified);
            String _txtWordTW = ChineseConverter.Convert(_Word, ChineseConversionDirection.SimplifiedToTraditional);

            String _strSql = String.Format(@" Select *,convert(nvarchar(10),CTime,120 ) as DTime
                from Resx_Info where Sys_Name='{0}' and (FValue like N'%{1}%' or FValue like N'%{2}%' ) ", _SysName, _txtWordCN, _txtWordTW);

            dbConnect();
            DataSet _DS = runSql.GetDataBySql(_strSql);

            if (_DS != null && _DS.Tables.Count > 0 && _DS.Tables[0].Rows.Count > 0)
            {
                CreateResx _CResx = new CreateResx();
                _DS.Tables[0].Columns.Add("Context");
                _DS.Tables[0].Columns.Add("Html");
                int iCount = 0;
                foreach (DataRow _Row in _DS.Tables[0].Rows)
                {
                    ++iCount;
                    string strJs   = "<span id='spJs" + iCount.ToString() + "'>" + _CResx.GetJScriptCode(_Row["FKey"].ToString().Trim(), _Row["FValue"].ToString().Trim()) + "</span>";
                    string strCs   = "<span id='spCs" + iCount.ToString() + "'>" + _CResx.GetCSharpCode(_Row["FKey"].ToString().Trim(), _Row["FValue"].ToString().Trim()) + "</span>";
                    string strHtml = "<span ><input type='text' id='spHtml" + iCount.ToString() + "' style='border:0px;width:300px;' value='<%=" + _CResx.GetCSharpCode(_Row["FKey"].ToString().Trim(), _Row["FValue"].ToString().Trim()) + "%>'/></span>";
                    _Row["Context"] = "JS替换代码: " + strJs
                                      + "  <a  href='javascript:void(0);' onclick='CopyToClipbord(\"spJs" + iCount.ToString() + "\");'>復制</a>"
                                      + "<br/>CS后臺替换代码:  " + strCs
                                      + "  <a  href='javascript:void(0);' onclick='CopyToClipbord(\"spCs" + iCount.ToString() + "\");'>復制</a>"
                                      + "<br/>html替换代码:  " + strHtml
                                      + "  <a  href='javascript:void(0);' onclick='CopyToClipbord(\"spHtml" + iCount.ToString() + "\");'>復制</a>";
                }
            }
            return(_DS);
        }
Пример #16
0
        static void Main(string[] args)
        {
            var sb          = new StringBuilder();
            var levelGroups = new[] { ChineseNumber.UpperLevels, ChineseNumber.LowerLevels };
            var nums        = new int[9].Let(i => i + 1);

            foreach (var levels in levelGroups.AsKvPairs())
            {
                foreach (var level in levels.Value.AsKvPairs())
                {
                    foreach (var num in nums)
                    {
                        var snumber     = levels.Key == 0 ? ChineseNumber.GetString(num, x => x.Upper = true) : ChineseNumber.GetString(num);
                        var str         = $"{snumber}{level.Value}";
                        var pinyin      = Pinyin.GetString(str);
                        var simplified  = ChineseConverter.ToSimplified(str);
                        var traditional = ChineseConverter.ToTraditional(str);
                        var tag         = num * Math.Pow(10, level.Key);
                        sb.AppendLine($@"{" ".Repeat(12)}new ChineseWord {{ Pinyin = ""{pinyin}"", Simplified = ""{simplified}"", Traditional = ""{traditional}"", Tag = {tag} }},");
                    }
                }
            }

            var csFile = Build(sb.ToString());

            File.WriteAllText("../../../NumberWords.cs", csFile);

            Console.WriteLine("File saved: NumberWords.cs");
        }
Пример #17
0
 /// <summary>
 /// 繁体转换为简体
 /// </summary>
 /// <param name="text">转换文本</param>
 /// <returns>简体文本</returns>
 public static string TraditionalToSimplified(this string text)
 {
     if (String.IsNullOrEmpty(text))
     {
         return(text);
     }
     return(ChineseConverter.Convert(text, ChineseConversionDirection.TraditionalToSimplified));
 }
Пример #18
0
 /// <summary>
 /// 繁体到简体
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static string TW_ZH(object s)
 {
     if (s == null)
     {
         s = string.Empty;
     }
     return(ChineseConverter.Convert(s.ToString(), ChineseConversionDirection.TraditionalToSimplified));
 }
Пример #19
0
        /// <summary>
        /// Converts <paramref name="s"/> from simplified chinese to traditional chinese.
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static string SimplifiedToTraditional(string s)
        {
            if (string.IsNullOrWhiteSpace(s))
            {
                return(s);
            }

            return(ChineseConverter.Convert(s, ChineseConversionDirection.SimplifiedToTraditional));
        }
        /// <summary>
        /// 重写修改方法,简体转繁体
        /// </summary>
        /// <param name="id"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public override Task <CameraRepairDto> UpdateAsync(int id, UpdateCameraRepairDto input)
        {
            string data = Newtonsoft.Json.JsonConvert.SerializeObject(input);

            string data2 = ChineseConverter.Convert(data, ChineseConversionDirection.SimplifiedToTraditional);

            UpdateCameraRepairDto input2 = Newtonsoft.Json.JsonConvert.DeserializeObject <UpdateCameraRepairDto>(data2);

            return(base.UpdateAsync(id, input2));
        }
Пример #21
0
 /// <summary>
 /// 简体转繁体:如果当前问TC,则根据chsStr参数翻译成繁体;否则返回enStr
 /// </summary>
 /// <param name="enStr">英文文字</param>
 /// <param name="chsStr">简体中文</param>
 /// <returns>如果当前问TC,则根据chsStr参数翻译成繁体;否则返回enStr</returns>
 public static string CHS2CHT(string enStr, string chsStr)
 {
     //判断是否为繁体
     if (IsTraditional_Chinese_Character() && !string.IsNullOrEmpty(chsStr))
     {
         return(ChineseConverter.Convert(HttpUtility.HtmlDecode(chsStr), ChineseConversionDirection.SimplifiedToTraditional));
     }
     else
     {
         return(HttpUtility.HtmlDecode(enStr));
     }
 }
Пример #22
0
 /// <summary>
 /// 繁体转简体
 /// </summary>
 /// <param name="str">繁体文字</param>
 /// <returns></returns>
 public static string CHT2CHS(string str)
 {
     //判断是否为繁体
     if (IsTraditional_Chinese_Character() && !string.IsNullOrEmpty(str))
     {
         return(ChineseConverter.Convert(str, ChineseConversionDirection.TraditionalToSimplified));
     }
     else
     {
         return(str);
     }
 }
Пример #23
0
 /// <summary>
 /// 简体到繁体
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static string ZH_TW(object s)
 {
     if (s == null)
     {
         return(string.Empty);
     }
     if (s is DBNull)
     {
         return(string.Empty);
     }
     return(ChineseConverter.Convert(s.ToString(), ChineseConversionDirection.SimplifiedToTraditional));
 }
        /// <summary>
        /// 重写新增表,增加简体转繁体功能
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <CameraRepairDto> CreateRustAsync(UpdateCameraRepairDto input)
        {
            string data = Newtonsoft.Json.JsonConvert.SerializeObject(input);

            string data2 = ChineseConverter.Convert(data, ChineseConversionDirection.SimplifiedToTraditional);

            UpdateCameraRepairDto input2 = Newtonsoft.Json.JsonConvert.DeserializeObject <UpdateCameraRepairDto>(data2);

            var reuust = await base.CreateAsync(input2);


            return(reuust);
        }
Пример #25
0
 private void chtchsConvert()
 {
     if (label_ch1.Content.ToString() == "繁体字段")
     {
         txtCh2.Text = ChineseConverter.Convert(txtCh1.Text,
                                                ChineseConversionDirection.TraditionalToSimplified);
     }
     else
     {
         txtCh2.Text = ChineseConverter.Convert(txtCh1.Text,
                                                ChineseConversionDirection.SimplifiedToTraditional);
     }
 }
Пример #26
0
        public string Generate()
        {
            var sb          = new StringBuilder();
            var levelGroups = new[] { ChineseNumber.UpperLevels, ChineseNumber.LowerLevels };
            var nums        = new int[9].Let(i => i + 1);
            var total       = 0;

            foreach (var levels in levelGroups.AsKvPairs())
            {
                foreach (var level in levels.Value.AsKvPairs())
                {
                    foreach (var num in nums)
                    {
                        var snumber     = levels.Key == 0 ? ChineseNumber.GetString(num, x => x.Upper = true) : ChineseNumber.GetString(num);
                        var str         = $"{snumber}{level.Value}";
                        var simplified  = ChineseConverter.ToSimplified(str);
                        var traditional = ChineseConverter.ToTraditional(str);

                        var chineseWord = new ChineseWord
                        {
                            Simplified        = simplified,
                            Traditional       = traditional,
                            SimplifiedPinyin  = Pinyin.GetString(ChineseType.Simplified, simplified),
                            TraditionalPinyin = Pinyin.GetString(ChineseType.Traditional, traditional),
                            Tag = num * Math.Pow(10, level.Key),
                        };

                        var line = $"{" ".Repeat(12)}new {nameof(ChineseWord)} " +
                                   $"{{ " +
                                   $"{nameof(ChineseWord.Simplified)} = \"{chineseWord.Simplified}\"" +
                                   $", {nameof(ChineseWord.Traditional)} = \"{chineseWord.Traditional}\"" +
                                   $", {nameof(ChineseWord.SimplifiedPinyin)} = \"{chineseWord.SimplifiedPinyin}\"" +
                                   $", {nameof(ChineseWord.TraditionalPinyin)} = \"{chineseWord.TraditionalPinyin}\"" +
                                   $", {nameof(ChineseWord.Tag)} = {chineseWord.Tag}" +
                                   $" }},";
                        sb.AppendLine(line);
                        total += 1;
                    }
                }
            }

            sb.AppendLine($@"{" ".Repeat(12)}new {nameof(ChineseWord)} {{ Simplified = ""两"", Traditional = ""两"", SimplifiedPinyin = ""liang3"", TraditionalPinyin = ""liang3"", Tag = 2 }},");
            sb.AppendLine($@"{" ".Repeat(12)}new {nameof(ChineseWord)} {{ Simplified = ""两百"", Traditional = ""两百"", SimplifiedPinyin = ""liang3 bai3"", TraditionalPinyin = ""liang3 bai3"", Tag = 200 }},");
            sb.AppendLine($@"{" ".Repeat(12)}new {nameof(ChineseWord)} {{ Simplified = ""两千"", Traditional = ""两千"", SimplifiedPinyin = ""liang3 qian1"", TraditionalPinyin = ""liang3 qian1"", Tag = 2000 }},");
            total += 3;

            sb.AppendLine($@"{" ".Repeat(12)}// Total {total} words.");

            return(Wrap(sb.ToString()).Replace("she4", "shi2"));  // 拾 = shi2
        }
Пример #27
0
        private void TransferTraditionalBtn_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckInput())
            {
                return;
            }

            listBox.Items.Clear();

            string t = ChineseConverter.Convert(textBox.Text.Trim(),
                                                ChineseConversionDirection.TraditionalToSimplified);

            listBox.Items.Add(t);
        }
Пример #28
0
        private void btn3_Click_1(object sender, RoutedEventArgs e)
        {
            if (!checkInput())
            {
                return;
            }

            listBox.Items.Clear();

            String t = ChineseConverter.Convert(textBox.Text.Trim(),
                                                ChineseConversionDirection.SimplifiedToTraditional);

            listBox.Items.Add(t);
        }
Пример #29
0
        private void Fan2jianBtn_Click(object sender, RoutedEventArgs e)
        {
            String text = inputText.Text.Trim();

            if (text == null || text == "")
            {
                MessageBox.Show("请输入汉字(繁体)");
            }
            else
            {
                String traditional = ChineseConverter.Convert(text, ChineseConversionDirection.TraditionalToSimplified);
                ouputList.Items.Clear();
                ouputList.Items.Add(traditional);
            }
        }
Пример #30
0
        public Boolean IsAddResxDetailInfo(string strKeyWord, string strSysName)
        {
            bool   blStatus   = true;
            String _txtWordCN = ChineseConverter.Convert(strKeyWord, ChineseConversionDirection.TraditionalToSimplified);
            String _txtWordTW = ChineseConverter.Convert(strKeyWord, ChineseConversionDirection.SimplifiedToTraditional);
            String _strSql    = String.Format(@" select * from  Resx_DetailInfo where (Resx_Text=N'{0}' or Resx_Text='{1}')  and Sys_Name='{2}' ", _txtWordCN, _txtWordTW, strSysName);

            dbConnect();
            DataSet ds = runSql.GetDataBySql(_strSql);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                blStatus = false;
            }
            return(blStatus);
        }