Esempio n. 1
0
        private void btn_Tran_Click(object sender, EventArgs e)
        {
            txtHiddenCount.Text = string.Empty;
            txtHiddenKey.Text   = string.Empty;
            errMsg = new List <string>();
            Input  = txt_Input.Text;

            #region - 字串檢核 -
            try
            {
                try
                {
                    richtxt_Output.Text = Input.Replace(@"""", @"\""");
                    resetFocus();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(SystemMsg.format(ex.Message));
            }
            #endregion
        }
Esempio n. 2
0
        private void btn_toJson_Click(object sender, EventArgs e)
        {
            txtHiddenCount.Text = string.Empty;
            txtHiddenKey.Text   = string.Empty;
            errMsg = new List <string>();
            Input  = txt_Input.Text;

            #region - 字串檢核 -
            try
            {
                Input = Setting.ReplaceExtra(Input);
                //排版字符
                if (!string.IsNullOrWhiteSpace(txt_Split.Text))
                {
                    Input = Input.Replace(txt_Split.Text, string.Concat(txt_Split.Text, Setting.LINE));
                }
                if (Input.IndexOf("{") > -1)
                {
                    try
                    {
                        richtxt_Output.Text = PraseToJson(Input);
                        //dll 問題
                        //var jsonObj = JsonConvert.DeserializeObject(Input);
                        //richtxt_Output.Text = JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented);
                    }
                    catch
                    {
                        richtxt_Output.Text = Input;
                    }
                }
                else
                {
                    try
                    {
                        string _formatStr = FormatXml(Input);
                        richtxt_Output.Text = _formatStr.Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>", "");
                    } catch {
                        richtxt_Output.Text = Input;
                    }
                }
                resetFocus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(SystemMsg.format(ex.Message));
            }
            #endregion
        }