WPF轮播图实现方式

 WPF开发者QQ群: 340500857  | 微信群 -> 进入公众号主页 加入组织

欢迎转发、分享、点赞、在看,谢谢~。  

01

效果预览

效果预览(更多效果请下载源码体验):

02


代码如下

一、MasterCarousel.cs 代码如下

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using WPFDevelopers.Controls.Helpers;namespace WPFDevelopers.Controls
{internal enum CarouselLoacation{Left,Right,Center}internal enum CarouselZIndex{Left = 20,Center = 30,Right = 20,LeftMask = 40,RightMask = 40}[DefaultProperty("Children")][ContentProperty("Children")][Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)][TemplatePart(Name = Part_ContentDockName, Type = typeof(Canvas))][TemplatePart(Name = Part_ButtonDockName, Type = typeof(StackPanel))]public class MasterCarousel : Control, IAddChild{private const string Part_ContentDockName = "PART_ContentDock";private const string Part_ButtonDockName = "PART_ButtonDock";static MasterCarousel(){DefaultStyleKeyProperty.OverrideMetadata(typeof(MasterCarousel), new FrameworkPropertyMetadata(typeof(MasterCarousel)));}public MasterCarousel(){//_uiElementCollection = new List<object>();//SizeChanged += MasterCarousel_SizeChanged;LoadeTimer();Loaded += MasterCarousel_Loaded;}#region feildbool _isLoaded = false;Canvas _Part_ContentDock;StackPanel _Part_ButtonDock;#endregion#region render relativeconst double _ScaleRatio = 0.95;const double _ScaleRatioEx = 1;const double _CycleInterval = 2000;double _ShellWidth = 0;double _ShellHeight = 0;double _ElementWidth = 0;double _ElementHeight = 0;double _ElementScale = 0.6;double _CenterDockLeft = 0;double _LeftDockLeft = 0;double _RightDockLeft = 0;double _DockOffset = 0.2;int _CarouselSize = 0;#endregion#regionDictionary<int, object> _mapResources = new Dictionary<int, object>();Dictionary<int, FrameworkElement> _mapFrameworkes = new Dictionary<int, FrameworkElement>();Dictionary<CarouselLoacation, int> _mapCarouselLocationFramewokes = new Dictionary<CarouselLoacation, int>();LinkedList<int> _BufferLinkedList = new LinkedList<int>();#endregion#region timerTimer _PlayTimer = new Timer();#endregion#region StoryBoardStoryboard _Storyboard = null;double _AnimationTime = 0.5;double _DelayAnimationTime = 0.7;bool _IsAinimationStart = false;bool _IsStoryboardWorking = false;#endregion#region overridepublic override void OnApplyTemplate(){base.OnApplyTemplate();_Part_ContentDock = GetTemplateChild(Part_ContentDockName) as Canvas;_Part_ButtonDock = GetTemplateChild(Part_ButtonDockName) as StackPanel;if (_Part_ContentDock == null || _Part_ButtonDock == null)throw new Exception("Some element is not in template!");}#endregionpublic bool IsStartAinimation{get { return (bool)GetValue(IsStartAinimationProperty); }set { SetValue(IsStartAinimationProperty, value); }}// Using a DependencyProperty as the backing store for IsStartAinimation.  This enables animation, styling, binding, etc...public static readonly DependencyProperty IsStartAinimationProperty =DependencyProperty.Register("IsStartAinimation", typeof(bool), typeof(MasterCarousel), new PropertyMetadata(default(bool), OnIsStartAinimationPropertyChangedCallback));private static void OnIsStartAinimationPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e){if (d == null)return;if (!(d is MasterCarousel control))return;if (bool.TryParse(e.NewValue?.ToString(), out bool bResult)){if (bResult)control.Start();elsecontrol.Stop();}}public IEnumerable ItemsSource{get { return (IEnumerable)GetValue(ItemsSourceProperty); }set { SetValue(ItemsSourceProperty, value); }}// Using a DependencyProperty as the backing store for Childrens.  This enables animation, styling, binding, etc...public static readonly DependencyProperty ItemsSourceProperty =DependencyProperty.Register("ItemsSource", typeof(IEnumerable), typeof(MasterCarousel), new PropertyMetadata(default(IEnumerable), OnItemsSourcePropertyChangedCallBack));private static void OnItemsSourcePropertyChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs e){if (!(d is MasterCarousel carousel))return;var vOldEvent = e.OldValue?.GetType()?.GetEvent("CollectionChanged");if (vOldEvent != null)vOldEvent.RemoveEventHandler(e.OldValue, new NotifyCollectionChangedEventHandler(carousel.ChildrenPropertyChanged));var vEvent = e.NewValue?.GetType()?.GetEvent("CollectionChanged");if (vEvent != null)vEvent.AddEventHandler(e.NewValue, new NotifyCollectionChangedEventHandler(carousel.ChildrenPropertyChanged));}void ChildrenPropertyChanged(object sender, NotifyCollectionChangedEventArgs e){switch (e.Action){case NotifyCollectionChangedAction.Add:break;case NotifyCollectionChangedAction.Remove:break;case NotifyCollectionChangedAction.Replace:break;case NotifyCollectionChangedAction.Move:break;case NotifyCollectionChangedAction.Reset:break;default:break;}}List<object> _uiElementCollection = new List<object>();[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]public List<object> Children => _uiElementCollection;public void AddChild(object value){throw new NotImplementedException();}public void AddText(string text){throw new NotImplementedException();}bool LoadeTimer(){_PlayTimer.Interval = _CycleInterval;_PlayTimer.Elapsed += PlayTimer_Elapsed;return true;}bool CalculationShellReletiveProperty(){//计算当前目标区域的尺寸if (_Part_ContentDock == null)return false;var vWidth = _Part_ContentDock.ActualWidth;var vHeight = _Part_ContentDock.ActualHeight;if (vWidth == 0 || vHeight == 0)return false;if (vWidth == _ShellWidth && vHeight == _ShellHeight)return false;_ShellWidth = vWidth;_ShellHeight = vHeight;//计算 元素的默认长度和宽度_ElementWidth = _ShellWidth * _ElementScale;_ElementHeight = _ShellHeight;_LeftDockLeft = 0;_CenterDockLeft = 0 + _ShellWidth * _DockOffset;_RightDockLeft = _ShellWidth - _ElementWidth;return true;}bool LoadCarousel(){if (Children.Count <= 0 && ItemsSource == null)return false;if (_Part_ButtonDock != null){foreach (var item in _Part_ButtonDock.Children){if (item is FrameworkElement frameworkElement){frameworkElement.MouseEnter -= Border_MouseEnter;frameworkElement.PreviewMouseDown -= Border_PreviewMouseDown;}}}_mapFrameworkes.Clear();_mapCarouselLocationFramewokes.Clear();_BufferLinkedList.Clear();_Part_ContentDock?.Children.Clear();_Part_ButtonDock?.Children.Clear();if (Children.Count > 0){_CarouselSize = Children.Count;for (int i = 0; i < _CarouselSize; i++){var vItem = Children[i];FrameworkElement frameworkElement;if (vItem is FrameworkElement)frameworkElement = vItem as FrameworkElement;else{var vContent = new ContentControl();vContent.HorizontalContentAlignment = HorizontalAlignment.Center;vContent.VerticalContentAlignment = VerticalAlignment.Center;vContent.Content = vItem;frameworkElement = vContent;}frameworkElement.Width = _ElementWidth;frameworkElement.Height = _ElementHeight;frameworkElement.RenderTransformOrigin = new Point(0.5, 1);var vTransformGroup = new TransformGroup{Children ={new ScaleTransform(){ ScaleY = _ScaleRatio},new SkewTransform(),new RotateTransform(),new TranslateTransform()}};frameworkElement.RenderTransform = vTransformGroup;Border border = new Border(){Margin = new Thickness(5),Width = 20,Height = 6,//CornerRadius = new CornerRadius(20),Background = Brushes.Gray,Tag = i,};border.MouseEnter += Border_MouseEnter;border.PreviewMouseDown += Border_PreviewMouseDown;_mapResources[i] = vItem;_mapFrameworkes[i] = frameworkElement;_Part_ContentDock?.Children.Add(frameworkElement);_Part_ButtonDock?.Children.Add(border);//第一个元素居中并且放大显示if (i == 0){var vScaleTransform = vTransformGroup.Children[0] as ScaleTransform;vScaleTransform.ScaleY = _ScaleRatioEx;frameworkElement.SetValue(Canvas.LeftProperty, _CenterDockLeft);Panel.SetZIndex(frameworkElement, (int)CarouselZIndex.Center);_mapCarouselLocationFramewokes.Add(CarouselLoacation.Center, i);}else if (i == 1){frameworkElement.SetValue(Canvas.LeftProperty, _RightDockLeft);Panel.SetZIndex(frameworkElement, (int)CarouselZIndex.Right);_mapCarouselLocationFramewokes.Add(CarouselLoacation.Right, i);}else if (i == _CarouselSize - 1){frameworkElement.SetValue(Canvas.LeftProperty, _LeftDockLeft);Panel.SetZIndex(frameworkElement, (int)CarouselZIndex.Left);_mapCarouselLocationFramewokes.Add(CarouselLoacation.Left, i);}else{_BufferLinkedList.AddLast(i);frameworkElement.SetValue(Canvas.LeftProperty, _CenterDockLeft);Panel.SetZIndex(frameworkElement, i);}}}else{_CarouselSize = ItemsSource.Count();int nIndex = 0;foreach (var item in ItemsSource){FrameworkElement frameworkElement;if (item is FrameworkElement)frameworkElement = item as FrameworkElement;else{var vContent = new ContentControl();vContent.HorizontalContentAlignment = HorizontalAlignment.Center;vContent.VerticalContentAlignment = VerticalAlignment.Center;vContent.Content = item;frameworkElement = vContent;}frameworkElement.Width = _ElementWidth;frameworkElement.Height = _ElementHeight;frameworkElement.RenderTransformOrigin = new Point(0.5, 1);var vTransformGroup = new TransformGroup{Children ={new ScaleTransform(){ ScaleY = _ScaleRatio},new SkewTransform(),new RotateTransform(),new TranslateTransform()}};frameworkElement.RenderTransform = vTransformGroup;Border border = new Border(){Width = 25,Height = 25,CornerRadius = new CornerRadius(25),Background = Brushes.Gray,Tag = nIndex,};border.MouseEnter += Border_MouseEnter;border.PreviewMouseDown += Border_PreviewMouseDown;_mapResources[nIndex] = item;_mapFrameworkes[nIndex] = frameworkElement;_Part_ContentDock?.Children.Add(frameworkElement);_Part_ButtonDock?.Children.Add(border);//第一个元素居中并且放大显示if (nIndex == 0){var vScaleTransform = vTransformGroup.Children[0] as ScaleTransform;vScaleTransform.ScaleY = _ScaleRatioEx;frameworkElement.SetValue(Canvas.LeftProperty, _CenterDockLeft);Panel.SetZIndex(frameworkElement, (int)CarouselZIndex.Center);_mapCarouselLocationFramewokes.Add(CarouselLoacation.Center, nIndex);}else if (nIndex == 1){frameworkElement.SetValue(Canvas.LeftProperty, _RightDockLeft);Panel.SetZIndex(frameworkElement, (int)CarouselZIndex.Right);_mapCarouselLocationFramewokes.Add(CarouselLoacation.Right, nIndex);}else if (nIndex == _CarouselSize - 1){frameworkElement.SetValue(Canvas.LeftProperty, _LeftDockLeft);Panel.SetZIndex(frameworkElement, (int)CarouselZIndex.Left);_mapCarouselLocationFramewokes.Add(CarouselLoacation.Left, nIndex);}else{_BufferLinkedList.AddLast(nIndex);frameworkElement.SetValue(Canvas.LeftProperty, _CenterDockLeft);Panel.SetZIndex(frameworkElement, nIndex);}}}return true;}#region 动画//从左边向右依次播放bool PlayCarouselLeftToRight(){if (_Storyboard == null){_Storyboard = new Storyboard();_Storyboard.Completed += Storyboard_Completed;}if (_IsStoryboardWorking)return false;_IsStoryboardWorking = true;_Storyboard?.Children.Clear();int nNextIndex = -1;//右边的动画移动到中间 后层{var vResult = _mapCarouselLocationFramewokes.GetValueOrDefault(CarouselLoacation.Right, -1);var vFrameworker = _mapFrameworkes.GetValueOrDefault(vResult, null);if (vFrameworker != null){//置于后层Int32Animation animation1 = new Int32Animation{To = vResult + 1,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//右边移动到中间DoubleAnimation animation2 = new DoubleAnimation{To = _CenterDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);//缩放DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatio,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);_BufferLinkedList.AddFirst(vResult);}_mapCarouselLocationFramewokes[CarouselLoacation.Right] = -1;}//中间的动画移动到右边{var vResult = _mapCarouselLocationFramewokes.GetValueOrDefault(CarouselLoacation.Center, -1);var vFrameworker = _mapFrameworkes.GetValueOrDefault(vResult, null);if (vFrameworker != null){//置于左边上层Int32Animation animation1 = new Int32Animation{To = (int)CarouselZIndex.Right,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//从中间到左边DoubleAnimation animation2 = new DoubleAnimation{//BeginTime = TimeSpan.FromSeconds(_DelayAnimationTime),To = _RightDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);//缩放DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatio,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);_mapCarouselLocationFramewokes[CarouselLoacation.Right] = vResult;}_mapCarouselLocationFramewokes[CarouselLoacation.Center] = -1;}//左边的动画移动到中间 上层{var vResult = _mapCarouselLocationFramewokes.GetValueOrDefault(CarouselLoacation.Left, -1);var vFrameworker = _mapFrameworkes.GetValueOrDefault(vResult, null);if (vFrameworker != null){//置于上层Int32Animation animation1 = new Int32Animation{To = (int)CarouselZIndex.Center,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//从左到中DoubleAnimation animation2 = new DoubleAnimation{To = _CenterDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);//缩放DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatioEx,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);_mapCarouselLocationFramewokes[CarouselLoacation.Center] = vResult;nNextIndex = vResult - 1;if (nNextIndex < 0)nNextIndex = _CarouselSize - 1;}_mapCarouselLocationFramewokes[CarouselLoacation.Left] = -1;}//后层记录推送到前台左侧if (nNextIndex >= 0){_BufferLinkedList.Remove(nNextIndex);var vFrameworker = _mapFrameworkes.GetValueOrDefault(nNextIndex, null);if (vFrameworker != null){//右侧置顶Int32Animation animation1 = new Int32Animation{To = (int)CarouselZIndex.Left,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//从中间移动到右侧DoubleAnimation animation2 = new DoubleAnimation{To = _LeftDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatio,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);_mapCarouselLocationFramewokes[CarouselLoacation.Left] = nNextIndex;}}else{if (_BufferLinkedList.Count > 0){var vResult = _BufferLinkedList.LastOrDefault();_BufferLinkedList.RemoveLast();var vFrameworker = _mapFrameworkes.GetValueOrDefault(vResult, null);if (vFrameworker != null){//右侧置顶Int32Animation animation1 = new Int32Animation{To = (int)CarouselZIndex.Left,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//从中间移动到右侧DoubleAnimation animation2 = new DoubleAnimation{To = _LeftDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatio,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);_mapCarouselLocationFramewokes[CarouselLoacation.Left] = vResult;}}}_Storyboard?.Begin();return true;}//从右向左依次播放bool PlayCarouselRightToLeft(){if (_Storyboard == null){_Storyboard = new Storyboard();_Storyboard.Completed += Storyboard_Completed;}_IsStoryboardWorking = true;_Storyboard?.Children.Clear();int nNextIndex = -1;//左边的动画移动到中间 后层{var vResult = _mapCarouselLocationFramewokes.GetValueOrDefault(CarouselLoacation.Left, -1);var vFrameworker = _mapFrameworkes.GetValueOrDefault(vResult, null);if (vFrameworker != null){//置于后层Int32Animation animation1 = new Int32Animation{To = vResult + 1,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//从左到中DoubleAnimation animation2 = new DoubleAnimation{To = _CenterDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);//缩放DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatio,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);_BufferLinkedList.AddLast(vResult);}_mapCarouselLocationFramewokes[CarouselLoacation.Left] = -1;}//中间的动画移动到左边{var vResult = _mapCarouselLocationFramewokes.GetValueOrDefault(CarouselLoacation.Center, -1);var vFrameworker = _mapFrameworkes.GetValueOrDefault(vResult, null);if (vFrameworker != null){//置于左边上层Int32Animation animation1 = new Int32Animation{To = (int)CarouselZIndex.Left,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//从中间到左边DoubleAnimation animation2 = new DoubleAnimation{//BeginTime = TimeSpan.FromSeconds(_DelayAnimationTime),To = _LeftDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);//缩放DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatio,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);_mapCarouselLocationFramewokes[CarouselLoacation.Left] = vResult;}_mapCarouselLocationFramewokes[CarouselLoacation.Center] = -1;}//右边的动画移动到中间{var vResult = _mapCarouselLocationFramewokes.GetValueOrDefault(CarouselLoacation.Right, -1);var vFrameworker = _mapFrameworkes.GetValueOrDefault(vResult, null);if (vFrameworker != null){//置于上层Int32Animation animation1 = new Int32Animation{To = (int)CarouselZIndex.Center,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//右边移动到中间DoubleAnimation animation2 = new DoubleAnimation{To = _CenterDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);//缩放DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatioEx,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);_mapCarouselLocationFramewokes[CarouselLoacation.Center] = vResult;nNextIndex = vResult + 1;if (nNextIndex >= _CarouselSize)nNextIndex = 0;}_mapCarouselLocationFramewokes[CarouselLoacation.Right] = -1;}//后层记录推送到前台if (nNextIndex >= 0){_BufferLinkedList.Remove(nNextIndex);var vFrameworker = _mapFrameworkes.GetValueOrDefault(nNextIndex, null);if (vFrameworker != null){//右侧置顶Int32Animation animation1 = new Int32Animation{To = (int)CarouselZIndex.Right,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//从中间移动到右侧DoubleAnimation animation2 = new DoubleAnimation{To = _RightDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatio,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);_mapCarouselLocationFramewokes[CarouselLoacation.Right] = nNextIndex;}}else{if (_BufferLinkedList.Count > 0){var vResult = _BufferLinkedList.FirstOrDefault();_BufferLinkedList.RemoveFirst();var vFrameworker = _mapFrameworkes.GetValueOrDefault(vResult, null);if (vFrameworker != null){//右侧置顶Int32Animation animation1 = new Int32Animation{To = (int)CarouselZIndex.Right,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//从中间移动到右侧DoubleAnimation animation2 = new DoubleAnimation{To = _RightDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatio,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);_mapCarouselLocationFramewokes[CarouselLoacation.Right] = vResult;}}}_Storyboard?.Begin();return true;}//当用户点击其中某个位置的动画时bool PlayCarouselWithIndex(int nIndex){//检查 nIndex是否有效if (nIndex < 0 || nIndex >= _CarouselSize)return false;//判断当前选中的是否处于中间播放位置{var vResult = _mapCarouselLocationFramewokes.GetValueOrDefault(CarouselLoacation.Center, -1);if (vResult == nIndex)return true;}//判断如果当前选中的在左侧等待区 播放顺序是从左向右{var vResult = _mapCarouselLocationFramewokes.GetValueOrDefault(CarouselLoacation.Left, -1);if (vResult == nIndex)return PlayCarouselLeftToRight();}//判断如果当前选中的在右侧等待区 播放顺序是从右向左{var vResult = _mapCarouselLocationFramewokes.GetValueOrDefault(CarouselLoacation.Right, -1);if (vResult == nIndex)return PlayCarouselRightToLeft();}//其他情况 return PlayCarouselWithIndexOutRange(nIndex);}bool PlayCarouselWithIndexOutRange(int nIndex){//检查 nIndex是否有效if (nIndex < 0 || nIndex >= _CarouselSize)return false;//计算前后动画位置var vPre = nIndex - 1;if (vPre < 0)vPre = _CarouselSize - 1;var vNext = nIndex + 1;if (vNext >= _CarouselSize)vNext = 0;if (_Storyboard == null){_Storyboard = new Storyboard();_Storyboard.Completed += Storyboard_Completed;}if (_IsStoryboardWorking)return false;_IsStoryboardWorking = true;_Storyboard?.Children.Clear();//清空队列_BufferLinkedList.Clear();//先将队列归位 全部置于中间后面隐藏{var vResult = _mapCarouselLocationFramewokes.GetValueOrDefault(CarouselLoacation.Right, -1);var vFrameworker = _mapFrameworkes.GetValueOrDefault(vResult, null);if (vFrameworker != null){//置于后层Int32Animation animation1 = new Int32Animation{To = vResult + 1,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//回到中间DoubleAnimation animation2 = new DoubleAnimation{To = _CenterDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);//缩放DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatio,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);}_mapCarouselLocationFramewokes[CarouselLoacation.Right] = -1;}{var vResult = _mapCarouselLocationFramewokes.GetValueOrDefault(CarouselLoacation.Center, -1);var vFrameworker = _mapFrameworkes.GetValueOrDefault(vResult, null);if (vFrameworker != null){//置于后层Int32Animation animation1 = new Int32Animation{To = vResult + 1,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//回到中间DoubleAnimation animation2 = new DoubleAnimation{To = _CenterDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);//缩放DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatio,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);}_mapCarouselLocationFramewokes[CarouselLoacation.Center] = -1;}{var vResult = _mapCarouselLocationFramewokes.GetValueOrDefault(CarouselLoacation.Left, -1);var vFrameworker = _mapFrameworkes.GetValueOrDefault(vResult, null);if (vFrameworker != null){//置于后层Int32Animation animation1 = new Int32Animation{To = vResult + 1,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//回到中间DoubleAnimation animation2 = new DoubleAnimation{To = _CenterDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);//缩放DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatio,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);}_mapCarouselLocationFramewokes[CarouselLoacation.Left] = -1;}//再调出目标位置动画for (int i = 0; i < _CarouselSize; i++){if (i == vPre) //放左侧{if (_mapFrameworkes.ContainsKey(i)){var vFrameworker = _mapFrameworkes.GetValueOrDefault(i, null);if (vFrameworker != null){//置于左边上层Int32Animation animation1 = new Int32Animation{To = (int)CarouselZIndex.Left,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//从中间到左边DoubleAnimation animation2 = new DoubleAnimation{BeginTime = TimeSpan.FromSeconds(_DelayAnimationTime),To = _LeftDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);//缩放DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatio,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);_mapCarouselLocationFramewokes[CarouselLoacation.Left] = i;}}}else if (i == nIndex) //放中间{if (_mapFrameworkes.ContainsKey(i)){var vFrameworker = _mapFrameworkes.GetValueOrDefault(i, null);if (vFrameworker != null){//置于中间上层Int32Animation animation1 = new Int32Animation{To = (int)CarouselZIndex.Center,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//到中间DoubleAnimation animation2 = new DoubleAnimation{BeginTime = TimeSpan.FromSeconds(_DelayAnimationTime),To = _CenterDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);//缩放DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatioEx,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);_mapCarouselLocationFramewokes[CarouselLoacation.Center] = i;}}}else if (i == vNext) //放右侧{if (_mapFrameworkes.ContainsKey(i)){var vFrameworker = _mapFrameworkes.GetValueOrDefault(i, null);if (vFrameworker != null){//置于右边上层Int32Animation animation1 = new Int32Animation{To = (int)CarouselZIndex.Right,Duration = TimeSpan.FromSeconds(_DelayAnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation1, vFrameworker);Storyboard.SetTargetProperty(animation1, new PropertyPath("(Panel.ZIndex)"));_Storyboard.Children.Add(animation1);//到右边DoubleAnimation animation2 = new DoubleAnimation{BeginTime = TimeSpan.FromSeconds(_DelayAnimationTime),To = _RightDockLeft,Duration = TimeSpan.FromSeconds(_AnimationTime),EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation2, vFrameworker);Storyboard.SetTargetProperty(animation2, new PropertyPath("(Canvas.Left)"));_Storyboard.Children.Add(animation2);//缩放DoubleAnimation animation3 = new DoubleAnimation(){Duration = TimeSpan.FromSeconds(_AnimationTime),To = _ScaleRatio,EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut },};Storyboard.SetTarget(animation3, vFrameworker);Storyboard.SetTargetProperty(animation3, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));_Storyboard.Children.Add(animation3);_mapCarouselLocationFramewokes[CarouselLoacation.Right] = i;}}}else_BufferLinkedList.AddLast(i);}_Storyboard?.Begin();return true;}bool Start(){if (!IsStartAinimation)return true;if (_IsAinimationStart)return true;_IsAinimationStart = true;_PlayTimer.Start();return true;}bool Stop(){if (_IsAinimationStart){_IsAinimationStart = false;_PlayTimer.Stop();}return true;}#endregionprivate void Storyboard_Completed(object sender, EventArgs e){_IsStoryboardWorking = false;}void PlayTimer_Elapsed(object sender, ElapsedEventArgs e){Application.Current.Dispatcher.BeginInvoke(new Action(() => PlayCarouselRightToLeft()));}void Border_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e){if (e.ChangedButton != System.Windows.Input.MouseButton.Left)return;if (sender is FrameworkElement frameworkElement){if (int.TryParse(frameworkElement.Tag?.ToString(), out int nResult))PlayCarouselWithIndex(nResult);}}private void Border_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e){if (sender is FrameworkElement frameworkElement){if (int.TryParse(frameworkElement.Tag?.ToString(), out int nResult))PlayCarouselWithIndex(nResult);}}void MasterCarousel_SizeChanged(object sender, SizeChangedEventArgs e){Stop();if (CalculationShellReletiveProperty()){LoadCarousel();Start();}}private void MasterCarousel_Loaded(object sender, RoutedEventArgs e){if (_isLoaded)return;Stop();if (CalculationShellReletiveProperty()){LoadCarousel();Start();}_isLoaded = true;}}
}

二、Carousel.xaml 代码如下 

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:controls="clr-namespace:WPFDevelopers.Controls"><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="Basic/ControlBasic.xaml"/></ResourceDictionary.MergedDictionaries><Style TargetType="{x:Type controls:MasterCarousel}" BasedOn="{StaticResource ControlBasicStyle}"><Setter Property="Background" Value="Transparent"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type controls:MasterCarousel}"><Grid Background="{TemplateBinding Background}" ><Viewbox><Canvas x:Name="PART_ContentDock" Width="900" Height="400"/></Viewbox><StackPanel x:Name="PART_ButtonDock" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center"Margin="0,210,0,0"/></Grid></ControlTemplate></Setter.Value></Setter>
</Style></ResourceDictionary>

