wxr
2020-04-21 f718d23a262a5a8e1241fdeaeb4153399f95e79d
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
using System;
using HDL_ON.Entity;
using Shared;
 
namespace HDL_ON.UI
{
    public partial class FloorsManagementPage
    {
        /// <summary>
        /// 楼层按钮修改名称点击事件
        /// </summary>
        void LoadEvent_FloorNamgeChange(Button btn,Button btnDel,RowLayout row)
        {
            btn.MouseUpEventHandler = (sender, e) =>
            {
                Action<string> editCallBack = (newName) =>
                {
                    //楼层名称不能为空
                    if (string.IsNullOrEmpty(newName))
                    {
                        new Tip()
                        {
                            CloseTime = 3,
                            Text = Language.StringByID(StringId.FloorNameCannotBeEmpty),
                            Direction = AMPopTipDirection.None,
                        }.Show(bodyView);
                        return;
                    }
                    if (DB_ResidenceData.residenceData.floors.Contains(newName))
                    {
                        return;
                    }
                    else
                    {
                        DB_ResidenceData.residenceData.floors[DB_ResidenceData.residenceData.floors.IndexOf(btn.Text)] = newName;
                        //DB_ResidenceData.residenceData.SaveResidenceData();
                        btn.Text = newName;
                        btnDel.Tag = newName;
                        row.Tag = newName;
                    }
                };
                new PublicAssmebly().LoadDialog_EditParater(StringId.EditFloorName, btn.Text, editCallBack);
            };
        }
 
 
        Button lastButton;
        /// <summary>
        /// 房间绑定楼层,楼层选中事件
        /// </summary>
        void LoadEvent_FloorChoose(Button btn)
        {
            btn.MouseUpEventHandler = (sender, e) => {
                if (lastButton != null)
                {
                    lastButton.IsSelected = false;
                    if (lastButton.Text == btn.Text)
                    {
                        lastButton = null;
                    }
                    //btn.IsBold = false;
                }
                btn.IsSelected = true;
                //btn.IsBold = true;
                lastButton = btn;
            };
        }
 
        /// <summary>
        /// 删除楼层
        /// </summary>
        void LoadEvent_DelFloor(Button btn)
        {
            btn.MouseUpEventHandler += (sender, e) =>
            {
                Action action = () =>
                {
                    //string delFloor = DB_ResidenceData.residenceData.floors[(int)(sender as Button).Tag];
                    refreshFloorList("del", btn.Tag.ToString());
                };
                new PublicAssmebly().TipMsg(StringId.Tip, StringId.DelFloorTip, action);
            };
        }
 
        /// <summary>
        /// 房间绑定楼层事件
        /// </summary>
        void LoadEvent_BindFloor()
        {
            btnConfrim.MouseUpEventHandler = (sender, e) =>
            {
                if (lastButton == null)
                {
                    return;
                }
                room.floorIndex = DB_ResidenceData.residenceData.floors.IndexOf(lastButton.Text.Trim());
                room.floorIndex = DB_ResidenceData.residenceData.floors.IndexOf(lastButton.Text.Trim());
                backAction?.Invoke();
                bodyView.RemoveFromParent();
                DB_ResidenceData.residenceData.SaveResidenceData();
            };
        }
 
    }
}