private StreamPageLabel CreateOneCompetibleLabel() { StreamPageLabel newLabel = new StreamPageLabel(); newLabel.Width = this.Width; newLabel.Height = this.Height; return(newLabel); }
private StreamPageLabel InsertOnePageAt(int index) { this.InsertPage(index); StreamPageLabel newLabel = CreateOneCompetibleLabel(); this.GetPage(index).AddChildLast(newLabel); return(newLabel); }
public void ResetData() { for (int i = this.pageCount - 1; i >= 0; --i) { this.RemovePageAt(i); } StreamPageLabel newLabel = InsertOnePageAt(0); string content = contentStrm.GetThisPage(newLabel); newLabel.Text = content; contentStrm.UpdateLocation(0, content.Length); PrepareSurroundPage(0); }
public void ScrollTo(int index, bool withAnimation) { if (index >= this.pageCount) { index = this.pageCount - 1; } else { if (index < 0) { index = 0; } } // 放在这里会影响动画的效率和流畅度,后续再改 foreach (Widget w in this.GetPage(index).Children) { if (w is StreamPageLabel) { StreamPageLabel st = w as StreamPageLabel; contentStrm.UpdateLocation(st.ContentIndex, st.ContentLenth); PrepareSurroundPage(index); } } if (withAnimation) { this.animationStartPos = this.panelContainer.X; this.animationElapsedTime = 0f; this.nextPos = -(this.Width * (float)index); this.animation = true; return; } this.pageIndex = index; this.panelContainer.X = -(this.Width * (float)this.pageIndex); this.animation = false; this.SetupPageVisible(); this.UpdateSprite(); }
private void PrepareNextPage(int baseIndex) { if (null == contentStrm) { return; } // not the lastest page, already have next page if (baseIndex < this.pageCount - 1) { return; } if (contentStrm.HasNext()) { StreamPageLabel newLabel = InsertOnePageAt(baseIndex + 1); string strcontent = contentStrm.GetNextPage(newLabel); newLabel.Text = strcontent; } }
private void PreparePrevPage(int baseIndex) { if (null == contentStrm) { return; } if (baseIndex > 0) { // already have one return; } if (contentStrm.HasPrev()) { StreamPageLabel newLabel = InsertOnePageAt(baseIndex); string strcontent = contentStrm.GetPrevPage(newLabel); newLabel.Text = strcontent; } }
private StreamPageLabel CreateOneCompetibleLabel() { StreamPageLabel newLabel = new StreamPageLabel(); newLabel.Width = this.Width; newLabel.Height = this.Height; return newLabel; }