wxr
2020-09-09 c3e1b733fc45bd9f0b88bfb560cfa87a270b079b
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
using System;
using System.Collections.Generic;
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,Floor floor)
        {
            btn.MouseUpEventHandler = (sender, e) =>
            {
                Action<string> editCallBack = (newName) =>
                {
                    //楼层名称不能为空
                    if (string.IsNullOrEmpty(newName))
                    {
                        new Tip()
                        {
                            CloseTime = 1,
                            Text = Language.StringByID(StringId.FloorNameCannotBeEmpty),
                            Direction = AMPopTipDirection.None,
                        }.Show(bodyView);
                        return;
                    }
                    if (DB_ResidenceData.residenceData.floors.Find((obj) => obj.name == newName) != null)
                    {
                        return;
                    }
                    else
                    {
                        floor.name = newName;
                        DB_ResidenceData.residenceData.SaveResidenceData();
                        btn.Text = newName;
                        btnDel.Tag = newName;
                        row.Tag = newName;
                    }
                };
                var floors = new List<string>();
                foreach (var f in DB_ResidenceData.residenceData.floors)
                {
                    floors.Add(f.name);
                }
                new PublicAssmebly().LoadDialog_EditParater(StringId.EditFloorName, btn.Text, editCallBack,StringId.FloorNameCannotBeEmpty,
                    StringId.EditFloorFailed_FloorAlreadyExist,floors);
            };
        }
 
 
        /// <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 = () =>
                {
                    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.floorId = lastButton.Tag.ToString();
                room.floorId = lastButton.Tag.ToString();
                backAction?.Invoke();
                bodyView.RemoveFromParent();
                DB_ResidenceData.residenceData.SaveResidenceData();
            };
        }
 
    }
}