예제 #1
0
        private void Carousel_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
        {
            if (!e.IsIntermediate)
            {
                Double offset   = Carousel.HorizontalOffset;
                Double width    = Carousel.ActualWidth;
                Int32  newIndex = (Int32)Math.Ceiling((offset - width / 2) / width);
                Int32  oldIndex = PageLabelViewElement.ActivatedParagraphIndex;

                PageLabelViewElement.ActivatedParagraphIndex = newIndex;

                Double newOffset = PageLabelViewElement.ActivatedParagraphIndex * width;

                Carousel.ChangeView(newOffset, null, null);

                PageLabelViewElement.UpdateHighlight();

                if (oldIndex != newIndex)
                {
                    ParagraphScrolled();
                }
            }
        }
예제 #2
0
        public void UpdateCarousel(Boolean trackPreviousParagraph, String firstChartTag)
        {
            paragraphs.Clear();

            if (ViewModel.IsBarChartVisible && BarChartElement.Tag?.ToString() == firstChartTag)
            {
                paragraphs.Add(BarChartWrapperElement);
            }
            if (ViewModel.IsGroupedBarChartVisible && GroupedBarChartElement.Tag?.ToString() == firstChartTag)
            {
                paragraphs.Add(GroupedBarChartWrapperElement);
            }
            if (ViewModel.IsLineChartVisible && LineChartElement.Tag?.ToString() == firstChartTag)
            {
                paragraphs.Add(LineChartWrapperElement);
            }
            if (ViewModel.IsDistributionVisible && DistributionViewElement.Tag?.ToString() == firstChartTag)
            {
                paragraphs.Add(DistributionWrapperElement);
            }
            if (ViewModel.IsDescriptiveStatisticsVisible && DescriptiveStatisticsViewElement.Tag?.ToString() == firstChartTag)
            {
                paragraphs.Add(DescriptiveStatisticsWrapperElement);
            }
            if (ViewModel.IsScatterplotVisible && ScatterplotElement.Tag?.ToString() == firstChartTag)
            {
                paragraphs.Add(ScatterplotWrapperElement);
            }
            if (ViewModel.IsPivotTableVisible && PivotTableViewElement.Tag?.ToString() == firstChartTag)
            {
                paragraphs.Add(PivotTableWrapperElement);
            }
            if (ViewModel.IsCorrelationStatisticsVisible && CorrelationStatisticsViewElement.Tag?.ToString() == firstChartTag)
            {
                paragraphs.Add(CorrelationStatisticsWrapperElement);
            }

            if (ViewModel.IsBarChartVisible && BarChartElement.Tag?.ToString() != firstChartTag)
            {
                paragraphs.Add(BarChartWrapperElement);
            }
            if (ViewModel.IsGroupedBarChartVisible && GroupedBarChartElement.Tag?.ToString() != firstChartTag)
            {
                paragraphs.Add(GroupedBarChartWrapperElement);
            }
            if (ViewModel.IsLineChartVisible && LineChartElement.Tag?.ToString() != firstChartTag)
            {
                paragraphs.Add(LineChartWrapperElement);
            }
            if (ViewModel.IsDistributionVisible && DistributionViewElement.Tag?.ToString() != firstChartTag)
            {
                paragraphs.Add(DistributionWrapperElement);
            }
            if (ViewModel.IsDescriptiveStatisticsVisible && DescriptiveStatisticsViewElement.Tag?.ToString() != firstChartTag)
            {
                paragraphs.Add(DescriptiveStatisticsWrapperElement);
            }
            if (ViewModel.IsScatterplotVisible && ScatterplotElement.Tag?.ToString() != firstChartTag)
            {
                paragraphs.Add(ScatterplotWrapperElement);
            }
            if (ViewModel.IsPivotTableVisible && PivotTableViewElement.Tag?.ToString() != firstChartTag)
            {
                paragraphs.Add(PivotTableWrapperElement);
            }
            if (ViewModel.IsCorrelationStatisticsVisible && CorrelationStatisticsViewElement.Tag?.ToString() != firstChartTag)
            {
                paragraphs.Add(CorrelationStatisticsWrapperElement);
            }
            if (ViewModel.IsNoPossibleVisualizationWarningVisible)
            {
                paragraphs.Add(NoVisualizationWarningWrapperElement);
            }

            Int32 index = 0;

            foreach (StackPanel paragraph in paragraphs)
            {
                Canvas.SetLeft(paragraph, ViewModel.MainPageViewModel.ParagraphWidth * index);
                index++;
            }
            ParagraphContainerCanvasElement.Width = index * ViewModel.MainPageViewModel.ParagraphWidth;

            // 먼저 전에 보이던 시각화와 같은 시각화가 있는지 본다. 있으면 그걸 먼저 보여줌 (바, 산점도)에서 산점도를 보다 바가 없어지면 그대로 산점도를 보여주고 싶음

            index = 0;
            Int32      sameIndex     = 0;
            StackPanel sameParagraph = null;

            foreach (StackPanel paragraph in paragraphs)
            {
                if (paragraph.Tag?.ToString() == PageLabelViewElement.ActivatedParagraphTag)
                {
                    sameParagraph = paragraph;
                    sameIndex     = index;
                }
                index++;
            }

            if (sameParagraph != null && trackPreviousParagraph)
            {
                PageLabelViewElement.ActivatedParagraphIndex = sameIndex;
                Carousel.ChangeView(sameIndex * ViewModel.MainPageViewModel.ParagraphWidth, null, null, true);
            }
            else
            {
                // 아니면 현재 위치를 유지해보자
                // 0으로 초기화

                Double offset = Carousel.HorizontalOffset;
                Double width  = Carousel.ActualWidth;

                Carousel.ChangeView(0, null, null, true);
                PageLabelViewElement.ActivatedParagraphIndex = 0;
            }

            ViewModel.ViewStatus.ActivatedChart = paragraphs[PageLabelViewElement.ActivatedParagraphIndex].Children.Last();
            PageLabelViewElement.Update(paragraphs);
        }