From 1e0014f5c2e2fe1cfaaacfb2bebe8adc577bc944 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期四, 14 五月 2020 18:01:26 +0800 Subject: [PATCH] 2020-05-14-3 --- HDL_ON/UI/Music/View/TipView.cs | 593 ++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 409 insertions(+), 184 deletions(-) diff --git a/HDL_ON/UI/Music/View/TipView.cs b/HDL_ON/UI/Music/View/TipView.cs index 6c1149b..62bcf42 100644 --- a/HDL_ON/UI/Music/View/TipView.cs +++ b/HDL_ON/UI/Music/View/TipView.cs @@ -1,233 +1,458 @@ 锘縰sing System; +using System.Collections.Generic; +using HDL_ON.UI.CSS; using Shared; + namespace HDL_ON.UI.Music.View { - public class TipView:FrameLayout + public class TipView { - - public void FieListView() + /// <summary> + /// 澶ф鍦嗚鍊� + /// </summary> + public int RradiusFrameLayout = 15; + /// <summary> + /// 灏忔鍦嗚鍊� + /// </summary> + public int radiusEditFrameLayout = 4; + /// <summary> + /// 杈撳叆妗� + /// </summary> + /// <param name="titleId">鏍囬鏂囨湰</param> + /// <param name="tnputEditTxet">杈撳叆鏂囨湰</param> + /// <param name="errorId_IsNullOrEmpty">杈撳叆妗嗘枃鏈负绌鸿嚜瀹氫箟鎻愮ず閿欒鏂囨湰</param> + /// <param name="errorId_PresenceP">妫�绱㈠凡瀛樺湪鍚嶇О鑷畾涔夋彁绀洪敊璇枃鏈�</param> + /// <param name="confirmAction">鍥炶皟鍑芥暟</param> + /// <param name="List">琚绱㈠垪琛�</param> + /// <param name="confirmAction">鍥炶皟鍑芥暟</param> + public void InputBox(int titleId, string tnputEditTxet,int errorId_IsNullOrEmpty, int errorId_PresenceP, List<string> List, Action<string> confirmAction) { - //涓绘帶浠� Dialog dialog = new Dialog() { BackgroundColor = Color.PopupBackgroundColor, }; - dialog.Show(); - //鐖舵帶浠� - FrameLayout frame = new FrameLayout { }; - dialog.AddChidren(frame); - frame.MouseUpEventHandler += (sen, e) => + + FrameLayout whiteView = new FrameLayout() { - dialog.Close(); - }; - //鐧借壊蹇埗鎺т欢 - FrameLayout dialogFra = new FrameLayout() - { - X = Application.GetRealWidth(16), - Y = Application.GetRealHeight(187), - Width = Application.GetRealWidth(344), - Height = Application.GetRealHeight(460), + //Gravity = Gravity.Center, + X=Application.GetRealWidth(53), + Y = Application.GetRealHeight(264), + Width = Application.GetRealWidth(270), + Height = Application.GetRealHeight(172), BackgroundColor = Color.WhiteColor, - Radius = (uint)Application.GetRealHeight(12), + BorderColor = 0x00000000, + BorderWidth = 0, + Radius = (uint)Application.GetRealHeight(RradiusFrameLayout), }; - frame.AddChidren(dialogFra); - //鏄剧ず澶撮儴淇℃伅鐖舵帶浠� - FrameLayout topFra = new FrameLayout() + dialog.AddChidren(whiteView); + + Button btnTitle = new Button() { - Width = Application.GetRealWidth(344), - Height = Application.GetRealHeight(70), + Y = Application.GetRealHeight(20), + X=Application.GetRealWidth(35), + Height = Application.GetRealHeight(22), + Width=Application.GetRealWidth(200), + TextColor =Color.SelectedColor, + TextSize =TextSize.Text16, + TextAlignment = TextAlignment.Center, + TextID = titleId, + }; - dialogFra.AddChidren(topFra); - //鍙栨秷鎺т欢 - Button cancelnBtn = new Button + whiteView.AddChidren(btnTitle); + + FrameLayout editBjView = new FrameLayout() { - X = Application.GetRealWidth(16), - Y = Application.GetRealHeight(24), - Width = Application.GetRealWidth(100), - Height = Application.GetRealHeight(20), - TextID = StringId.cancelMusic, - TextAlignment = TextAlignment.CenterLeft, - TextColor = Color.MusicNoTxetColor, + // Gravity = Gravity.CenterHorizontal, + Y = btnTitle.Bottom + Application.GetRealHeight(16), + X=Application.GetRealWidth(24), + Width = Application.GetRealWidth(222), + Height = Application.GetRealHeight(40), + BackgroundColor =Color.ViewColor, + BorderColor = 0x00000000, + BorderWidth = 0, + Radius = (uint)Application.GetMinRealAverage(radiusEditFrameLayout), + }; + whiteView.AddChidren(editBjView); + + EditText editText = new EditText() + { + X = Application.GetRealWidth(12), + Y=Application.GetRealHeight(10), + Width = Application.GetRealWidth(160), + Height=Application.GetRealHeight(20), + Text = tnputEditTxet, + TextColor = Color.TextColor, TextSize = TextSize.Text14, + TextAlignment=TextAlignment.CenterLeft, + }; - topFra.AddChidren(cancelnBtn); - cancelnBtn.MouseUpEventHandler += (sen, e) => + editBjView.AddChidren(editText); + + Button clearIconBtn = new Button + { + X = Application.GetRealWidth(194), + Y = Application.GetRealHeight(8), + Width = Application.GetMinRealAverage(24), + Height = Application.GetMinRealAverage(24), + UnSelectedImagePath = "MusicIcon/clear.png", + }; + editBjView.AddChidren(clearIconBtn); + clearIconBtn.MouseUpEventHandler += (sender, e) => + { + editText.Text = ""; + }; + + Button btnLine = new Button() + { + Y = whiteView.Height-Application.GetRealHeight(44+1), + Height = Application.GetRealHeight(1), + BackgroundColor =Color.LineColor, + }; + whiteView.AddChidren(btnLine); + + Button btnCancel = new Button() + { + Y = btnLine.Bottom, + Width = Application.GetRealWidth(135), + Height = Application.GetRealHeight(44), + TextAlignment = TextAlignment.Center, + TextColor = Color.TextCancelColor, + TextSize = TextSize.Text16, + TextID = StringId.cancelMusic, + }; + whiteView.AddChidren(btnCancel); + + Button btnConfirm = new Button() + { + X = btnCancel.Right, + Y = btnLine.Bottom, + Width = Application.GetRealWidth(135), + Height = Application.GetRealHeight(44), + TextAlignment = TextAlignment.Center, + TextColor = Color.WhiteColor, + IsBold = true, + TextSize = TextSize.Text16, + TextID = StringId.confirmMusic, + BackgroundColor = Color.SelectedColor, + Gravity = Gravity.BottomRight, + }; + whiteView.AddChidren(btnConfirm); + btnConfirm.SetCornerWithSameRadius(Application.GetRealHeight(RradiusFrameLayout), HDLUtils.RectCornerBottomRight); + + dialog.Show(); + btnCancel.MouseUpEventHandler += (sender, e) => { dialog.Close(); }; - //鏍囬鎺т欢 - Button txetBtn = new Button + Button btnTip = new Button { - X = cancelnBtn.Right + Application.GetRealWidth(20), - Y = Application.GetRealHeight(23), - Width = Application.GetRealWidth(100), + Width = Application.GetRealWidth(0), + }; + whiteView.AddChidren(btnTip);//涓�鐩撮敊璇紝涓�鐩寸寷鐐癸紝涓�鐩村姞鎺т欢 + btnConfirm.MouseUpEventHandler += (sender, e) => + { + string listNameText = editText.Text.Trim(); + if (string.IsNullOrEmpty(listNameText) || List.Contains(listNameText)) + { + string tipMsgString = ""; + if (string.IsNullOrEmpty(editText.Text.Trim())) + { + tipMsgString = Language.StringByID(errorId_IsNullOrEmpty); + } + else + { + tipMsgString = Language.StringByID(errorId_PresenceP); + } + + whiteView.Height = Application.GetRealHeight(183); + btnLine.Y = whiteView.Height - Application.GetRealHeight(44 + 1); + btnCancel.Y = btnLine.Bottom; + btnConfirm.Y = btnLine.Bottom; + btnConfirm.Gravity = Gravity.BottomRight; + + btnTip.X = Application.GetRealWidth(24); + btnTip.Y = editBjView.Bottom + Application.GetRealHeight(12); + btnTip.Width = Application.GetRealWidth(222); + btnTip.Height = Application.GetRealHeight(17); + btnTip.Text = tipMsgString; + btnTip.TextColor = Color.RedColor; + btnTip.TextSize = TextSize.Text12; + btnTip.TextAlignment = TextAlignment.CenterLeft; + + return; + } + + + confirmAction(editText.Text.Trim()); + dialog.Close(); + }; + + } + + /// <summary> + /// 杈撳叆妗� + /// </summary> + /// <param name="titleId">鏍囬鏂囨湰</param> + /// <param name="tnputEditTxet">杈撳叆鏂囨湰</param> + /// <param name="errorId_IsNullOrEmpty">杈撳叆妗嗘湰鏂囦负绌鸿嚜瀹氫箟鎻愮ず閿欒鏂囨湰</param> + /// <param name="confirmAction">鍥炶皟鍑芥暟</param> + public void InputBox(int titleId, string tnputEditTxet, int errorId_IsNullOrEmpty, Action<string> confirmAction) + { + Dialog dialog = new Dialog() + { + BackgroundColor = Color.PopupBackgroundColor, + }; + + FrameLayout whiteView = new FrameLayout() + { + //Gravity = Gravity.Center, + X = Application.GetRealWidth(53), + Y = Application.GetRealHeight(264), + Width = Application.GetRealWidth(270), + Height = Application.GetRealHeight(172), + BackgroundColor = Color.WhiteColor, + BorderColor = 0x00000000, + BorderWidth = 0, + Radius = (uint)Application.GetRealHeight(RradiusFrameLayout), + }; + dialog.AddChidren(whiteView); + + Button btnTitle = new Button() + { + Y = Application.GetRealHeight(20), + X = Application.GetRealWidth(35), Height = Application.GetRealHeight(22), - TextColor = Color.TextColor, + Width = Application.GetRealWidth(200), + TextColor = Color.SelectedColor, TextSize = TextSize.Text16, TextAlignment = TextAlignment.Center, - TextID = StringId.myList, - IsBold=true, - }; - topFra.AddChidren(txetBtn); + TextID = titleId, - //娣诲姞鍥炬爣鎺т欢 - Button addIconBtn = new Button - { - X = Application.GetRealWidth(304), - Y = Application.GetRealHeight(20), - Width = Application.GetMinRealAverage(28), - Height = Application.GetMinRealAverage(28), - UnSelectedImagePath = "MusicIcon/addMusic.png", }; - topFra.AddChidren(addIconBtn); - + whiteView.AddChidren(btnTitle); - VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout + FrameLayout editBjView = new FrameLayout() { - Y = Application.GetRealHeight(70), - Height = dialogFra.Height - Application.GetRealHeight(70), - Width = Application.GetRealWidth(344), + // Gravity = Gravity.CenterHorizontal, + Y = btnTitle.Bottom + Application.GetRealHeight(16), + X = Application.GetRealWidth(24), + Width = Application.GetRealWidth(222), + Height = Application.GetRealHeight(40), + BackgroundColor = Color.ViewColor, + BorderColor = 0x00000000, + BorderWidth = 0, + Radius = (uint)Application.GetMinRealAverage(radiusEditFrameLayout), }; - dialogFra.AddChidren(verticalScrolViewLayout); - addIconBtn.MouseUpEventHandler += (sender, e) => + whiteView.AddChidren(editBjView); + + EditText editText = new EditText() { - new PublicAssmebly().LoadDialog_EditParater(StringId.addNewList, StringId.listNameInput, "", (name) => - { - if (string.IsNullOrEmpty(name)) - { - //鍒楄〃鍚嶄负绌� - new PublicAssmebly().TipMsg(StringId.tip, StringId.listNameNull); - return; - } - foreach (var lists in A31MusicModel.Current.FileLists) - { - if (lists.ListName == name) - { - //鍒楄〃鍚嶇О鐩稿悓 - new PublicAssmebly().TipMsg(StringId.tip, StringId.listNamesSame); - return; - } - } - A31MusicModel.Current.FileLists.Add(new FileListInfo { ListName = name, }); - A31MusicModel.Save(); - FileView(verticalScrolViewLayout); - }); + X = Application.GetRealWidth(12), + Y = Application.GetRealHeight(10), + Width = Application.GetRealWidth(160), + Height = Application.GetRealHeight(20), + Text = tnputEditTxet, + TextColor = Color.TextColor, + TextSize = TextSize.Text14, + TextAlignment = TextAlignment.CenterLeft, }; - FileView(verticalScrolViewLayout); + editBjView.AddChidren(editText); + + Button clearIconBtn = new Button + { + X = Application.GetRealWidth(194), + Y = Application.GetRealHeight(8), + Width = Application.GetMinRealAverage(24), + Height = Application.GetMinRealAverage(24), + UnSelectedImagePath = "MusicIcon/clear.png", + }; + editBjView.AddChidren(clearIconBtn); + clearIconBtn.MouseUpEventHandler += (sender, e) => + { + editText.Text = ""; + }; + + Button btnLine = new Button() + { + Y = whiteView.Height - Application.GetRealHeight(44 + 1), + Height = Application.GetRealHeight(1), + BackgroundColor = Color.LineColor, + }; + whiteView.AddChidren(btnLine); + + Button btnCancel = new Button() + { + Y = btnLine.Bottom, + Width = Application.GetRealWidth(135), + Height = Application.GetRealHeight(44), + TextAlignment = TextAlignment.Center, + TextColor = Color.TextCancelColor, + TextSize = TextSize.Text16, + TextID = StringId.cancelMusic, + }; + whiteView.AddChidren(btnCancel); + + Button btnConfirm = new Button() + { + X = btnCancel.Right, + Y = btnLine.Bottom, + Width = Application.GetRealWidth(135), + Height = Application.GetRealHeight(44), + TextAlignment = TextAlignment.Center, + TextColor = Color.WhiteColor, + IsBold = true, + TextSize = TextSize.Text16, + TextID = StringId.confirmMusic, + BackgroundColor = Color.SelectedColor, + Gravity=Gravity.BottomRight, + }; + whiteView.AddChidren(btnConfirm); + btnConfirm.SetCornerWithSameRadius(Application.GetRealHeight(RradiusFrameLayout), HDLUtils.RectCornerBottomRight); + dialog.Show(); + btnCancel.MouseUpEventHandler += (sender, e) => + { + dialog.Close(); + }; + + Button btnTip = new Button + { + Width = Application.GetRealWidth(0), + }; + whiteView.AddChidren(btnTip);//涓�鐩撮敊璇紝涓�鐩寸寷鐐癸紝涓�鐩村姞鎺т欢 + + btnConfirm.MouseUpEventHandler += (sender, e) => + { + if (string.IsNullOrEmpty(editText.Text.Trim())) + { + + whiteView.Height = Application.GetRealHeight(183); + btnLine.Y = whiteView.Height - Application.GetRealHeight(44 + 1); + btnCancel.Y = btnLine.Bottom; + btnConfirm.Y = btnLine.Bottom; + btnConfirm.Gravity = Gravity.BottomRight; + + btnTip.X = Application.GetRealWidth(24); + btnTip.Y = editBjView.Bottom + Application.GetRealHeight(12); + btnTip.Width = Application.GetRealWidth(222); + btnTip.Height = Application.GetRealHeight(17); + btnTip.Text = Language.StringByID(errorId_IsNullOrEmpty); + btnTip.TextColor = Color.RedColor; + btnTip.TextSize = TextSize.Text12; + btnTip.TextAlignment = TextAlignment.CenterLeft; + return; + } + + + confirmAction(editText.Text.Trim()); + dialog.Close(); + }; } - void FileView(VerticalScrolViewLayout verticalScrolViewLayout) + + /// <summary> + /// 纭畾鎻愮ず妗� + /// </summary> + /// <param name="titleId">鏍囬鏂囨湰</param> + /// <param name="tipTxet">鑷畾涔夋彁绀烘枃鏈�</param> + /// <param name="confirmAction">鍥炶皟鍑芥暟</param> + public void TipBox(int titleId, int tipTxet, Action confirmAction) { - verticalScrolViewLayout.RemoveAll(); - for (int i = 0; i < A31MusicModel.Current.FileLists.Count; i++) + Dialog dialog = new Dialog() { - var list = A31MusicModel.Current.FileLists[i]; - RowLayout addFlieRow = new RowLayout - { - Height = Application.GetRealHeight(78), - LineColor = Color.WhiteColor, - SubViewWidth = Application.GetRealWidth(80),//鏀瑰彉缂栬緫鎺т欢瀹藉害澶氬皯锛� - }; - verticalScrolViewLayout.AddChidren(addFlieRow); - //鏂囦欢鍥炬爣 - Button fileIconBtn = new Button - { - X = Application.GetRealWidth(12), - Y = Application.GetRealHeight(8), - Width = Application.GetMinRealAverage(62), - Height = Application.GetMinRealAverage(62), - UnSelectedImagePath = "MusicIcon/file.png", - }; - addFlieRow.AddChidren(fileIconBtn); + BackgroundColor = Color.PopupBackgroundColor, + }; - //鏂囦欢鍚嶆帶浠� - Button fileNameBtn = new Button - { - X = fileIconBtn.Right + Application.GetRealWidth(12), - Y = Application.GetRealHeight(29), - Width = Application.GetRealWidth(189), - Height = Application.GetRealHeight(20), - TextColor = Color.TextColor, - TextSize = TextSize.Text14, - TextAlignment = TextAlignment.CenterLeft, - Text = list.ListName, - }; - addFlieRow.AddChidren(fileNameBtn); + FrameLayout whiteView = new FrameLayout() + { + //Gravity = Gravity.Center, + X = Application.GetRealWidth(53), + Y = Application.GetRealHeight(264), + Width = Application.GetRealWidth(270), + Height = Application.GetRealHeight(140), + BackgroundColor = Color.WhiteColor, + BorderColor = 0x00000000, + BorderWidth = 0, + Radius = (uint)Application.GetRealHeight(RradiusFrameLayout), + }; + dialog.AddChidren(whiteView); - ///缂栬緫鎺т欢 - var editBtn = new Button - { - BackgroundColor = Color.MusicEditColor, - Text = Language.StringByID(StringId.editMusic), - TextColor = Color.WhiteColor, - TextSize = TextSize.Text16, - }; - addFlieRow.AddRightView(editBtn); + Button titleBtn = new Button() + { + Y = Application.GetRealHeight(20), + X = Application.GetRealWidth(35), + Height = Application.GetRealHeight(22), + Width = Application.GetRealWidth(270 - 35 * 2), + TextColor = Color.SelectedColor, + TextSize = TextSize.Text16, + TextAlignment = TextAlignment.Center, + TextID = titleId, + }; + whiteView.AddChidren(titleBtn); - editBtn.MouseUpEventHandler += (sender, e) => - { - new PublicAssmebly().LoadDialog_EditParater(StringId.ChangeName, list.ListName, (name) => - { - if (string.IsNullOrEmpty(name)) - { - //鍒楄〃鍚嶄负绌� - new PublicAssmebly().TipMsg(StringId.tip, StringId.listNameNull); - return; - } - foreach (var lists in A31MusicModel.Current.FileLists) - { - if (lists.ListName == name) - { - //鍒楄〃鍚嶇О鐩稿悓 - new PublicAssmebly().TipMsg(StringId.tip, StringId.listNamesSame); - return; - } - } + Button tipBtn = new Button() + { + Y = titleBtn.Bottom + Application.GetRealHeight(8), + X = Application.GetRealWidth(20), + Height = Application.GetRealHeight(22), + Width = Application.GetRealWidth(270 - 20 * 2), + TextColor = Color.TextCancelColor, + TextSize = TextSize.Text12, + TextAlignment = TextAlignment.Center, + TextID = tipTxet, + }; + whiteView.AddChidren(tipBtn); - var file = A31MusicModel.Current.FileLists.Find((c) => { return c.ListName == list.ListName; }); - if (file != null) - { - if (file.ListName != name) - { ///淇敼鍚嶇О涓嶄竴鏍锋洿鏂颁繚瀛� - file.ListName = name; - fileNameBtn.Text = name; - A31MusicModel.Save(); - } - } - if (list.ListName != name) - { ///淇敼鍚嶇О涓嶄竴鏍锋洿鏂颁繚瀛� - list.ListName = name; - fileNameBtn.Text = name; - A31MusicModel.Save(); - } - }); - }; + Button btnLine = new Button() + { + Y = whiteView.Height - Application.GetRealHeight(44 + 1), + Height = Application.GetRealHeight(1), + BackgroundColor = Color.LineColor, + }; + whiteView.AddChidren(btnLine); - ///鍒犻櫎鎺т欢 - var delBtn = new Button - { - BackgroundColor = Color.MusicDelColor, - Text = Language.StringByID(StringId.delMusic), - TextColor = Color.WhiteColor, - TextSize=TextSize.Text16, - }; - addFlieRow.AddRightView(delBtn); - delBtn.MouseUpEventHandler += (sender, e) => - { - new PublicAssmebly().TipMsg(StringId.tip, StringId.delMusicFile, () => - { - addFlieRow.RemoveFromParent(); - A31MusicModel.Current.FileLists.Remove(list); - A31MusicModel.Save(); - }); + Button btnCancel = new Button() + { + Y = btnLine.Bottom, + Width = Application.GetRealWidth(135), + Height = Application.GetRealHeight(44), + TextAlignment = TextAlignment.Center, + TextColor = Color.TextCancelColor, + TextSize = TextSize.Text16, + TextID = StringId.cancelMusic, + }; + whiteView.AddChidren(btnCancel); - }; + Button btnConfirm = new Button() + { + X = btnCancel.Right, + Y = btnLine.Bottom, + Width = Application.GetRealWidth(135), + Height = Application.GetRealHeight(44), + TextAlignment = TextAlignment.Center, + TextColor = Color.WhiteColor, + IsBold = true, + TextSize = TextSize.Text16, + TextID = StringId.confirmMusic, + BackgroundColor = Color.SelectedColor, + Gravity = Gravity.BottomRight, + }; + whiteView.AddChidren(btnConfirm); + btnConfirm.SetCornerWithSameRadius(Application.GetRealHeight(RradiusFrameLayout), HDLUtils.RectCornerBottomRight); + dialog.Show(); + btnCancel.MouseUpEventHandler += (sender, e) => + { + dialog.Close(); + }; - } - + btnConfirm.MouseUpEventHandler += (sender, e) => + { + confirmAction(); + dialog.Close(); + }; } + } } -- Gitblit v1.8.0