wxr
2021-07-01 43b0d5870d528f23ecd6aeceb6cfd4325188b46f
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
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,SpatialInfo 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 (SpatialInfo.CurrentSpatial.FloorList.Find((obj) => obj.roomName == newName) != null)
                    {
                        return;
                    }
                    else
                    {
                        var waitPage = new Loading();
                        MainPage.BaseView.AddChidren(waitPage);
                        waitPage.Start(Language.StringByID(StringId.PleaseWait));
                        new System.Threading.Thread(() =>
                        {
                            try
                            {
                                var editResult = SpatialInfo.CurrentSpatial.UpdateFloor(floor);
                                Application.RunOnMainThread(() =>
                                {
                                    if (editResult == DAL.Server.StateCode.SUCCESS)
                                    {
                                        floor.roomName = newName;
                                        btn.Text = newName;
                                    }
                                });
                            }
                            catch { }
                            finally
                            {
                                Application.RunOnMainThread(() => {
                                    waitPage.Hide();
                                    waitPage.RemoveFromParent();
                                });
                            }
                        })
                        { IsBackground = true }.Start();
                    }
                };
                var floors = new List<string>();
                foreach (var f in SpatialInfo.CurrentSpatial.FloorList)
                {
                    floors.Add(f.roomName);
                }
                new PublicAssmebly().LoadDialog_EditParater(StringId.EditFloorName, btn.Text, editCallBack,StringId.FloorNameCannotBeEmpty,
                    StringId.EditFloorFailed_FloorAlreadyExist,floors);
            };
        }
 
        /// <summary>
        /// 删除楼层
        /// </summary>
        void LoadEvent_DelFloor(Button btn)
        {
            btn.MouseUpEventHandler += (sender, e) =>
            {
                Action action = () =>
                {
                    //该楼层删除之后,绑定该楼层的房间要重置绑定的楼层
                    foreach (var r in SpatialInfo.CurrentSpatial.RoomList)
                    {
                        if (r.parentId == btn.Tag.ToString())
                        {
                            r.parentId = "";
                        }
                    }
                    SpatialInfo.CurrentSpatial.DelFloor(btn.Tag.ToString());
                    for (int i = 0; i < floorsListView.ChildrenCount; i++)
                    {
                        if (floorsListView.GetChildren(i).GetType() == typeof(RowLayout))
                        {
                            RowLayout row = floorsListView.GetChildren(i) as RowLayout;
                            if (row.Tag == null)
                                continue;
                            if (row.Tag.ToString() == btn.Tag.ToString())
                            {
                                row.RemoveFromParent();
                                int count = SpatialInfo.CurrentSpatial.FloorList.Count > 8 ? 8 : SpatialInfo.CurrentSpatial.FloorList.Count;
                                var contentViewHeight = (count + 1) * Application.GetRealHeight(50);
                                contentView.Height = contentViewHeight;
                                floorsListView.Height = count * Application.GetRealHeight(50);
                            }
                        }
                    }
                };
                new PublicAssmebly().TipOptionMsg(StringId.Tip, StringId.DelFloorTip, action);
            };
        }
    }
}