// Token: 0x06008770 RID: 34672 RVA: 0x0024FBDC File Offset: 0x0024DDDC
            private void ValidateSharedSizeGroup()
            {
                double num   = 0.0;
                int    i     = 0;
                int    count = this._registry.Count;

                while (i < count)
                {
                    num = Math.Max(num, this._registry[i]._minSize);
                    i++;
                }
                bool flag   = !DoubleUtil.AreClose(this._minSize, num);
                int  j      = 0;
                int  count2 = this._registry.Count;

                while (j < count2)
                {
                    DefinitionBase definitionBase = this._registry[j];
                    bool           flag2          = !DoubleUtil.AreClose(definitionBase._minSize, num);
                    bool           flag3;
                    if (!definitionBase.UseSharedMinimum)
                    {
                        flag3 = !flag2;
                    }
                    else if (flag2)
                    {
                        flag3 = !flag;
                    }
                    else
                    {
                        flag3 = (definitionBase.LayoutWasUpdated && DoubleUtil.GreaterThanOrClose(definitionBase._minSize, this.MinSize));
                    }
                    if (!flag3)
                    {
                        Grid grid = (Grid)definitionBase.Parent;
                        grid.InvalidateMeasure();
                    }
                    else if (!DoubleUtil.AreClose(num, definitionBase.SizeCache))
                    {
                        Grid grid2 = (Grid)definitionBase.Parent;
                        grid2.InvalidateArrange();
                    }
                    definitionBase.UseSharedMinimum = flag2;
                    definitionBase.LayoutWasUpdated = false;
                    j++;
                }
                this._minSize = num;
                this._layoutUpdatedHost.LayoutUpdated -= this._layoutUpdated;
                this._layoutUpdatedHost     = null;
                this._broadcastInvalidation = true;
            }
示例#2
0
            /// <summary>
            /// OnLayoutUpdated handler. Validates that all participating definitions
            /// have updated min size value. Forces another layout update cycle if needed.
            /// </summary>
            private void OnLayoutUpdated(object sender, EventArgs e)
            {
                double sharedMinSize = 0;

                //  accumulate min size of all participating definitions
                for (int i = 0, count = _registry.Count; i < count; ++i)
                {
                    sharedMinSize = Math.Max(sharedMinSize, _registry[i].MinSize);
                }

                bool sharedMinSizeChanged = !DoubleUtil.AreClose(_minSize, sharedMinSize);

                //  compare accumulated min size with min sizes of the individual definitions
                for (int i = 0, count = _registry.Count; i < count; ++i)
                {
                    DefinitionBase definitionBase = _registry[i];

                    if (sharedMinSizeChanged || definitionBase.LayoutWasUpdated)
                    {
                        //  if definition's min size is different, then need to re-measure
                        if (!DoubleUtil.AreClose(sharedMinSize, definitionBase.MinSize))
                        {
                            Grid parentGrid = (Grid)definitionBase.Parent;
                            parentGrid.InvalidateMeasure();
                            definitionBase.UseSharedMinimum = true;
                        }
                        else
                        {
                            definitionBase.UseSharedMinimum = false;

                            //  if measure is valid then also need to check arrange.
                            //  Note: definitionBase.SizeCache is volatile but at this point
                            //  it contains up-to-date final size
                            if (!DoubleUtil.AreClose(sharedMinSize, definitionBase.SizeCache))
                            {
                                Grid parentGrid = (Grid)definitionBase.Parent;
                                parentGrid.InvalidateArrange();
                            }
                        }

                        definitionBase.LayoutWasUpdated = false;
                    }
                }

                _minSize = sharedMinSize;

                _layoutUpdatedHost.LayoutUpdated -= _layoutUpdated;
                _layoutUpdatedHost = null;

                _broadcastInvalidation = true;
            }
            // Token: 0x06008771 RID: 34673 RVA: 0x0024FD2C File Offset: 0x0024DF2C
            private void ValidateSharedSizeGroupLegacy()
            {
                double num   = 0.0;
                int    i     = 0;
                int    count = this._registry.Count;

                while (i < count)
                {
                    num = Math.Max(num, this._registry[i].MinSize);
                    i++;
                }
                bool flag   = !DoubleUtil.AreClose(this._minSize, num);
                int  j      = 0;
                int  count2 = this._registry.Count;

                while (j < count2)
                {
                    DefinitionBase definitionBase = this._registry[j];
                    if (flag || definitionBase.LayoutWasUpdated)
                    {
                        if (!DoubleUtil.AreClose(num, definitionBase.MinSize))
                        {
                            Grid grid = (Grid)definitionBase.Parent;
                            grid.InvalidateMeasure();
                            definitionBase.UseSharedMinimum = true;
                        }
                        else
                        {
                            definitionBase.UseSharedMinimum = false;
                            if (!DoubleUtil.AreClose(num, definitionBase.SizeCache))
                            {
                                Grid grid2 = (Grid)definitionBase.Parent;
                                grid2.InvalidateArrange();
                            }
                        }
                        definitionBase.LayoutWasUpdated = false;
                    }
                    j++;
                }
                this._minSize = num;
                this._layoutUpdatedHost.LayoutUpdated -= this._layoutUpdated;
                this._layoutUpdatedHost     = null;
                this._broadcastInvalidation = true;
            }
