Beispiel #1
0
        private static void OnMinimumHeightChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RandomPanel panel = ( RandomPanel )d;

            panel.CoerceValue(RandomPanel.MaximumHeightProperty);
            panel.InvalidateMeasure();
        }
Beispiel #2
0
 private static void SeedChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
 {
     if (obj is RandomPanel)
     {
         RandomPanel owner = ( RandomPanel )obj;
         owner._random = new Random(( int )args.NewValue);
         owner.InvalidateArrange();
     }
 }
Beispiel #3
0
        private static void OnInvalidateMeasure(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RandomPanel panel = d as RandomPanel;

            if (panel.MinimumWidth > panel.MaximumWidth)
            {
                throw new InvalidDataException("MinWidth can't be greater than MaxWidth.");
            }
            else if (panel.MinimumHeight > panel.MaximumHeight)
            {
                throw new InvalidDataException("MinHeight can't be greater than MaxHeight.");
            }
            else
            {
                (( AnimationPanel )d).InvalidateMeasure();
            }
        }
Beispiel #4
0
        protected override Size MeasureChildrenOverride(UIElementCollection children, Size constraint)
        {
            Size availableSize = new Size(double.PositiveInfinity, double.PositiveInfinity);

            foreach (UIElement child in children)
            {
                if (child == null)
                {
                    continue;
                }

                Size childSize = new Size(1d * _random.Next(Convert.ToInt32(MinimumWidth), Convert.ToInt32(MaximumWidth)),
                                          1d * _random.Next(Convert.ToInt32(MinimumHeight), Convert.ToInt32(MaximumHeight)));
                child.Measure(childSize);
                RandomPanel.SetActualSize(child, childSize);
            }
            return(new Size());
        }
Beispiel #5
0
        private static object CoerceMinimumWidth(DependencyObject d, object baseValue)
        {
            RandomPanel panel = ( RandomPanel )d;
            double      value = ( double )baseValue;

            if (double.IsNaN(value) || double.IsInfinity(value) || (value < 0d))
            {
                return(DependencyProperty.UnsetValue);
            }

            double maximum = panel.MaximumWidth;

            if (value > maximum)
            {
                return(maximum);
            }

            return(baseValue);
        }
Beispiel #6
0
        protected override Size ArrangeChildrenOverride(UIElementCollection children, Size finalSize)
        {
            foreach (UIElement child in children)
            {
                if (child == null)
                {
                    continue;
                }

                Size childSize = RandomPanel.GetActualSize(child);

                double x = _random.Next(0, ( int )(Math.Max(finalSize.Width - childSize.Width, 0)));
                double y = _random.Next(0, ( int )(Math.Max(finalSize.Height - childSize.Height, 0)));

                double width  = Math.Min(finalSize.Width, childSize.Width);
                double height = Math.Min(finalSize.Height, childSize.Height);

                this.ArrangeChild(child, new Rect(new Point(x, y), new Size(width, height)));
            }
            return(finalSize);
        }
Beispiel #7
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.layoutCombo = ((System.Windows.Controls.ComboBox)(target));

            #line 130 "..\..\..\..\..\..\Samples\Panels\Views\SwitchPanelView.xaml"
                this.layoutCombo.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.OnLayoutComboSelectionChanged);

            #line default
            #line hidden
                return;

            case 2:
                this._switchPanel = ((Xceed.Wpf.Toolkit.Panels.SwitchPanel)(target));

            #line 161 "..\..\..\..\..\..\Samples\Panels\Views\SwitchPanelView.xaml"
                this._switchPanel.ActiveLayoutChanged += new System.Windows.RoutedEventHandler(this.OnSwitchPanelLayoutChanged);

            #line default
            #line hidden
                return;

            case 3:
                this._wrapPanel = ((Xceed.Wpf.Toolkit.Panels.WrapPanel)(target));
                return;

            case 4:
                this._randomPanel = ((Xceed.Wpf.Toolkit.Panels.RandomPanel)(target));
                return;

            case 5:
                this._item1 = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 6:
                this._item2 = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 7:
                this._item3 = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 8:
                this._item4 = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 9:
                this._item5 = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 10:
                this._item6 = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 11:
                this._item7 = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 12:
                this._item8 = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 13:
                this._openSourceScreenShot = ((System.Windows.Controls.Image)(target));
                return;

            case 14:
                this._openSourceScreenShotDesc = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 15:
                this._openSourceTextHyperlink = ((System.Windows.Controls.StackPanel)(target));
                return;

            case 16:

            #line 181 "..\..\..\..\..\..\Samples\Panels\Views\SwitchPanelView.xaml"
                ((System.Windows.Documents.Hyperlink)(target)).RequestNavigate += new System.Windows.Navigation.RequestNavigateEventHandler(this.Hyperlink_RequestNavigate);

            #line default
            #line hidden
                return;

            case 17:
                this._minimumWidth = ((Xceed.Wpf.Toolkit.DoubleUpDown)(target));
                return;

            case 18:
                this._maximumWidth = ((Xceed.Wpf.Toolkit.DoubleUpDown)(target));
                return;

            case 19:
                this._minimumHeight = ((Xceed.Wpf.Toolkit.DoubleUpDown)(target));
                return;

            case 20:
                this._maximumHeight = ((Xceed.Wpf.Toolkit.DoubleUpDown)(target));
                return;
            }
            this._contentLoaded = true;
        }