private bool TryGetDataSeries(int dataLevel, FsItem dataPoint, out Series ser) { if (chart1.ChartAreas.Count == dataLevel) { if (dataPoint == Empty) { ser = null; return(false); } //create chart area and series var ca = new ChartArea("chartAreaLevel" + dataLevel) { Position = { Auto = false, X = 0, Y = 0, Height = 100, Width = 100 } }; if (dataLevel > 0) { ca.BackColor = Color.Transparent; } chart1.ChartAreas.Add(ca); ser = new Series("seriesLevel" + dataLevel) { ChartArea = ca.Name, ChartType = SeriesChartType.Doughnut, IsXValueIndexed = true }; chart1.Series.Add(ser); _totals.Add(ser, 0); } else { ser = chart1.Series[dataLevel]; } return(true); }
private void LoadChartDataCollection(int dataLevel, FsItem dataPoint, long precedingObjectSize) { Series ser; if (!TryGetDataSeries(dataLevel, dataPoint, out ser)) { return; } if (precedingObjectSize > 0) { var delta = precedingObjectSize - _totals[ser]; if (delta > 0) { AddOrExtendPlaceHolder(delta, ser); } } foreach (var point in dataPoint.Items) { if (point.Size > _filterThreshold) { AddPoint(ser, point.Size, point); } else { AddOrExtendPlaceHolder(point.Size, ser); } if (point.Items != null && point.Items.Count > 0) { LoadChartDataCollection(dataLevel + 1, point, precedingObjectSize); } precedingObjectSize += point.Size; } LoadChartDataCollection(dataLevel + 1, Empty, precedingObjectSize); }
private FsItem Deserialize(ResponseBodyStream data, string fullPath) { fullPath = WebDavPath.Clean(fullPath); var fakeRoot = new FsFolder(WebDavPath.Parent(fullPath), null, CloudFolderType.Generic, null, null); FsFolder currentFolder = fakeRoot; FsFolder lastFolder = null; int lvl = 0; var parseOp = (ParseOp)data.ReadShort(); while (parseOp != ParseOp.Done) { switch (parseOp) { case ParseOp.ReadItem: break; case ParseOp.Pin: if (lastFolder != null) { currentFolder = lastFolder; lvl++; parseOp = (ParseOp)data.ReadShort(); continue; } else { throw new Exception("lastFolder = null"); } case ParseOp.PinUpper: if (currentFolder == fakeRoot) { parseOp = (ParseOp)data.ReadShort(); continue; } else if (currentFolder.Parent != null) { currentFolder = currentFolder.Parent; lvl--; parseOp = (ParseOp)data.ReadShort(); if (currentFolder == null) { throw new Exception("No parent folder A"); } continue; } else { throw new Exception("No parent folder B"); } case ParseOp.Unknown15: long skip = data.ReadPu32(); for (long i = 0; i < skip; i++) { data.ReadPu32(); data.ReadPu32(); } break; default: throw new Exception("Unknown parse operation"); } FsItem item = GetItem(data, currentFolder); currentFolder.Items.Add(item); if (item is FsFolder fsFolder) { lastFolder = fsFolder; fsFolder.IsChildsLoaded = lvl < Depth; } parseOp = (ParseOp)data.ReadShort(); } var res = fakeRoot.Items[0]; return(res); }
private FsItem Deserialize(ResponseBodyStream data, string fullPath) { var fakeFolder = new FsFolder(string.Empty, null, CloudFolderType.Generic, null, null); FsFolder currentFolder = fakeFolder; FsFolder lastFolder = null; int itemStart = data.ReadShort(); while (itemStart != 0) { switch (itemStart) { case 1: break; case 2: if (lastFolder != null) { currentFolder = lastFolder; itemStart = data.ReadShort(); continue; } else { throw new Exception("lastFolder = null"); } case 3: if (currentFolder == fakeFolder) { itemStart = data.ReadShort(); continue; } else if (currentFolder.Parent != null) { currentFolder = currentFolder.Parent; if (currentFolder == null) { throw new Exception("No parent folder"); } continue; } else { throw new Exception("No parent folder"); } case 15: var skip = data.ReadPu32(); for (int i = 0; i < skip; i++) { data.ReadPu32(); data.ReadPu32(); } break; default: throw new Exception("Unknown itemStart"); } FsItem item = GetItem(data, currentFolder); currentFolder.Items.Add(item); if (item is FsFolder fsFolder) { lastFolder = fsFolder; } itemStart = data.ReadShort(); } var res = fakeFolder.Items[0]; return(res); }