From b02e8275a21dc06bf54b66273485d44e007a2616 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期一, 20 七月 2020 14:50:17 +0800
Subject: [PATCH] 新代码
---
ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFunctionSettionForm.cs | 542 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 542 insertions(+), 0 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFunctionSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFunctionSettionForm.cs
new file mode 100755
index 0000000..bebb777
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFunctionSettionForm.cs
@@ -0,0 +1,542 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+
+namespace Shared.Phone.UserCenter.DevicePanel
+{
+ /// <summary>
+ /// 鏂规偊闈㈡澘鍔熻兘璁剧疆
+ /// </summary>
+ public class PanelFangyueFunctionSettionForm : EditorCommonForm
+ {
+ #region 鈻� 鍙橀噺澹版槑___________________________
+
+ /// <summary>
+ /// 鍒楄〃鎺т欢
+ /// </summary>
+ private FrameListControl listview = null;
+ /// <summary>
+ /// 褰撳墠閫夋嫨鐨勮澶�
+ /// </summary>
+ private CommonDevice nowSelectDevice = null;
+ /// <summary>
+ /// 褰撳墠閫夋嫨鐨勫洖璺帶浠�
+ /// </summary>
+ private NormalViewControl nowSelectControl = null;
+ /// <summary>
+ /// 璁惧澶囨敞鐨勬帶浠�
+ /// </summary>
+ private FrameCaptionInputControl btnDeviceName = null;
+ /// <summary>
+ /// 璁惧鐨勬煇涓�鍥炶矾
+ /// </summary>
+ private CommonDevice deviceObj = null;
+ /// <summary>
+ /// 璁惧鐨勭被鍨�
+ /// </summary>
+ private DeviceEnumInfo deviceEnum = null;
+ /// <summary>
+ /// 璁惧闇�瑕佷繚瀛樼殑璁惧鍚嶅瓧
+ /// </summary>
+ private Dictionary<int, string> dicDeviceSaveName = new Dictionary<int, string>();
+ /// <summary>
+ /// 淇℃伅缂栬緫鎺т欢
+ /// </summary>
+ private InformationEditorControl tableContr = null;
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖朹____________________________
+
+ /// <summary>
+ /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
+ /// </summary>
+ /// <param name="i_device">璁惧鐨勬煇涓�鍥炶矾</param>
+ /// <param name="i_deviceEnum">璁惧鐨勭被鍨�</param>
+ public void ShowForm(CommonDevice i_device, DeviceEnumInfo i_deviceEnum)
+ {
+ this.deviceObj = i_device;
+ this.deviceEnum = i_deviceEnum;
+
+ //璁剧疆澶撮儴淇℃伅
+ base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uFunctionSettingUp));
+
+ //鍒濆鍖栦腑閮ㄤ俊鎭�
+ this.InitMiddleFrame();
+
+ //鍒濆鍖栧彸涓婅鑿滃崟
+ this.InitTopRightMenu();
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栦腑閮ㄤ俊鎭�
+ /// </summary>
+ private void InitMiddleFrame()
+ {
+ //娓呯┖bodyFrame
+ this.ClearBodyFrame();
+
+ var listBackControl = new VerticalFrameControl();
+ listBackControl.Height = bodyFrameLayout.Height;
+ bodyFrameLayout.AddChidren(listBackControl);
+
+ //鍒濆鍖栨甯�
+ this.tableContr = new InformationEditorControl();
+ this.listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uDeviceEditor), 1028);
+
+ //鍒濆鍖栬澶囧洖璺浘鏍�
+ this.InitDeviceEpointIcon(listBackControl);
+
+ //淇濆瓨
+ var btnFinish = new BottomClickButton();
+ btnFinish.TextID = R.MyInternationalizationString.uSave;
+ bodyFrameLayout.AddChidren(btnFinish);
+ btnFinish.ButtonClickEvent += (sender, e) =>
+ {
+ //璁板綍璧峰綋鍓嶆鍦ㄦ搷浣滅殑鍥炶矾鍚嶅瓧
+ dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = btnDeviceName.Text.Trim();
+ foreach (var epoint in dicDeviceSaveName.Keys)
+ {
+ var device = Common.LocalDevice.Current.GetDevice(deviceObj.DeviceAddr, epoint);
+ if (device == null || dicDeviceSaveName[epoint] == string.Empty)
+ {
+ //涓嶈兘鍏佽绌虹櫧鍚嶅瓧
+ continue;
+ }
+ string newName = dicDeviceSaveName[epoint];
+ string oldName = Common.LocalDevice.Current.GetDeviceEpointName(device);
+ if (oldName != newName)
+ {
+ //璁惧鍚嶇О淇敼
+ var result = Common.LocalDevice.Current.ReName(device, newName);
+ if (result == false)
+ {
+ return;
+ }
+ }
+ }
+ //鍏抽棴鑷韩
+ this.CloseForm();
+ };
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栬彍鍗曡
+ /// </summary>
+ private void InitMenuRow()
+ {
+ this.listview.RemoveAll();
+
+ //鍥炶矾澶囨敞
+ string caption = Language.StringByID(R.MyInternationalizationString.uDeviceEpointNote);
+ string nameValue = Common.LocalDevice.Current.GetDeviceEpointName(nowSelectDevice);
+ if (dicDeviceSaveName.ContainsKey(nowSelectDevice.DeviceEpoint) == true)
+ {
+ nameValue = dicDeviceSaveName[nowSelectDevice.DeviceEpoint];
+ }
+
+ this.btnDeviceName = new FrameCaptionInputControl(caption, nameValue, listview.rowSpace / 2);
+ listview.AddChidren(btnDeviceName);
+ btnDeviceName.InitControl();
+ btnDeviceName.AddBottomLine();
+ btnDeviceName.txtInput.FinishInputEvent += () =>
+ {
+ string oldName = Common.LocalDevice.Current.GetDeviceEpointName(nowSelectDevice);
+ if (btnDeviceName.Text.Trim() == string.Empty)
+ {
+ //灏嗗悕瀛楄繕鍘�
+ btnDeviceName.Text = oldName;
+ }
+ if (oldName != btnDeviceName.Text.Trim())
+ {
+ //璁惧鍚嶇О淇敼
+ var result = Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim());
+ if (result == false)
+ {
+ return;
+ }
+ //鍥炶矾澶囨敞淇敼鎴愬姛!
+ string msg = Language.StringByID(R.MyInternationalizationString.uDeviceEpointReNoteSuccess);
+ this.ShowMassage(ShowMsgType.Tip, msg);
+ }
+ };
+
+ //鎵�灞炲尯鍩�
+ var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
+ listview.AddChidren(rowBeloneArea);
+ rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), nowSelectDevice);
+ //搴曠嚎
+ rowBeloneArea.AddBottomLine();
+ rowBeloneArea.SelectRoomEvent += (roomKeys) =>
+ {
+ //鍙樻洿鎴块棿
+ HdlRoomLogic.Current.ChangedRoom(nowSelectDevice, roomKeys);
+ };
+
+ //娣诲姞鍔熻兘绫诲瀷琛�
+ this.AddFunctionTypeRow();
+ //鍒濆鍖栨甯冨畬鎴�
+ tableContr.FinishInitControl();
+ }
+
+ #endregion
+
+ #region 鈻� 鍙充笂瑙掕彍鍗昣________________________
+
+ /// <summary>
+ /// 鍒濆鍖栧彸涓婅鑿滃崟
+ /// </summary>
+ private void InitTopRightMenu()
+ {
+ //妫�娴嬫鍥炶矾鏄惁鎷ユ湁瀹氫綅鍔熻兘
+ if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(nowSelectDevice) == false)
+ {
+ return;
+ }
+ var btnIcon = new MostRightIconControl(69, 69);
+ btnIcon.UnSelectedImagePath = "Item/More.png";
+ topFrameLayout.AddChidren(btnIcon);
+ btnIcon.InitControl();
+ btnIcon.ButtonClickEvent += ((sender, e) =>
+ {
+ //鏄剧ず鍙充笂瑙掕彍鍗曠晫闈�
+ this.ShowTopRightMenu();
+ });
+ }
+
+ /// <summary>
+ /// 鏄剧ず鍙充笂瑙掕彍鍗曠晫闈�
+ /// </summary>
+ private void ShowTopRightMenu()
+ {
+ int menuCount = 1;
+ string deviceMenu = string.Empty;
+ //妫�娴嬫鍥炶矾鏄惁鎷ユ湁瀹氫綅鍔熻兘
+ bool canTest = Common.LocalDevice.Current.DeviceIsCanFixedPosition(nowSelectDevice);
+ //if (canTest == true)
+ //{
+ // menuCount = 2;
+ //}
+ var frame = new TopRightMenuControl(menuCount, 1);
+ if (canTest == true)
+ {
+ //瀹氫綅
+ deviceMenu = Language.StringByID(R.MyInternationalizationString.uFixedPosition);
+ frame.AddRowMenu(deviceMenu, "Item/FixedPosition.png", "Item/FixedPositionSelected.png", () =>
+ {
+ //鍙戦�佸畾浣嶅姛鑳�
+ Common.LocalDevice.Current.SetFixedPositionCommand(nowSelectDevice);
+ });
+ }
+
+ //鍒犻櫎
+ //deviceMenu = Language.StringByID(R.MyInternationalizationString.uDelete);
+ //frame.AddRowMenu(deviceMenu, "Item/DeleteIcon2.png", "Item/DeleteIcon2Selected.png", () =>
+ //{
+ //});
+ }
+
+ #endregion
+
+ #region 鈻� 鍔熻兘绫诲瀷___________________________
+
+ /// <summary>
+ /// 娣诲姞鍔熻兘绫诲瀷琛�
+ /// </summary>
+ private void AddFunctionTypeRow()
+ {
+ //鑷畾涔夊姛鑳界被鍨嬫帶浠�
+ var rowFunction = new DeviceFunctionTypeRowControl(nowSelectDevice, listview.rowSpace / 2);
+ if (rowFunction.CanShowRow == true)
+ {
+ listview.AddChidren(rowFunction);
+ rowFunction.InitControl();
+ //搴曠嚎
+ rowFunction.AddBottomLine();
+ }
+ }
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖栬澶囧洖璺浘鏍嘷________________
+
+ /// <summary>
+ /// 鍒濆鍖栬澶囧洖璺浘鏍�
+ /// </summary>
+ private void InitDeviceEpointIcon(VerticalFrameControl listBackControl)
+ {
+ bool hadDevice = false;
+ var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceObj.DeviceAddr);
+ var listSort = new List<CommonDevice>();
+ foreach (var device in listDevice)
+ {
+ //濡傛灉鏄户鐢靛櫒
+ if (device.Type == DeviceType.OnOffOutput)
+ {
+ listSort.Add(device);
+ if (device.DeviceEpoint == deviceObj.DeviceEpoint)
+ {
+ //鑳藉鍖归厤寰楀埌杩欎釜鍥炶矾
+ hadDevice = true;
+ }
+ }
+ }
+ //鎺掑簭
+ listSort.Sort((obj1, obj2) =>
+ {
+ if (obj1.DeviceEpoint > obj2.DeviceEpoint)
+ {
+ return 1;
+ }
+ return -1;
+ });
+ if (hadDevice == false)
+ {
+ //濡傛灉鍖归厤涓嶅埌杩欎釜鍥炶矾,鍒欓粯璁ょ涓�涓�
+ this.deviceObj = listSort[0];
+ }
+
+ var frameBorder = new FrameLayout();
+ frameBorder.Y = Application.GetRealHeight(150);
+ frameBorder.Gravity = Gravity.CenterHorizontal;
+ frameBorder.Width = this.GetPictrueRealSize(426);
+ frameBorder.Height = this.GetPictrueRealSize(426);
+ listBackControl.frameTable.AddChidren(frameBorder);
+
+ var btnPic = new PicViewControl(frameBorder.Width, frameBorder.Height, false);
+
+ frameBorder.AddChidren(btnPic);
+
+ if (deviceEnum.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueEight)
+ {
+ //鍥涘紑鍏帶闈㈡澘
+ btnPic.UnSelectedImagePath = "DeviceItem/PanelFangyueEightButtonTable.png";
+ this.InitEightButtonPanelIcon(frameBorder, listSort);
+ }
+ else if (deviceEnum.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFour)
+ {
+ //鍙屽紑鍥涙帶闈㈡澘
+ btnPic.UnSelectedImagePath = "DeviceItem/PanelFangyueFourButtonTable.png";
+ this.InitFourButtonPanelIcon(frameBorder, listSort);
+ }
+ else
+ {
+ //鍗曞紑鍙屾帶闈㈡澘
+ btnPic.UnSelectedImagePath = "DeviceItem/PanelFangyueTwoButtonTable.png";
+ this.InitTwoButtonPanelIcon(frameBorder, listSort);
+ }
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栨寜閽帶浠�
+ /// </summary>
+ /// <param name="frame">瀹瑰櫒</param>
+ /// <param name="device">璁惧瀵硅薄</param>
+ /// <returns></returns>
+ private NormalViewControl InitDeviceButtonControl(FrameLayout frame, CommonDevice device)
+ {
+ var btnIcon = new NormalViewControl(this.GetPictrueRealSize(52), this.GetPictrueRealSize(52), false);
+ btnIcon.Text = "CHANNEL" + device.DeviceEpoint;
+ btnIcon.TextAlignment = TextAlignment.Center;
+ btnIcon.TextColor = UserCenterColor.Current.TextGrayColor1;
+ btnIcon.IsBold = true;
+ if (frame is FrameLayoutStatuControl)
+ {
+ ((FrameLayoutStatuControl)frame).AddChidren(btnIcon, ChidrenBindMode.BindEvent);
+ ((FrameLayoutStatuControl)frame).ButtonClickEvent += (sender, e) =>
+ {
+ //鎸夐敭鐐瑰嚮
+ this.DeviceEpointSelectEvent(btnIcon, null);
+ };
+ }
+ else
+ {
+ frame.AddChidren(btnIcon);
+ //鐐瑰嚮浜嬩欢
+ btnIcon.ButtonClickEvent += (sender, e) =>
+ {
+ //鎸夐敭鐐瑰嚮
+ this.DeviceEpointSelectEvent(btnIcon, null);
+ };
+ }
+
+ if (device.DeviceEpoint == deviceObj.DeviceEpoint)
+ {
+ //鍒濆鍖栬彍鍗曡
+ this.DeviceEpointSelectEvent(btnIcon, null);
+ }
+ return btnIcon;
+ }
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖栦簩鎸夐敭鍥炬爣___________________
+
+ /// <summary>
+ /// 鍒濆鍖栧崟寮�鍙屾帶闈㈡澘鐨勫浘鏍�
+ /// </summary>
+ /// <param name="frameBack">瀹瑰櫒</param>
+ /// <param name="listDevice">璁惧鍒楄〃</param>
+ private void InitTwoButtonPanelIcon(FrameLayout frameBack, List<CommonDevice> listDevice)
+ {
+ //鎸夐敭1
+ var btnButton1 = this.InitDeviceButtonControl(frameBack, listDevice[0]);
+ btnButton1.Height = this.GetPictrueRealSize(175);
+ btnButton1.Width = this.GetPictrueRealSize(361);
+ btnButton1.Y = this.GetPictrueRealSize(39);
+ btnButton1.Gravity = Gravity.CenterHorizontal;
+
+ //鎸夐敭2
+ var btnButton2 = this.InitDeviceButtonControl(frameBack, listDevice[1]);
+ btnButton2.Height = this.GetPictrueRealSize(175);
+ btnButton2.Width = this.GetPictrueRealSize(361);
+ btnButton2.Y = btnButton1.Bottom;
+ btnButton2.Gravity = Gravity.CenterHorizontal;
+ }
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖栧洓鎸夐敭鍥炬爣___________________
+
+ /// <summary>
+ /// 鍒濆鍖栧弻寮�鍥涙帶閿潰鏉跨殑鍥炬爣
+ /// </summary>
+ /// <param name="frameBack">瀹瑰櫒</param>
+ /// <param name="listDevice">璁惧鍒楄〃</param>
+ private void InitFourButtonPanelIcon(FrameLayout frameBack, List<CommonDevice> listDevice)
+ {
+ //鎸夐敭1
+ var btnButton1 = this.InitDeviceButtonControl(frameBack, listDevice[0]);
+ btnButton1.TextSize = 8;
+ btnButton1.Height = this.GetPictrueRealSize(175);
+ btnButton1.Width = this.GetPictrueRealSize(183);
+ btnButton1.X = this.GetPictrueRealSize(34);
+ btnButton1.Y = this.GetPictrueRealSize(30);
+
+ //鎸夐敭2
+ var btnButton2 = this.InitDeviceButtonControl(frameBack, listDevice[1]);
+ btnButton2.TextSize = 8;
+ btnButton2.Height = this.GetPictrueRealSize(175);
+ btnButton2.Width = this.GetPictrueRealSize(183);
+ btnButton2.X = btnButton1.Right;
+ btnButton2.Y = btnButton1.Y;
+
+ //鎸夐敭3
+ var btnButton3 = this.InitDeviceButtonControl(frameBack, listDevice[2]);
+ btnButton3.TextSize = 8;
+ btnButton3.Height = this.GetPictrueRealSize(175);
+ btnButton3.Width = this.GetPictrueRealSize(183);
+ btnButton3.X = btnButton1.X;
+ btnButton3.Y = btnButton1.Bottom + this.GetPictrueRealSize(4);
+
+ //鎸夐敭4
+ var btnButton4 = this.InitDeviceButtonControl(frameBack, listDevice[3]);
+ btnButton4.TextSize = 8;
+ btnButton4.Height = this.GetPictrueRealSize(175);
+ btnButton4.Width = this.GetPictrueRealSize(183);
+ btnButton4.X = btnButton2.X;
+ btnButton4.Y = btnButton3.Y;
+ }
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖栧叓鎸夐敭鍥炬爣___________________
+
+ /// <summary>
+ /// 鍒濆鍖栧洓寮�鍏帶闈㈡澘鐨勫浘鏍�
+ /// </summary>
+ /// <param name="frameBack">瀹瑰櫒</param>
+ /// <param name="listDevice">璁惧鍒楄〃</param>
+ private void InitEightButtonPanelIcon(FrameLayout frameBack, List<CommonDevice> listDevice)
+ {
+ //鎸夐敭1锝炴寜閿�2
+ var frame1 = new FrameLayout();
+ frame1.X = this.GetPictrueRealSize(34);
+ frame1.Y = this.GetPictrueRealSize(30);
+ frame1.Height = this.GetPictrueRealSize(183);
+ frame1.Width = this.GetPictrueRealSize(183);
+ frameBack.AddChidren(frame1);
+ this.InitEightButtonPanelIcon(frame1, listDevice[0], listDevice[1]);
+
+ //鎸夐敭3锝炴寜閿�4
+ var frame2 = new FrameLayout();
+ frame2.X = frame1.Right;
+ frame2.Y = frame1.Y;
+ frame2.Height = frame1.Height;
+ frame2.Width = frame1.Width;
+ frameBack.AddChidren(frame2);
+ this.InitEightButtonPanelIcon(frame2, listDevice[2], listDevice[3]);
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栧叓鎸夐敭闈㈡澘鐨勫浘鏍�
+ /// </summary>
+ /// <param name="frameBack">瀹瑰櫒</param>
+ /// <param name="device1">璁惧1</param>
+ /// <param name="device2">璁惧2</param>
+ private void InitEightButtonPanelIcon(FrameLayout frameBack, CommonDevice device1, CommonDevice device2)
+ {
+ //鎸夐敭1
+ var frameButton1 = new FrameLayoutStatuControl();
+ frameButton1.UseClickStatu = false;
+ frameButton1.Height = this.GetPictrueRealSize(92);
+ frameButton1.Width = this.GetPictrueRealSize(183);
+ frameBack.AddChidren(frameButton1);
+ var btnButton1 = this.InitDeviceButtonControl(frameButton1, device1);
+ btnButton1.TextSize = 8;
+ btnButton1.Height = this.GetPictrueRealSize(35);
+ btnButton1.Width = this.GetPictrueRealSize(183);
+ btnButton1.Y = this.GetPictrueRealSize(37);
+
+ //鎸夐敭2
+ var frameButton2 = new FrameLayoutStatuControl();
+ frameButton2.UseClickStatu = false;
+ frameButton2.Height = frameButton1.Height;
+ frameButton2.Width = frameButton1.Width;
+ frameButton2.Y = frameButton1.Bottom;
+ frameBack.AddChidren(frameButton2);
+ var btnButton2 = this.InitDeviceButtonControl(frameButton2, device2);
+ btnButton2.TextSize = 8;
+ btnButton2.Height = btnButton1.Height;
+ btnButton2.Width = btnButton1.Width;
+ btnButton2.Y = this.GetPictrueRealSize(20);
+ }
+
+ #endregion
+
+ #region 鈻� 鍥炶矾閫夋嫨___________________________
+
+ /// <summary>
+ /// 鍥炶矾閫夋嫨浜嬩欢
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void DeviceEpointSelectEvent(object sender, MouseEventArgs e)
+ {
+ var nowContr = (NormalViewControl)sender;
+ if (nowSelectControl != null)
+ {
+ //鍚屼竴涓笢瑗�,涓嶉笩浠�
+ if (nowSelectControl.Text == nowContr.Text)
+ {
+ return;
+ }
+ //涓嶉�夋嫨鐘舵��
+ nowSelectControl.TextColor = UserCenterColor.Current.TextGrayColor1;
+ //璁板綍瀹冪殑鍚嶅瓧
+ dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = btnDeviceName.Text.Trim();
+ }
+ //閫夋嫨鐘舵��
+ nowContr.TextColor = 0xfffb744a;
+
+ nowSelectControl = nowContr;
+ nowSelectDevice = Common.LocalDevice.Current.GetDevice(deviceObj.DeviceAddr, Convert.ToInt32(nowContr.Text.Replace("CHANNEL", string.Empty)));
+
+ //閲嶆柊鍒濆鍖栬彍鍗曡
+ this.InitMenuRow();
+ }
+
+ #endregion
+ }
+}
--
Gitblit v1.8.0