WPF特效-實現弧形旋轉輪播圖

來源:互聯網
上載者:User

標籤:wpf   this   list   效能   nts   oid   rac   +=   on()   

原文:WPF特效-實現弧形旋轉輪播圖

? ? ? ?項目遇到,琢磨並實現了迴圈演算法,主要處理迴圈替換顯示問題

? ? ? (如:12張圖組成一個圓弧,但總共有120張圖需要呈現,如何在滑動中進行顯示塊的替換,並毫無卡頓)

? ? ? ?處理的自己感覺比較滿意,記錄一下。

? ? ? 2D:


? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

? ??

? ? ?2D動態Gif效果:

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??


? ? ? ?2D思路: Canvas作為承載控制項,控制顯示個數,以角度作為判斷是否顯示的標準。 同時圖片以線程池或者延時載入的方式實現載入效能的最佳化。

? ? ? ?2D迴圈關鍵:

? ? ?? ?private void UpdateLocation()
? ? ? ? {
? ? ? ? ? ? for (int i = 0; i < this.ElementList.Count; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? NavItem oItem = this.ElementList[i];


? ? ? ? ? ? ? ? if(oItem.Degree - this.CenterDegree >= this.TotalDegree /2d)
? ? ? ? ? ? ? ? ? ? oItem.Degree -= this.TotalDegree;
? ? ? ? ? ? ? ? else if(this.CenterDegree - oItem.Degree > this.TotalDegree / 2d)
? ? ? ? ? ? ? ? ? ? oItem.Degree += this.TotalDegree;


? ? ? ? ? ? ? ? if (oItem.Degree >= 90d && oItem.Degree < 270d) // Degree 在90-270之間的顯示
? ? ? ? ? ? ? ? ? ? this.SetElementVisiable(oItem);
? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? this.SetElementInvisiable(oItem);
? ? ? ? ? ? }
? ? ? ? }


? ? ? 3D:

? ? ? ??


? ? ? 3D動態Gif效果:

??

? ? ? ? ? ? ? ? ? ? ?


? ? ? 3D思路:以Viewport3D 作為容器,ModelVisual3D 實現元素塊的承載,轉動效果通過控制Camera的Angle角度實現。?

? ? ? ? ? ? ? ? ? ? ? 以顯示塊構成圓弧的角度以及Camera的旋轉角度為依據控制元素塊是否呈現或隱藏。


? ? ? 3D迴圈替換關鍵

? ? ? ? private void DoUpdateLayout()
? ? ? ? {
? ? ? ? ? ? for (int i = 0; i < this.ElementList.Count; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? InteractivePanel3D oVisualItem = this.ElementList[i];
? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? if (oVisualItem.Degree + this.CameraAngleYZm.Angle >= this.TotalDegree / 2d)
? ? ? ? ? ? ? ? ? ? oVisualItem.Degree -= this.TotalDegree;
? ? ? ? ? ? ? ? else if (oVisualItem.Degree + this.CameraAngleYZm.Angle <= -this.TotalDegree / 2d)
? ? ? ? ? ? ? ? ? ? oVisualItem.Degree += this.TotalDegree;


? ? ? ? ? ? ? ? //元素塊角度與3D情境旋轉角度的角度差; 角度差在定義的範圍內則元素塊顯示,否則隱藏
? ? ? ? ? ? ? ? double dDistanceToCenter = Math.Abs(oVisualItem.Degree + this.CameraAngleY.Angle - COriginViewprotAngel);
? ? ? ? ? ? ? ? if (dDistanceToCenter <= CBoundDegree)
? ? ? ? ? ? ? ? ? ? this.SetVisualItemVisible(oVisualItem);
? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? this.SetVisualItemInvisible(oVisualItem);
? ? ? ? ? ? }
? ? ? ? }


WPF特效-實現弧形旋轉輪播圖

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.