private void FindOptimalMeasureWidths()
        {
            //double pageContentWidth = ViewModelLocator.Instance.Main.CurrentPageLayout.GetContentWidth();
            //List<MeasureSegmentController> testList = new List<MeasureSegmentController>();
            _sharedMeasuresProps = new List <SharedMeasureProperties>();

            for (int i = 0; i < _scoreFile.Part.FirstOrDefault().Measure.Count; i++)
            {
                //! all measures (from all parts) of current index i
                Dictionary <string, List <AntiCollisionHelper> > measureContentPropertiesList = new Dictionary <string, List <AntiCollisionHelper> >();
                List <MeasureSegmentController> measureOfAllParts = _measureSegmentsContainer.MeasureSegments.Select(x => x.Value[i]).ToList();
                int shortestDuration = measureOfAllParts.Select(x => x.GetMinDuration()).Min();
                SharedMeasureProperties sharedMeasureProperties = new SharedMeasureProperties(measureOfAllParts.FirstOrDefault().MeasureId);
                //! collect collision helpers from all parts (current measureId only)
                foreach (var measure in measureOfAllParts)
                {
                    List <AntiCollisionHelper> acHelpers = measure.GetContentItemsProperties(shortestDuration);
                    sharedMeasureProperties.AddAntiCollisionHelper(measure.PartId, acHelpers);
                    measureContentPropertiesList.Add(measure.PartId, acHelpers);
                }
                //! calculate measure attributes widths (beginning = clef, key, timeSig)
                Tuple <double, double, double> attributesWidth = LayoutHelpers.GetAttributesWidth(measureOfAllParts);
                sharedMeasureProperties.AddMeasureAttributesWidths(attributesWidth);

                sharedMeasureProperties.GenerateFractionPositions();

                _sharedMeasuresProps.Add(sharedMeasureProperties);
                //! Set calculated minimalWidth of current meeasureId in all parts
                double currentMeasureMinWidth = sharedMeasureProperties.SharedWidth;
                measureOfAllParts.ForEach(x => x.MinimalWidth = currentMeasureMinWidth);
                //! each part measure => get width => get max => stretch to optimal => set optimal width each part measure
            }
            //! update measureWidth with new calculated minimalWidth
            _measureSegmentsContainer.UpdateMeasureWidths();
            //! init measure content stretch info of all measures
            GetOptimalStretch();

            ArrangeAndStretchMeasuresContent();
            //! collect measures into systems
            SystemsCollector(_measureSegmentsContainer.MeasureSegments.FirstOrDefault().Value.Select(measure => measure.MeasureId).ToList());
            //! collect pages (using layoutPageInfo)
            PagesCollector();
        }
        /// <summary>
        /// Collect measures into systems
        /// </summary>
        /// <param name="unarrangedMeasures"></param>
        public void SystemsCollector(List <string> unarrangedMeasures)
        {
            //! collection of layout information about pages generated from score
            _layoutPageInfo = new Dictionary <int, LayoutPageContentInfo>();
            int pageIndex = 0;
            LayoutPageContentInfo pageContent = new LayoutPageContentInfo(pageIndex);
            double currentWidth = 0.0;
            //double currentHeight = 0.0; //! TODO horizontal layout spacing calculations

            List <SharedMeasureProperties> measuresToSystem = new List <SharedMeasureProperties>();

            for (int i = 0; i < unarrangedMeasures.Count; i++)
            {
                string measureId = unarrangedMeasures[i];
                SharedMeasureProperties currentMeasureProperties = _sharedMeasuresProps.FirstOrDefault(x => x.MeasureId == measureId);
                currentWidth += currentMeasureProperties.SharedWidth;
                //! if calculated width would be to high, collected measures represents one system
                if (currentWidth > pageContent.PageContentWidth)
                {
                    List <SharedMeasureProperties> sharedMeasuresCollection = new List <SharedMeasureProperties>(measuresToSystem);
                    LayoutSystemInfo layoutSystem = new LayoutSystemInfo(sharedMeasuresCollection);

                    bool systemFitsOnPage = pageContent.AddSystemDimensionInfo(layoutSystem);
                    //! if this system won't fit inside page (too low heigh space available - add to new page and continue
                    if (!systemFitsOnPage)
                    {
                        pageContent.ArrangeSystems();
                        _layoutPageInfo.Add(pageIndex, pageContent);
                        pageIndex++;
                        pageContent = new LayoutPageContentInfo(pageIndex);
                        pageContent.AddSystemDimensionInfo(layoutSystem);
                    }
                    measuresToSystem.Clear();
                    currentWidth = 0.0;
                }
                else
                {
                    //! add measure to collection
                    if (currentMeasureProperties != null)
                    {
                        measuresToSystem.Add(currentMeasureProperties);
                    }
                    else
                    {
                        Log.LoggIt.Log($"Measure Id: {measureId} not found in SharedMeasureProperties");
                    }
                }
                //! if any measure left unarranged
                if (i == unarrangedMeasures.Count - 1 && measuresToSystem.Count != 0)
                {
                    List <SharedMeasureProperties> sharedMeasuresCollection = new List <SharedMeasureProperties>(measuresToSystem);
                    LayoutSystemInfo layoutSystem = new LayoutSystemInfo(sharedMeasuresCollection);

                    bool systemFitsOnPage = pageContent.AddSystemDimensionInfo(layoutSystem);
                    if (!systemFitsOnPage)
                    {
                        pageContent.ArrangeSystems();
                        _layoutPageInfo.Add(pageIndex, pageContent);
                        pageIndex++;
                        pageContent = new LayoutPageContentInfo(pageIndex);
                        pageContent.AddSystemDimensionInfo(layoutSystem);
                        pageContent.ArrangeSystems();
                        _layoutPageInfo.Add(pageIndex, pageContent);
                    }
                    else
                    {
                        pageContent.ArrangeSystems();
                        _layoutPageInfo.Add(pageIndex, pageContent);
                    }
                }
                //! if it is last measure and page not added to layoutPageInfo
                if (i == unarrangedMeasures.Count - 1 && _layoutPageInfo.Count != pageIndex + 1)
                {
                    pageContent.ArrangeSystems();
                    _layoutPageInfo.Add(pageIndex, pageContent);
                }
            }
        }