void StreamHelper::formateStream(vector<string> &vs)
{
    for(size_t i=0;i<vs.size();i++)
    {
        string s = vs[i];
        if(s.find('|') != string::npos)
        {
            string ahalf(s.substr(0,s.find('|'))),
                    bhalf(s.substr(0,3));
			ahalf.push_back((char)10);
            bhalf.append(s.substr(s.find('|')+1,s.size()-1));

            vs.erase(vs.begin()+i);
            vs.insert(vs.begin()+i,ahalf);
            vs.insert(vs.begin()+i+1,bhalf);

        }
    }
}
void CGetBlackOutDlg::OnMouseDown( UINT nflags, CPoint point)
{
	if (mWon) return;
	int x,y,cx,cy,i,piece;
	x=y=cx=cy=piece=0;
	for(i = 0 ; i < mBoard.numpieces(); i++) {
		x = mBoard.pborder() + 
			(mBoard.piece(i)->xpos() * (mBoard.pper() + mBoard.pborder()));
		y = mBoard.pborder() + 
			(mBoard.piece(i)->ypos() * (mBoard.pper() + mBoard.pborder()));
		cx = (mBoard.piece(i)->width() * mBoard.pper());
		if (mBoard.piece(i)->width() == 2)
			cx += mBoard.pborder();

		cy = (mBoard.piece(i)->height() * mBoard.pper());
		if (mBoard.piece(i)->height() == 2)
			cy += mBoard.pborder();
		CRect piecerect(x,y,x+cx,y+cy);
		if (piecerect.PtInRect(point)) {
			piece=i;
			i=mBoard.numpieces();
			mMoving = TRUE;
			mMouseStartPoint = point;
			mPieceMoving = piece;
			break;
		}
	}
	int moves = 0;
	if (mMoving) {
		int x,y,sx,sy,sx2,sy2;
		x=y=sx=sy=sx2=sy2=0;
		x = -mBoard.pper(); y = 0;
		if (mBoard.canmove(mPieceMoving,x,y)) {
			moves++;
			sx=x;sy=y;
		}
		x = mBoard.pper(); y = 0;
		if (mBoard.canmove(mPieceMoving,x,y)) {
			moves++;
			if (moves < 2) {
				sx=x;sy=y;
			} else {
				sx2=x;sy2=y;
			}
		}
		x = 0; y = mBoard.pper();
		if (mBoard.canmove(mPieceMoving,x,y)) {
			moves++;
			if (moves < 2) {
				sx=x;sy=y;
			} else {
				sx2=x;sy2=y;
			}
		}
		x = 0; y = -mBoard.pper();
		if (mBoard.canmove(mPieceMoving,x,y)) {
			moves++;
			if (moves < 2) {
				sx=x;sy=y;
			} else {
				sx2=x;sy2=y;
			}
		}

		if (moves == 1) {
			CPoint delta(point);
			delta += CPoint(sx,sy);
			OnMouseMove(0, delta);
			OnMouseUp(0,CPoint());
		} else if (moves == 2) {
			CRect piecerect(mBoard.piece(mPieceMoving)->mPieceRect);
			int deltax, deltay;deltax=deltay=0;
			if (abs(sx) == mBoard.pper() 
					&& abs(sx2) == mBoard.pper()) {
				CRect lhalf(piecerect);
				CRect rhalf(piecerect);
				lhalf.BottomRight().x -= lhalf.Width() / 2;
				rhalf.TopLeft().x = lhalf.BottomRight().x;
				if (lhalf.PtInRect(point)) {
					deltax = sx2;
				} else {
					deltax = sx;
				}
				CPoint delta(point);
				delta += CPoint(deltax,deltay);
				OnMouseMove(0, delta);
				OnMouseUp(0,CPoint());
			} else if (abs(sy) == mBoard.pper() 
					&& abs(sy2) == mBoard.pper()) {
				CRect thalf(piecerect);
				CRect bhalf(piecerect);
				thalf.BottomRight().y -= thalf.Height() / 2;
				bhalf.TopLeft().y = thalf.BottomRight().y;
				if (thalf.PtInRect(point)) {
					deltay = sy;
				} else {
					deltay = sy2;
				}
				CPoint delta(point);
				delta += CPoint(deltax,deltay);
				OnMouseMove(0, delta);
				OnMouseUp(0,CPoint());
			} else if (
					sx == mBoard.pper()
					&& sy2 == mBoard.pper()
					||
					sx2 == mBoard.pper()
					&& sy == mBoard.pper()
					) {
				if (distance(topright(piecerect),point)
					< distance(point, bottomleft(piecerect))) {
					deltay = sy2;
				} else {
					deltax = sx;
				}
				CPoint delta(point);
				delta += CPoint(deltax,deltay);
				OnMouseMove(0, delta);
				OnMouseUp(0,CPoint());		
			} else if (
				sx == -mBoard.pper()
				&& sy2 == mBoard.pper()
				||
				sx2 == -mBoard.pper()
				&& sy == mBoard.pper()
				) {
				if (distance(topleft(piecerect),point)
					< distance(point, bottomright(piecerect))) {
					deltay = sy2;
				} else {
					deltax = sx;
				}
				CPoint delta(point);
				delta += CPoint(deltax,deltay);
				OnMouseMove(0, delta);
				OnMouseUp(0,CPoint());		
			} else if (
				sx == mBoard.pper()
				&& sy2 == -mBoard.pper()
				||
				sx2 == mBoard.pper()
				&& sy == -mBoard.pper()
				) {
				if (distance(topleft(piecerect),point)
					< distance(point, bottomright(piecerect))) {
					deltax = sx;
				} else {
					deltay = sy2;
				}
				CPoint delta(point);
				delta += CPoint(deltax,deltay);
				OnMouseMove(0, delta);
				OnMouseUp(0,CPoint());	
			} else if (
				sx == -mBoard.pper()
				&& sy2 == -mBoard.pper()
				||
				sx2 == -mBoard.pper()
				&& sy == -mBoard.pper()
				) {
				if (distance(topright(piecerect),point)
					< distance(point, bottomleft(piecerect))) {
					deltax = sx;
				} else {
					deltay = sy2;
				}
				CPoint delta(point);
				delta += CPoint(deltax,deltay);
				OnMouseMove(0, delta);
				OnMouseUp(0,CPoint());	
			}			
		}
	}


}