From ea318e20d9a513bfae81a9203cef4bca0fc23c2c Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期三, 30 九月 2020 11:01:15 +0800
Subject: [PATCH] 202009301
---
HDL_ON/Entity/Room.cs | 109 ++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 84 insertions(+), 25 deletions(-)
diff --git a/HDL_ON/Entity/Room.cs b/HDL_ON/Entity/Room.cs
index 7884d78..6bfcc90 100644
--- a/HDL_ON/Entity/Room.cs
+++ b/HDL_ON/Entity/Room.cs
@@ -4,64 +4,123 @@
namespace HDL_ON.Entity
{
+
/// <summary>
/// 鎴块棿瀵硅薄
- /// 鎴块棿鍛藉悕瑙勫垯 typeof (Room).Name + "_" + etNameBox.Text.Trim ();
/// </summary>
- [System.Serializable]
+ [Serializable]
+ public class Floor
+ {
+ /// <summary>
+ /// 妤煎眰鍚嶇О
+ /// </summary>
+ public string name = "1F";
+ /// <summary>
+ /// 妤煎眰ID
+ /// </summary>
+ public string sid;
+ }
+
+
+ /// <summary>
+ /// 鎴块棿瀵硅薄
+ /// </summary>
+ [Serializable]
public class Room
{
/// <summary>
/// 鎴块棿鍚�
/// </summary>
public string name = "Room";
+
+ public string roomSavePath
+ {
+ get
+ {
+ return "RoomPath_" + sid;
+ }
+ }
/// <summary>
/// 鎴块棿ID
/// </summary>
public string sid;
/// <summary>
- /// 妤煎眰绱㈠紩
- /// </summary>
- public int floorIndex = -1;
-
- /// <summary>
/// 鎴块棿鑳屾櫙
/// </summary>
public string backgroundImage = "Classification/Room/Roombg.png";
/// <summary>
+ /// 妤煎眰绱㈠紩
+ /// </summary>
+ public string floorId = "";
+ /// <summary>
/// 妤煎眰
/// </summary>
- public string floor {
+ [Newtonsoft.Json.JsonIgnore]
+ public string floorName
+ {
get
{
- string str = "";
- if (floorIndex != -1)
+ if (DB_ResidenceData.residenceData.floors.Count > 0)
{
- if (floorIndex < DB_ResidenceData.residenceData.floors.Count)
- str = DB_ResidenceData.residenceData.floors[floorIndex];
+ var f = DB_ResidenceData.residenceData.floors.Find((obj) => obj.sid == floorId);
+ if (f != null)
+ {
+ return f.name + " ";
+ }
}
- return str;
+ return "";
}
}
-
-
/// <summary>
/// 鎴块棿鍔熻兘鍒楄〃
/// </summary>
- [Newtonsoft.Json.JsonIgnore]
- public List<Function> functions = new List<Function>();
-
- public void RefreshFunctions()
+ List<Function> functions = new List<Function>();
+ /// <summary>
+ /// 鍒锋柊鎴块棿鍔熻兘鍒楄〃
+ /// </summary>
+ public List<Function> GetRoomFunctions(bool needRefresh)
{
- List<Function> funcList = new List<Function>();
- foreach (var f in DB_ResidenceData.residenceData.functionList.functions)
+ if(needRefresh)
{
- if (f.roomIdList.Contains(sid) && sid != null)
+ functions = new List<Function>();
+ }
+ if (functions.Count == 0)
+ {
+ foreach (var f in DB_ResidenceData.functionList.GetAllFunction())
{
- funcList.Add(f);
+ if (f.roomIdList.Contains(sid) && sid != null)
+ {
+ functions.Add(f);
+ }
}
}
- functions = funcList;
+ return functions;
}
+ /// <summary>
+ /// 澧炲姞鎴块棿鍔熻兘
+ /// </summary>
+ public void AddRoomFunction(Function function)
+ {
+ functions.Add(function);
+ }
+ /// <summary>
+ /// 鍒犻櫎鎴块棿鍔熻兘
+ /// </summary>
+ public void RemoveRoomFunction(Function function)
+ {
+ functions.Remove(functions.Find((obj) => obj.sid == function.sid));
+ }
+
+ /// <summary>
+ /// 淇濆瓨鎴块棿鏁版嵁
+ /// </summary>
+ public void SaveRoomData()
+ {
+ var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
+ FileUtils.WriteFileByBytes("RoomData_" + this.sid, ssd);
+ MainPage.Log($"Save FunctionData {name} : {this.sid}");
+ }
+
+
}
-}
+}
\ No newline at end of file
--
Gitblit v1.8.0