三、CarouselExample.xaml 代码如下 

<UserControl x:Class="WPFDevelopers.Samples.ExampleViews.CarouselExample"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"xmlns:wpfdev="https://github.com/yanjinhuagood/WPFDevelopers"mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"><Grid><wpfdev:MasterCarousel IsStartAinimation="True"><wpfdev:MasterCarousel.Children><!--<Border Background="Red"/><Border Background="Blue"/><Border Background="Green"/><Border Background="Yellow"/><Border Background="Pink"/>--><Image Source="pack://application:,,,/WPFDevelopers.Samples;component/Images/Craouse/0.jpg"/><Image Source="pack://application:,,,/WPFDevelopers.Samples;component/Images/Craouse/1.jpg"/><Image Source="pack://application:,,,/WPFDevelopers.Samples;component/Images/Craouse/2.jpg"/><Image Source="pack://application:,,,/WPFDevelopers.Samples;component/Images/Craouse/3.jpg"/><Image Source="pack://application:,,,/WPFDevelopers.Samples;component/Images/Craouse/4.jpg"/></wpfdev:MasterCarousel.Children></wpfdev:MasterCarousel></Grid>
</UserControl>

源码地址

github:https://github.com/yanjinhuagood/WPFDevelopers.git

gitee:https://gitee.com/yanjinhua/WPFDevelopers.git

