예제 #1
0
        protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
        {
            if (this.ElementTree == null)
            {
                return;
            }

            if (this.GetBitState(ForcingLocationStateKey) && e.Property == RadElement.BoundsProperty)
            {
                return;
            }

            base.OnPropertyChanged(e);

            if (!this.GetBitState(ControlInitiatedPropertyChangeStateKey))
            {
                this.BitState[RootElementInitiatedPropertyChangeStateKey] = true;
                if (e.Property == RootRadElement.ControlBoundsProperty)
                {
                    this.ElementTree.Control.Bounds = (Rectangle)e.NewValue;
                }
                else if (e.Property == RootRadElement.StretchHorizontallyProperty)
                {
                    RoutedEventArgs args = new RoutedEventArgs(new StretchEventArgs(true, (bool)e.NewValue), StretchChangedEvent);
                    this.RaiseTunnelEvent(this, args);
                }
                else if (e.Property == RootRadElement.StretchVerticallyProperty)
                {
                    RoutedEventArgs args = new RoutedEventArgs(new StretchEventArgs(false, (bool)e.NewValue), StretchChangedEvent);
                    this.RaiseTunnelEvent(this, args);
                }
                else if (e.Property == RadElement.BoundsProperty)
                {
                    if (!this.UseNewLayoutSystem)
                    {
                        if (this.AutoSize && this.AutoSizeMode == RadAutoSizeMode.FitToAvailableSize)
                        {
                            //this.Size = this.ElementTree.Control.Size;
                        }
                        else
                        {
                            this.ElementTree.LockControlLayout();
                            this.ElementTree.Control.Size = ((Rectangle)e.NewValue).Size;
                            this.ElementTree.UnlockControlLayout();
                        }
                    }
                    if ((this.Shape != null) && (this.ElementTree != null) &&
                        this.ApplyShapeToControl)
                    {
                        Rectangle oldBounds = (Rectangle)e.OldValue;
                        Rectangle newBounds = (Rectangle)e.NewValue;
                        //change region only of the Size has changed
                        if (oldBounds.Size != newBounds.Size)
                        {
                            Rectangle boundsRect = new Rectangle(Point.Empty, new Size(this.Size.Width, this.Size.Height));
                            this.ElementTree.Control.Region = this.Shape.CreateRegion(boundsRect);
                        }
                    }
                }
                else if ((e.Property == ShapeProperty) && this.ApplyShapeToControl)
                {
                    ElementShape shape = e.NewValue as ElementShape;
                    if ((shape != null) && (this.ElementTree != null))
                    {
                        this.ElementTree.Control.Region = new Region(shape.GetElementShape(this));
                    }
                }
                else if (e.Property == ApplyShapeToControlProperty)
                {
                    if ((bool)e.NewValue && this.Shape != null)
                    {
                        this.ElementTree.Control.Region = new Region(this.Shape.GetElementShape(this));
                    }
                    else
                    {
                        this.ElementTree.Control.Region = null;
                    }
                }

                //ask the component handler to sync its ambient properties - e.g. BackColor, ForeColor, etc.
                this.ElementTree.ComponentTreeHandler.OnAmbientPropertyChanged(e.Property);
                //Note ! the following lines should be the last in the routine in order to avoid infinite loop when the corresponding control's property changes
                this.BitState[RootElementInitiatedPropertyChangeStateKey] = false;
            }
            this.BitState[ControlInitiatedPropertyChangeStateKey] = false;
        }
예제 #2
0
 protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
 {
     if (this.ElementTree == null || this.GetBitState(281474976710656L) && e.Property == RadElement.BoundsProperty)
     {
         return;
     }
     base.OnPropertyChanged(e);
     if (!this.GetBitState(35184372088832L))
     {
         this.BitState[70368744177664L] = true;
         if (e.Property == RootRadElement.ControlBoundsProperty)
         {
             this.ElementTree.Control.Bounds = (Rectangle)e.NewValue;
         }
         else if (e.Property == RadElement.StretchHorizontallyProperty)
         {
             this.RaiseTunnelEvent((RadElement)this, new RoutedEventArgs((EventArgs) new StretchEventArgs(true, (bool)e.NewValue), RootRadElement.StretchChangedEvent));
         }
         else if (e.Property == RadElement.StretchVerticallyProperty)
         {
             this.RaiseTunnelEvent((RadElement)this, new RoutedEventArgs((EventArgs) new StretchEventArgs(false, (bool)e.NewValue), RootRadElement.StretchChangedEvent));
         }
         else if (e.Property == RadElement.BoundsProperty)
         {
             if (this.Shape != null && this.ElementTree != null && this.ApplyShapeToControl && ((Rectangle)e.OldValue).Size != ((Rectangle)e.NewValue).Size)
             {
                 this.ElementTree.Control.Region = this.Shape.CreateRegion(new Rectangle(Point.Empty, new Size(this.Size.Width, this.Size.Height)));
             }
         }
         else if (e.Property == RadElement.ShapeProperty && this.ApplyShapeToControl)
         {
             ElementShape newValue = e.NewValue as ElementShape;
             if (newValue != null && this.ElementTree != null)
             {
                 this.ElementTree.Control.Region = new Region(newValue.GetElementShape((RadElement)this));
             }
         }
         else if (e.Property == RootRadElement.ApplyShapeToControlProperty)
         {
             if ((bool)e.NewValue && this.Shape != null)
             {
                 this.ElementTree.Control.Region = new Region(this.Shape.GetElementShape((RadElement)this));
             }
             else
             {
                 this.ElementTree.Control.Region = (Region)null;
             }
         }
         else if (e.Property == RootRadElement.ControlDefaultSizeProperty)
         {
             this.OnControlDefaultSizeChanged(e);
         }
         if (e.Property == RadItem.ShadowDepthProperty || e.Property == RadItem.EnableElementShadowProperty || (e.Property == RadItem.ShadowColorProperty || e.Property == RootRadElement.ControlBoundsProperty) || (e.Property == RadElement.VisibilityProperty || e.Property == RadElement.BoundsProperty || e.Property == VisualElement.BackColorProperty))
         {
             this.PaintControlShadow();
         }
         this.ElementTree.ComponentTreeHandler.OnAmbientPropertyChanged(e.Property);
         this.BitState[70368744177664L] = false;
     }
     this.BitState[35184372088832L] = false;
 }