public void DeleteProto(MyProto proto) { int protoIndex = 0; XElement xe = GetProtoElement(proto.ProtoID, proto.MenuID, out protoIndex); if (xe == null) { return; } xe.Remove(); }
public void UpdateProto(MyProto proto) { int protoIndex = 0; XElement xe = GetProtoElement(proto.ProtoID, proto.MenuID, out protoIndex); if (xe == null) { return; } xe.Attribute("ProtoCode").SetValue(proto.ProtoCode); xe.Attribute("ProtoEnName").SetValue(proto.ProtoEnName); xe.Attribute("ProtoCnName").SetValue(proto.ProtoCnName); xe.Attribute("ProtoDesc").SetValue(proto.ProtoDesc); }
private List <MyProto> GetProtoListByMenuName(long menuID) { int index = 0; XElement xe = GetXElementByID(menuID, out index); if (xe == null) { return(null); } List <XElement> lst = xe.Elements("Proto").ToList(); if (lst == null || lst.Count == 0) { return(null); } List <MyProto> retList = new List <MyProto>(); for (int i = 0; i < lst.Count; i++) { long protoID = long.Parse(lst[i].Attribute("ProtoID").Value); string protoCode = lst[i].Attribute("ProtoCode").Value; string protoEnName = lst[i].Attribute("ProtoEnName").Value; string protoCnName = lst[i].Attribute("ProtoCnName").Value; string protoDesc = lst[i].Attribute("ProtoDesc").Value; string protoCategory = lst[i].Attribute("ProtoCategory") == null ? "C2S" : lst[i].Attribute("ProtoCategory").Value; string isCSharp = lst[i].Attribute("IsCSharp") == null ? "false" : lst[i].Attribute("IsCSharp").Value; string isLua = lst[i].Attribute("IsLua") == null ? "false" : lst[i].Attribute("IsLua").Value; MyProto proto = new MyProto(); proto.ProtoID = protoID; proto.ProtoCode = protoCode; proto.ProtoEnName = protoEnName; proto.ProtoCnName = protoCnName; proto.ProtoDesc = protoDesc; proto.ProtoCategory = protoCategory; proto.IsCSharp = bool.Parse(isCSharp); proto.IsLua = bool.Parse(isLua); proto.MenuID = menuID; retList.Add(proto); } return(retList); }
//=================================================== #region 协议操作 public void AddProto(MyProto node, long menuID) { int index = 0; XElement xMenu = GetXElementByID(menuID, out index); if (xMenu == null) { MessageBox.Show("添加协议失败 找不到菜单"); return; } xMenu.Attribute("HasChild").SetValue(true); XElement xe = new XElement("Proto", new XAttribute("ProtoID", node.ProtoID), new XAttribute("ProtoCode", node.ProtoCode), new XAttribute("ProtoEnName", node.ProtoEnName), new XAttribute("ProtoCnName", node.ProtoCnName), new XAttribute("ProtoDesc", node.ProtoDesc)); xMenu.Add(xe); }
public bool MoveProto(MyProto proto, bool isPrev) { //元素的索引 int protoIndex = 0; XElement xe = GetProtoElement(proto.ProtoID, proto.MenuID, out protoIndex); if (isPrev) { //上移 if (protoIndex == 0) { MessageBox.Show("已经是第一个"); return(false); } int toIndex = protoIndex - 1; XElement prev = GetProtoElementByIndex(proto.MenuID, toIndex); prev.AddBeforeSelf(xe); xe.Remove(); } else { int menuindex = 0; //下移 if (protoIndex == GetXElementByID(proto.MenuID, out menuindex).Elements("Proto").ToList().Count - 1) { MessageBox.Show("已经是最后一个"); return(false); } int toIndex = protoIndex + 1; XElement next = GetProtoElementByIndex(proto.MenuID, toIndex); next.AddAfterSelf(xe); xe.Remove(); } return(true); }