WPF开发者QQ群: 340500857 

blogs: https://www.cnblogs.com/yanjinhua

Github:https://github.com/yanjinhuagood

出处:https://www.cnblogs.com/yanjinhua

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

转载请著名作者 出处 https://github.com/yanjinhuagood

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/299158.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

学过物理的人才能看懂的笑话,你能看明白几个?

全世界只有3.14 % 的人关注了爆炸吧知识1丈夫买了几斤廉价藕&#xff0c;满以为可对妻子炫耀了。不料妻子破口大骂&#xff1a;笨蛋&#xff01;为何不买别的菜&#xff0c;这藕一斤少说也有半斤窟窿啊&#xff01;还说便宜&#xff1f;2第一次坐飞机的两位老妇人在飞机起飞前找…

cisco 双ISP线路接入,链路自动切换方案

最近接到的一个项目&#xff0c;客户总部在惠州&#xff0c;分部在香港&#xff0c;在香港分部设有ERP服务器与邮件服务器&#xff0c;总部出口为铁通10M光纤与网通1M DDN 专线&#xff08;新增&#xff09;&#xff0c;原总部是用netscreen 防火墙与香港的pix 515作IPsec 对接…

js遮罩层以及移动端的上拉框

今天发一个之前写的移动端的项目&#xff0c;主要是讲一下遮罩层的应用&#xff0c;以及顺带提一下移动开发的一些事情。首先按钮点击弹出遮罩层这个大家很熟悉了&#xff0c;这里还是给大家提供一份代码&#xff0c;跟通用的没太大区别&#xff0c;主要讲一下方法&#xff1a;…

