using System; using Shared.Common; namespace Shared.Phone.Device.CommonForm { public class FunctionMainView : FrameLayout { /// /// name /// public Button NameButton; /// /// collect /// public Button CollectButton; /// /// Image /// public Button IconButton; /// /// ImageBG /// public Button ImageBG; /// /// statu /// public Button StatuButton; /// /// switch /// public Button SwitchButton; /// /// CardBG /// public Button CardBG; /// /// v_Selected /// private bool v_Selected; /// /// IsSelected /// public bool IsSelected { set { try { v_Selected = value; SetStatu(v_Selected); } catch { }; } get { return v_Selected; } } public FunctionMainView(int x,int y) { X = Application.GetRealWidth(x); Y = Application.GetRealHeight(y); Width = Application.GetMinRealAverage(487); Height = Application.GetMinRealAverage(348); } /// /// init /// public void Init() { //var bg = new Button //{ // Width = Application.GetMinReal(487), // Height = Application.GetMinReal(348), //UnSelectedImagePath = "Item/FunctionViewBG.png" //}; //AddChidren(bg); CardBG = new Button { Width = Application.GetMinRealAverage(487), Height = Application.GetMinRealAverage(348), UnSelectedImagePath = "Item/FunctionCardView.png", SelectedImagePath = "Item/FunctionCardViewSelected.png", Gravity=Gravity.CenterHorizontal }; AddChidren(CardBG); NameButton = new Button() { X=Application.GetMinRealAverage(40), Y = Application.GetMinRealAverage(17), Width = Application.GetMinRealAverage(320), Height = Application.GetMinRealAverage(63), TextColor = ZigbeeColor.Current.GXCTextGrayColor, SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor, TextAlignment=TextAlignment.CenterLeft, TextSize=15 }; AddChidren(NameButton); CollectButton = new Button { X = Application.GetMinRealAverage(366), Y = Application.GetMinRealAverage(14), Width = Application.GetMinRealAverage(107), Height = Application.GetMinRealAverage(107), UnSelectedImagePath="Item/Collection1.png", SelectedImagePath="Item/CollectionSelected1.png" }; AddChidren(CollectButton); var imgFL = new FrameLayout { X = Application.GetMinRealAverage(40), Y = Application.GetMinRealAverage(101), Width = Application.GetMinRealAverage(124), Height = Application.GetMinRealAverage(124) }; AddChidren(imgFL); ImageBG = new Button() { //X=Application.GetMinRealAverage(40), //Y = Application.GetMinRealAverage(101), Width = Application.GetMinRealAverage(124), Height = Application.GetMinRealAverage(124), Gravity=Gravity.Center, BackgroundColor = ZigbeeColor.Current.GXCForFunctionUnSelectedBackgroundColor, SelectedBackgroundColor = ZigbeeColor.Current.GXCForFunctionBackgroundColor, Radius=(uint)Application.GetMinRealAverage(124/2) }; imgFL.AddChidren(ImageBG); IconButton = new Button() { //X=Application.GetMinRealAverage(63), //Y = Application.GetMinRealAverage(121), Width = Application.GetMinRealAverage(84), Height = Application.GetMinRealAverage(84), Gravity=Gravity.Center }; imgFL.AddChidren(IconButton); StatuButton = new Button() { X=Application.GetMinRealAverage(46), Y = Application.GetMinRealAverage(239), Width = Application.GetMinRealAverage(279), Height = Application.GetMinRealAverage(60), TextColor = ZigbeeColor.Current.GXCTextBlackColor, SelectedTextColor = ZigbeeColor.Current.GXCTextSelectedColor, TextAlignment=TextAlignment.CenterLeft, TextSize=14, IsBold=true }; AddChidren(StatuButton); SwitchButton = new Button { X = Application.GetMinRealAverage(325), Y = Application.GetMinRealAverage(202), Width = Application.GetMinRealAverage(109), Height = Application.GetMinRealAverage(104), UnSelectedImagePath = "Item/Switch1.png", SelectedImagePath = "Item/SwitchSelected1.png" }; AddChidren(SwitchButton); } /// /// SetStatu /// /// private void SetStatu(bool statu) { NameButton.IsSelected = IconButton.IsSelected = SwitchButton.IsSelected = StatuButton.IsSelected = CardBG.IsSelected = statu; NameButton.IsBold = statu; } /// /// SetDeviceImage /// /// /// public void SetDeviceImage(string img,string seletedImg) { IconButton.UnSelectedImagePath = img; IconButton.SelectedImagePath = seletedImg; } /// /// SetDeviceName /// /// public void SetDeviceName(string name) { NameButton.Text = name; } /// /// SetStatu /// /// public void SetStatuText(string statu) { StatuButton.Text = statu; } /// /// SetCollect /// /// public void SetCollect(bool collect) { CollectButton.IsSelected = collect; } /// /// CanControl /// /// public void CanControl(bool cmd) { SwitchButton.Visible = cmd; } } }