Beispiel #1
0
        void LabelOnSizeChanged(object sender, SizeChangedEventArgs sizeChangedEventArgs)
        {
            var label = (FrameworkElement)sender;
            AbstractAxesLabelCollection <TX, TXSize, TY, TYSize> factory = _labelAssociations[label];

            factory.LabelResized(label, new AxesIntervals <TX, TXSize, TY, TYSize>(VisibleIntervalX, VisibleIntervalY), new Size(ActualWidth, ActualHeight));
        }
Beispiel #2
0
        void AddLabel(AbstractAxesLabelCollection <TX, TXSize, TY, TYSize> hostFactory, FrameworkElement label)
        {
            Func <FrameworkElement, Tuple <TX, TY> > getPosition = l => Tuple.Create((TX)l.GetValue(XProperty), (TY)l.GetValue(YProperty));

            // Get positions already taken up by precending factories within the same override group.
            HashSet <Tuple <TX, TY> > positioned = new HashSet <Tuple <TX, TY> >();
            List <AbstractAxesLabelCollection <TX, TXSize, TY, TYSize> > precedingFactories = _labelFactoryGroups
                                                                                              .First(g => g.Key == hostFactory.OverrideGroup)
                                                                                              .Reverse() // Factories need to be updated in reverse order, since the later ones have precedence.
                                                                                              .TakeWhile(f => f != hostFactory)
                                                                                              .ToList();

            if (hostFactory.OverrideGroup != null)
            {
                foreach (var factory in precedingFactories)
                {
                    foreach (var taken in factory.Select(getPosition))
                    {
                        positioned.Add(taken);
                    }
                }
            }

            // Only add children positioned on locations which have not been populated yet by preceding factories within the same override group.
            Tuple <TX, TY> desiredPosition = getPosition(label);

            if (!positioned.Contains(desiredPosition))
            {
                // Set Z index to position later defined factories more on top.
                var index = LabelFactories.IndexOf(hostFactory);
                label.SetValue(ZIndexProperty, index);

                _labelAssociations[label] = hostFactory;
                label.Loaded      += LabelOnLoaded;
                label.SizeChanged += LabelOnSizeChanged;
                Children.Add(label);
            }
        }