public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (context != null && context.Container != null) { return(base.ConvertFrom(context, culture, value)); } if (value is string) { if (noneString.Equals(value)) { return(null); } try { string[] tokens = (value as string).Split('|'); if (tokens.Length == 0 || string.IsNullOrEmpty(tokens[0])) { return(null); } if (shownError) { return(null); } ElementShape elementShape = null; Type shapeType = RadTypeResolver.Instance.GetTypeByName(tokens[0].Trim()); if (shapeType == null) { return(null); } if (!(typeof(ElementShape)).IsAssignableFrom(shapeType)) { VSCacheError.ShowVSCacheError((typeof(ElementShape)).Assembly, shapeType.Assembly); shownError = true; } else { elementShape = (ElementShape)Activator.CreateInstance(shapeType); if (tokens.Length > 1) { elementShape.DeserializeProperties(tokens[1]); } } return(elementShape); } catch (Exception ex) { MessageBox.Show("Error deserializing custom shape: " + ex.ToString()); return(null); } } return(base.ConvertFrom(context, culture, value)); }
protected override void OnPropertyChanged(RadPropertyChangedEventArgs e) { if (e.Property == RadElement.BoundsProperty) { if (!this.UseNewLayoutSystem) { if (this.AutoSize && this.AutoSizeMode == RadAutoSizeMode.FitToAvailableSize) { //this.Size = this.ElementTree.Control.Size; } else { this.ElementTree.ComponentTreeHandler.ElementTree.LockControlLayout(); this.ElementTree.Control.Size = ((Rectangle)e.NewValue).Size; this.ElementTree.ComponentTreeHandler.ElementTree.UnlockControlLayout(); } } if ((this.Shape != null) && (this.formControl != 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) { CreateRegionFromShape(newBounds.Size); } } } else if ((e.Property == ShapeProperty) && this.ApplyShapeToControl) { ElementShape shape = e.NewValue as ElementShape; if ((shape != null) && (this.ElementTree != null)) { CreateRegionFromShape(this.Size); } } else if (e.Property == ApplyShapeToControlProperty) { if ((bool)e.NewValue && this.Shape != null) { CreateRegionFromShape(this.Size); } else { this.ElementTree.Control.Region = null; } } else { base.OnPropertyChanged(e); } }
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; }
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; }
public override object ConvertFrom( ITypeDescriptorContext context, CultureInfo culture, object value) { if (context != null && context.Container != null) { return(base.ConvertFrom(context, culture, value)); } if (!(value is string)) { return(base.ConvertFrom(context, culture, value)); } if ("(none)".Equals(value)) { return((object)null); } try { string[] strArray = (value as string).Split('|'); if (strArray.Length == 0 || string.IsNullOrEmpty(strArray[0]) || ElementShapeConverter.shownError) { return((object)null); } ElementShape elementShape = (ElementShape)null; string str = strArray[0].Trim(); System.Type type = Assembly.GetExecutingAssembly().GetType(str, false, false); if ((object)type == null) { switch (str) { case "Telerik.WinControls.Tests.DonutShape": type = typeof(DonutShape); break; case "Telerik.WinControls.Tests.QAShape": type = typeof(QAShape); break; case "Telerik.WinControls.EllipseShape": type = typeof(EllipseShape); break; case "Telerik.WinControls.RoundRectShape": type = typeof(RoundRectShape); break; case "Telerik.WinControls.ChamferedRectShape": type = typeof(ChamferedRectShape); break; case "Telerik.WinControls.UI.OfficeShape": type = typeof(OfficeShape); break; case "Telerik.WinControls.UI.TabIEShape": type = typeof(TabIEShape); break; case "Telerik.WinControls.UI.TabOffice12Shape": type = typeof(TabOffice12Shape); break; case "Telerik.WinControls.UI.TabVsShape": type = typeof(TabVsShape); break; case "Telerik.WinControls.UI.TrackBarDThumbShape": type = typeof(TrackBarDThumbShape); break; case "Telerik.WinControls.UI.TrackBarLThumbShape": type = typeof(TrackBarLThumbShape); break; case "Telerik.WinControls.UI.TrackBarRThumbShape": type = typeof(TrackBarRThumbShape); break; case "Telerik.WinControls.UI.TrackBarUThumbShape": type = typeof(TrackBarUThumbShape); break; } } if ((object)type == null) { type = RadTypeResolver.Instance.GetTypeByName(str); } if ((object)type == null) { return((object)null); } if (!typeof(ElementShape).IsAssignableFrom(type)) { VSCacheError.ShowVSCacheError(typeof(ElementShape).Assembly, type.Assembly); ElementShapeConverter.shownError = true; } else { elementShape = (ElementShape)Activator.CreateInstance(type); if (strArray.Length > 1) { elementShape.DeserializeProperties(strArray[1]); } } return((object)elementShape); } catch (Exception ex) { int num = (int)MessageBox.Show("Error deserializing custom shape: " + ex.ToString()); return((object)null); } }