public void InsertKey(string key, string prevKey, string nextKey, CDVAtom cellContent) { CDVDocumentCell cell = new CDVDocumentCell(); cell.Key = key; cell.NextKey = nextKey; cell.PrevKey = prevKey; cell.Item = cellContent; cellContent.Parent = this; }
private void RequestAsyncKey(string key) { if (DataSource != null) { lock (pRequestedKeys) { if (!pRequestedKeys.Contains(key)) { CDVDocumentCell cell = new CDVDocumentCell(); cell.Key = key; DataSource.AsyncRequestData(this, cell); } } } }
public void InitWithKey(string key) { if (Document.ContainsKey(key)) { CDVDocumentCell atom = Document.GetItemForKey(key); Size atomSize = atom.Item.Size; Point atomLoc = atom.Item.Location; Point newAtomLoc = new Point(0, Height / 2 - atomSize.Height / 2); atom.Item.Offset(newAtomLoc.X - atomLoc.X, newAtomLoc.Y - atomLoc.Y); MainAtom = atom; MainAtomPosition = 50; } else { MainAtom = null; MainAtomPosition = -1; RequestAsyncKey(key); } Invalidate(); }
public void OnCDVDataAvailable(CDVDocumentCell data) { lock (pRequestedKeys) { if (!Document.Cells.ContainsKey(data.Key)) { Document.Cells[data.Key] = data; if (MainAtom == null) { MainAtom = data; MainAtomPosition = 0; } Debugger.Log(0, "", "Received documentCell " + data.Key + "\n"); } pRequestedKeys.Remove(data.Key); } // TODO: Invalidate only if expected documentpart that should be displayed // and user was waiting for it Invalidate(); }
/// <summary> /// Assumption is that at least MainAtom is correctly placed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CalendarDataView_Paint(object sender, PaintEventArgs e) { CDVDocumentCell firstDrawn = null; if (MainAtom == null) { e.Graphics.DrawString("Please wait a moment...", SystemFonts.MenuFont, Brushes.Black, BoundsFloat, CDVContext.StringFormatCenterCenter); return; } CDVContext ctx = new CDVContext(); ctx.g = e.Graphics; ctx.ScreenRect = this.ClientRectangle; CDVDocumentCell last = MainAtom; Rectangle clientArea = this.ClientRectangle; // drawing main atom if (MainAtom.RefreshLayout) { DataSource.SyncRefreshLayout(this, MainAtom); } MainAtom.Prepare(ctx, 5000); MainAtom.Item.DrawInRect(ctx); if (MainAtom.Item.Bounds.Bottom > ctx.ScreenRect.Top && MainAtom.Item.Bounds.Top < ctx.ScreenRect.Bottom) { firstDrawn = MainAtom; } //Debugger.Log(0, "", "Bottom: " + last.Item.Bounds.Bottom + ", Height: " + Height + "\n"); // drawing after while (Document.ContainsKey(last.NextKey) && last.Item.Bounds.Bottom < Height) { // drawing next atom CDVDocumentCell nc = Document.GetItemForKey(last.NextKey); if (nc.RefreshLayout) { DataSource.SyncRefreshLayout(this, nc); } nc.Prepare(ctx, 5000); nc.MoveAfter(last); nc.Item.DrawInRect(ctx); if (nc.Item.Bounds.Bottom > ctx.ScreenRect.Top && nc.Item.Bounds.Top < ctx.ScreenRect.Bottom && firstDrawn == null) { firstDrawn = nc; } last = nc; } if (!Document.ContainsKey(last.NextKey)) { // here place order to datasource for nextkey RequestAsyncKey(last.NextKey); } last = MainAtom; while (Document.ContainsKey(last.PrevKey) && last.Item.Bounds.Top > 0) { CDVDocumentCell nc = Document.GetItemForKey(last.PrevKey); if (nc.RefreshLayout) { DataSource.SyncRefreshLayout(this, nc); } nc.Prepare(ctx, 5000); nc.MoveBefore(last); nc.Item.DrawInRect(ctx); if (nc.Item.Bounds.Bottom > ctx.ScreenRect.Top && nc.Item.Bounds.Top < ctx.ScreenRect.Bottom && firstDrawn == null) { firstDrawn = nc; } last = nc; } if (!Document.ContainsKey(last.PrevKey)) { // here place order to datasource for nextkey RequestAsyncKey(last.PrevKey); } // setting MainAtom to document part, that is really drawn on the screen if (firstDrawn != MainAtom) { //Debugger.Log(0, "", "MainAtom changed\n"); MainAtom = firstDrawn; } }
public void MoveBefore(CDVDocumentCell before) { Item.Offset(0, before.Item.Bounds.Top - Item.Size.Height - Item.Bounds.Location.Y); }
public void MoveAfter(CDVDocumentCell after) { Item.Offset(0, after.Item.Bounds.Bottom - Item.Bounds.Location.Y); }