private void CreateItems(IBasicModel model) { if (model == null) { return; } treeView1.BeginUpdate(); _model.Nodes.Clear(); var atr_model = model.GetType().GetCustomAttributes(typeof(ModelItem), true); if (atr_model.Length != 0) { var atr = atr_model[0] as ModelItem; var creator = NodeFactory.Select(atr); creator.ContextMenuFactory = this.ContextMenuFactory; creator.NodeFactory = this.NodeFactory; var root = creator.Creat(model, atr) as Node; _model.Nodes.Add(root); } var mapdata_item = new MapDataItem(); var map_creator = NodeFactory.Select(mapdata_item); var root_mapdata = map_creator.Creat(model, mapdata_item) as Node; _model.Nodes.Add(root_mapdata); treeView1.EndUpdate(); }
private void CreateItem(string routeName, MapLayer layer, MapRoute route) { GameObject itemObj = Instantiate(m_item) as GameObject; itemObj.name = routeName; itemObj.transform.SetParent(m_grid, false); itemObj.transform.localScale = Vector3.one; MapDataItem dataItem = itemObj.AddComponent <MapDataItem>(); itemObj.SetActive(true); dataItem.SetData(new HandleData(routeName, layer, route)); Debug.Log("====" + routeName); }
public MapDataItemVM(MapDataItem d) : this(d.X, d.Y, 0, 0, d.Name, d.Description) { PresentationFile = d.PresentationFileName; }
public async Task <long> FillDictionaryAsync(string cPath) // includes trailing "\" { // runs on background thread long totalSize = 0; long curdirFileSize = 0; long curdirFolderSize = 0; await Task.Run(async() => { try { if (_DataDict.Count() % 100 == 0) { // upgrade status on foreground thread _txtStatus.Dispatcher.Invoke( DispatcherPriority.Normal, new Action <TextBlock>(otxtblk => { otxtblk.Text = cPath; // update status } ), _txtStatus); } var dirInfo = new DirectoryInfo(cPath); if ((dirInfo.Attributes & FileAttributes.ReparsePoint) != 0) { // some folders are not really there: they're redirect junction points. return; } var nDepth = cPath.Where(c => c == PathSep).Count(); var curDirFiles = Directory.GetFiles(cPath); if (curDirFiles.Length > 0) // if cur folder contains any files (not dirs) { foreach (var file in curDirFiles) { /* * C:\Users\calvinh\AppData\Local\Packages\WINSTO~1\LOCALS~1\Cache\0\0-DevApps-https∺∯∯next-services.apps.microsoft.com∯search∯6.3.9600-0∯788∯en-US_en-US∯c∯US∯cp∯10005001∯DevApps∯pc∯0∯pt∯x64∯af∯0∯lf∯1∯pn∯1∿developerName=Microsoft%20Corporation.dat * C:\Users\calvinh\AppData\Local\Packages\winstore_cw5n1h2txyewy\LocalState\Cache\0\0-DevApps-https∺∯∯next-services.apps.microsoft.com∯search∯6.3.9600-0∯788∯en-US_en-US∯c∯US∯cp∯10005001∯DevApps∯pc∯0∯pt∯x64∯af∯0∯lf∯1∯pn∯1∿developerName=Microsoft%20Corporation.dat */ try { var finfo = new FileInfo(file); curdirFileSize += finfo.Length; } catch (PathTooLongException) { } } _DataDict[cPath + DataSuffix] = // size of files in cur folder, excluding children new MapDataItem() { Depth = nDepth + 1, Size = curdirFileSize, NumFiles = curDirFiles.Length, Index = _DataDict.Count }; } var curDirFolders = Directory.GetDirectories(cPath); // now any subfolders if (curDirFolders.Length > 0) { foreach (var dir in curDirFolders) { curdirFolderSize += await FillDictionaryAsync(System.IO.Path.Combine(cPath, dir) + PathSep); // recur } } totalSize += curdirFileSize + curdirFolderSize; _DataDict[cPath] = new MapDataItem() { Depth = nDepth, Size = curdirFileSize + curdirFolderSize, Index = _DataDict.Count }; } catch (PathTooLongException) { } catch (Exception ex) { if (ex is UnauthorizedAccessException) { System.Diagnostics.Trace.WriteLine("Ex: " + ex.Message); } else { throw; } } }); return(totalSize); }