精简ABP的模块依赖

ABP的模块非常方便我们扩展自己的或使用ABP提供的模块功能&#xff0c;对于ABP自身提供的模块间的依赖关系想一探究竟&#xff0c;并且试着把不必要的模块拆掉&#xff0c;找到那部分核心模块。本次使用的是AspNetBoilerplate。源码下载从Github下载ABP源码后&#xff0c;进入s…

你这飞机会爆炸吗?航空公司含泪甩卖49元机票,却被超模君挖出秘密!

全世界只有3.14 % 的人关注了爆炸吧知识制作团队制作人 超模君编剧 恐恐恐插画 杨羊羊 友情出演 超模君 章小天……小天吐槽时刻……超模君之后还会采访谁呢小天有小道消息哦扫描这个二维码你将会有机会见识到超模君的科普沙雕网友们一起斗图↓↓↓↓…

linux nginx mysql php 5.5._搭建基于Linux6.3+Nginx1.2+PHP5+MySQL5.5的Web服务器全过程

之前的Web服务器都是通过yum搭建的&#xff0c;想要添加新模块或者更新某些软件都很不方便(牵一发而动全身啊&#xff01;)。所以&#xff0c;现在准备将环境改为源码编译安装&#xff0c;这样便于调整&#xff0c;性能上也会比yum方式好很多。以下是我的安装步骤&#xff0c;我…

