using System;
|
using System.Collections.Generic;
|
using Shared.Common;
|
|
namespace Shared.Phone.Device.Category
|
{
|
public class SelectHouse : FrameLayout
|
{
|
public Action<string> HouseAction;
|
|
Dialog dialogBackground;
|
/// <summary>
|
/// Init
|
/// </summary>
|
public void Init()
|
{
|
dialogBackground = new Dialog
|
{
|
BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
|
};
|
dialogBackground.Show();
|
var dialog = new FrameLayout()
|
{
|
};
|
dialogBackground.AddChidren(dialog);
|
|
dialog.MouseUpEventHandler += (sender, e) =>
|
{
|
RemoveView();
|
};
|
|
var bg = new Button
|
{
|
X = Application.GetRealWidth(35),
|
Y = Application.GetRealHeight(256),
|
Width = Application.GetMinRealAverage(449),
|
Height = Application.GetMinRealAverage(475),
|
UnSelectedImagePath = "Item/SelectHouse.png"
|
};
|
dialog.AddChidren(bg);
|
|
var changeHomeFL = new FrameLayout()
|
{
|
X = Application.GetRealWidth(35),
|
Y = Application.GetRealHeight(256),
|
Height = Application.GetMinRealAverage(449),
|
Width = Application.GetMinRealAverage(475),
|
Radius = CommonPage.BigFormRadius,
|
//BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
};
|
dialog.AddChidren(changeHomeFL);
|
|
var changeHomeBtn = new Button()
|
{
|
X = Application.GetRealWidth(80),
|
Y=Application.GetRealHeight(20),
|
Width = Application.GetRealWidth(350),
|
Height = Application.GetMinRealAverage(150),
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
TextID = R.MyInternationalizationString.ChangeHome,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 14,
|
IsBold = true
|
};
|
changeHomeFL.AddChidren(changeHomeBtn);
|
|
var scrolView = new VerticalScrolViewLayout()
|
{
|
Y = changeHomeBtn.Bottom,
|
Height = Application.GetMinRealAverage(300),
|
VerticalScrollBarEnabled = false
|
};
|
changeHomeFL.AddChidren(scrolView);
|
|
if (Config.Instance.HomeFilePathList.Count > 0)
|
{
|
foreach (var housePath in Config.Instance.HomeFilePathList)
|
{
|
var home = House.GetHouseByFilePath(housePath);
|
if (home == null)
|
{
|
continue;
|
}
|
AddFloor(scrolView, home);
|
}
|
}
|
}
|
|
/// <summary>
|
/// AddFloor
|
/// </summary>
|
/// <param name="verticalScrolView"></param>
|
private void AddFloor(VerticalScrolViewLayout verticalScrolView, House house)
|
{
|
var frow = new CommonForm.LeftIconButtonRow(449, 150);
|
frow.Tag = house.FileName;
|
frow.Init("Item/House.png", "Item/HouseSelected.png", house.Name);
|
verticalScrolView.AddChidren(frow);
|
if (Config.Instance.HomeId == house.Id)
|
{
|
frow.IsSelected = true;
|
}
|
|
frow.ButtonClickEvent += SelectFloor_MouseUpEvent;
|
}
|
|
/// <summary>
|
/// SelectFloor_MouseUpEvent
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="mouseEventArgs"></param>
|
private void SelectFloor_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
|
{
|
(sender as CommonForm.LeftIconButtonRow).IsSelected = true;
|
var home = House.GetHouseByFilePath((sender as CommonForm.LeftIconButtonRow).Tag.ToString());
|
RemoveView();
|
HouseAction?.Invoke(home.Id);
|
}
|
|
/// <summary>
|
/// RemoveView
|
/// </summary>
|
private void RemoveView()
|
{
|
dialogBackground.Close();
|
RemoveFromParent();
|
}
|
}
|
}
|