using Shared.Common; using Shared.Phone.UserCenter; using System; using System.Collections.Generic; using System.Globalization; namespace Shared.Phone.Category { /// /// 添加或者编辑场景的界面 /// public class AddOrEditorSceneForm : EditorCommonForm { #region ■ 变量声明___________________________ /// /// 修改的场景 /// private SceneUI editorScene = null; /// /// 克隆的场景(临时编辑用) /// private SceneUI cloneScene = null; /// /// 场景当前的房间ID /// private string nowRoomId = string.Empty; /// /// 整个界面的上下滑动控件 /// private VerticalFrameControl listBodyControl = null; #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// /// 编辑的场景对象 public void ShowForm(SceneUI i_editorScene) { this.ScrollEnabled = false; this.editorScene = i_editorScene; //克隆一个临时编辑的变量 this.cloneScene = new SceneUI(); if (i_editorScene != null) { cloneScene.Name = i_editorScene.Name; cloneScene.IconPath = i_editorScene.IconPath; cloneScene.IconPathType = i_editorScene.IconPathType; var room = HdlRoomLogic.Current.GetRoomBySceneId(i_editorScene.Id); if (room != null) { //当前的房间 this.nowRoomId = room.Id; } //设置头部信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.EditorScene)); } else { //设置头部信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.AddScence)); } //初始化中部信息 this.InitMiddleFrame(); } /// /// 初始化中部信息 /// private void InitMiddleFrame() { this.listBodyControl = new VerticalFrameControl(); listBodyControl.Height = bodyFrameLayout.Height; bodyFrameLayout.AddChidren(listBodyControl); //场景图片这部分的白色背景 var framePicBack = new FrameLayout(); framePicBack.Height = Application.GetRealHeight(559); framePicBack.BackgroundColor = UserCenterColor.Current.White; listBodyControl.frameTable.AddChidren(framePicBack); //场景图片底部阴影 var btnShadow = new PicViewControl(916, 487); btnShadow.Y = Application.GetRealHeight(46); btnShadow.Gravity = Gravity.CenterHorizontal; btnShadow.UnSelectedImagePath = "Room/Room_Rectangle.png"; framePicBack.AddChidren(btnShadow); //场景图片 var btnPic = new ImageView(); btnPic.Y = Application.GetRealHeight(46); btnPic.Width = Application.GetMinRealAverage(887); btnPic.Height = Application.GetMinRealAverage(444); btnPic.Radius = (uint)Application.GetRealHeight(17); btnPic.Gravity = Gravity.CenterHorizontal; if (this.editorScene == null) { btnPic.ImagePath = "SceneIcon/0.png"; } else if (this.editorScene.IconPathType == 0) { btnPic.ImagePath = this.editorScene.IconPath; } else { btnPic.ImageBytes = Global.ReadFileByHomeId(this.editorScene.IconPath); } framePicBack.AddChidren(btnPic); //图片遮罩 var btnZhezhao = new FrameLayout(); btnZhezhao.Width = btnPic.Width; btnZhezhao.Height = btnPic.Height; btnZhezhao.Y = btnPic.Y; btnZhezhao.Gravity = Gravity.CenterHorizontal; btnZhezhao.Radius = btnPic.Radius; framePicBack.AddChidren(btnZhezhao); btnZhezhao.MouseUpEventHandler += (sender, e) => { //房间图片选择 this.ScenePictrueSelect(btnPic); }; //初始化信息编辑控件 this.InitInfoEditorControl(); } #endregion #region ■ 初始化信息编辑_____________________ /// /// 初始化信息编辑控件 /// private void InitInfoEditorControl() { //白色背景框 var frameBack = new FrameLayout(); frameBack.Y = Application.GetRealHeight(582); frameBack.Height = Application.GetRealHeight(429); frameBack.BackgroundColor = UserCenterColor.Current.White; this.listBodyControl.frameTable.AddChidren(frameBack); //信息编辑 var btnTitle = new NormalViewControl(300, 60, true); btnTitle.X = ControlCommonResourse.XXLeft; btnTitle.Y = Application.GetRealHeight(46); btnTitle.TextSize = 15; btnTitle.TextID = R.MyInternationalizationString.uInfoEditor; btnTitle.TextColor = UserCenterColor.Current.TextColor2; frameBack.AddChidren(btnTitle); //场景名称 var rowScene = new FrameCaptionInputControl(Language.StringByID(R.MyInternationalizationString.SceneName), this.cloneScene.Name); rowScene.txtInput.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputSceneName); rowScene.Y = btnTitle.Bottom + Application.GetRealHeight(23); frameBack.AddChidren(rowScene); //底线 rowScene.AddBottomLine(); //所属区域 var rowBelong = new BelongAreaControl(); //rowBelong.Y= rowScene.Bottom+ } #endregion #region ■ 场景图片选择_______________________ /// /// 场景图片选择 /// /// private void ScenePictrueSelect(ImageView imageContr) { var menuContr = new BottomMenuSelectForm(); menuContr.AddForm(3); //默认图库 menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.LocalPicture), () => { var localPic = new Device.Room.AddRoomSelectPicByLocal(); UserView.HomePage.Instance.AddChidren(localPic); UserView.HomePage.Instance.PageIndex += 1; localPic.Show(); localPic.action = (imgPath) => { if (string.IsNullOrEmpty(imgPath) == true) { return; } this.cloneScene.IconPathType = 0; this.cloneScene.IconPath = imgPath; imgPath = IO.FileUtils.GetImageFilePath(imgPath); imageContr.ImageBytes = IO.FileUtils.ReadFile(imgPath); }; }); //拍照 menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.Photograph), () => { //通过相机拍照裁剪 CropImage.TakePicture((imagePath) => { if (string.IsNullOrEmpty(imagePath) == true) { return; } this.cloneScene.IconPathType = 1; imageContr.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath); System.IO.File.Delete(imagePath); }, "HdlPic", 2, 1); }); //我的相册 menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.MyAblums), () => { //从相册选择图片裁剪 CropImage.SelectPicture((imagePath) => { if (string.IsNullOrEmpty(imagePath) == true) { return; } this.cloneScene.IconPathType = 2; imageContr.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath); System.IO.File.Delete(imagePath); }, "HdlPic", 2, 1); }); } #endregion #region ■ 一般方法___________________________ #endregion } }