ASP 缩略图 (纠错版)

网上很多缩略的代码&#xff0c;不过很多都是错误的。 这个是纠正版&#xff0c;本人已修改。 Code<%Function PicReSize(picURL)FileName1Mid(picURL,13,22)Set Jpeg Server.CreateObject("Persits.Jpeg") 获取源图片路径Path Server.MapPath(picURL) 打开源图…

Blazor Server 应用程序中进行 HTTP 请求

翻译自 Waqas Anwar 2021年5月4日的文章 《Making HTTP Requests in Blazor Server Apps》 [1]Blazor Server 应用使用标准的 ASP.NET Core 应用程序&#xff0c;在服务端执行 .NET 代码。在 Blazor Server 应用程序中&#xff0c;我们可以像在 ASP.NET Core Web 应用程序中那样…

遍历属性动态展示列

为什么80%的码农都做不了架构师&#xff1f;>>> 前端根据后台返回json对象(Map)进行动态列展示。 javascript属性遍历和访问&#xff1a; //var obj {name:"h2do",age:0,sex:"男"}; function User(){this.name "h2do";this.age 0…

厉害了!这几位小学生竟然在艺术界掀起一阵风暴,简直是灵魂画手无疑.........

全世界只有3.14 % 的人关注了爆炸吧知识高能预警&#xff01;请查阅全文&#xff01;在孩子们的眼中&#xff0c;世间万物都被赋予了无限的想象力&#xff0c;而绘画是他们独特想法和思维的表达。一支小小的画笔&#xff0c;便能创造一个千奇百怪的世界。为鼓励孩子们拿起画笔&…

