From 34e965100d635346e2d4cd6e6013bdaed66b3004 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期四, 02 一月 2020 19:52:13 +0800
Subject: [PATCH] 2019.1.2-3
---
ZigbeeApp/Shared/Phone/Device/CommonForm/SceneMainView.cs | 226 +++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 196 insertions(+), 30 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneMainView.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneMainView.cs
old mode 100755
new mode 100644
index 9318ae8..49ce8a9
--- a/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneMainView.cs
+++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/SceneMainView.cs
@@ -16,7 +16,7 @@
/// <summary>
/// SceneIcon
/// </summary>
- public Button SceneIcon;
+ public ImageView SceneIcon;
/// <summary>
/// statu
/// </summary>
@@ -26,9 +26,17 @@
/// </summary>
private Button CardBG;
/// <summary>
+ /// sceneBG
+ /// </summary>
+ public Button sceneBG;
+ /// <summary>
/// v_Selected
/// </summary>
private bool v_Selected;
+ /// <summary>
+ /// scene
+ /// </summary>
+ public SceneUI scene;
/// <summary>
/// IsSelected
@@ -50,63 +58,81 @@
}
}
+ /// <summary>
+ /// SceneMainView
+ /// </summary>
+ /// <param name="x"></param>
+ /// <param name="y"></param>
public SceneMainView(int x, int y)
{
X = Application.GetRealWidth(x);
Y = Application.GetRealHeight(y);
- Width = Application.GetMinRealAverage(487);
- Height = Application.GetMinRealAverage(348);
+ Width = Application.GetRealWidth(487);
+ Height = Application.GetRealHeight(358);
}
/// <summary>
/// init
/// </summary>
- public void Init()
+ public void Init(SceneUI sceneUI)
{
-
- CardBG = new Button
- {
- Width = Application.GetMinRealAverage(487),
- Height = Application.GetMinRealAverage(348),
- UnSelectedImagePath = "Item/FunctionCardView.png",
- Gravity = Gravity.CenterHorizontal
- };
- AddChidren(CardBG);
+ this.scene = sceneUI;
- SceneIcon = new Button
+ InitFrame();
+
+ InitStatu();
+ }
+
+ /// <summary>
+ /// InitFrame
+ /// </summary>
+ private void InitFrame()
+ {
+ //CardBG = new Button
+ //{
+ // Width = Application.GetMinRealAverage(487),
+ // Height = Application.GetMinRealAverage(348),
+ // UnSelectedImagePath = "Item/FunctionCardView.png",
+ // Gravity = Gravity.CenterHorizontal
+ //};
+ //AddChidren(CardBG);
+
+ SceneIcon = new ImageView
{
- X = Application.GetMinRealAverage(14),
+ X=Application.GetRealWidth(14),
Width = Application.GetMinRealAverage(458),
- Height = Application.GetRealHeight(305),
- Gravity = Gravity.CenterHorizontal
+ Height = Application.GetMinRealAverage(305),
+ Gravity = Gravity.CenterHorizontal,
+ Radius= (uint)Application.GetRealHeight(17)
};
AddChidren(SceneIcon);
+ //SceneIcon.SetViewShadow(true);
+ //SceneIcon.SetCornerWithSameRadius(Application.GetRealHeight(100), HDLUtils.RectCornerBottomRight);
- var sceneBG = new Button
+ sceneBG = new Button
{
Width = Application.GetMinRealAverage(487),
Height = Application.GetMinRealAverage(348),
- UnSelectedImagePath = "Item/SceneCard.png",
+ UnSelectedImagePath = "Scene/Background.png",
Gravity = Gravity.CenterHorizontal
};
AddChidren(sceneBG);
TimeButton = new Button()
{
- X = Application.GetMinRealAverage(40),
- Y = Application.GetMinRealAverage(17),
- Width = Application.GetMinRealAverage(320),
+ X = Application.GetMinRealAverage(30),
+ Y = Application.GetMinRealAverage(20),
+ Width = Application.GetMinRealAverage(63),
Height = Application.GetMinRealAverage(63),
TextColor = ZigbeeColor.Current.GXCTextSelectedColor3,
TextAlignment = TextAlignment.CenterLeft,
- Text="58s"
};
AddChidren(TimeButton);
CollectButton = new Button
{
- X = Application.GetMinRealAverage(366),
- Y = Application.GetMinRealAverage(14),
+ X = Application.GetMinRealAverage(350),
+ Y = Application.GetMinRealAverage(1),
Width = Application.GetMinRealAverage(107),
Height = Application.GetMinRealAverage(107),
UnSelectedImagePath = "Item/Collection1.png",
@@ -120,15 +146,31 @@
Y = Application.GetMinRealAverage(239),
Width = Application.GetMinRealAverage(279),
Height = Application.GetMinRealAverage(60),
- TextColor = ZigbeeColor.Current.GXCTextBlackColor,
+ TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
SelectedTextColor = ZigbeeColor.Current.GXCTextSelectedColor,
TextAlignment = TextAlignment.CenterLeft,
- Text="璧峰簥"
+ TextSize = 14,
+ IsBold = true
};
AddChidren(SceneNameButton);
-
}
+ /// <summary>
+ /// InitStatu
+ /// </summary>
+ private void InitStatu()
+ {
+ SetTimeByDelayTime(scene.SceneDelayTime);
+ SetSceneNameText(scene.Name);
+ SetIcon(scene.IconPath);
+ SetCollect(Common.Room.CurrentRoom.GetLoveRoom().SceneUIFilePathList.Contains(scene.FileName));
+
+ TimeButton.MouseUpEventHandler += SetTimeEvents;
+ CollectButton.MouseUpEventHandler += CollectionEvent;
+ SceneIcon.MouseUpEventHandler += SceneUpHandler;
+ SceneNameButton.MouseUpEventHandler += SceneUpHandler;
+ sceneBG.MouseUpEventHandler += SceneUpHandler;
+ }
/// <summary>
/// SetTimeText
@@ -136,10 +178,12 @@
/// <param name="name"></param>
public void SetTimeText(string name)
{
- TimeButton.Width = Application.GetMinRealAverage(320);
+ TimeButton.Width = Application.GetMinRealAverage(280);
TimeButton.Height = Application.GetMinRealAverage(63);
TimeButton.UnSelectedImagePath = string.Empty;
TimeButton.Text = name;
+ TimeButton.TextSize = 14;
+ TimeButton.IsBold = true;
}
/// <summary>
@@ -151,6 +195,22 @@
TimeButton.Height = Application.GetMinRealAverage(63);
TimeButton.UnSelectedImagePath = "Item/Time.png";
TimeButton.Text = string.Empty;
+ }
+
+ /// <summary>
+ /// SetIimeByDelayTime
+ /// </summary>
+ /// <param name="time"></param>
+ public void SetTimeByDelayTime(int time)
+ {
+ if (time > 0)
+ {
+ SetTimeText(CommonFormResouce.GetTimeString(time));
+ }
+ else
+ {
+ SetTimeImage();
+ }
}
/// <summary>
@@ -168,7 +228,14 @@
/// <param name="iconPath"></param>
public void SetIcon(string iconPath)
{
- SceneIcon.UnSelectedImagePath = iconPath;
+ if (scene.IconPathType == 0)
+ {
+ SceneIcon.ImagePath = iconPath;
+ }
+ else
+ {
+ SceneIcon.ImagePath = System.IO.Path.Combine(Config.Instance.FullPath, iconPath);
+ }
}
/// <summary>
@@ -179,5 +246,104 @@
{
CollectButton.IsSelected = collect;
}
+
+ /// <summary>
+ /// 璋冪敤鍦烘櫙
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="args"></param>
+ private async void SceneUpHandler(object sender, MouseEventArgs args)
+ {
+ if (scene.RemainTime > 0 && scene.SceneDelayTime == 0)
+ {
+ CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying));
+ return;
+ }
+ //1鎴愬姛 0澶辫触
+ //鍚庨潰琛ヤ笂鐩稿叧鎻愮ず
+ // Error鍙傛暟鍚箟
+ //<para>1锛氱綉鍏虫棤娉曡В鏋愬懡浠ゆ暟鎹��</para>
+ //<para>2锛氬崗璋冨櫒姝e湪鍗囩骇鎴栧浠�/鎭㈠鏁版嵁
+ //<para>3锛氭搷浣滆澶�/缁�/鍦烘櫙涓嶅瓨鍦�</para>
+ //<para>4锛氬叾浠栭敊璇�</para>
+ //<para>5锛氭暟鎹紶杈撻敊璇紙鍦ㄦ煇娆″鎴风鍚戠綉鍏冲彂閫佹暟鎹殑杩囩▼涓紝缃戝叧鍦ㄥ悎鐞嗘椂闂磋寖鍥村唴鎺ユ敹瀹㈡埛绔暟鎹笉瀹屾暣瀵艰嚧璇ラ敊璇彂鐢熴�傚瀹㈡埛绔悜缃戝叧涓�娆″彂閫�100涓瓧鑺傜殑鏁版嵁锛屼絾缃戝叧绛夊緟鎺ユ敹浜嗕竴绉掑彧鎺ユ敹浜�80涓瓧鑺傘�傚彂鐢熻閿欒锛岀綉鍏冲皢涓诲姩鍏抽棴瀹㈡埛绔繛鎺ワ級</para>
+ var sceneOpenAllData = await ZigBee.Device.Scene.ControlSceneAsync(scene.Id, scene.SceneDelayTime);
+
+ if (sceneOpenAllData == null || sceneOpenAllData.sceneOpenData == null)
+ {
+ return;
+ }
+ if (sceneOpenAllData.sceneOpenData.Result == 0)
+ {
+ if (sceneOpenAllData.errorResponData == null)
+ {
+ return;
+ }
+ CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.ControlSceneFail);
+ }
+
+ scene.RemainTime = scene.SceneDelayTime;
+ scene.SceneDelayTime = 0;
+ new System.Threading.Thread(() =>
+ {
+ while (scene.RemainTime > 0)
+ {
+ System.Threading.Thread.Sleep(1000);
+ Application.RunOnMainThread(() =>
+ {
+ SetTimeText(CommonFormResouce.GetTimeString(scene.RemainTime));
+ });
+ scene.RemainTime -= 1;
+ }
+ Application.RunOnMainThread(() =>
+ {
+ SetTimeImage();
+ });
+ })
+ { IsBackground = true }.Start();
+ }
+
+ /// <summary>
+ /// 鏀惰棌
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="mouseEventArgs"></param>
+ private void CollectionEvent(object sender,MouseEventArgs mouseEventArgs)
+ {
+ (sender as Button).IsSelected = !(sender as Button).IsSelected;
+ if ((sender as Button).IsSelected)
+ {
+ Shared.Common.Room.CurrentRoom.GetLoveRoom().AddScene(scene);
+ }
+ else
+ {
+ Shared.Common.Room.CurrentRoom.GetLoveRoom().RemoveScene(scene);
+ }
+ scene.Save();
+ }
+
+ /// <summary>
+ /// setTimeEvent
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="mouseEventArgs"></param>
+ private void SetTimeEvents(object sender, MouseEventArgs mouseEventArgs)
+ {
+ if (scene.RemainTime > 0)
+ {
+ CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying));
+ return;
+ }
+ var timeSelect = new SelectTime();
+ CommonPage.Instance.AddChidren(timeSelect);
+ timeSelect.TempTime = scene.SceneDelayTime;
+ timeSelect.Init();
+ timeSelect.TimeAction = (t) =>
+ {
+ scene.SceneDelayTime = t;
+ SetTimeByDelayTime(t);
+ };
+ }
+
}
}
--
Gitblit v1.8.0