using System; using System.Collections.Generic; using Shared.Common; namespace Shared.Phone.Device.CommonForm { public class SelectTime: UserCenter.FrameLayoutBase { public Action TimeAction; Button TempSelectBtn; Button TempTimeBtn; public int TempTime; /// /// Init /// public void Init() { var dialog = new FrameLayout() { BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor }; AddChidren(dialog); dialog.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); }; var backgroundFL = new FrameLayout { Y = Application.GetRealHeight(596), Height = Application.GetRealHeight(1325), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; backgroundFL.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight); dialog.AddChidren(backgroundFL); var topView = new FrameLayout { Height = Application.GetRealHeight(138) }; backgroundFL.AddChidren(topView); var cancle = new Button { X=Application.GetRealWidth(80), Width=Application.GetRealWidth(300), TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.GXCTextGrayColor, TextID=R.MyInternationalizationString.Cancel, TextSize=14 }; topView.AddChidren(cancle); var title = new Button { Width = Application.GetRealWidth(300), Gravity=Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextBlackColor2, TextID=R.MyInternationalizationString.Delay, TextSize = 16 }; topView.AddChidren(title); var confrim=new Button { X = Application.GetRealWidth(CommonFormResouce.AppRealWidth-80-300), Width = Application.GetRealWidth(300), TextAlignment = TextAlignment.CenterRight, TextColor = ZigbeeColor.Current.GXCTextSelectedColor2, TextID = R.MyInternationalizationString.Complete, TextSize = 14 }; topView.AddChidren(confrim); var Line = new FrameLayout() { Y = topView.Height - 1, Height = 1, BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2 }; topView.AddChidren(Line); var timeLayout = new VerticalScrolViewLayout { Y = Application.GetRealHeight(207), Height = Application.GetRealHeight(703 + 127 * 2 + 12+12), ScrollEnabled = false, VerticalScrollBarEnabled = false, }; backgroundFL.AddChidren(timeLayout); TempSelectBtn = new Button(); TempTimeBtn = new Button(); var notOpen = new Button { X = Application.GetRealWidth(80), Y=Application.GetRealHeight(1200), Width=Application.GetRealWidth(400), Height=Application.GetRealHeight(80), TextColor = ZigbeeColor.Current.GXCTextGrayColor4, TextID = R.MyInternationalizationString.NotOpen, TextAlignment = TextAlignment.CenterLeft, TextSize=14 }; backgroundFL.AddChidren(notOpen); cancle.MouseUpEventHandler += Close; confrim.MouseUpEventHandler += Confrim_MouseEvent; notOpen.MouseUpEventHandler += NotOpen_MouseEvent; var tList = new List(); tList.Add(15); tList.Add(30); tList.Add(60); tList.Add(60 * 5); tList.Add(60 * 15); tList.Add(60 * 30); tList.Add(60 * 60); foreach(var t in tList) { AddTime(timeLayout, t); } } /// /// AddTime /// /// private void AddTime(VerticalScrolViewLayout verticalScrolView, int timess) { var row = new FrameLayout { Height = Application.GetRealHeight(127+12), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; verticalScrolView.AddChidren(row); var trow = new FrameLayout { Y=Application.GetRealHeight(12), Height = Application.GetRealHeight(127), BackgroundColor=ZigbeeColor.Current.GXCBackgroundColor }; row.AddChidren(trow); var timeBtn = new Button { X = Application.GetRealWidth(80), Width=Application.GetRealWidth(500), TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.GXCTextGrayColor4, SelectedTextColor = ZigbeeColor.Current.GXCTextBlackColor, IsSelected=false, TextSize=14 }; trow.AddChidren(timeBtn); var selectBtn = new Button { X = Application.GetRealWidth(942), Width = this.GetPictrueRealSize(60), Height=this.GetPictrueRealSize(60), Gravity=Gravity.CenterVertical, UnSelectedImagePath="Item/ItemSelected.png", Visible=false }; trow.AddChidren(selectBtn); var Line = new FrameLayout() { Y = row.Height - 1, Width = Application.GetRealWidth(919), Height = 1, Gravity=Gravity.CenterHorizontal, BackgroundColor = Common.ZigbeeColor.Current.GXCGrayLineColor2 }; row.AddChidren(Line); EventHandler eventHandler = (sender, e) => { TempTimeBtn.IsSelected = false; TempSelectBtn.Visible = false; timeBtn.IsSelected = true; selectBtn.Visible = true; TempTimeBtn = timeBtn; TempSelectBtn = selectBtn; TempTime = timess; }; timeBtn.MouseUpEventHandler += eventHandler; trow.MouseUpEventHandler += eventHandler; timeBtn.Text =CommonFormResouce.GetTimeString(timess); if (timess == TempTime) { timeBtn.IsSelected = true; selectBtn.Visible = true; TempTimeBtn = timeBtn; TempSelectBtn = selectBtn; } } /// /// Close /// /// /// private void Close(object sender,MouseEventArgs mouseEventArgs) { RemoveFromParent(); } /// /// Confrim_MouseEvent /// /// /// private void Confrim_MouseEvent(object sender,MouseEventArgs mouseEventArgs) { TimeAction.Invoke(TempTime); RemoveFromParent(); } /// /// NotOpen_MouseEvent /// /// /// private void NotOpen_MouseEvent(object sender,MouseEventArgs mouseEventArgs) { TimeAction.Invoke(0); RemoveFromParent(); } } }