標籤: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特效-實現弧形旋轉輪播圖