示例#4
0
        private static void InitGrid(Grid grid, DtoTableViewModel vm)
        {
            if (vm != null && grid != null)
            {
                grid.RowDefinitions.Clear();
                grid.ColumnDefinitions.Clear();
                foreach (var row in vm.Rows)
                {
                    grid.RowDefinitions.Add(new RowDefinition());
                }
                foreach (var col in vm.Columns)
                {
                    grid.ColumnDefinitions.Add(new ColumnDefinition() { SharedSizeGroup = "col" + col.Column.ToString() });
                }

                grid.InvalidateArrange();
                grid.UpdateLayout();
            }
        }
示例#5
0
        // Calculated content height
        protected virtual void initialChildren()
        {
            double w = System.Windows.Application.Current.Host.Content.ActualWidth;

            topShadow = GetTemplateChild("TopShadow") as Rectangle;
            bottomShadow = GetTemplateChild("BottomShadow") as Rectangle;
            contentView = GetTemplateChild("ContentView") as Grid;
            buttonContainer = GetTemplateChild("ButtonContainer") as StackPanel;
            curtain = GetTemplateChild("Curtain") as Rectangle;

            // Add an optional title label
            titleLabel = null;
            if (title != null)
            {
                titleLabel = new TextBlock();
                titleLabel.Text = title;
                titleLabel.Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0xd9, 0xf3));
                titleLabel.FontSize = 42;
                titleLabel.HorizontalAlignment = HorizontalAlignment.Center;
                titleLabel.TextWrapping = TextWrapping.Wrap;
                titleLabel.TextAlignment = TextAlignment.Center;
                titleLabel.Margin = new Thickness(0, 8, 0, 8);
                titleLabel.SetValue(Grid.RowProperty, 0);
                contentView.Children.Add(titleLabel);
            }

            // Add any custom content
            if (contentElement != null)
            {
                contentElement.SetValue(Grid.RowProperty, 1);
                contentView.Children.Add(contentElement);
                contentView.InvalidateArrange();
                contentView.UpdateLayout();

                double measuredWidth = contentElement.ActualWidth + contentElement.Margin.Left + contentElement.Margin.Right;
                double measuredHeight = 0;
                if (titleLabel != null)
                {
                    measuredHeight += titleLabel.ActualHeight;
                }

                double contentHeight = Math.Max(contentElement.ActualHeight, contentElement.Height);
                if(!double.IsNaN(contentHeight))
                    measuredHeight += contentHeight + contentElement.Margin.Top + contentElement.Margin.Bottom;
                else
                    measuredHeight += 240 + contentElement.Margin.Top + contentElement.Margin.Bottom;

                expectedContentSize = new Size(measuredWidth, measuredHeight);
            }
            else
            {
                expectedContentSize = new Size(w, 240);
            }

            // Add custom buttons
            if (buttonTitles.Count > 0)
            {
                foreach (string buttonTitle in buttonTitles)
                {
                    var button = new Avarice.Controls.Button();
                    button.Content = buttonTitle;
                    button.Margin = new Thickness(20, 0, 20, 0);
                    button.HorizontalAlignment = HorizontalAlignment.Right;
                    buttonContainer.Children.Add(button);
                    button.Click += OnButtonClick;
                }
            }
            else if(Buttons.Count > 0)
            {
                foreach (var button in Buttons)
                {
                    button.Margin = new Thickness(20, 0, 20, 0);
                    button.HorizontalAlignment = HorizontalAlignment.Right;
                    buttonContainer.Children.Add(button);
                    button.Click += OnButtonClick;
                }

            }
        }
        private static void RebuildGridChildren(Grid grid)
        {
            int column = 0;
            int row = 0;
            var columnCount = GetColumns(grid);
            for (int i = 0; i < grid.Children.Count; i++)
            {
                var child = grid.Children[i];
                if (child == null) continue;

                Grid.SetColumn(child, column);
                Grid.SetRow(child, row);

                column++;
                if (column >= columnCount)
                {
                    column = 0;
                    row++;
                }
            }

            grid.InvalidateArrange();
            grid.InvalidateVisual();
        }
