Ejemplo n.º 1
0
 internal void InitializeForContext(
     VirtualizingLayoutContext context,
     IFlowLayoutAlgorithmDelegates callbacks)
 {
     FlowAlgorithm.InitializeForContext(context, callbacks);
     context.LayoutStateCore = this;
 }
Ejemplo n.º 2
0
        private void FlowSlice_Click(object sender, RoutedEventArgs e)
        {
            //TODO: Dinar: prepare generating implementation
            if (model == null)
            {
                return;
            }
            RedrawModel();
            currentStatus.Content = "Генерация в процессе.";
            currentStatus.UpdateLayout();
            //TODO: Move to some input checking
            double splitterAccuracy  = 0;
            double detalizerAccuracy = 0;

            try
            {
                splitterAccuracy  = double.Parse(textBox_Splitter_Accuracy.Text, CultureInfo.InvariantCulture);
                detalizerAccuracy = double.Parse(textBox_Detalizer_Accuracy.Text, CultureInfo.InvariantCulture);
            }
            catch (Exception)
            {
                currentStatus.Content = "Генерация прервана. Введите корректные настройки точностей.";
                return;
            }

            IAlgorithm alg = new FlowAlgorithm(splitterAccuracy, detalizerAccuracy);
            Stopwatch  sw  = new Stopwatch();

            sw.Start();
            mid_surface_model = alg.Run(new SolverData(model));
            sw.Stop();
            RedrawMidSurface();
            currentStatus.Content = "Генерация завершена успешно. Затраченное время: " + sw.Elapsed;
        }
Ejemplo n.º 3
0
        internal void UninitializeForContext(VirtualizingLayoutContext context)
        {
            FlowAlgorithm.UninitializeForContext(context);

            if (m_cachedFirstElement != null)
            {
                context.RecycleElement(m_cachedFirstElement);
            }
        }
Ejemplo n.º 4
0
 // If it's realized then we shouldn't be caching it
 internal void EnsureFirstElementOwnership(VirtualizingLayoutContext context)
 {
     if (m_cachedFirstElement != null && FlowAlgorithm.GetElementIfRealized(0) != null)
     {
         // We created the element, but then flowlayout algorithm took ownership, so we can clear it and
         // let flowlayout algorithm do its thing.
         context.RecycleElement(m_cachedFirstElement);
         m_cachedFirstElement = null;
     }
 }
Ejemplo n.º 5
0
        internal void InitializeForContext(VirtualizingLayoutContext context, IFlowLayoutAlgorithmDelegates callbacks)
        {
            FlowAlgorithm.InitializeForContext(context, callbacks);

            if (_estimationBuffer.Count == 0)
            {
                _estimationBuffer.AddRange(Enumerable.Repeat(0.0, BufferSize));
            }

            context.LayoutState = this;
        }
Ejemplo n.º 6
0
        internal void InitializeForContext(
            VirtualizingLayoutContext context,
            IFlowLayoutAlgorithmDelegates callbacks)
        {
            FlowAlgorithm.InitializeForContext(context, callbacks);
            if (m_estimationBuffer.Count == 0)
            {
                m_estimationBuffer.Resize(BufferSize, 0.0);
            }

            context.LayoutStateCore = this;
        }
Ejemplo n.º 7
0
        internal void InitializeForContext(
            VirtualizingLayoutContext context,
            IFlowLayoutAlgorithmDelegates callbacks)
        {
            FlowAlgorithm.InitializeForContext(context, callbacks);

            if (m_lineSizeEstimationBuffer.Count == 0)
            {
                m_lineSizeEstimationBuffer.Resize(BufferSize, 0.0);
                m_itemsPerLineEstimationBuffer.Resize(BufferSize, 0.0);
            }

            ((ILayoutContextOverrides)context).LayoutStateCore = this;
        }
        internal void EnsureElementSize(
            Size availableSize,
            VirtualizingLayoutContext context,
            double layoutItemWidth,
            double layoutItemHeight,
            UniformGridLayoutItemsStretch stretch,
            Orientation orientation,
            double minRowSpacing,
            double minColumnSpacing,
            int maxItemsPerLine)
        {
            if (maxItemsPerLine == 0)
            {
                maxItemsPerLine = 1;
            }

            if (context.ItemCount > 0)
            {
                // If the first element is realized we don't need to cache it or to get it from the context
                var realizedElement = FlowAlgorithm.GetElementIfRealized(0);
                if (realizedElement != null)
                {
                    realizedElement.Measure(availableSize);
                    SetSize(realizedElement, layoutItemWidth, layoutItemHeight, availableSize, stretch, orientation, minRowSpacing, minColumnSpacing, maxItemsPerLine);
                    _cachedFirstElement = null;
                }
                else
                {
                    if (_cachedFirstElement == null)
                    {
                        // we only cache if we aren't realizing it
                        _cachedFirstElement = context.GetOrCreateElementAt(
                            0,
                            ElementRealizationOptions.ForceCreate | ElementRealizationOptions.SuppressAutoRecycle); // expensive
                    }

                    _cachedFirstElement.Measure(availableSize);

                    SetSize(_cachedFirstElement, layoutItemWidth, layoutItemHeight, availableSize, stretch, orientation, minRowSpacing, minColumnSpacing, maxItemsPerLine);

                    // See if we can move ownership to the flow algorithm. If we can, we do not need a local cache.
                    bool added = FlowAlgorithm.TryAddElement0(_cachedFirstElement);
                    if (added)
                    {
                        _cachedFirstElement = null;
                    }
                }
            }
        }
