示例#1
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value, false);
            BackFrame backFrame = (BackFrame)value;
            PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(null);

            for (int i = 0; i < properties.Count; i++)
            {
                if (properties[i].IsBrowsable)
                {
                    if (backFrame.IsCustomXamlFrame() && (properties[i].Name == "FrameWidth" || properties[i].Name == "FrameGradientEndColor" || properties[i].Name == "FrameGradientType" || properties[i].Name == "FrameHatchStyle" || properties[i].Name == "BackGradientEndColor" || properties[i].Name == "BackGradientType" || properties[i].Name == "BackHatchStyle"))
                    {
                        propertyDescriptorCollection.Add(TypeDescriptor.CreateProperty(value.GetType(), properties[i], new ReadOnlyAttribute(true)));
                    }
                    else
                    {
                        propertyDescriptorCollection.Add(properties[i]);
                    }
                }
            }
            return(propertyDescriptorCollection);
        }
        public RectangleF GetFrameRectangle(GaugeGraphics g)
        {
            RectangleF result;

            if (this.Parent is GaugeCore)
            {
                result = new RectangleF(0f, 0f, (float)(((GaugeCore)this.Parent).GetWidth() - 1), (float)(((GaugeCore)this.Parent).GetHeight() - 1));
            }
            else
            {
                if ((this.FrameShape == BackFrameShape.Rectangular || this.FrameShape == BackFrameShape.RoundedRectangular) && this.Parent is CircularGauge)
                {
                    CircularGauge circularGauge = (CircularGauge)this.Parent;
                    if (circularGauge.ParentObject != null)
                    {
                        result = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));
                        if (circularGauge.Position.Rectangle.Width > 0.0 && circularGauge.Position.Rectangle.Height > 0.0)
                        {
                            if (!double.IsNaN((double)circularGauge.AspectRatio))
                            {
                                if (circularGauge.AspectRatio >= 1.0)
                                {
                                    float width = result.Width;
                                    result.Width = result.Height * circularGauge.AspectRatio;
                                    result.X    += (float)((width - result.Width) / 2.0);
                                }
                                else
                                {
                                    float height = result.Height;
                                    result.Height = result.Width / circularGauge.AspectRatio;
                                    result.Y     += (float)((height - result.Height) / 2.0);
                                }
                            }
                            else
                            {
                                float num = circularGauge.Position.Rectangle.Width / circularGauge.Position.Rectangle.Height;
                                if (circularGauge.Position.Rectangle.Width > circularGauge.Position.Rectangle.Height)
                                {
                                    float num2 = result.Height * num;
                                    result.X    += (float)((result.Width - num2) / 2.0);
                                    result.Width = num2;
                                }
                                else
                                {
                                    float num3 = result.Width / num;
                                    result.Y     += (float)((result.Height - num3) / 2.0);
                                    result.Height = num3;
                                }
                            }
                        }
                    }
                    else
                    {
                        result = circularGauge.absoluteRect;
                        if (!double.IsNaN((double)circularGauge.AspectRatio))
                        {
                            if (result.Width > result.Height * circularGauge.AspectRatio)
                            {
                                float width2 = result.Width;
                                result.Width = result.Height * circularGauge.AspectRatio;
                                result.X    += (float)((width2 - result.Width) / 2.0);
                            }
                            else
                            {
                                float height2 = result.Height;
                                result.Height = result.Width / circularGauge.AspectRatio;
                                result.Y     += (float)((height2 - result.Height) / 2.0);
                            }
                        }
                        PointF empty = PointF.Empty;
                        empty.X = (float)(0.0 - g.Graphics.Transform.OffsetX + g.InitialOffset.X);
                        empty.Y = (float)(0.0 - g.Graphics.Transform.OffsetY + g.InitialOffset.Y);
                        result.Offset(empty.X, empty.Y);
                    }
                    goto IL_0371;
                }
                result = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f));
            }
            goto IL_0371;
IL_0371:
            if (this.FrameShape == BackFrameShape.Circular || this.IsCustomXamlFrame())
            {
                if (result.Width > result.Height)
                {
                    result.X    += (float)((result.Width - result.Height) / 2.0);
                    result.Width = result.Height;
                }
                else if (result.Height > result.Width)
                {
                    result.Y     += (float)((result.Height - result.Width) / 2.0);
                    result.Height = result.Width;
                }
            }
            float xamlFrameAspectRatio = BackFrame.GetXamlFrameAspectRatio(this.Shape);

            if (xamlFrameAspectRatio > 1.0)
            {
                float num4 = result.Height * xamlFrameAspectRatio;
                result.X    += (float)((result.Width - num4) / 2.0);
                result.Width = num4;
            }
            else if (xamlFrameAspectRatio < 1.0)
            {
                float num5 = result.Width / xamlFrameAspectRatio;
                result.Y     += (float)((result.Height - num5) / 2.0);
                result.Height = num5;
            }
            if (this.Parent is GaugeCore)
            {
                if (this.ShadowOffset < 0.0)
                {
                    result.X      -= this.ShadowOffset;
                    result.Y      -= this.ShadowOffset;
                    result.Width  += this.ShadowOffset;
                    result.Height += this.ShadowOffset;
                }
                else if (this.ShadowOffset > 0.0)
                {
                    result.Width  -= this.ShadowOffset;
                    result.Height -= this.ShadowOffset;
                }
            }
            return(result);
        }