示例#7
0
            /// <summary>
            /// OnLayoutUpdated handler. Validates that all participating definitions
            /// have updated min size value. Forces another layout update cycle if needed.
            /// </summary>
            private void OnLayoutUpdated(object sender, EventArgs e)
            {
                double sharedMinSize = 0;

                //  accumulate min size of all participating definitions
                for (int i = 0, count = _registry.Count; i < count; ++i)
                {
                    sharedMinSize = Math.Max(sharedMinSize, _registry[i]._minSize);
                }

                bool sharedMinSizeChanged = !DoubleUtil.AreClose(_minSize, sharedMinSize);

                //  compare accumulated min size with min sizes of the individual definitions
                for (int i = 0, count = _registry.Count; i < count; ++i)
                {
                    DefinitionBase definitionBase = _registry[i];

                    // we'll set d.UseSharedMinimum to maintain the invariant:
                    //      d.UseSharedMinimum iff d._minSize < this.MinSize
                    // i.e. iff d is not a "long-pole" definition.
                    //
                    // Measure/Arrange of d's Grid uses d._minSize for long-pole
                    // definitions, and max(d._minSize, shared size) for
                    // short-pole definitions.  This distinction allows us to react
                    // to changes in "long-pole-ness" more efficiently and correctly,
                    // by avoiding remeasures when a long-pole definition changes.
                    bool useSharedMinimum = !DoubleUtil.AreClose(definitionBase._minSize, sharedMinSize);

                    // before doing that, determine whether d's Grid needs to be remeasured.
                    // It's important _not_ to remeasure if the last measure is still
                    // valid, otherwise infinite loops are possible
                    bool measureIsValid;
                    if (!definitionBase.UseSharedMinimum)
                    {
                        // d was a long-pole.  measure is valid iff it's still a long-pole,
                        // since previous measure didn't use shared size.
                        measureIsValid = !useSharedMinimum;
                    }
                    else if (useSharedMinimum)
                    {
                        // d was a short-pole, and still is.  measure is valid
                        // iff the shared size didn't change
                        measureIsValid = !sharedMinSizeChanged;
                    }
                    else
                    {
                        // d was a short-pole, but is now a long-pole.  This can
                        // happen in several ways:
                        //  a. d's minSize increased to or past the old shared size
                        //  b. other long-pole definitions decreased, leaving
                        //      d as the new winner
                        // In the former case, the measure is valid - it used
                        // d's new larger minSize.  In the latter case, the
                        // measure is invalid - it used the old shared size,
                        // which is larger than d's (possibly changed) minSize
                        measureIsValid = (definitionBase.LayoutWasUpdated &&
                                          DoubleUtil.GreaterThanOrClose(definitionBase._minSize, this.MinSize));
                    }

                    if (!measureIsValid)
                    {
                        Grid parentGrid = (Grid)definitionBase.Parent;
                        parentGrid.InvalidateMeasure();
                    }
                    else if (!DoubleUtil.AreClose(sharedMinSize, definitionBase.SizeCache))
                    {
                        //  if measure is valid then also need to check arrange.
                        //  Note: definitionBase.SizeCache is volatile but at this point
                        //  it contains up-to-date final size
                        Grid parentGrid = (Grid)definitionBase.Parent;
                        parentGrid.InvalidateArrange();
                    }

                    // now we can restore the invariant, and clear the layout flag
                    definitionBase.UseSharedMinimum = useSharedMinimum;
                    definitionBase.LayoutWasUpdated = false;
                }

                _minSize = sharedMinSize;

                _layoutUpdatedHost.LayoutUpdated -= _layoutUpdated;
                _layoutUpdatedHost = null;

                _broadcastInvalidation = true;
            }