/// <summary> /// 重建字体, 先实现功能,后面可以考虑优化GC /// </summary> /// <param name="maxWidth">重建设置最大宽</param> /// <param name="maxHeight">重建设置最大高</param> /// <returns></returns> public bool ReBuild(int maxWidth, int maxHeight) { m_MaxWidth = maxWidth; m_MaxHeight = maxHeight; var oldMap = m_PicNodeMap; m_PicNodeMap = new Dictionary <FontRectKey, PicNode <FontRectKey> >(); m_Root = null; m_CurrentPic = null; var iter = oldMap.GetEnumerator(); while (iter.MoveNext()) { var node = iter.Current.Value; if (node != null && node.key != null) { InsertNode(node.key.value, node.key.fontSize, node.key.fontSizeType, node.key.hDpi, node.key.vDpi, node.width, node.height); } } iter.Dispose(); return(true); }
// 插入节点 private bool InsertNode(PicNode <FontRectKey> newNode) { if (newNode == null) { return(false); } Func <BTreeNode <FontRectKey>, bool> func = null; switch (m_CombineType) { case RectCombineType.left: func = preTraveralTree; break; case RectCombineType.middle: func = midTraveralTree; break; case RectCombineType.right: func = lastTraveralTree; break; default: return(false); } bool ret = false; if (func != null) { InitRoot(); m_CurrentPic = newNode; ret = func(m_Root); } return(ret); }
private bool InsertNode(FontRectKey key, int width, int height) { if (key == null) { return(false); } PicNode <FontRectKey> newNode = new PicNode <FontRectKey>(); newNode.key = key; newNode.width = width; newNode.height = height; bool ret = InsertNode(newNode); if (!ret && !newNode.IsRot) { newNode.IsRot = true; newNode.width = height; newNode.height = width; ret = InsertNode(newNode); } if (ret) { m_PicNodeMap[key] = newNode; } return(ret); }
public void OnDestroy() { // 暂时这样后面考虑回池等 m_Root = null; m_CurrentPic = null; if (m_PicNodeMap != null) { m_PicNodeMap.Clear(); } }
private void moveNext() { //ImageLoopType _imageLoopType = picNodes[0].getLoopType(); PicNode tempPicNode = picNodes[0].Clone(); for (int i = 0; i < picNodes.Count - 1; i++) { picNodes[i].setLoopType(picNodes[i].next.getLoopType(), moveConstant); } picNodes[picNodes.Count - 1].setLoopType(tempPicNode.getLoopType(), moveConstant); }
public HomeDetailModel(PicNode node, FolderDesc desc) { if (node == null) throw new ArgumentException("文件夹节点不能为空!"); this.PicNode = node; this.FolderDesc = desc; // 核心代码如下:根据文件的路径查找文件信息 DirectoryInfo dir = new DirectoryInfo(FileConfiguration.FullPath + this.PicNode.Path.Replace("/", @"\")); if (!dir.Exists) dir.Create(); // 而后将不在文件夹和文件都剔除 this.FileInfos = dir.GetFiles("*.*"); DirectoryInfo tmp = new DirectoryInfo(FileConfiguration.FullPath); foreach (var f in this.FileInfos) { string result = f.FullName.Substring(tmp.FullName.Length, f.FullName.Length - tmp.FullName.Length); if (!string.IsNullOrEmpty(result)) result = result.Replace("\\", "/"); FileRecord record = FileRecord.Find(result); if (record != null) { this.FileInfos = this.FileInfos.ToList(); this.FileInfos.Remove(f); } } this.DictionaryInfos = dir.GetDirectories("*.*"); foreach (var d in this.DictionaryInfos) { string result = d.FullName.Substring(tmp.FullName.Length, d.FullName.Length - tmp.FullName.Length); if (!string.IsNullOrEmpty(result)) result = result.Replace("\\", "/"); PicNode folder = PicNode.Find(result, 1); if (folder != null) { this.DictionaryInfos = this.DictionaryInfos.ToList(); this.DictionaryInfos.Remove(d); } } }
public Folder(PicNode node, FolderDesc desc) { if (node == null) throw new ArgumentException("文件夹节点不能为空!"); this.PicNode = node; this.FolderDesc = desc; // 核心代码如下:根据文件的路径查找文件信息 DirectoryInfo dir = new DirectoryInfo(FileConfiguration.FullPath + this.PicNode.Path.Replace("/", @"\\")); if (!dir.Exists) dir.Create(); this.FileInfos = dir.GetFiles("*.*"); this.DictionaryInfos = dir.GetDirectories("*.*"); }
public JsonResult CreateNode(FileNodeOperationDateContract contract) { if (contract == null) throw new ArgumentNullException("the argument is null!!!!!"); PicNode parent = PicNode.Load(contract.ParentId.Value); if (parent == null) throw new ArgumentException("the parentid is null!!!!"); PicNode temp = PicNode.FindByPath(parent.Path + "/" + contract.Name); if (temp != null) return Json(new { status = 0, success = false, message = "请确定文件夹名称在该目录下是否唯一!" }); PicNode node = new PicNode(); node.IsFile = false; node.Status = 0; node.Root = parent.Root; node.Name = contract.Name; node.Path = parent.Path + "/" + node.Name; PicNode.Insert(node); return Json(new { id = node.Id.ToString(), status = node.Status.ToString(), success = true, message = "成功创建文件夹!" }); }
private IList<PicNode> GetSubs(PicNode picNode) { try { if (picNode == null) throw new NullReferenceException("picNode for picking up sub node is null!!!"); return PicNode.GetSubs(picNode).ToList(); } catch (Exception ex) { throw ex; } }
public void InsertNew(PicNode picNode) { if (picNode == null) throw new ArgumentNullException("argument is nulll!!! f**k you !!"); SqlServerUtility sql = new SqlServerUtility(); sql.AddParameter("@Status", SqlDbType.Int, picNode.Status); sql.AddParameter("@IsFile", SqlDbType.Bit, picNode.IsFile); sql.AddParameter("@Root", SqlDbType.NVarChar, picNode.Root); sql.AddParameter("@Path", SqlDbType.NVarChar, picNode.Path); sql.AddParameter("@Name", SqlDbType.NVarChar, picNode.Name); SqlDataReader reader = sql.ExecuteSqlReader(SqlInsertNew); if (reader != null && !reader.IsClosed && reader.Read()) { if (!reader.IsDBNull(0)) picNode.Id = int.Parse(reader.GetDecimal(0).ToString()); reader.Close(); } else { if (reader != null && !reader.IsClosed) reader.Close(); } }