コード例 #1
0
        private Dictionary <int, Tuple <double, double> > GeneratePositionsTable(List <MeasureSegmentController> partMeasureSegment, List <int> positionIndexes, double startingPosition)
        {
            double staffSpace = ViewModel.ViewModelLocator.Instance.Main.CurrentPageLayout.StaffSpace.MMToWPFUnit();
            Dictionary <int, int> durationOfPosition = GetDurationOfPosition(partMeasureSegment, positionIndexes);
            int shortestDuration = durationOfPosition.Values.Where(x => x > 0).Min();
            Dictionary <int, Tuple <double, double> > positions = new Dictionary <int, Tuple <double, double> >();
            double currentStartPosition = startingPosition;

            for (int i = 0; i < durationOfPosition.Count; i++)
            {
                if (i == 0)
                {
                    int    currentDuration = durationOfPosition[positionIndexes[i]];
                    double previewSpacing  = staffSpace * LayoutHelpers.SpacingValue(currentDuration, shortestDuration, 0.6);
                    positions.Add(positionIndexes[i], Tuple.Create(currentStartPosition, previewSpacing));
                }
                else
                {
                    int    currentDuration = durationOfPosition[positionIndexes[i]];
                    double previewSpacing  = staffSpace * LayoutHelpers.SpacingValue(currentDuration, shortestDuration, 0.6);
                    currentStartPosition += previewSpacing;
                    positions.Add(positionIndexes[i], Tuple.Create(currentStartPosition, previewSpacing));
                }
            }
            return(positions);
        }