这两天使用silverlight编写一个在wince 7.0上运行的photovIEw小工具,中间遇到许多问题,现在记录下来,方便以后查找。
HWND hWnd;
IXRBitmAPImagePtr image_background;
IXRImagePtr image_control;
IXRImagePtr pFull_image;
IXRScaletransformPtr pImageScale;
IXRRotatetransformPtr pImageRotate;
IXRScrollVIEwerPtr pScroll;
IXRCanvasPtr pFull;
float fWIDth,fheight;
HWND hWndTaskbar = NulL; // The Taskbar
BOol mode = false;
图片放大/缩小:
HRESulT OnBSClicked(IXRDependencyObject* source,XRMousebuttonEventArgs* args)
{
HRESulT retcode;
BSTR pname;
float fActualX,fActualY;
static float x = 1.0;
static float y = 1.0;
if(Failed(retcode = source->Getname(&pname)))
return retcode;
if(!wcscmp(pname,L"btn_small"))
{
if(x > 0.5)
x -= 0.1;
if(y > 0.5)
y -= 0.1;
}
else
{
x += 0.1;
y += 0.1;
}
//image_control->GetActualX(&fActualX);
//image_control->GetActualY(&fActualY);
//pImageScale->SetCenterX(fActualX + fWIDth/2);
//pImageScale->SetCenterY(fActualY + fheight/2);
pImageScale->SetScaleX(x);
pImageScale->SetScaleY(y);
if( 1.0 < x )
{
pScroll->SetVerticalScrollbarVisibility(XRScrollbarVisibility_Visible);
pScroll->SetHorizontalScrollbarVisibility(XRScrollbarVisibility_Visible);
}
else
{
pScroll->SetVerticalScrollbarVisibility(XRScrollbarVisibility_HIDden);
pScroll->SetHorizontalScrollbarVisibility(XRScrollbarVisibility_HIDden);
}
image_control->SetWIDth(x * fWIDth);
image_control->SetHeight(y * fheight);
image_control->SetRendertransform(pImageScale);
image_control->SetStretch(XRStretch_UniformToFill);
return S_OK;
}
图片翻转:
HRESulT OnRotateClicked(IXRDependencyObject* source,XRMousebuttonEventArgs* args)
{
HRESulT retcode;
BSTR pname;
static float angle = 0;
//float centerX = fWIDth/2;
//float centerY = fheight/2;
float centerX = 0.5;
float centerY = 0.5;
if(Failed(retcode = source->Getname(&pname)))
return retcode;
if(!wcscmp(pname,L"btn_forward"))
{
angle += 90;
}
else
angle -= 90;
pImageRotate->SetAngle(angle);
pImageRotate->SetCenterX(centerX);
pImageRotate->SetCenterY(centerY);
image_control->SetRendertransform(pImageRotate);
return S_OK;
}
删除图片:
HRESulT OnDelClicked(IXRDependencyObject* source,XRMousebuttonEventArgs* args)
{
if(IDOK == MessageBox(hWnd,L"Are you sure to delete the picture?",L"PhotoVIEw",MB_OKCANCEL))
Deletefile(ImageArry[i]);
return S_OK;
}
图片全屏:
HRESulT OnPlayClicked(IXRDependencyObject* source,XRMousebuttonEventArgs* args)
{
if (mode)
{
if(hWndTaskbar != NulL)
ShowWindow(hWndTaskbar,SW_SHOW);
pScroll->Setopacity(100);
pScroll->SetVisibility(XRVisibility_Visible);
pFull->SetVisibility(XRVisibility_Collapsed);
::SetwindowPos(hWnd,/*HWND_topMOST*/HWND_NOtopMOST,50,640,480,SWP_NOOWNERZORDER|SWP_SHOWWINDOW);
mode = false;
}
else
{
if (hWndTaskbar != NulL) ShowWindow(hWndTaskbar,SW_HIDE);
int iFullWIDth = GetSystemMetrics(SM_CXSCREEN);
int iFullHeight = GetSystemMetrics(SM_CYSCREEN);
pImageScale->SetScaleX(1.0);
pImageScale->SetScaleY(1.0);
pScroll->Setopacity(0);
pScroll->SetVisibility(XRVisibility_Collapsed);
pFull->SetRendertransform(pImageScale);
pFull->Setopacity(100);
pFull->SetVisibility(XRVisibility_Visible);
::SetwindowPos(hWnd,HWND_topMOST/*HWND_NOtopMOST*/,iFullWIDth,iFullHeight,SWP_NOOWNERZORDER|SWP_SHOWWINDOW);
//pScroll->UpdateLayout();
mode = true;
}
return S_OK;
}
总结以上是内存溢出为你收集整理的silverlight在wince上的应用全部内容,希望文章能够帮你解决silverlight在wince上的应用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)