xm
2020-04-16 6fa9d69da922c8049f5acfcbb9ce9fd26811024c
ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionFileContentForm.cs
New file
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shared.Phone.UserCenter.HideOption
{
    /// <summary>
    /// 文件内容
    /// </summary>
    public class HideOptionFileContentForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm(string i_file)
        {
            //设置头部信息
            base.SetTitleText("文件内容");
            //初始化中部信息
            this.InitMiddleFrame(i_file);
        }
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame(string i_file)
        {
            if (i_file.EndsWith(".png") == true || i_file.EndsWith(".jpg") == true || i_file.EndsWith(".JPG") == true)
            {
                var btnPic = new ImageView();
                btnPic.Y = Application.GetRealHeight(60);
                btnPic.Width = Application.GetMinRealAverage(887);
                btnPic.Height = Application.GetMinRealAverage(444);
                btnPic.Gravity = Gravity.CenterHorizontal;
                btnPic.Radius= (uint)Application.GetRealHeight(17);
                btnPic.ImageBytes = Shared.IO.FileUtils.ReadFile(i_file);
                bodyFrameLayout.AddChidren(btnPic);
            }
            else
            {
                string textValue = System.Text.Encoding.UTF8.GetString(Shared.IO.FileUtils.ReadFile(i_file)).Trim();
                textValue = textValue.Replace(",", "\r\n");
                if (textValue.StartsWith("{") == true)
                {
                    textValue = "{\r\n" + textValue.Substring(1);
                }
                if (textValue.EndsWith("}") == true)
                {
                    textValue = textValue.Substring(0, textValue.Length - 1) + "\r\n}";
                }
                var btnText = new EditTextView();
                btnText.Width = bodyFrameLayout.Width;
                btnText.Height = bodyFrameLayout.Height;
                btnText.TextAlignment = TextAlignment.TopLeft;
                btnText.TextColor = UserCenterColor.Current.TextColor1;
                btnText.Text = textValue;
                btnText.Enable = false;
                bodyFrameLayout.AddChidren(btnText);
            }
        }
        #endregion
        #region ■ 一般方法___________________________
        #endregion
    }
}