/// <summary> /// 字符转换为锚定信息 /// </summary> /// <param name="str">字符</param> /// <returns>锚定信息</returns> public static FCAnchor convertStrToAnchor(String str) { str = str.ToLower(); bool left = false, top = false, right = false, bottom = false; String[] strs = str.Split(','); for (int i = 0; i < strs.Length; i++) { String anchorStr = strs[i]; if (anchorStr == "left") { left = true; } else if (anchorStr == "top") { top = true; } else if (anchorStr == "right") { right = true; } else if (anchorStr == "bottom") { bottom = true; } } FCAnchor anchor = new FCAnchor(left, top, right, bottom); return(anchor); }
/// <summary> /// 锚定信息转化为字符 /// </summary> /// <param name="anchor"> 锚定信息</param> /// <returns>字符</returns> public static String convertAnchorToStr(FCAnchor anchor) { ArrayList <String> strs = new ArrayList <String>(); if (anchor.left) { strs.add("Left"); } if (anchor.top) { strs.add("Top"); } if (anchor.right) { strs.add("Right"); } if (anchor.bottom) { strs.add("Bottom"); } String anchorStr = ""; int size = strs.size(); if (size > 0) { for (int i = 0; i < size; i++) { anchorStr += strs[i]; if (i != size - 1) { anchorStr += ","; } } } else { anchorStr = "None"; } return(anchorStr); }