wxr
2020-03-13 171bf03f3664226eeff2b20ee9bd2e914b63a17d
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
using System;
using HDL_ON.Entity;
using Shared;
 
namespace HDL_ON.UI
{
    public partial class FloorsManagementPage
    {
        /// <summary>
        /// 楼层按钮修改名称点击事件
        /// </summary>
        void LoadEvent_FloorNamgeChange(string floor,Button btn)
        {
            btn.MouseUpEventHandler = (sender, e) =>
            {
                Action<string> editCallBack = (newName) =>
                {
                    if (DB_ResidenceData.residenceData.floors.Contains(newName))
                    {
                        return;
                    }
                    else
                    {
                        DB_ResidenceData.residenceData.floors.Add(newName);
                        DB_ResidenceData.residenceData.SaveResidenceData();
                        btn.Text = newName;
                    }
                };
                new PublicAssmebly().LoadDialog_EditParater(StringId.EditFloorName, floor, 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 = (sender as Button).Tag.ToString();
                    DB_ResidenceData.residenceData.floors.Remove(delFloor);
                    DB_ResidenceData.residenceData.SaveResidenceData();
                    topCallBack("del", delFloor);
                };
                new PublicAssmebly().TipMsg(StringId.Tip, StringId.DelFloorTip, action);
            };
        }
 
        /// <summary>
        /// 房间绑定楼层事件
        /// </summary>
        void LoadEvent_BindFloor()
        {
            btnConfrim.MouseUpEventHandler = (sender, e) =>
            {
                if (lastButton != null)
                {
                    room.floorIndex = DB_ResidenceData.residenceData.floors.IndexOf(lastButton.Text.Trim());
                }
                room.floorIndex = DB_ResidenceData.residenceData.floors.IndexOf(lastButton.Text.Trim());
                if (backAction != null)
                {
                    backAction();
                }
                bodyView.RemoveFromParent();
                DB_ResidenceData.residenceData.SaveResidenceData();
            };
        }
 
    }
}