using System; using HDL_ON.Entity; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI { public class PublicAssmebly { /// /// 向framelayout添加顶部区域 /// /// /// public void LoadTopView(FrameLayout frame, string tilte) { FrameLayout view = new FrameLayout() { Height = Application.GetRealHeight(64), BackgroundColor = CSS_Color.TopViewColor, }; frame.AddChidren(view); Button btnBack = new Button() { X = Application.GetRealWidth(10), Y = Application.GetRealHeight(29), Width = Application.GetRealWidth(40), Height = Application.GetRealHeight(28), UnSelectedImagePath = "Public/BackIcon.png", }; frame.AddChidren(btnBack); btnBack.MouseUpEventHandler += (sender, e) => { frame.RemoveFromParent(); }; Button btnTilte = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(30), Width = Application.GetRealWidth(150), Height = Application.GetRealHeight(25), TextAlignment = TextAlignment.Center, TextSize = CSS_FontSize.HeadlineFontSize, TextColor = CSS_Color.FirstLevelTitleColor, Text = tilte }; frame.AddChidren(btnTilte); } /// /// 向dialog添加顶部区域 /// /// /// /// public void LoadTopView(Dialog dialog, FrameLayout frame, string tilte) { FrameLayout view = new FrameLayout() { Height = Application.GetRealHeight(64), BackgroundColor = CSS_Color.TopViewColor, }; frame.AddChidren(view); Button btnBack = new Button() { X = Application.GetRealWidth(10), Y = Application.GetRealHeight(29), Width = Application.GetRealWidth(40), Height = Application.GetRealHeight(28), UnSelectedImagePath = "Public/BackIcon.png", }; frame.AddChidren(btnBack); btnBack.MouseUpEventHandler += (sender, e) => { dialog.Close(); }; Button btnTilte = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(30), Width = Application.GetRealWidth(150), Height = Application.GetRealHeight(25), TextAlignment = TextAlignment.Center, TextSize = CSS_FontSize.HeadlineFontSize, TextColor = CSS_Color.FirstLevelTitleColor, Text = tilte }; frame.AddChidren(btnTilte); } /// /// 向framelayout添加顶部区域,拥有功能配置按钮 /// /// /// public void LoadTopView(FrameLayout frame, string tilte,Function function) { FrameLayout view = new FrameLayout() { Height = Application.GetRealHeight(64), BackgroundColor = CSS_Color.TopViewColor, }; frame.AddChidren(view); Button btnBack = new Button() { X = Application.GetRealWidth(10), Y = Application.GetRealHeight(29), Width = Application.GetRealWidth(40), Height = Application.GetRealHeight(28), UnSelectedImagePath = "Public/BackIcon.png", }; frame.AddChidren(btnBack); btnBack.MouseUpEventHandler += (sender, e) => { frame.RemoveFromParent(); }; Button btnTilte = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(30), Width = Application.GetRealWidth(150), Height = Application.GetRealHeight(25), TextAlignment = TextAlignment.Center, TextSize = CSS_FontSize.HeadlineFontSize, TextColor = CSS_Color.FirstLevelTitleColor, Text = tilte }; frame.AddChidren(btnTilte); var btnSetting = new Button() { X = Application.GetRealWidth(337), Y = Application.GetRealHeight(29), Width = Application.GetMinRealAverage(28), Height = Application.GetMinRealAverage(28), UnSelectedImagePath = "Public/FuncInfoSetIcon.png", }; frame.AddChidren(btnSetting); btnSetting.MouseUpEventHandler += (sender, e) => { var infoView = new FunctionBaseInfoSetPage(function); MainPage.BasePageView.AddChidren(infoView); infoView.LoadPage(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; } /// /// 向framelayout添加顶部区域,拥有功能配置按钮 /// /// /// public void LoadTopView(FrameLayout frame, string tilte, string type,Action callBack) { FrameLayout view = new FrameLayout() { Height = Application.GetRealHeight(64), BackgroundColor = CSS_Color.TopViewColor, }; frame.AddChidren(view); Button btnBack = new Button() { X = Application.GetRealWidth(10), Y = Application.GetRealHeight(29), Width = Application.GetRealWidth(40), Height = Application.GetRealHeight(28), UnSelectedImagePath = "Public/BackIcon.png", }; frame.AddChidren(btnBack); btnBack.MouseUpEventHandler += (sender, e) => { frame.RemoveFromParent(); }; Button btnTilte = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(30), Width = Application.GetRealWidth(150), Height = Application.GetRealHeight(25), TextAlignment = TextAlignment.Center, TextSize = CSS_FontSize.HeadlineFontSize, TextColor = CSS_Color.FirstLevelTitleColor, Text = tilte }; frame.AddChidren(btnTilte); var btnAddIcon = new Button() { X = Application.GetRealWidth(337), Y = Application.GetRealHeight(29), Width = Application.GetMinRealAverage(28), Height = Application.GetMinRealAverage(28), UnSelectedImagePath = "Public/AddIcon.png", }; frame.AddChidren(btnAddIcon); btnAddIcon.MouseUpEventHandler += (sender, e) => { switch (type) { case "floors": Action callBackAction = (floorName) => { if (DB_ResidenceData.residenceData.floors.Contains(floorName)) { return; } else { DB_ResidenceData.residenceData.floors.Add(floorName); DB_ResidenceData.residenceData.SaveResidenceData(); callBack("add", floorName); } }; LoadDialog_EditParater(StringId.AddFloors, DB_ResidenceData.residenceData.floors.Count + 1 + " F", callBackAction); break; case "rooms": callBack("", ""); break; } }; } /// /// 加载修改参数的小弹窗 /// /// 回调函数 public void LoadDialog_EditParater(int titleId, string editParater, Action callBackAction) { Dialog dialog = new Dialog() { BackgroundColor = 0x99000000, }; FrameLayout contentView = new FrameLayout() { Gravity = Gravity.Center, Width = Application.GetRealWidth(270), Height = Application.GetRealHeight(172), BackgroundColor = CSS.CSS_Color.MainBackgroundColor, BorderColor = 0x00000000, BorderWidth = 0, Radius = (uint)Application.GetMinRealAverage(10), }; dialog.AddChidren(contentView); Button btnTitle = new Button() { Y = Application.GetRealHeight(10), Height = Application.GetRealHeight(42), TextColor = CSS.CSS_Color.MainColor, TextSize = CSS.CSS_FontSize.SubheadingFontSize, TextAlignment = TextAlignment.Center, IsBold = true, TextID = titleId, }; contentView.AddChidren(btnTitle); FrameLayout editView = new FrameLayout() { Gravity = Gravity.CenterHorizontal, Y = btnTitle.Bottom + Application.GetRealHeight(6), Width = Application.GetRealWidth(222), Height = Application.GetRealHeight(40), BackgroundColor = CSS.CSS_Color.BackgroundColor, BorderColor = 0x00000000, BorderWidth = 0, Radius = (uint)Application.GetMinRealAverage(4), }; contentView.AddChidren(editView); EditText etParater = new EditText() { X = Application.GetRealWidth(12), Width = Application.GetRealWidth(182), Text = editParater, TextColor = CSS.CSS_Color.FirstLevelTitleColor, TextSize = CSS.CSS_FontSize.TextFontSize, }; editView.AddChidren(etParater); Button btnLine = new Button() { Y = Application.GetRealHeight(128), Height = Application.GetRealHeight(1), BackgroundColor = CSS.CSS_Color.DividingLineColor, }; contentView.AddChidren(btnLine); Button btnCancel = new Button() { Y = btnLine.Bottom, Width = Application.GetRealWidth(134), Height = Application.GetRealHeight(43), TextAlignment = TextAlignment.Center, TextColor = CSS_Color.TextualColor, TextSize = CSS_FontSize.SubheadingFontSize, SelectedTextColor = CSS_Color.MainBackgroundColor, SelectedBackgroundColor = CSS_Color.MainColor, TextID = StringId.Cancel, }; contentView.AddChidren(btnCancel); Button btnBottomLine = new Button() { X = btnCancel.Right, Y = btnLine.Bottom, Height = Application.GetRealHeight(43), Width = Application.GetRealWidth(1), BackgroundColor = CSS_Color.DividingLineColor, }; contentView.AddChidren(btnBottomLine); Button btnConfirm = new Button() { X = btnBottomLine.Right, Y = btnLine.Bottom, Width = Application.GetRealWidth(135), Height = Application.GetRealHeight(43), TextAlignment = TextAlignment.Center, TextColor = CSS.CSS_Color.TextualColor, TextSize = CSS_FontSize.SubheadingFontSize, SelectedTextColor = CSS_Color.MainBackgroundColor, SelectedBackgroundColor = CSS_Color.MainColor, TextID = StringId.Confirm, }; contentView.AddChidren(btnConfirm); dialog.Show(); btnCancel.MouseDownEventHandler += (sender, e) => { btnCancel.IsSelected = true; }; btnCancel.MouseUpEventHandler += (sender, e) => { btnCancel.IsSelected = false; dialog.Close(); }; btnConfirm.MouseDownEventHandler += (sender, e) => { btnConfirm.IsSelected = true; }; btnConfirm.MouseUpEventHandler += (sender, e) => { btnConfirm.IsSelected = false; if ((titleId == StringId.EditFloorName && etParater.Text.Trim() != editParater) || titleId == StringId.AddFloors) { if (DB_ResidenceData.residenceData.floors.Contains(etParater.Text.Trim())) { contentView.Height = Application.GetRealHeight(183); btnLine.Y = Application.GetRealHeight(139); btnBottomLine.Y = btnLine.Bottom; btnCancel.Y = btnLine.Bottom; btnConfirm.Y = btnLine.Bottom; var btnTip = new Button() { X = editView.X, Y = editView.Bottom, Width = Application.GetRealWidth(182), Height = Application.GetRealHeight(30), TextID = StringId.AddFloorFailed_FloorAlreadyExist, TextColor = CSS_Color.WarningColor, TextSize = CSS_FontSize.TextFontSize, }; contentView.AddChidren(btnTip); return; } callBackAction(etParater.Text.Trim()); } if(titleId == StringId.RoomName) { if(editParater != etParater.Text.Trim()) { callBackAction(etParater.Text.Trim()); } } dialog.Close(); }; } /// /// 加载提示弹窗 /// /// /// /// public void TipMsg(int titleId, int msgId, Action callBackAction) { Dialog dialog = new Dialog() { BackgroundColor = 0x99000000, }; FrameLayout contentView = new FrameLayout() { Gravity = Gravity.Center, Width = Application.GetRealWidth(270), Height = Application.GetRealHeight(140), BackgroundColor = CSS.CSS_Color.MainBackgroundColor, BorderColor = 0x00000000, BorderWidth = 0, Radius = (uint)Application.GetMinRealAverage(10), }; dialog.AddChidren(contentView); Button btnTitle = new Button() { Y = Application.GetRealHeight(16), Height = Application.GetRealHeight(30), TextColor = CSS_Color.MainColor, TextSize = CSS_FontSize.SubheadingFontSize, TextAlignment = TextAlignment.Center, IsBold = true, TextID = titleId, }; contentView.AddChidren(btnTitle); Button btnMsg = new Button() { Gravity = Gravity.CenterHorizontal, Height = Application.GetRealHeight(25), Y = btnTitle.Bottom, Width = Application.GetRealHeight(200), TextAlignment = TextAlignment.Center, TextColor = CSS_Color.TextualColor, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, TextID = msgId, }; contentView.AddChidren(btnMsg); Button btnLine = new Button() { Y = Application.GetRealHeight(96), Height = Application.GetRealHeight(1), BackgroundColor = CSS.CSS_Color.DividingLineColor, }; contentView.AddChidren(btnLine); Button btnCancel = new Button() { Y = btnLine.Bottom, Width = Application.GetRealWidth(134), Height = Application.GetRealHeight(43), TextAlignment = TextAlignment.Center, TextColor = CSS_Color.TextualColor, TextSize = CSS_FontSize.SubheadingFontSize, SelectedTextColor = CSS_Color.MainBackgroundColor, SelectedBackgroundColor = CSS_Color.MainColor, TextID = StringId.Cancel, }; contentView.AddChidren(btnCancel); Button btnBottomLine = new Button() { X = btnCancel.Right, Y = btnLine.Bottom, Height = Application.GetRealHeight(43), Width = Application.GetRealWidth(1), BackgroundColor = CSS_Color.DividingLineColor, }; contentView.AddChidren(btnBottomLine); Button btnConfirm = new Button() { X = btnBottomLine.Right, Y = btnLine.Bottom, Width = Application.GetRealWidth(135), Height = Application.GetRealHeight(43), TextAlignment = TextAlignment.Center, TextColor = CSS_Color.TextualColor, TextSize = CSS_FontSize.SubheadingFontSize, SelectedTextColor = CSS_Color.MainBackgroundColor, SelectedBackgroundColor = CSS_Color.MainColor, TextID = StringId.Confirm, }; contentView.AddChidren(btnConfirm); dialog.Show(); btnCancel.MouseDownEventHandler += (sender, e) => { btnCancel.IsSelected = true; }; btnCancel.MouseUpEventHandler += (sender, e) => { btnCancel.IsSelected = false; dialog.Close(); }; btnConfirm.MouseDownEventHandler += (sender, e) => { btnConfirm.IsSelected = true; }; btnConfirm.MouseUpEventHandler += (sender, e) => { btnConfirm.IsSelected = false; callBackAction(); dialog.Close(); }; } } }