using Shared.Phone.UserCenter; using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.MainPage { /// /// 选择本地设备图片的界面 /// public class SelectLocalDeviceImageForm : EditorCommonForm { #region ■ 变量声明___________________________ /// /// 结束选择的事件(图片名字) /// public Action FinishSelectEvent = null; /// /// 当前选择的图标控件 /// private PicViewControl selectContr = null; #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// public void ShowForm() { //初始化中部信息 this.InitMiddleFrame(); //设置头部信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.SelectIcon)); } /// /// 初始化中部信息 /// private void InitMiddleFrame() { //清空bodyFrame this.ClearBodyFrame(); //列表控件 var listView = new VerticalListControl(); listView.Height = bodyFrameLayout.Height; bodyFrameLayout.AddChidren(listView); int space = this.GetPictrueRealSize(46); int backWidth = (listView.Width - ControlCommonResourse.XXLeft * 2 - space * 3) / 4; //防止误差,分两步计算 int iconWidth = backWidth - this.GetPictrueRealSize(43) - this.GetPictrueRealSize(43); //一共28张图片 FrameLayout frameRow = null; for (int i = 0; i < 28; i++) { //4个一组 if (i % 4 == 0) { //行控件 frameRow = new FrameLayout(); frameRow.Height = backWidth + Application.GetRealHeight(58); listView.AddChidren(frameRow); } //背景 var frameBack = new FrameLayoutStatuControl(); frameBack.UseClickStatu = false; frameBack.Height = backWidth; frameBack.Width = backWidth; frameBack.Radius = (uint)backWidth / 2; frameBack.BackgroundColor = UserCenterColor.Current.White; frameBack.X = ControlCommonResourse.XXLeft + (i % 4) * (backWidth + space); frameBack.Y = Application.GetRealHeight(58); frameRow.AddChidren(frameBack); //图片 var btnIcon = new PicViewControl(iconWidth, iconWidth, false); btnIcon.UnSelectedImagePath = $"FunctionIcon/{i + 1}Icon.png"; btnIcon.SelectedImagePath = $"FunctionIcon/{i + 1}IconSelected.png"; btnIcon.Gravity = Gravity.Center; frameBack.AddChidren(btnIcon, ChidrenBindMode.BindEvent); frameBack.ButtonClickEvent += (sender, e) => { btnIcon.IsSelected = !btnIcon.IsSelected; if (this.selectContr != null && this.selectContr.UnSelectedImagePath != btnIcon.UnSelectedImagePath) { //取消掉前一个 this.selectContr.IsSelected = false; } this.selectContr = btnIcon; }; } //确定 var btnSave = new BottomClickButton(); btnSave.TextID = R.MyInternationalizationString.uConfirm1; bodyFrameLayout.AddChidren(btnSave); btnSave.ButtonClickEvent += (sender, e) => { if (this.selectContr != null && this.selectContr.IsSelected == true) { //调用回调函数 this.FinishSelectEvent?.Invoke(this.selectContr.UnSelectedImagePath); } this.CloseForm(); }; //调整桌布高度 listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(23)); } #endregion #region ■ 界面关闭___________________________ /// /// 界面关闭 /// public override void CloseFormBefore() { this.FinishSelectEvent = null; base.CloseFormBefore(); } #endregion } }