private void ShiftButtons(ShootModeInfo info, string targetShootMode) { if (info == null) { return; } var selectedIndex = FindCandidateIndex(info?.ShootModeCapability, targetShootMode); int currentIndex = 0; foreach (var i in info.ShootModeCapability.Candidates) { var button = Buttons.Children[currentIndex] as EllipseButton; var scale = i == targetShootMode ? 1.0 : 0.6; double newX = (currentIndex - selectedIndex) * 50; if (newX < 0) { newX -= 30; } else if (newX > 0) { newX += 30; } var story = AnimationHelper.CreateMoveAndResizeAnimation(new MoveAndResizeAnimation() { Target = button, Duration = TimeSpan.FromMilliseconds(300), newX = newX, newScaleX = scale, newScaleY = scale, }); if (currentIndex == 0) { story.Completed += Story_Completed; } story.Begin(); currentIndex++; } }
/// <summary> /// Clear all buttons and create new buttons. /// </summary> /// <param name="info"></param> void UpdateCandidates(ShootModeInfo info) { if (info == null) { return; } var targetShootMode = info.ShootModeCapability.Current; var selectedIndex = FindCandidateIndex(info.ShootModeCapability, targetShootMode); int currentIndex = 0; Buttons.Children.Clear(); foreach (var i in info.ShootModeCapability.Candidates) { var scale = i == targetShootMode ? 1.0 : 0.6; double newX = (currentIndex - selectedIndex) * 50; if (newX < 0) { newX -= 30; } else if (newX > 0) { newX += 30; } EllipseButton button = null; if (selectedIndex == currentIndex) { if (CurrentModeButtonTemplate != null) { button = CreateBaseButton(CurrentModeButtonTemplate, scale); } else { button = CreateBaseButton(CurrentModeButtonImage, scale); } } else { if (info.IconTemplates?.ContainsKey(i) ?? false) { button = CreateBaseButton(info.IconTemplates[i], scale); } else if (info.Icons?.ContainsKey(i) ?? false) { button = CreateBaseButton(info.Icons[i], scale); } } if (button != null) { Buttons.Children.Add(button); (button.RenderTransform as CompositeTransform).TranslateX = newX; } currentIndex++; } }