public frmAnimation(IAnimationItem animation, string cockpitBaseFolder) { InitializeComponent(); _animation = animation; baseFolder = cockpitBaseFolder; Initialize(); }
private Image GenerateAnimationImage(IAnimationItem animation) { var animationId = Array.IndexOf(config.Animations, animation); var triggers = animation.Triggers?.Where(x => x is AnimationTriggerClientRequest).Select(x => (AnimationTriggerClientRequest)x).ToArray() ?? new IAnimationTrigger[0]; Bitmap initialImage; lock (animationImages) { // Fetch the image we want to animate initialImage = animationImages[animationId]; foreach (var trigger in triggers) { object nextValue = 0.0; //= animation.LastAppliedValue ?? 0; if (trigger is AnimationTriggerClientRequest) { nextValue = previousResults.First(x => x.Request.Name == ((AnimationTriggerClientRequest)trigger).Request.Name && x.Request.Unit == ((AnimationTriggerClientRequest)trigger).Request.Unit).Result; } //animation.LastAppliedValue = nextValue; lock (config.Animations) { config.Animations.ToArray()[animationId] = animation; } if (trigger.Actions != null) { foreach (var action in trigger.Actions) { if (action is AnimationActionRotate) { // Rotate our control background, either clockwise or counter-clockwise, depending on the value of the Request Result var rotateAction = (AnimationActionRotate)action; var displayVal = (double)nextValue % rotateAction.MaximumValueExpected; var rotateAngle = (float)((360 * displayVal) / rotateAction.MaximumValueExpected); if (!rotateAction.RotateClockwise) { rotateAngle = -rotateAngle; } var centrePoint = new PointF { X = initialImage.Width * rotateAction.CentrePoint.X / 100, Y = initialImage.Height * rotateAction.CentrePoint.Y / 100 }; initialImage = RotateImage(initialImage, centrePoint, rotateAngle); } if (action is AnimationActionClip) { // Clip a circle or square using the 2 points to mark the outer edge or top-left/bottom-right initialImage = ClipImage(initialImage, ((AnimationActionClip)action).Style, ((AnimationActionClip)action).StartPoint, ((AnimationActionClip)action).EndPoint); } if (action is AnimationActionMove) { var moveAction = (AnimationActionMove)action; bool moveVertically = moveAction.Type == AnimationActionTypeEnum.MoveY; var moveAmount = moveAction.Invert ? -1 : 1 * (double)nextValue % moveAction.MaxValue / moveAction.MaxValue; //var moveAmount = moveAction.Invert ? -1 : 1 * ((double)nextValue % moveAction.MaxValue); initialImage = MoveImage(initialImage, moveVertically, moveAmount); } } } } } return(initialImage); }
/// <summary> /// /// </summary> /// <param name="item"></param> public void AddItem(IAnimationItem item) { AnimationItemBase obj = (AnimationItemBase)item; obj.SetViewItem(); obj.Dock = DockStyle.Fill; this.listBox.Items.Add(obj); this.panel.Controls.Clear(); this.panel.Controls.Add(obj); }
public void Clear() { Name = null; Author = null; Type = InstrumentType.Other; CreateDate = DateTime.Now; BackgroundImagePath = null; Aircraft = new string[0]; AnimationUpdateInMs = 50; Animations = new IAnimationItem[0]; HasChanged = false; }
private void ChangeAnimationType_Select(object sender, EventArgs e) { var selectedType = cmbAnimationType.SelectedItem?.ToString(); gpAnimationDrawing.Visible = false; gpAnimationImage.Visible = false; gpAnimationActionMoveX.Visible = false; if (!populatingForm) { IAnimationItem newAnimation = null; if (selectedType == "Drawing") { newAnimation = new AnimationDrawing { Name = _animation.Name, Type = AnimationItemTypeEnum.Drawing, FillColor = Color.White, FillMethod = FillTypeEnum.Solid, OffsetX = 50, OffsetY = 50, Triggers = _animation.Triggers }; } if (selectedType == "Image") { newAnimation = new AnimationImage { Name = _animation.Name, Type = AnimationItemTypeEnum.Image, ImagePath = "", Triggers = _animation.Triggers }; pbAnimationImage.BackgroundImage?.Dispose(); pbAnimationImage.BackgroundImage = new Bitmap(1, 1); pbAnimationImage.Image?.Dispose(); pbAnimationImage.Image = new Bitmap(1, 1); } _animation = newAnimation; PopulateTab(0); } //if (_animation.Type == AnimationItemTypeEnum.Image) //{ // gpAnimationImage.Visible = true; //} //if(_animation.Type == AnimationItemTypeEnum.Drawing) //{ // gpAnimationDrawing.Visible = true; //} }