花开的声音 - 张靓颖

姓名&#xff1a;张靓颖 / Jane Zhang性别&#xff1a;女 地区&#xff1a;内地 职业&#xff1a;歌手 星座&#xff1a;天秤座 血型&#xff1a;O 身高&#xff1a;162cm张靓颖&#xff0c;中国女歌手&#xff0c;四川成都人。2005年参加湖南卫视…

基于事件驱动架构构建微服务第5部分:容器化(Web Api Core 和 SQL Server Linux)

原文链接&#xff1a;https://logcorner.com/building-microservices-through-event-driven-architecture-part5-dockerization-web-api-core-and-sql-server-linux/在本文中&#xff0c;我将谈谈web api和sql server linux数据库的容器化Web API将发布并上线&#xff0c;它需要…

爆笑!物理书上的照片能不能好好选选啊喂!

全世界只有3.14 % 的人关注了爆炸吧知识在物理书里&#xff0c;有各种物理大佬的照片。他们正襟危坐&#xff0c;他们不苟言笑&#xff0c;他们看起来就很“物理”。但是&#xff0c;知识君想说&#xff0c;谁不是个有血有肉的人啊&#xff1f;&#xff01;选照片的时候给我好好…

计算机网络体系结构概述

1.Internet结构 2.计算机网络的体系结构 1&#xff09;网路协议主要由以下三要素组成&#xff1a; 语法&#xff0c;即数据与控制信息的结构或格式&#xff1b; 语义&#xff0c;即需要发出何种控制信息&#xff0c;完成何种动作以及做出何种响应&#xff1b; 同步&#xff0c;…

