bool PullToRefreshTrait::OnPreviewTouchMoved(Control& source, const TouchEventInfo& touchEventInfo) { if(_captured) { int offset; if(_direction == PULL_TO_REFRESH_DIRECTION_TOP) offset = (touchEventInfo.GetCurrentPosition() - _touchDownPoint).y; else offset = -(touchEventInfo.GetCurrentPosition() - _touchDownPoint).y; float progress = (float)offset / (float)PULL_TO_REFRESH_OFFSET_LIMIT; if(progress > 1.0f) { progress = 1.0f; } Canvas *canvas = _progressControl->GetCanvasN(); int doneSize = (int)(canvas->GetBoundsF().width * progress); int undoneSize = canvas->GetBounds().width - doneSize; if(undoneSize < 0) { undoneSize = 0; } Rectangle progressRectangle = canvas->GetBounds(); progressRectangle.width -= undoneSize; progressRectangle.x += undoneSize / 2; canvas->SetCompositeMode(COMPOSITE_MODE_OVERLAY); canvas->FillRectangle(Color(0x569cdd, false), progressRectangle); delete canvas; } return false; }
result RoundedAvatar::OnDraw(void) { result r = E_SUCCESS; Canvas * pCanvas = GetCanvasN(); if (pCanvas != null) { if (pAvatar != null) { r = pCanvas->DrawBitmap(pCanvas->GetBounds(), *pAvatar); } else { r = pCanvas->DrawBitmap(pCanvas->GetBounds(), *pAvatarPlaceholder); } r = pCanvas->DrawBitmap(pCanvas->GetBounds(), *pAvatarRounding); TryCatch(r == E_SUCCESS, , "Failed DrawBitmap pAvatarRounding"); delete pCanvas; } return r; CATCH: AppLogException("$${Function:OnDraw} is failed.", GetErrorMessage(r)); delete pCanvas; return r; }
result MessageDocElement::OnDraw() { Canvas *pCanvas = GetCanvasN(); if (pCanvas) { pCanvas->DrawNinePatchedBitmap(pCanvas->GetBounds(), *_pBitmap); delete pCanvas; } return E_SUCCESS; }
result ItemForm::OnDraw(void) { result r = E_SUCCESS; Canvas* pCanvas = GetCanvasN(); Rectangle rt = pCanvas->GetBounds(); Application * app = Application::GetInstance(); AppResource * res = app->GetAppResource(); Bitmap * pBitmap = res->GetBitmapN(L"form_bg.png", BITMAP_PIXEL_FORMAT_ARGB8888); pCanvas->DrawBitmap(rt, *pBitmap); delete pBitmap; delete pCanvas; return r; }
bool SkyObject::Draw() { Point* zoomedPoint = new Point(); Canvas* canvas; canvas = SkyCanvas::GetStarCanvas(1); Point* point = Projector:: GetProjection(RAH, DED, sign, canvas->GetBounds().width, canvas->GetBounds().height); if (point == null) { delete zoomedPoint; return false; } Projector::Zoom(point, zoomedPoint, 1); DrawCanvas(canvas, zoomedPoint); Projector::Zoom(point, zoomedPoint, 2); canvas = SkyCanvas::GetStarCanvas(2); DrawCanvas(canvas, zoomedPoint); Projector::Zoom(point, zoomedPoint, 4); canvas = SkyCanvas::GetStarCanvas(4); DrawCanvas(canvas, zoomedPoint); delete zoomedPoint; return true; }