public void OnUpdate(Int64 lastMSec, Int64 curMSec, double scale, Panel container, NicoLabelListModel labels) { double w = container.ActualWidth; double h = container.ActualHeight; foreach (NicoComment comm in comments) { Int64 vposMSec = comm.VPos * 10; if (vposMSec >= lastMSec && vposMSec < curMSec) { NicoLabel label = new NicoLabel(); // label.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)); // child of container.Children.Add(label); // label->setAttribute(Qt::WA_TransparentForMouseEvents); label.SetByNicoComment(comm); if (_noShadow) { label.SetShadowDepth(0); } label.Birth(w, h, scale); label.DoMove((int)(curMSec - vposMSec)); labels.checkCollision(label, scale, container); labels.Add(label); } } }
public void checkCollision(NicoLabel label, double scale, Panel container) { foreach(NicoLabel item in labels) { if (label == item) { continue; } if (label.collideWith(item)) { if (label.moveDown(container.ActualHeight)) { // moved done checkCollision(label, scale, container); return; } else { // overflow return; } } } }
public void Add(NicoLabel label) { labels.Add(label); }
public bool collideWith(NicoLabel other) { double thisHeight = this.getHeight() + _space; double otherHeight = other.getHeight() + _space; if (_bOverflow || other.isOverflow()) { return false; } if (_posGroup != other._posGroup) { return false; } if (this.y()+thisHeight <= other.y()) { return false; } if (this.y() >= other.y() + otherHeight) { return false; } if (_posGroup != PosGroupType.Normal) { return true; } if (other.x()+other.getWidth() > this.x()) { return true; } if (-this.x()/(_xSpeed*_scale)*other.getXSpeed()+other.x()+other.getWidth() > 0) { return true; } return false; }