.NET 6 全新指标 System.Diagnostics.Metrics 介绍

前言工友们, .NET 6 Preview 7 已经在8月10号发布了, 除了众多的功能更新和性能改进之外, 在 preview 7 版本中, 也新增了全新的指标API, System.Diagnostics.Metrics, 为了让应用能有更好的可观测性, 在之前的发布的.NET 5中, 也把 Activity 增强为 ActivitySource, 主要原因还…

42张动图带你走进神奇的物理世界,超震撼!

全世界只有3.14 % 的人关注了爆炸吧知识世界之大&#xff0c;无奇不有。生活中其实有许多神奇的物理化学现象。下面就一起来看看吧&#xff01;图片加载慢稍加等待即可哦~神 奇 的 物 理 反 应1.锤击被液氮冻上的康乃馨&#xff0c;求康乃馨的心理阴影面积。2.比重比空气还大的…

Linux优化之IO子系统监控与调优

Linux优化之IO子系统作为服务器主机来讲&#xff0c;最大的两个IO类型 &#xff1a;1.磁盘IO 2.网络IO这是我们调整最多的两个部分所在磁盘IO是如何实现的在内存调优中&#xff0c;一直在讲到为了加速性能&#xff0c;linux内核一般情况下都会尝试将磁盘上的慢速设备上的文件缓…

用3年时间破解学界200多年难题,年仅21岁的天才竟因谈了一场恋爱挂掉了.........

全世界只有3.14 % 的人关注了爆炸吧知识俗话说&#xff0c;英雄难过美人关&#xff0c;即便是智商超群的数学天才也毫不例外。破得了百年的世界难题&#xff0c;却解不开一个小小的爱情谜团......没错&#xff0c;这位为情所困的数学天才&#xff0c;便是今天的主人公——伽罗瓦…

投影变换与视口变换

一些说明&#xff1a; 0. 投影变换&#xff1a;描述如何指定视景体(viewing volume)的形状和方向。视口变换&#xff1a;解释如何控制三维模型坐标到屏幕坐标的变换。 1. 无论是透视投影还是平行投影&#xff08;正交投影&#xff09;&#xff0c;只有在视景体中的物体才可见。…

java 按钮设置图片_Java中如何设置带图片按钮的大小

在java部分需要用到图形界面编程的项目中&#xff0c;经常会使用图片设置对按钮进行美化&#xff0c;但是使用时会出现一个很麻烦的问题&#xff0c; 按照方法&#xff1a;JButton jb1 new JButton();jb1.setBounds(0, 0, 25, 20);ImageIcon ii new ImageIcon("images/x…