wxr
2023-05-30 b07d4f6ffbbc942c2e00fbedee5203bbec8d52fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using HDL_ON.UI.CSS;
using System;
using Shared;
using HDL_ON.Entity;
using System.Text.RegularExpressions;
 
namespace HDL_ON.UI
{
    public partial class FunctionBaseInfoSetPage
    {
        void LoadEventList()
        {
            LoadEvent_ChangeFunctionName ();
            SkipChooseRoomPage();
            DelDeviceEvent();
 
        }
 
        /// <summary>
        /// 修改功能名称按钮点击事件
        /// </summary>
        void LoadEvent_ChangeFunctionName()
        {
            EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
                //创建回调事件
                Action<string> callBackAction = (name) =>
                {
                    if (string.IsNullOrEmpty(name))
                    {
                        new Tip()
                        {
                            CloseTime = 1,
                            Text = Language.StringByID(StringId.DeviceNameCannotBeEmpty),
                            Direction = AMPopTipDirection.None,
                        }.Show(bodyView);
                        return;
                    }
                    if (function.name != name)
                    {
                        function.name = name;
                        btnFunctionName.Text = name;
                        function.UpdataFuncitonInfo();
                        actionRefresh?.Invoke();
                    }
                };
                new PublicAssmebly().LoadDialog_EditParater(StringId.ChangeName, function.name, callBackAction,StringId.DeviceNameCannotBeEmpty,0,new System.Collections.Generic.List<string>());
            };
            btnEditName.MouseUpEventHandler = eventHandler;
            btnFunctionName.MouseUpEventHandler = eventHandler;
        }
 
        /// <summary>
        /// 跳转到位置管理页面
        /// </summary>
        void SkipChooseRoomPage()
        {
            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                //修改功能所属房间之后的回调事件
                Action chooseRoomBackAction = () => {
                    try
                    {
                        btnLocationValues.Text = function.GetRoomListName();
                    }
                    catch { }
                };
                var view = new ChooseRoomPage(function,chooseRoomBackAction);
                MainPage.BasePageView.AddChidren(view);
                view.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            if (btnLocationInfoRight != null)
            {
                btnLocationInfoRight.MouseUpEventHandler = eventHandler;
            }
            if (btnLocationValues != null)
            {
                btnLocationValues.MouseUpEventHandler = eventHandler;
            }
                
        }
        /// <summary>
        /// 解绑设备的事件
        /// </summary>
        void DelDeviceEvent()
        {
 
            EventHandler<MouseEventArgs> ClickEvent = (sener, e) =>
            {
                new HDL_ON.UI.Music.View.TipView().TipBox(-1, StringId.AreYouSureToDeleteThisDevice, () =>
                {
                    UI2.FuntionControlView.VideoDoorLock.VideDoorLockSend.Current.DelDevice(this.function, (isBool) =>
                    {
                        Application.RunOnMainThread(() =>
                        {
                            if (!isBool)
                            {
                                new Tip()
                                {
                                    CloseTime = 1,
                                    Text = Language.StringByID(StringId.delFail),
                                    Direction = AMPopTipDirection.None,
                                }.Show(bodyView);
                                return;
                            }
                            //删除本地文件                                  
                            UI2.FuntionControlView.VideoDoorLock.CommonMethod.Current.DeleteFunction(this.function);
                            this.RemoveFromParent();
                            this.actionDel?.Invoke();
                        });
 
                    });
 
                });
            };
            this.delView.MouseUpEventHandler += ClickEvent;
            this.delTextBtn.MouseUpEventHandler += ClickEvent;
            this.delRightBtn.MouseUpEventHandler += ClickEvent;
        }
 
 
    }
}