Ejemplo n.º 9
0
        internal void EnsureElementSize(
            Size availableSize,
            VirtualizingLayoutContext context,
            double layoutItemWidth,
            double LayoutItemHeight,
            UniformGridLayoutItemsStretch stretch,
            Orientation orientation,
            double minRowSpacing,
            double minColumnSpacing)
        {
            if (context.ItemCount > 0)
            {
                // If the first element is realized we don't need to cache it or to get it from the context
                var realizedElement = FlowAlgorithm.GetElementIfRealized(0);
                if (realizedElement != null)
                {
                    realizedElement.Measure(availableSize);
                    SetSize(realizedElement, layoutItemWidth, LayoutItemHeight, availableSize, stretch, orientation, minRowSpacing, minColumnSpacing);
                    _cachedFirstElement = null;
                }
                else
                {
                    if (_cachedFirstElement == null)
                    {
                        // we only cache if we aren't realizing it
                        _cachedFirstElement = context.GetOrCreateElementAt(
                            0,
                            ElementRealizationOptions.ForceCreate | ElementRealizationOptions.SuppressAutoRecycle); // expensive
                    }

                    _cachedFirstElement.Measure(availableSize);

                    // This doesn't need to be done in the UWP version and I'm not sure why. If we
                    // don't do this here, and we receive a recycled element then it will be shown
                    // at its previous arrange point, but we don't want it shown at all until its
                    // arranged.
                    _cachedFirstElement.Arrange(new Rect(-10000.0, -10000.0, 0, 0));

                    SetSize(_cachedFirstElement, layoutItemWidth, LayoutItemHeight, availableSize, stretch, orientation, minRowSpacing, minColumnSpacing);

                    // See if we can move ownership to the flow algorithm. If we can, we do not need a local cache.
                    bool added = FlowAlgorithm.TryAddElement0(_cachedFirstElement);
                    if (added)
                    {
                        _cachedFirstElement = null;
                    }
                }
            }
        }
Ejemplo n.º 10
0
        internal void EnsureElementSize(
            Size availableSize,
            VirtualizingLayoutContext context,
            double layoutItemWidth,
            double LayoutItemHeight,
            UniformGridLayoutItemsStretch stretch,
            Orientation orientation,
            double minRowSpacing,
            double minColumnSpacing,
            uint maxItemsPerLine)
        {
            if (maxItemsPerLine == 0)
            {
                maxItemsPerLine = 1;
            }

            if (context.ItemCount > 0)
            {
                // If the first element is realized we don't need to get it from the context
                var realizedElement = FlowAlgorithm.GetElementIfRealized(0);
                if (realizedElement != null)
                {
                    realizedElement.Measure(availableSize);
                    SetSize(realizedElement.DesiredSize, layoutItemWidth, LayoutItemHeight, availableSize, stretch, orientation, minRowSpacing, minColumnSpacing, maxItemsPerLine);
                }
                else
                {
                    // Not realized by flowlayout, so do this now!
                    if (context.GetOrCreateElementAt(0, ElementRealizationOptions.ForceCreate) is { } firstElement)
                    {
                        firstElement.Measure(availableSize);
                        SetSize(firstElement.DesiredSize, layoutItemWidth, LayoutItemHeight, availableSize, stretch, orientation, minRowSpacing, minColumnSpacing, maxItemsPerLine);
                        context.RecycleElement(firstElement);
                    }
                }
            }
        }
Ejemplo n.º 11
0
 internal void UninitializeForContext(VirtualizingLayoutContext context)
 {
     FlowAlgorithm.UninitializeForContext(context);
 }