private ValueAnimator CreateTransitionAnimator(long d, bool inz) { //((Activity)getContext()).getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, // WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); //chartView.enabled = false; //zoomedChartView.enabled = false; chartView.transitionMode = BaseChartView.TRANSITION_MODE_PARENT; zoomedChartView.transitionMode = BaseChartView.TRANSITION_MODE_CHILD; var param = new TransitionParams(); param.pickerEndOut = chartView.pickerDelegate.pickerEnd; param.pickerStartOut = chartView.pickerDelegate.pickerStart; param.date = d; int dateIndex = Array.BinarySearch(data.chartData.x, d); if (dateIndex < 0) { dateIndex = data.chartData.x.Length - 1; } param.xPercentage = data.chartData.xPercentage[dateIndex]; zoomedChartView.Visibility = Visibility.Visible; zoomedChartView.transitionParams = param; chartView.transitionParams = param; int max = 0; int min = int.MaxValue; for (int i = 0; i < data.chartData.lines.Count; i++) { if (data.chartData.lines[i].y[dateIndex] > max) { max = data.chartData.lines[i].y[dateIndex]; } if (data.chartData.lines[i].y[dateIndex] < min) { min = data.chartData.lines[i].y[dateIndex]; } } float pYPercentage = ((float)min + (max - min) - chartView.currentMinHeight) / (chartView.currentMaxHeight - chartView.currentMinHeight); var hidden = chartView.Visibility == Visibility.Collapsed; chartView.FillTransitionParams(param); zoomedChartView.FillTransitionParams(param); ValueAnimator animator = ValueAnimator.OfFloat(inz ? 0f : 1f, inz ? 1f : 0f); animator.AddUpdateListener(new AnimatorUpdateListener(animation => { float fullWidth = chartView.chartWidth / (chartView.pickerDelegate.pickerEnd - chartView.pickerDelegate.pickerStart); float offset = fullWidth * chartView.pickerDelegate.pickerStart - BaseChartView.HORIZONTAL_PADDING; param.pY = (float)chartView.chartArea.Top + (1f - pYPercentage) * (float)chartView.chartArea.Height; param.pX = chartView.chartFullWidth * param.xPercentage - offset; param.progress = (float)animation.GetAnimatedValue(); zoomedChartView.Invalidate(); zoomedChartView.FillTransitionParams(param); chartView.Invalidate(); if (hidden) { _ = chartView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { chartView.Visibility = Visibility.Visible; }); } })); animator.SetDuration(400); animator.setInterpolator(new FastOutSlowInInterpolator()); return(animator); }
private void ZoomOut(bool animated) { if (data.chartData.x == null) { return; } chartHeaderView.zoomOut(chartView, animated); //chartView.legendSignatureView.chevron.setAlpha(1f); zoomedChartView.SetHeader(null); long d = chartView.GetSelectedDate(); data.activeZoom = 0; //chartView.Visibility = Visibility.Visible; zoomedChartView.ClearSelection(); zoomedChartView.SetHeader(null); chartView.SetHeader(chartHeaderView); if (!animated) { zoomedChartView.Visibility = Visibility.Collapsed; //chartView.enabled = true; //zoomedChartView.enabled = false; chartView.Invalidate(); //((Activity)getContext()).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); //for (CheckBoxHolder checkbox : checkBoxes) //{ // checkbox.checkBox.setAlpha(1); // checkbox.checkBox.enabled = true; //} } else { ValueAnimator animator = CreateTransitionAnimator(d, false); animator.AddListener(new AnimatorUpdateListener(animator => { _ = zoomedChartView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { zoomedChartView.Visibility = Visibility.Collapsed; }); chartView.transitionMode = BaseChartView.TRANSITION_MODE_NONE; zoomedChartView.transitionMode = BaseChartView.TRANSITION_MODE_NONE; //chartView.enabled = true; //zoomedChartView.enabled = false; if (chartView is not StackLinearChartView) { chartView.legendShowing = true; chartView.MoveLegend(); chartView.AnimateLegend(true); chartView.Invalidate(); } else { chartView.legendShowing = false; chartView.ClearSelection(); } //((Activity)getContext()).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); })); //for (CheckBoxHolder checkbox : checkBoxes) //{ // checkbox.checkBox.animate().alpha(1f).start(); // checkbox.checkBox.enabled = true; //} animator.Start(); } }