黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter.HideOption
{
    /// <summary>
    /// 文件内容
    /// </summary>
    public class HideOptionFileContentForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 解密
        /// </summary>
        private bool decryptPassword = false;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm(string i_file)
        {
            this.ScrollEnabled = false;
            //设置头部信息
            base.SetTitleText("文件内容");
 
            //初始化中部信息
            this.InitMiddleFrame(i_file);
 
            var btnButton = new NormalViewControl(200, 69, true);
            btnButton.Gravity = Gravity.CenterVertical;
            btnButton.X = bodyFrameLayout.Width - Application.GetRealWidth(200) - HdlControlResourse.XXLeft;
            btnButton.TextColor = UserCenterColor.Current.TopLayoutTitleText;
            btnButton.TextAlignment = TextAlignment.BottomRight;
            btnButton.TextSize = 17;
            btnButton.Text = "翻译";
            topFrameLayout.AddChidren(btnButton);
            btnButton.ButtonClickEvent += (sender, e) =>
            {
                if (this.decryptPassword == false)
                {
                    this.decryptPassword = true;
                    //初始化中部信息
                    this.InitMiddleFrame(i_file);
                }
            };
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame(string i_file)
        {
            if (i_file == string.Empty) { return; }
 
            this.ClearBodyFrame();
 
            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 = this.GetPictrueRealSize(887);
                btnPic.Height = this.GetPictrueRealSize(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();
                this.SetTextContent(textValue);
            }
        }
 
        /// <summary>
        /// 自定义设置显示的文本
        /// </summary>
        /// <param name="i_text"></param>
        public void SetTextContent(string textValue)
        {
            if (this.decryptPassword == true)
            {
                var strArry = textValue.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
 
                textValue = string.Empty;
                foreach (var strtext in strArry)
                {
                    string value = HdlCommonLogic.Current.DecryptPassword(HdlUserCenterResourse.FileEncryptKey, strtext);
                    textValue += value + "\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;
#if Android
            btnText.Foucs = false;
#endif
            bodyFrameLayout.AddChidren(btnText);
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        #endregion
    }
}