This repository has been archived by the owner on Sep 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FanFunnelAnimation.cs
61 lines (52 loc) · 2.33 KB
/
FanFunnelAnimation.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#region #CustomAnimation
using DevExpress.XtraCharts;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace AnimationExample {
class FanFunnelAnimation : FunnelAnimationBase {
const float AnimationStartAngle = 270;
const float MaxSweepAngle = 180;
const float HalfMaxSweepAngle = 90;
public override void ApplyState(
SceneModifier modifier,
RectangleF diagramBounds,
FunnelSeriesPointLayoutParameters funnelParameters,
float progress
) {
RectangleF funnelBounds = funnelParameters.Bounds;
float fanCenterX = funnelBounds.Left + funnelBounds.Width / 2;
float fanCenterY = funnelBounds.Bottom;
float fanRadius = (float)Math.Sqrt(
(funnelBounds.Left - fanCenterX) * (funnelBounds.Left - fanCenterX)
+ (funnelBounds.Height) * (funnelBounds.Height)
);
float startAngle = AnimationStartAngle - HalfMaxSweepAngle * progress;
float sweepAngle = MaxSweepAngle * progress;
float endAngle = startAngle + sweepAngle;
float fanLeftBoundEndX =
fanCenterX + (float)Math.Cos(startAngle / 180 * Math.PI) * fanRadius;
float fanLeftBoundEndY =
fanCenterY + (float)Math.Sin(startAngle / 180 * Math.PI) * fanRadius;
float fanRightBoundEndX =
fanCenterX + (float)Math.Cos(endAngle / 180 * Math.PI) * fanRadius;
float fanRightBoundEndY =
fanCenterY + (float)Math.Sin(endAngle / 180 * Math.PI) * fanRadius;
RectangleF fanBounds = new RectangleF(
fanCenterX - fanRadius,
fanCenterY - fanRadius,
2 * fanRadius,
2 * fanRadius
);
GraphicsPath path = new GraphicsPath();
path.AddLine(fanCenterX, fanCenterY, fanLeftBoundEndX, fanLeftBoundEndY);
path.AddArc(fanBounds, startAngle, sweepAngle);
path.AddLine(fanRightBoundEndX, fanRightBoundEndY, fanCenterX, fanCenterY);
modifier.Clip(path);
}
protected override ChartElement CreateObjectForClone() {
return new FanFunnelAnimation();
}
}
}
#endregion #CustomAnimation