private void OnLoaded(object sender, RoutedEventArgs e)
        {
            var presentationSource = PresentationSource.FromVisual(this);

            if (presentationSource != null)
            {
                if (presentationSource.CompositionTarget != null)
                {
                    Matrix         m            = presentationSource.CompositionTarget.TransformFromDevice;
                    ScaleTransform dpiTransform = new ScaleTransform(m.M11, m.M22);
                    if (dpiTransform.CanFreeze)
                    {
                        dpiTransform.Freeze();
                    }
                    RenderTransform = dpiTransform;

                    // Масштабируем текст обратно
                    if (Parent is Page page)
                    {
                        page.FontSize *= 1 / m.M11;
                    }
                }

                // Обязательно нужно отписаться, иначе декоратор будет срабатывать повторно,
                // когда будут закрыты все документы и открыт новый. Содержимое панели
                // будет масштабироваться в геометрической прогрессии
                Loaded -= OnLoaded;
            }
        }
        Image InitializeImage(Image image)
        {
            image.Stretch          = Filter(imageSourceService.Stretch);
            image.StretchDirection = Filter(imageSourceService.StretchDirection);
            image.Opacity          = FilterOpacity(imageSourceService.Opacity);
            image.Source           = imageSourceService.ImageSource;
            image.MaxHeight        = FilterLength(imageSourceService.MaxHeight);
            image.MaxWidth         = FilterLength(imageSourceService.MaxWidth);
            image.ClearValue(FrameworkElement.HeightProperty);
            image.ClearValue(FrameworkElement.WidthProperty);
            double scale = FilterZoom(imageSourceService.Zoom) / 100;

            if (scale == 1)
            {
                image.LayoutTransform = Transform.Identity;
            }
            else
            {
                var scaleTransform = new ScaleTransform(scale, scale);
                scaleTransform.Freeze();
                image.LayoutTransform = scaleTransform;
            }
            UpdateImagePosition(image);
            return(image);
        }
Beispiel #3
0
        private static ScaleTransform CreateFlipXTransform()
        {
            var flipXTransform = new ScaleTransform(-1, 1);

            flipXTransform.Freeze();
            return(flipXTransform);
        }
Beispiel #4
0
        public EdgeProgressBar()
        {
            this.Loaded += (s, e) =>
            {
                if (bScaleBackToPixels)
                {
                    Matrix         m            = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice;
                    ScaleTransform dpiTransform = new ScaleTransform(1 / m.M11, 1 / m.M22);
                    if (dpiTransform.CanFreeze)
                    {
                        dpiTransform.Freeze();
                    }
                    this.LayoutTransform = dpiTransform;
                }

                ProgressWidth = (int)this.ActualWidth - 20;
                bm            = BitmapFactory.New(ProgressWidth, 8);
                image.Source  = bm;
                image.Effect  = null;

                RenderGeometry();
            };

            InitializeComponent();
            backRectFill   = WriteableBitmapExtensions.ConvertColor((Color)ColorConverter.ConvertFromString("#B4B4B4"));
            backRectStroke = WriteableBitmapExtensions.ConvertColor((Color)ColorConverter.ConvertFromString("#ABABAB"));
            backEmpty      = WriteableBitmapExtensions.ConvertColor((Color)ColorConverter.ConvertFromString("#FFFFFF"));
            r0             = WriteableBitmapExtensions.ConvertColor((Color)ColorConverter.ConvertFromString("#4687E8"));
            l1             = WriteableBitmapExtensions.ConvertColor((Color)ColorConverter.ConvertFromString("#79C0F9"));
            l2             = WriteableBitmapExtensions.ConvertColor((Color)ColorConverter.ConvertFromString("#6DB3F7"));
            l3             = WriteableBitmapExtensions.ConvertColor((Color)ColorConverter.ConvertFromString("#63A8F7"));
            l4             = WriteableBitmapExtensions.ConvertColor((Color)ColorConverter.ConvertFromString("#589CF5"));
            lm1            = WriteableBitmapExtensions.ConvertColor((Color)ColorConverter.ConvertFromString("#59A3F6"));
            lm2            = WriteableBitmapExtensions.ConvertColor((Color)ColorConverter.ConvertFromString("#5095F6"));
        }
Beispiel #5
0
 public DpiDecorator()
 {
     this.Loaded += (s, e) => {
         Matrix         m            = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice;
         ScaleTransform dpiTransform = new ScaleTransform(1 / m.M11, 1 / m.M22);
         if (dpiTransform.CanFreeze)
         {
             dpiTransform.Freeze();
         }
         this.LayoutTransform = dpiTransform;
     };
 }
 public DpiDecorator()
 {
     this.Loaded += (RoutedEventHandler)((s, e) =>
     {
         Matrix transformToDevice = PresentationSource.FromVisual((Visual)this).CompositionTarget.TransformToDevice;
         ScaleTransform scaleTransform = new ScaleTransform(1.0 / transformToDevice.M11, 1.0 / transformToDevice.M22);
         if (scaleTransform.CanFreeze)
         {
             scaleTransform.Freeze();
         }
         this.LayoutTransform = (Transform)scaleTransform;
     });
 }
Beispiel #7
0
            protected override void OnRender(DrawingContext drawingContext)
            {
                var    renderSize     = this.RenderSize;
                var    document       = editor.Document;
                var    textView       = editor.TextArea.TextView;
                double documentHeight = textView.DocumentHeight;

                foreach (var marker in textMarkerService.TextMarkers)
                {
                    if (!IsVisibleInAdorner(marker))
                    {
                        continue;
                    }
                    var    location       = document.GetLocation(marker.StartOffset);
                    double visualTop      = textView.GetVisualTopByDocumentLine(location.Line);
                    double renderPos      = visualTop / documentHeight * renderSize.Height;
                    var    brush          = GetBrush(marker.MarkerColor);
                    bool   isLineOrCircle = false;
                    if ((marker.MarkerTypes & (TextMarkerTypes.LineInScrollBar)) != 0)
                    {
                        drawingContext.DrawRectangle(brush, null, new Rect(3, renderPos - 1, renderSize.Width - 6, 2));
                        isLineOrCircle = true;
                    }
                    if ((marker.MarkerTypes & (TextMarkerTypes.CircleInScrollBar)) != 0)
                    {
                        const double radius = 3;
                        drawingContext.DrawEllipse(brush, null, new Point(renderSize.Width / 2, renderPos), radius, radius);
                        isLineOrCircle = true;
                    }
                    if (!isLineOrCircle)
                    {
                        var translateTransform = new TranslateTransform(6, renderPos);
                        translateTransform.Freeze();
                        drawingContext.PushTransform(translateTransform);

                        if ((marker.MarkerTypes & (TextMarkerTypes.ScrollBarLeftTriangle)) != 0)
                        {
                            var scaleTransform = new ScaleTransform(-1, 1);
                            scaleTransform.Freeze();
                            drawingContext.PushTransform(scaleTransform);
                            drawingContext.DrawGeometry(brush, null, triangleGeometry);
                            drawingContext.Pop();
                        }
                        if ((marker.MarkerTypes & (TextMarkerTypes.ScrollBarRightTriangle)) != 0)
                        {
                            drawingContext.DrawGeometry(brush, null, triangleGeometry);
                        }
                        drawingContext.Pop();
                    }
                }
            }
Beispiel #8
0
        public void Scale(real xScale, real yScale)
        {
            ScaleTransform rt = new ScaleTransform();

            rt.ScaleX = xScale;
            rt.ScaleY = yScale;

            if (rt.CanFreeze)
            {
                rt.Freeze();
            }
            FCanvas.PushTransform(rt);
            GraphicsSave[GraphicsSave.Count - 1]++;
        }
Beispiel #9
0
        private void UpdateScale(float scale)
        {
            if (scale < 0.25f)
            {
                scale = 0.25f;
            }
            if (scale > 4)
            {
                scale = 4;
            }
            var transform = new ScaleTransform(scale, scale);

            transform.Freeze();
            Application.Current.Resources["LayoutScale"] = transform;
        }
        /// <summary>  </summary>
        public override void InitializeTransform()
        {
            const double mercatorSize       = 360;
            var          translateTransform = new TranslateTransform(MapView.ReferenceSize / 2 - 180, MapView.ReferenceSize / 2 - 180);
            var          zoomTransform      = new ScaleTransform(MapView.ZoomAdjust * MapView.ReferenceSize / mercatorSize, MapView.ZoomAdjust * MapView.ReferenceSize / mercatorSize, MapView.ReferenceSize / 2, MapView.ReferenceSize / 2);
            var          transformGroup     = new TransformGroup();

            transformGroup.Children.Add(translateTransform);
            transformGroup.Children.Add(zoomTransform);

            zoomTransform.Freeze();
            translateTransform.Freeze();
            transformGroup.Freeze();

            RenderTransform = transformGroup;
        }
        static partial void ScaleRect(ref Rect rect, ref Transform transform)
        {
            // Scales the RectangleGeometry to compensate inaccurate hit testing in WPF.
            // See http://stackoverflow.com/a/19335624/1136211

            rect.Scale(1e6, 1e6);

            var scaleTransform = new ScaleTransform(1e-6, 1e-6); // reverts rect scaling

            scaleTransform.Freeze();

            var transformGroup = new TransformGroup();

            transformGroup.Children.Add(scaleTransform);
            transformGroup.Children.Add(transform);

            transform = transformGroup;
        }
Beispiel #12
0
        void SetScaleTransform(DependencyObject textObj, DependencyObject vc, double scale)
        {
            Debug.Assert(textObj != this || !wpfSupportsPerMonitorDpi);
            if (vc == null || textObj == null)
            {
                return;
            }

            if (scale == 1)
            {
                vc.SetValue(LayoutTransformProperty, Transform.Identity);
            }
            else
            {
                var st = new ScaleTransform(scale, scale);
                st.Freeze();
                vc.SetValue(LayoutTransformProperty, st);
            }

            SetTextFormattingMode(textObj, scale);
        }
Beispiel #13
0
        public DpiDecorator()
        {
            Loaded += (s, e) =>
            {
                var presentationSource = PresentationSource.FromVisual(this);
                if (presentationSource == null)
                {
                    return;
                }
                if (presentationSource.CompositionTarget == null)
                {
                    return;
                }

                var matrix       = presentationSource.CompositionTarget.TransformToDevice;
                var dpiTransform = new ScaleTransform(1 / matrix.M11, 1 / matrix.M22);
                if (dpiTransform.CanFreeze)
                {
                    dpiTransform.Freeze();
                }
                LayoutTransform = dpiTransform;
            };
        }
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            if (null != e)
            {
                e.Handled = true;
            }


            var source = PresentationSource.FromVisual(this);

            if (null != source && null != source.CompositionTarget)
            {
                var matrix = source.CompositionTarget.TransformToDevice;

                var dpiTransform = new ScaleTransform(1 / matrix.M11, 1 / matrix.M22);

                if (dpiTransform.CanFreeze)
                {
                    dpiTransform.Freeze();
                }

                LayoutTransform = dpiTransform;
            }
        }
 private void Browser_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         this.isLoaded = true;
         Matrix         transformToDevice = PresentationSource.FromVisual((Visual)sender).CompositionTarget.TransformToDevice;
         ScaleTransform scaleTransform    = new ScaleTransform(1.0 / transformToDevice.M11, 1.0 / transformToDevice.M22);
         if (scaleTransform.CanFreeze)
         {
             scaleTransform.Freeze();
         }
         this.LayoutTransform = (Transform)scaleTransform;
         this.zoomLevel       = Math.Log(transformToDevice.M11) / Math.Log(1.2);
         if ((double)this.mCustomZoomLevel == 0.0)
         {
             return;
         }
         this.zoomLevel += Math.Log10((double)this.mCustomZoomLevel) / Math.Log10(1.2);
     }
     catch (Exception ex)
     {
         Logger.Warning("Failed to get zoom factor of browser with url {0} and error :{1}", (object)this.url, (object)ex.ToString());
     }
 }
Beispiel #16
0
 static MapRectangle()
 {
     geometryScaleTransform.Freeze();
 }
Beispiel #17
0
        private void RenderTheme(DrawingContext dc)
        {
            Size size        = RenderSize;
            bool horizontal  = Orientation == Orientation.Horizontal;
            bool isClickable = IsClickable && IsEnabled;
            bool isHovered   = isClickable && IsHovered;
            bool isPressed   = isClickable && IsPressed;
            ListSortDirection?sortDirection = SortDirection;
            bool isSorted   = sortDirection != null;
            bool isSelected = IsSelected;
            bool hasBevel   = (!isHovered && !isPressed && !isSorted && !isSelected);

            EnsureCache((int)AeroFreezables.NumFreezables);

            if (horizontal)
            {
                // When horizontal, rotate the rendering by -90 degrees
                Matrix m1 = new Matrix();
                m1.RotateAt(-90.0, 0.0, 0.0);
                Matrix m2 = new Matrix();
                m2.Translate(0.0, size.Height);

                MatrixTransform horizontalRotate = new MatrixTransform(m1 * m2);
                horizontalRotate.Freeze();
                dc.PushTransform(horizontalRotate);

                double temp = size.Width;
                size.Width  = size.Height;
                size.Height = temp;
            }

            if (hasBevel)
            {
                // This is a highlight that can be drawn by just filling the background with the color.
                // It will be seen through the gab between the border and the background.
                LinearGradientBrush bevel = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.NormalBevel);
                if (bevel == null)
                {
                    bevel            = new LinearGradientBrush();
                    bevel.StartPoint = new Point();
                    bevel.EndPoint   = new Point(0.0, 1.0);
                    bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.0));
                    bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.4));
                    bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFC, 0xFC, 0xFD), 0.4));
                    bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFB, 0xFC, 0xFC), 1.0));
                    bevel.Freeze();

                    CacheFreezable(bevel, (int)AeroFreezables.NormalBevel);
                }

                dc.DrawRectangle(bevel, null, new Rect(0.0, 0.0, size.Width, size.Height));
            }

            // Fill the background
            AeroFreezables backgroundType = AeroFreezables.NormalBackground;

            if (isPressed)
            {
                backgroundType = AeroFreezables.PressedBackground;
            }
            else if (isHovered)
            {
                backgroundType = AeroFreezables.HoveredBackground;
            }
            else if (isSorted || isSelected)
            {
                backgroundType = AeroFreezables.SortedBackground;
            }

            LinearGradientBrush background = (LinearGradientBrush)GetCachedFreezable((int)backgroundType);

            if (background == null)
            {
                background            = new LinearGradientBrush();
                background.StartPoint = new Point();
                background.EndPoint   = new Point(0.0, 1.0);

                switch (backgroundType)
                {
                case AeroFreezables.NormalBackground:
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.0));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.4));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF7, 0xF8, 0xFA), 0.4));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF1, 0xF2, 0xF4), 1.0));
                    break;

                case AeroFreezables.PressedBackground:
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBC, 0xE4, 0xF9), 0.0));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBC, 0xE4, 0xF9), 0.4));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x8D, 0xD6, 0xF7), 0.4));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x8A, 0xD1, 0xF5), 1.0));
                    break;

                case AeroFreezables.HoveredBackground:
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE3, 0xF7, 0xFF), 0.0));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE3, 0xF7, 0xFF), 0.4));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBD, 0xED, 0xFF), 0.4));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xB7, 0xE7, 0xFB), 1.0));
                    break;

                case AeroFreezables.SortedBackground:
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF2, 0xF9, 0xFC), 0.0));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF2, 0xF9, 0xFC), 0.4));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE1, 0xF1, 0xF9), 0.4));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xD8, 0xEC, 0xF6), 1.0));
                    break;
                }

                background.Freeze();

                CacheFreezable(background, (int)backgroundType);
            }

            dc.DrawRectangle(background, null, new Rect(0.0, 0.0, size.Width, size.Height));

            if (size.Width >= 2.0)
            {
                // Draw the borders on the sides
                AeroFreezables sideType = AeroFreezables.NormalSides;
                if (isPressed)
                {
                    sideType = AeroFreezables.PressedSides;
                }
                else if (isHovered)
                {
                    sideType = AeroFreezables.HoveredSides;
                }
                else if (isSorted || isSelected)
                {
                    sideType = AeroFreezables.SortedSides;
                }

                if (SeparatorVisibility == Visibility.Visible)
                {
                    Brush sideBrush;
                    if (SeparatorBrush != null)
                    {
                        sideBrush = SeparatorBrush;
                    }
                    else
                    {
                        sideBrush = (Brush)GetCachedFreezable((int)sideType);
                        if (sideBrush == null)
                        {
                            LinearGradientBrush lgBrush = null;
                            if (sideType != AeroFreezables.SortedSides)
                            {
                                lgBrush            = new LinearGradientBrush();
                                lgBrush.StartPoint = new Point();
                                lgBrush.EndPoint   = new Point(0.0, 1.0);
                                sideBrush          = lgBrush;
                            }

                            switch (sideType)
                            {
                            case AeroFreezables.NormalSides:
                                lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF2, 0xF2, 0xF2), 0.0));
                                lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEF, 0xEF, 0xEF), 0.4));
                                lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE7, 0xE8, 0xEA), 0.4));
                                lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xDE, 0xDF, 0xE1), 1.0));
                                break;

                            case AeroFreezables.PressedSides:
                                lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x7A, 0x9E, 0xB1), 0.0));
                                lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x7A, 0x9E, 0xB1), 0.4));
                                lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x50, 0x91, 0xAF), 0.4));
                                lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x4D, 0x8D, 0xAD), 1.0));
                                break;

                            case AeroFreezables.HoveredSides:
                                lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x88, 0xCB, 0xEB), 0.0));
                                lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x88, 0xCB, 0xEB), 0.4));
                                lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x69, 0xBB, 0xE3), 0.4));
                                lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x69, 0xBB, 0xE3), 1.0));
                                break;

                            case AeroFreezables.SortedSides:
                                sideBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x96, 0xD9, 0xF9));
                                break;
                            }

                            sideBrush.Freeze();

                            CacheFreezable(sideBrush, (int)sideType);
                        }
                    }

                    dc.DrawRectangle(sideBrush, null, new Rect(0.0, 0.0, 1.0, Max0(size.Height - 0.95)));
                    dc.DrawRectangle(sideBrush, null, new Rect(size.Width - 1.0, 0.0, 1.0, Max0(size.Height - 0.95)));
                }
            }

            if (isPressed && (size.Width >= 4.0) && (size.Height >= 4.0))
            {
                // When pressed, there are added borders on the left and top
                LinearGradientBrush topBrush = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.PressedTop);
                if (topBrush == null)
                {
                    topBrush            = new LinearGradientBrush();
                    topBrush.StartPoint = new Point();
                    topBrush.EndPoint   = new Point(0.0, 1.0);
                    topBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x86, 0xA3, 0xB2), 0.0));
                    topBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x86, 0xA3, 0xB2), 0.1));
                    topBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xAA, 0xCE, 0xE1), 0.9));
                    topBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xAA, 0xCE, 0xE1), 1.0));
                    topBrush.Freeze();

                    CacheFreezable(topBrush, (int)AeroFreezables.PressedTop);
                }

                dc.DrawRectangle(topBrush, null, new Rect(0.0, 0.0, size.Width, 2.0));

                LinearGradientBrush pressedBevel = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.PressedBevel);
                if (pressedBevel == null)
                {
                    pressedBevel            = new LinearGradientBrush();
                    pressedBevel.StartPoint = new Point();
                    pressedBevel.EndPoint   = new Point(0.0, 1.0);
                    pressedBevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xA2, 0xCB, 0xE0), 0.0));
                    pressedBevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xA2, 0xCB, 0xE0), 0.4));
                    pressedBevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x72, 0xBC, 0xDF), 0.4));
                    pressedBevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x6E, 0xB8, 0xDC), 1.0));
                    pressedBevel.Freeze();

                    CacheFreezable(pressedBevel, (int)AeroFreezables.PressedBevel);
                }

                dc.DrawRectangle(pressedBevel, null, new Rect(1.0, 0.0, 1.0, size.Height - 0.95));
                dc.DrawRectangle(pressedBevel, null, new Rect(size.Width - 2.0, 0.0, 1.0, size.Height - 0.95));
            }

            if (size.Height >= 2.0)
            {
                // Draw the bottom border
                AeroFreezables bottomType = AeroFreezables.NormalBottom;
                if (isPressed)
                {
                    bottomType = AeroFreezables.PressedOrHoveredBottom;
                }
                else if (isHovered)
                {
                    bottomType = AeroFreezables.PressedOrHoveredBottom;
                }
                else if (isSorted || isSelected)
                {
                    bottomType = AeroFreezables.SortedBottom;
                }

                SolidColorBrush bottomBrush = (SolidColorBrush)GetCachedFreezable((int)bottomType);
                if (bottomBrush == null)
                {
                    switch (bottomType)
                    {
                    case AeroFreezables.NormalBottom:
                        bottomBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xD5, 0xD5, 0xD5));
                        break;

                    case AeroFreezables.PressedOrHoveredBottom:
                        bottomBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x93, 0xC9, 0xE3));
                        break;

                    case AeroFreezables.SortedBottom:
                        bottomBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x96, 0xD9, 0xF9));
                        break;
                    }

                    bottomBrush.Freeze();

                    CacheFreezable(bottomBrush, (int)bottomType);
                }

                dc.DrawRectangle(bottomBrush, null, new Rect(0.0, size.Height - 1.0, size.Width, 1.0));
            }

            if (isSorted && (size.Width > 14.0) && (size.Height > 10.0))
            {
                // Draw the sort arrow
                TranslateTransform positionTransform = new TranslateTransform((size.Width - 8.0) * 0.5, 1.0);
                positionTransform.Freeze();
                dc.PushTransform(positionTransform);

                bool         ascending     = (sortDirection == ListSortDirection.Ascending);
                PathGeometry arrowGeometry = (PathGeometry)GetCachedFreezable(ascending ? (int)AeroFreezables.ArrowUpGeometry : (int)AeroFreezables.ArrowDownGeometry);
                if (arrowGeometry == null)
                {
                    arrowGeometry = new PathGeometry();
                    PathFigure arrowFigure = new PathFigure();

                    if (ascending)
                    {
                        arrowFigure.StartPoint = new Point(0.0, 4.0);

                        LineSegment line = new LineSegment(new Point(4.0, 0.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);

                        line = new LineSegment(new Point(8.0, 4.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);
                    }
                    else
                    {
                        arrowFigure.StartPoint = new Point(0.0, 0.0);

                        LineSegment line = new LineSegment(new Point(8.0, 0.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);

                        line = new LineSegment(new Point(4.0, 4.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);
                    }

                    arrowFigure.IsClosed = true;
                    arrowFigure.Freeze();

                    arrowGeometry.Figures.Add(arrowFigure);
                    arrowGeometry.Freeze();

                    CacheFreezable(arrowGeometry, ascending ? (int)AeroFreezables.ArrowUpGeometry : (int)AeroFreezables.ArrowDownGeometry);
                }

                // Draw two arrows, one inset in the other. This is to achieve a double gradient over both the border and the fill.
                LinearGradientBrush arrowBorder = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.ArrowBorder);
                if (arrowBorder == null)
                {
                    arrowBorder            = new LinearGradientBrush();
                    arrowBorder.StartPoint = new Point();
                    arrowBorder.EndPoint   = new Point(1.0, 1.0);
                    arrowBorder.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x3C, 0x5E, 0x72), 0.0));
                    arrowBorder.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x3C, 0x5E, 0x72), 0.1));
                    arrowBorder.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xC3, 0xE4, 0xF5), 1.0));
                    arrowBorder.Freeze();
                    CacheFreezable(arrowBorder, (int)AeroFreezables.ArrowBorder);
                }

                dc.DrawGeometry(arrowBorder, null, arrowGeometry);

                LinearGradientBrush arrowFill = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.ArrowFill);
                if (arrowFill == null)
                {
                    arrowFill            = new LinearGradientBrush();
                    arrowFill.StartPoint = new Point();
                    arrowFill.EndPoint   = new Point(1.0, 1.0);
                    arrowFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x61, 0x96, 0xB6), 0.0));
                    arrowFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x61, 0x96, 0xB6), 0.1));
                    arrowFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xCA, 0xE6, 0xF5), 1.0));
                    arrowFill.Freeze();
                    CacheFreezable(arrowFill, (int)AeroFreezables.ArrowFill);
                }

                // Inset the fill arrow inside the border arrow
                ScaleTransform arrowScale = (ScaleTransform)GetCachedFreezable((int)AeroFreezables.ArrowFillScale);
                if (arrowScale == null)
                {
                    arrowScale = new ScaleTransform(0.75, 0.75, 3.5, 4.0);
                    arrowScale.Freeze();
                    CacheFreezable(arrowScale, (int)AeroFreezables.ArrowFillScale);
                }

                dc.PushTransform(arrowScale);

                dc.DrawGeometry(arrowFill, null, arrowGeometry);

                dc.Pop(); // Scale Transform
                dc.Pop(); // Position Transform
            }

            if (horizontal)
            {
                dc.Pop(); // Horizontal Rotate
            }
        }
        /// <summary> Returns a Transform object for a spatial reference. </summary>
        /// <param name="reference"> The spatial reference. </param>
        /// <returns> The resulting render transform. </returns>
        public static Transform CreateTransform(SpatialReference reference)
        {
            switch (reference)
            {
            case SpatialReference.PtvMercator:
            {
                const double EARTH_RADIUS  = 6371000.0;
                const double MERCATOR_SIZE = EARTH_RADIUS * 2.0 * Math.PI;

                var translateTransform = new TranslateTransform(MapView.ReferenceSize / 2, MapView.ReferenceSize / 2);
                var zoomTransform      = new ScaleTransform(MapView.ZoomAdjust * MapView.ReferenceSize / MERCATOR_SIZE, -MapView.ZoomAdjust * MapView.ReferenceSize / MERCATOR_SIZE, MapView.ReferenceSize / 2, MapView.ReferenceSize / 2);
                var transformGroup     = new TransformGroup();
                transformGroup.Children.Add(translateTransform);
                transformGroup.Children.Add(zoomTransform);

                zoomTransform.Freeze();
                translateTransform.Freeze();
                transformGroup.Freeze();

                return(transformGroup);
            }

            case SpatialReference.PtvMercatorInvertedY:
            {
                const double EARTH_RADIUS  = 6371000.0;
                const double MERCATOR_SIZE = EARTH_RADIUS * 2.0 * Math.PI;

                var translateTransform = new TranslateTransform(MapView.ReferenceSize / 2, MapView.ReferenceSize / 2);
                var zoomTransform      = new ScaleTransform(MapView.ZoomAdjust * MapView.ReferenceSize / MERCATOR_SIZE, MapView.ZoomAdjust * MapView.ReferenceSize / MERCATOR_SIZE, MapView.ReferenceSize / 2, MapView.ReferenceSize / 2);
                var transformGroup     = new TransformGroup();
                transformGroup.Children.Add(translateTransform);
                transformGroup.Children.Add(zoomTransform);

                zoomTransform.Freeze();
                translateTransform.Freeze();
                transformGroup.Freeze();

                return(transformGroup);
            }

            case SpatialReference.WebMercator:
            {
                const double EARTH_RADIUS  = 6378137.0;
                const double MERCATOR_SIZE = EARTH_RADIUS * 2.0 * Math.PI;

                var translateTransform = new TranslateTransform(MapView.ReferenceSize / 2, MapView.ReferenceSize / 2);
                var zoomTransform      = new ScaleTransform(MapView.ZoomAdjust * MapView.ReferenceSize / MERCATOR_SIZE, -MapView.ZoomAdjust * MapView.ReferenceSize / MERCATOR_SIZE, MapView.ReferenceSize / 2, MapView.ReferenceSize / 2);
                var transformGroup     = new TransformGroup();
                transformGroup.Children.Add(translateTransform);
                transformGroup.Children.Add(zoomTransform);

                zoomTransform.Freeze();
                translateTransform.Freeze();
                transformGroup.Freeze();

                return(transformGroup);
            }

            case SpatialReference.WebMercatorInvertedY:
            {
                const double EARTH_RADIUS  = 6378137.0;
                const double MERCATOR_SIZE = EARTH_RADIUS * 2.0 * Math.PI;

                var translateTransform = new TranslateTransform(MapView.ReferenceSize / 2, MapView.ReferenceSize / 2);
                var zoomTransform      = new ScaleTransform(MapView.ZoomAdjust * MapView.ReferenceSize / MERCATOR_SIZE, MapView.ZoomAdjust * MapView.ReferenceSize / MERCATOR_SIZE, MapView.ReferenceSize / 2, MapView.ReferenceSize / 2);
                var transformGroup     = new TransformGroup();
                transformGroup.Children.Add(translateTransform);
                transformGroup.Children.Add(zoomTransform);

                zoomTransform.Freeze();
                translateTransform.Freeze();
                transformGroup.Freeze();

                return(transformGroup);
            }

            default:
                throw new ArgumentException("not supported");
            }
        }
        static GridViewColumnHeaderChrome()
        {
            SnapsToDevicePixelsProperty.OverrideMetadata(
                typeof(GridViewColumnHeaderChrome), new FrameworkPropertyMetadata(true));

            NormalBorderPen = new Lazy <Pen>(
                () => {
                var pen = new Pen {
                    Thickness = 1.0, Brush = Brushes.Transparent
                };
                pen.Freeze();
                return(pen);
            });

            InnerBorderPen = new Lazy <Pen>(
                () => {
                var brush = new LinearGradientBrush(
                    Color.FromArgb(0xFF, 0xFD, 0xFE, 0xFF),
                    Color.FromArgb(0xFF, 0xFC, 0xFD, 0xFE),
                    90);
                brush.Freeze();
                var pen = new Pen(brush, 1);
                pen.Freeze();
                return(pen);
            });

            SeparatorPen = new Lazy <Pen>(
                () => {
                var brush = new LinearGradientBrush(
                    Color.FromArgb(0xFF, 0xDE, 0xE9, 0xF7),
                    Color.FromArgb(0x00, 0xDE, 0xE9, 0xF7),
                    90);
                brush.Freeze();
                var pen = new Pen(brush, 1);
                pen.Freeze();
                return(pen);
            });

            PressedBorderPen = new Lazy <Pen>(
                () => {
                var brush = new LinearGradientBrush(
                    Color.FromArgb(0xFF, 0xC0, 0xCB, 0xD9),
                    Color.FromArgb(0xFF, 0xC0, 0xCB, 0xD9),
                    90);
                brush.Freeze();
                var pen = new Pen(brush, 1)
                {
                    StartLineCap = PenLineCap.Square,
                    EndLineCap   = PenLineCap.Square
                };
                pen.Freeze();
                return(pen);
            });
            PressedBackgroundBrush = new Lazy <Brush>(
                () => {
                var brush = new LinearGradientBrush(
                    Color.FromArgb(0xFF, 0xF6, 0xF7, 0xF8),
                    Color.FromArgb(0xFF, 0xF6, 0xF7, 0xF8),
                    90);
                brush.Freeze();
                return(brush);
            });
            PressedHighlightBrush = new Lazy <Brush>(
                () => {
                var brush = new LinearGradientBrush(
                    Color.FromArgb(0xFF, 0xC1, 0xCC, 0xDA),
                    Color.FromArgb(0xFF, 0xEB, 0xEE, 0xF2),
                    90);
                brush.Freeze();
                return(brush);
            });

            HoveredBorderPen = new Lazy <Pen>(
                () => {
                var brush = new LinearGradientBrush(
                    Color.FromArgb(0xFF, 0xDE, 0xE9, 0xF7),
                    Color.FromArgb(0xFF, 0xE3, 0xE8, 0xEE),
                    90);
                brush.Freeze();
                var pen = new Pen(brush, 1)
                {
                    StartLineCap = PenLineCap.Square,
                    EndLineCap   = PenLineCap.Square
                };
                pen.Freeze();
                return(pen);
            });
            HoveredBackgroundBrush = new Lazy <Brush>(
                () => {
                var brush = new LinearGradientBrush(
                    Color.FromArgb(0xFF, 0xF3, 0xF8, 0xFD),
                    Color.FromArgb(0xFF, 0xEF, 0xF3, 0xF9),
                    90);
                brush.Freeze();
                return(brush);
            });

            ArrowUpGeometry = new Lazy <PathGeometry>(
                () => {
                var geometry      = new PathGeometry();
                var figure        = new PathFigure();
                figure.StartPoint = new Point(0.0, 4.0);
                var segment       = new LineSegment(new Point(3.5, 0.0), false);
                segment.Freeze();
                figure.Segments.Add(segment);
                segment = new LineSegment(new Point(7.0, 4.0), false);
                segment.Freeze();
                figure.Segments.Add(segment);
                figure.IsClosed = true;
                figure.Freeze();
                geometry.Figures.Add(figure);
                geometry.Freeze();
                return(geometry);
            });
            ArrowDownGeometry = new Lazy <PathGeometry>(
                () => {
                var geometry      = new PathGeometry();
                var figure        = new PathFigure();
                figure.StartPoint = new Point(0.0, 0.0);
                var segment       = new LineSegment(new Point(7.0, 0.0), false);
                segment.Freeze();
                figure.Segments.Add(segment);
                segment = new LineSegment(new Point(3.5, 4.0), false);
                segment.Freeze();
                figure.Segments.Add(segment);
                figure.IsClosed = true;
                figure.Freeze();
                geometry.Figures.Add(figure);
                geometry.Freeze();
                return(geometry);
            });
            ArrowBorderBrush = new Lazy <Brush>(
                () => {
                var brush = new LinearGradientBrush {
                    StartPoint = new Point(),
                    EndPoint   = new Point(1, 1)
                };
                brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x3C, 0x5E, 0x72), 0.0));
                brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x3C, 0x5E, 0x72), 0.1));
                brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xC3, 0xE4, 0xF5), 1.0));
                brush.Freeze();
                return(brush);
            });
            ArrowFillBrush = new Lazy <Brush>(
                () => {
                var brush = new LinearGradientBrush {
                    StartPoint = new Point(),
                    EndPoint   = new Point(1, 1)
                };
                brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x61, 0x96, 0xB6), 0.0));
                brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x61, 0x96, 0xB6), 0.1));
                brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xCA, 0xE6, 0xF5), 1.0));
                brush.Freeze();
                return(brush);
            });
            ArrowFillScale = new Lazy <Transform>(
                () => {
                var transform = new ScaleTransform(0.75, 0.75, 3.5, 4);
                transform.Freeze();
                return(transform);
            });
        }
        protected override void OnRender(DrawingContext drawingContext)
        {
            var view = this.TextView;

            if (view == null || !view.VisualLinesValid)
            {
                return;
            }
            if (!Workspace.CurrentWorkspace.DebugContext.IsDebuggerAttached)
            {
                return;
            }
            if (!Workspace.CurrentWorkspace.DebugContext.IsPaused)
            {
                return;
            }
            if (Workspace.CurrentWorkspace.CurrentDocument != Workspace.CurrentWorkspace.DebugContext.CurrentDocument)
            {
                return;
            }
            var color = new SolidColorBrush(ConfigHost.Coloring.ExecutionMarker.MainColor);

            color.Freeze();
            var pen = new Pen(new SolidColorBrush(ConfigHost.Coloring.ExecutionMarker.BorderColor), 2);

            pen.Freeze();

            var line = view.GetVisualLine(Workspace.CurrentWorkspace.DebugContext.CurrentLine);

            if (line == null)
            {
                return;
            }
            var lineTop = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop) - view.VerticalOffset;
            var lineBot = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextBottom) - view.VerticalOffset;
            var geo     = new StreamGeometry();

            using (var context = geo.Open())
            {
                context.BeginFigure(new Point(3, 5), true, true);
                context.LineTo(new Point(6, 5), false, false);
                context.LineTo(new Point(6, 2), false, false);
                context.LineTo(new Point(10, 6.5), false, false);
                context.LineTo(new Point(6, 11), false, false);
                context.LineTo(new Point(6, 8), false, false);
                context.LineTo(new Point(3, 8), false, false);
            }
            var       transgroup = new TransformGroup();
            Transform t;

            t = new TranslateTransform(-16, lineTop);
            t.Freeze();
            transgroup.Children.Add(t);

            t = new ScaleTransform((lineBot - lineTop) / 14, (lineBot - lineTop) / 14);
            t.Freeze();
            transgroup.Children.Add(t);

            transgroup.Freeze();
            geo.Transform = transgroup;
            geo.Freeze();

            drawingContext.DrawGeometry(color, pen, geo);
        }
        private void RenderTheme(DrawingContext dc)
        {
            Size renderSize = this.RenderSize;
            bool flag1      = this.Orientation == Orientation.Horizontal;
            bool flag2      = this.IsClickable && this.IsEnabled;
            bool flag3      = flag2 && this.IsHovered;
            bool flag4      = flag2 && this.IsPressed;
            ListSortDirection?sortDirection = this.SortDirection;
            bool hasValue   = sortDirection.HasValue;
            bool isSelected = this.IsSelected;
            bool flag5      = !flag3 && !flag4 && !hasValue && !isSelected;

            DataGridHeaderBorder.EnsureCache(19);
            if (flag1)
            {
                Matrix matrix1 = new Matrix();
                matrix1.RotateAt(-90.0, 0.0, 0.0);
                Matrix matrix2 = new Matrix();
                matrix2.Translate(0.0, renderSize.Height);
                MatrixTransform matrixTransform = new MatrixTransform(matrix1 * matrix2);
                matrixTransform.Freeze();
                dc.PushTransform((Transform)matrixTransform);
                double width = renderSize.Width;
                renderSize.Width  = renderSize.Height;
                renderSize.Height = width;
            }
            if (flag5)
            {
                LinearGradientBrush linearGradientBrush = (LinearGradientBrush)DataGridHeaderBorder.GetCachedFreezable(0);
                if (linearGradientBrush == null)
                {
                    linearGradientBrush            = new LinearGradientBrush();
                    linearGradientBrush.StartPoint = new Point();
                    linearGradientBrush.EndPoint   = new Point(0.0, 1.0);
                    linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.0));
                    linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.4));
                    linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)252, (byte)252, (byte)253), 0.4));
                    linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)251, (byte)252, (byte)252), 1.0));
                    linearGradientBrush.Freeze();
                    DataGridHeaderBorder.CacheFreezable((Freezable)linearGradientBrush, 0);
                }
                dc.DrawRectangle((Brush)linearGradientBrush, (Pen)null, new Rect(0.0, 0.0, renderSize.Width, renderSize.Height));
            }
            DataGridHeaderBorder.AeroFreezables aeroFreezables1 = DataGridHeaderBorder.AeroFreezables.NormalBackground;
            if (flag4)
            {
                aeroFreezables1 = DataGridHeaderBorder.AeroFreezables.PressedBackground;
            }
            else if (flag3)
            {
                aeroFreezables1 = DataGridHeaderBorder.AeroFreezables.HoveredBackground;
            }
            else if (hasValue || isSelected)
            {
                aeroFreezables1 = DataGridHeaderBorder.AeroFreezables.SortedBackground;
            }
            LinearGradientBrush linearGradientBrush1 = (LinearGradientBrush)DataGridHeaderBorder.GetCachedFreezable((int)aeroFreezables1);

            if (linearGradientBrush1 == null)
            {
                linearGradientBrush1            = new LinearGradientBrush();
                linearGradientBrush1.StartPoint = new Point();
                linearGradientBrush1.EndPoint   = new Point(0.0, 1.0);
                switch (aeroFreezables1)
                {
                case DataGridHeaderBorder.AeroFreezables.NormalBackground:
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.0));
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.4));
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)247, (byte)248, (byte)250), 0.4));
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)241, (byte)242, (byte)244), 1.0));
                    break;

                case DataGridHeaderBorder.AeroFreezables.PressedBackground:
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)188, (byte)228, (byte)249), 0.0));
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)188, (byte)228, (byte)249), 0.4));
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)141, (byte)214, (byte)247), 0.4));
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)138, (byte)209, (byte)245), 1.0));
                    break;

                case DataGridHeaderBorder.AeroFreezables.HoveredBackground:
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)227, (byte)247, byte.MaxValue), 0.0));
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)227, (byte)247, byte.MaxValue), 0.4));
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)189, (byte)237, byte.MaxValue), 0.4));
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)183, (byte)231, (byte)251), 1.0));
                    break;

                case DataGridHeaderBorder.AeroFreezables.SortedBackground:
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)242, (byte)249, (byte)252), 0.0));
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)242, (byte)249, (byte)252), 0.4));
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)225, (byte)241, (byte)249), 0.4));
                    linearGradientBrush1.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)216, (byte)236, (byte)246), 1.0));
                    break;
                }
                linearGradientBrush1.Freeze();
                DataGridHeaderBorder.CacheFreezable((Freezable)linearGradientBrush1, (int)aeroFreezables1);
            }
            dc.DrawRectangle((Brush)linearGradientBrush1, (Pen)null, new Rect(0.0, 0.0, renderSize.Width, renderSize.Height));
            if (renderSize.Width >= 2.0)
            {
                DataGridHeaderBorder.AeroFreezables aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.NormalSides;
                if (flag4)
                {
                    aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.PressedSides;
                }
                else if (flag3)
                {
                    aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.HoveredSides;
                }
                else if (hasValue || isSelected)
                {
                    aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.SortedSides;
                }
                if (this.SeparatorVisibility == Visibility.Visible)
                {
                    Brush brush;
                    if (this.SeparatorBrush != null)
                    {
                        brush = this.SeparatorBrush;
                    }
                    else
                    {
                        brush = (Brush)DataGridHeaderBorder.GetCachedFreezable((int)aeroFreezables2);
                        if (brush == null)
                        {
                            LinearGradientBrush linearGradientBrush2 = (LinearGradientBrush)null;
                            if (aeroFreezables2 != DataGridHeaderBorder.AeroFreezables.SortedSides)
                            {
                                linearGradientBrush2            = new LinearGradientBrush();
                                linearGradientBrush2.StartPoint = new Point();
                                linearGradientBrush2.EndPoint   = new Point(0.0, 1.0);
                                brush = (Brush)linearGradientBrush2;
                            }
                            switch (aeroFreezables2 - 6)
                            {
                            case DataGridHeaderBorder.AeroFreezables.NormalBevel:
                                linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)242, (byte)242, (byte)242), 0.0));
                                linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)239, (byte)239, (byte)239), 0.4));
                                linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)231, (byte)232, (byte)234), 0.4));
                                linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)222, (byte)223, (byte)225), 1.0));
                                break;

                            case DataGridHeaderBorder.AeroFreezables.NormalBackground:
                                linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)122, (byte)158, (byte)177), 0.0));
                                linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)122, (byte)158, (byte)177), 0.4));
                                linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)80, (byte)145, (byte)175), 0.4));
                                linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)77, (byte)141, (byte)173), 1.0));
                                break;

                            case DataGridHeaderBorder.AeroFreezables.PressedBackground:
                                linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)136, (byte)203, (byte)235), 0.0));
                                linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)136, (byte)203, (byte)235), 0.4));
                                linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)105, (byte)187, (byte)227), 0.4));
                                linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)105, (byte)187, (byte)227), 1.0));
                                break;

                            case DataGridHeaderBorder.AeroFreezables.HoveredBackground:
                                brush = (Brush) new SolidColorBrush(Color.FromArgb(byte.MaxValue, (byte)150, (byte)217, (byte)249));
                                break;
                            }
                            brush.Freeze();
                            DataGridHeaderBorder.CacheFreezable((Freezable)brush, (int)aeroFreezables2);
                        }
                    }
                    dc.DrawRectangle(brush, (Pen)null, new Rect(0.0, 0.0, 1.0, DataGridHeaderBorder.Max0(renderSize.Height - 0.95)));
                    dc.DrawRectangle(brush, (Pen)null, new Rect(renderSize.Width - 1.0, 0.0, 1.0, DataGridHeaderBorder.Max0(renderSize.Height - 0.95)));
                }
            }
            if (flag4 && renderSize.Width >= 4.0 && renderSize.Height >= 4.0)
            {
                LinearGradientBrush linearGradientBrush2 = (LinearGradientBrush)DataGridHeaderBorder.GetCachedFreezable(5);
                if (linearGradientBrush2 == null)
                {
                    linearGradientBrush2            = new LinearGradientBrush();
                    linearGradientBrush2.StartPoint = new Point();
                    linearGradientBrush2.EndPoint   = new Point(0.0, 1.0);
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)134, (byte)163, (byte)178), 0.0));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)134, (byte)163, (byte)178), 0.1));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)170, (byte)206, (byte)225), 0.9));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)170, (byte)206, (byte)225), 1.0));
                    linearGradientBrush2.Freeze();
                    DataGridHeaderBorder.CacheFreezable((Freezable)linearGradientBrush2, 5);
                }
                dc.DrawRectangle((Brush)linearGradientBrush2, (Pen)null, new Rect(0.0, 0.0, renderSize.Width, 2.0));
                LinearGradientBrush linearGradientBrush3 = (LinearGradientBrush)DataGridHeaderBorder.GetCachedFreezable(10);
                if (linearGradientBrush3 == null)
                {
                    linearGradientBrush3            = new LinearGradientBrush();
                    linearGradientBrush3.StartPoint = new Point();
                    linearGradientBrush3.EndPoint   = new Point(0.0, 1.0);
                    linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)162, (byte)203, (byte)224), 0.0));
                    linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)162, (byte)203, (byte)224), 0.4));
                    linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)114, (byte)188, (byte)223), 0.4));
                    linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)110, (byte)184, (byte)220), 1.0));
                    linearGradientBrush3.Freeze();
                    DataGridHeaderBorder.CacheFreezable((Freezable)linearGradientBrush3, 10);
                }
                dc.DrawRectangle((Brush)linearGradientBrush3, (Pen)null, new Rect(1.0, 0.0, 1.0, renderSize.Height - 0.95));
                dc.DrawRectangle((Brush)linearGradientBrush3, (Pen)null, new Rect(renderSize.Width - 2.0, 0.0, 1.0, renderSize.Height - 0.95));
            }
            if (renderSize.Height >= 2.0)
            {
                DataGridHeaderBorder.AeroFreezables aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.NormalBottom;
                if (flag4)
                {
                    aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.PressedOrHoveredBottom;
                }
                else if (flag3)
                {
                    aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.PressedOrHoveredBottom;
                }
                else if (hasValue || isSelected)
                {
                    aeroFreezables2 = DataGridHeaderBorder.AeroFreezables.SortedBottom;
                }
                SolidColorBrush solidColorBrush = (SolidColorBrush)DataGridHeaderBorder.GetCachedFreezable((int)aeroFreezables2);
                if (solidColorBrush == null)
                {
                    switch (aeroFreezables2)
                    {
                    case DataGridHeaderBorder.AeroFreezables.NormalBottom:
                        solidColorBrush = new SolidColorBrush(Color.FromArgb(byte.MaxValue, (byte)213, (byte)213, (byte)213));
                        break;

                    case DataGridHeaderBorder.AeroFreezables.PressedOrHoveredBottom:
                        solidColorBrush = new SolidColorBrush(Color.FromArgb(byte.MaxValue, (byte)147, (byte)201, (byte)227));
                        break;

                    case DataGridHeaderBorder.AeroFreezables.SortedBottom:
                        solidColorBrush = new SolidColorBrush(Color.FromArgb(byte.MaxValue, (byte)150, (byte)217, (byte)249));
                        break;
                    }
                    solidColorBrush.Freeze();
                    DataGridHeaderBorder.CacheFreezable((Freezable)solidColorBrush, (int)aeroFreezables2);
                }
                dc.DrawRectangle((Brush)solidColorBrush, (Pen)null, new Rect(0.0, renderSize.Height - 1.0, renderSize.Width, 1.0));
            }
            if (hasValue && renderSize.Width > 14.0 && renderSize.Height > 10.0)
            {
                TranslateTransform translateTransform = new TranslateTransform((renderSize.Width - 8.0) * 0.5, 1.0);
                translateTransform.Freeze();
                dc.PushTransform((Transform)translateTransform);
                ListSortDirection?nullable = sortDirection;
                bool         flag6         = nullable.GetValueOrDefault() == ListSortDirection.Ascending && nullable.HasValue;
                PathGeometry pathGeometry  = (PathGeometry)DataGridHeaderBorder.GetCachedFreezable(flag6 ? 17 : 18);
                if (pathGeometry == null)
                {
                    pathGeometry = new PathGeometry();
                    PathFigure pathFigure = new PathFigure();
                    if (flag6)
                    {
                        pathFigure.StartPoint = new Point(0.0, 4.0);
                        LineSegment lineSegment1 = new LineSegment(new Point(4.0, 0.0), false);
                        lineSegment1.Freeze();
                        pathFigure.Segments.Add((PathSegment)lineSegment1);
                        LineSegment lineSegment2 = new LineSegment(new Point(8.0, 4.0), false);
                        lineSegment2.Freeze();
                        pathFigure.Segments.Add((PathSegment)lineSegment2);
                    }
                    else
                    {
                        pathFigure.StartPoint = new Point(0.0, 0.0);
                        LineSegment lineSegment1 = new LineSegment(new Point(8.0, 0.0), false);
                        lineSegment1.Freeze();
                        pathFigure.Segments.Add((PathSegment)lineSegment1);
                        LineSegment lineSegment2 = new LineSegment(new Point(4.0, 4.0), false);
                        lineSegment2.Freeze();
                        pathFigure.Segments.Add((PathSegment)lineSegment2);
                    }
                    pathFigure.IsClosed = true;
                    pathFigure.Freeze();
                    pathGeometry.Figures.Add(pathFigure);
                    pathGeometry.Freeze();
                    DataGridHeaderBorder.CacheFreezable((Freezable)pathGeometry, flag6 ? 17 : 18);
                }
                LinearGradientBrush linearGradientBrush2 = (LinearGradientBrush)DataGridHeaderBorder.GetCachedFreezable(14);
                if (linearGradientBrush2 == null)
                {
                    linearGradientBrush2            = new LinearGradientBrush();
                    linearGradientBrush2.StartPoint = new Point();
                    linearGradientBrush2.EndPoint   = new Point(1.0, 1.0);
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)60, (byte)94, (byte)114), 0.0));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)60, (byte)94, (byte)114), 0.1));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)195, (byte)228, (byte)245), 1.0));
                    linearGradientBrush2.Freeze();
                    DataGridHeaderBorder.CacheFreezable((Freezable)linearGradientBrush2, 14);
                }
                dc.DrawGeometry((Brush)linearGradientBrush2, (Pen)null, (Geometry)pathGeometry);
                LinearGradientBrush linearGradientBrush3 = (LinearGradientBrush)DataGridHeaderBorder.GetCachedFreezable(15);
                if (linearGradientBrush3 == null)
                {
                    linearGradientBrush3            = new LinearGradientBrush();
                    linearGradientBrush3.StartPoint = new Point();
                    linearGradientBrush3.EndPoint   = new Point(1.0, 1.0);
                    linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)97, (byte)150, (byte)182), 0.0));
                    linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)97, (byte)150, (byte)182), 0.1));
                    linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, (byte)202, (byte)230, (byte)245), 1.0));
                    linearGradientBrush3.Freeze();
                    DataGridHeaderBorder.CacheFreezable((Freezable)linearGradientBrush3, 15);
                }
                ScaleTransform scaleTransform = (ScaleTransform)DataGridHeaderBorder.GetCachedFreezable(16);
                if (scaleTransform == null)
                {
                    scaleTransform = new ScaleTransform(0.75, 0.75, 3.5, 4.0);
                    scaleTransform.Freeze();
                    DataGridHeaderBorder.CacheFreezable((Freezable)scaleTransform, 16);
                }
                dc.PushTransform((Transform)scaleTransform);
                dc.DrawGeometry((Brush)linearGradientBrush3, (Pen)null, (Geometry)pathGeometry);
                dc.Pop();
                dc.Pop();
            }
            if (!flag1)
            {
                return;
            }
            dc.Pop();
        }
Beispiel #22
0
        private void RenderTheme(DrawingContext dc)
        {
            Size renderSize = base.RenderSize;
            bool flag       = Orientation == Orientation.Horizontal;
            bool flag2      = IsClickable && base.IsEnabled;
            bool flag3      = flag2 && IsHovered;
            bool flag4      = flag2 && IsPressed;
            ListSortDirection?sortDirection = SortDirection;
            bool hasValue   = sortDirection.HasValue;
            bool isSelected = IsSelected;
            bool flag5      = !flag3 && !flag4 && !hasValue && !isSelected;

            EnsureCache(19);
            if (flag)
            {
                Matrix trans = default(Matrix);
                trans.RotateAt(-90.0, 0.0, 0.0);
                Matrix trans2 = default(Matrix);
                trans2.Translate(0.0, renderSize.Height);
                MatrixTransform matrixTransform = new MatrixTransform(trans * trans2);
                matrixTransform.Freeze();
                dc.PushTransform(matrixTransform);
                double width = renderSize.Width;
                renderSize.Width  = renderSize.Height;
                renderSize.Height = width;
            }
            if (flag5)
            {
                LinearGradientBrush linearGradientBrush = (LinearGradientBrush)GetCachedFreezable(0);
                if (linearGradientBrush == null)
                {
                    linearGradientBrush            = new LinearGradientBrush();
                    linearGradientBrush.StartPoint = default(Point);
                    linearGradientBrush.EndPoint   = new Point(0.0, 1.0);
                    linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.0));
                    linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.4));
                    linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 252, 252, 253), 0.4));
                    linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 251, 252, 252), 1.0));
                    linearGradientBrush.Freeze();
                    CacheFreezable(linearGradientBrush, 0);
                }
                dc.DrawRectangle(linearGradientBrush, null, new Rect(0.0, 0.0, renderSize.Width, renderSize.Height));
            }
            AeroFreezables aeroFreezables = AeroFreezables.NormalBackground;

            if (flag4)
            {
                aeroFreezables = AeroFreezables.PressedBackground;
            }
            else if (flag3)
            {
                aeroFreezables = AeroFreezables.HoveredBackground;
            }
            else if (hasValue | isSelected)
            {
                aeroFreezables = AeroFreezables.SortedBackground;
            }
            LinearGradientBrush linearGradientBrush2 = (LinearGradientBrush)GetCachedFreezable((int)aeroFreezables);

            if (linearGradientBrush2 == null)
            {
                linearGradientBrush2            = new LinearGradientBrush();
                linearGradientBrush2.StartPoint = default(Point);
                linearGradientBrush2.EndPoint   = new Point(0.0, 1.0);
                switch (aeroFreezables)
                {
                case AeroFreezables.NormalBackground:
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.0));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), 0.4));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 247, 248, 250), 0.4));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 241, 242, 244), 1.0));
                    break;

                case AeroFreezables.PressedBackground:
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 188, 228, 249), 0.0));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 188, 228, 249), 0.4));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 141, 214, 247), 0.4));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 138, 209, 245), 1.0));
                    break;

                case AeroFreezables.HoveredBackground:
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 227, 247, byte.MaxValue), 0.0));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 227, 247, byte.MaxValue), 0.4));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 189, 237, byte.MaxValue), 0.4));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 183, 231, 251), 1.0));
                    break;

                case AeroFreezables.SortedBackground:
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 242, 249, 252), 0.0));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 242, 249, 252), 0.4));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 225, 241, 249), 0.4));
                    linearGradientBrush2.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 216, 236, 246), 1.0));
                    break;
                }
                linearGradientBrush2.Freeze();
                CacheFreezable(linearGradientBrush2, (int)aeroFreezables);
            }
            dc.DrawRectangle(linearGradientBrush2, null, new Rect(0.0, 0.0, renderSize.Width, renderSize.Height));
            if (renderSize.Width >= 2.0)
            {
                AeroFreezables aeroFreezables2 = AeroFreezables.NormalSides;
                if (flag4)
                {
                    aeroFreezables2 = AeroFreezables.PressedSides;
                }
                else if (flag3)
                {
                    aeroFreezables2 = AeroFreezables.HoveredSides;
                }
                else if (hasValue | isSelected)
                {
                    aeroFreezables2 = AeroFreezables.SortedSides;
                }
                if (SeparatorVisibility == Visibility.Visible)
                {
                    Brush brush;
                    if (SeparatorBrush != null)
                    {
                        brush = SeparatorBrush;
                    }
                    else
                    {
                        brush = (Brush)GetCachedFreezable((int)aeroFreezables2);
                        if (brush == null)
                        {
                            LinearGradientBrush linearGradientBrush3 = null;
                            if (aeroFreezables2 != AeroFreezables.SortedSides)
                            {
                                linearGradientBrush3            = new LinearGradientBrush();
                                linearGradientBrush3.StartPoint = default(Point);
                                linearGradientBrush3.EndPoint   = new Point(0.0, 1.0);
                                brush = linearGradientBrush3;
                            }
                            switch (aeroFreezables2)
                            {
                            case AeroFreezables.NormalSides:
                                linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 242, 242, 242), 0.0));
                                linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 239, 239, 239), 0.4));
                                linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 231, 232, 234), 0.4));
                                linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 222, 223, 225), 1.0));
                                break;

                            case AeroFreezables.PressedSides:
                                linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 122, 158, 177), 0.0));
                                linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 122, 158, 177), 0.4));
                                linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 80, 145, 175), 0.4));
                                linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 77, 141, 173), 1.0));
                                break;

                            case AeroFreezables.HoveredSides:
                                linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 136, 203, 235), 0.0));
                                linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 136, 203, 235), 0.4));
                                linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 105, 187, 227), 0.4));
                                linearGradientBrush3.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 105, 187, 227), 1.0));
                                break;

                            case AeroFreezables.SortedSides:
                                brush = new SolidColorBrush(Color.FromArgb(byte.MaxValue, 150, 217, 249));
                                break;
                            }
                            brush.Freeze();
                            CacheFreezable(brush, (int)aeroFreezables2);
                        }
                    }
                    dc.DrawRectangle(brush, null, new Rect(0.0, 0.0, 1.0, Max0(renderSize.Height - 0.95)));
                    dc.DrawRectangle(brush, null, new Rect(renderSize.Width - 1.0, 0.0, 1.0, Max0(renderSize.Height - 0.95)));
                }
            }
            if (flag4 && renderSize.Width >= 4.0 && renderSize.Height >= 4.0)
            {
                LinearGradientBrush linearGradientBrush4 = (LinearGradientBrush)GetCachedFreezable(5);
                if (linearGradientBrush4 == null)
                {
                    linearGradientBrush4            = new LinearGradientBrush();
                    linearGradientBrush4.StartPoint = default(Point);
                    linearGradientBrush4.EndPoint   = new Point(0.0, 1.0);
                    linearGradientBrush4.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 134, 163, 178), 0.0));
                    linearGradientBrush4.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 134, 163, 178), 0.1));
                    linearGradientBrush4.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 170, 206, 225), 0.9));
                    linearGradientBrush4.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 170, 206, 225), 1.0));
                    linearGradientBrush4.Freeze();
                    CacheFreezable(linearGradientBrush4, 5);
                }
                dc.DrawRectangle(linearGradientBrush4, null, new Rect(0.0, 0.0, renderSize.Width, 2.0));
                LinearGradientBrush linearGradientBrush5 = (LinearGradientBrush)GetCachedFreezable(10);
                if (linearGradientBrush5 == null)
                {
                    linearGradientBrush5            = new LinearGradientBrush();
                    linearGradientBrush5.StartPoint = default(Point);
                    linearGradientBrush5.EndPoint   = new Point(0.0, 1.0);
                    linearGradientBrush5.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 162, 203, 224), 0.0));
                    linearGradientBrush5.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 162, 203, 224), 0.4));
                    linearGradientBrush5.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 114, 188, 223), 0.4));
                    linearGradientBrush5.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 110, 184, 220), 1.0));
                    linearGradientBrush5.Freeze();
                    CacheFreezable(linearGradientBrush5, 10);
                }
                dc.DrawRectangle(linearGradientBrush5, null, new Rect(1.0, 0.0, 1.0, renderSize.Height - 0.95));
                dc.DrawRectangle(linearGradientBrush5, null, new Rect(renderSize.Width - 2.0, 0.0, 1.0, renderSize.Height - 0.95));
            }
            if (renderSize.Height >= 2.0)
            {
                AeroFreezables aeroFreezables3 = AeroFreezables.NormalBottom;
                if (flag4)
                {
                    aeroFreezables3 = AeroFreezables.PressedOrHoveredBottom;
                }
                else if (flag3)
                {
                    aeroFreezables3 = AeroFreezables.PressedOrHoveredBottom;
                }
                else if (hasValue | isSelected)
                {
                    aeroFreezables3 = AeroFreezables.SortedBottom;
                }
                SolidColorBrush solidColorBrush = (SolidColorBrush)GetCachedFreezable((int)aeroFreezables3);
                if (solidColorBrush == null)
                {
                    switch (aeroFreezables3)
                    {
                    case AeroFreezables.NormalBottom:
                        solidColorBrush = new SolidColorBrush(Color.FromArgb(byte.MaxValue, 213, 213, 213));
                        break;

                    case AeroFreezables.PressedOrHoveredBottom:
                        solidColorBrush = new SolidColorBrush(Color.FromArgb(byte.MaxValue, 147, 201, 227));
                        break;

                    case AeroFreezables.SortedBottom:
                        solidColorBrush = new SolidColorBrush(Color.FromArgb(byte.MaxValue, 150, 217, 249));
                        break;
                    }
                    solidColorBrush.Freeze();
                    CacheFreezable(solidColorBrush, (int)aeroFreezables3);
                }
                dc.DrawRectangle(solidColorBrush, null, new Rect(0.0, renderSize.Height - 1.0, renderSize.Width, 1.0));
            }
            if (hasValue && renderSize.Width > 14.0 && renderSize.Height > 10.0)
            {
                TranslateTransform translateTransform = new TranslateTransform((renderSize.Width - 8.0) * 0.5, 1.0);
                translateTransform.Freeze();
                dc.PushTransform(translateTransform);
                bool         flag6        = sortDirection == ListSortDirection.Ascending;
                PathGeometry pathGeometry = (PathGeometry)GetCachedFreezable(flag6 ? 17 : 18);
                if (pathGeometry == null)
                {
                    pathGeometry = new PathGeometry();
                    PathFigure pathFigure = new PathFigure();
                    if (flag6)
                    {
                        pathFigure.StartPoint = new Point(0.0, 4.0);
                        LineSegment lineSegment = new LineSegment(new Point(4.0, 0.0), false);
                        lineSegment.Freeze();
                        pathFigure.Segments.Add(lineSegment);
                        lineSegment = new LineSegment(new Point(8.0, 4.0), false);
                        lineSegment.Freeze();
                        pathFigure.Segments.Add(lineSegment);
                    }
                    else
                    {
                        pathFigure.StartPoint = new Point(0.0, 0.0);
                        LineSegment lineSegment2 = new LineSegment(new Point(8.0, 0.0), false);
                        lineSegment2.Freeze();
                        pathFigure.Segments.Add(lineSegment2);
                        lineSegment2 = new LineSegment(new Point(4.0, 4.0), false);
                        lineSegment2.Freeze();
                        pathFigure.Segments.Add(lineSegment2);
                    }
                    pathFigure.IsClosed = true;
                    pathFigure.Freeze();
                    pathGeometry.Figures.Add(pathFigure);
                    pathGeometry.Freeze();
                    CacheFreezable(pathGeometry, flag6 ? 17 : 18);
                }
                LinearGradientBrush linearGradientBrush6 = (LinearGradientBrush)GetCachedFreezable(14);
                if (linearGradientBrush6 == null)
                {
                    linearGradientBrush6            = new LinearGradientBrush();
                    linearGradientBrush6.StartPoint = default(Point);
                    linearGradientBrush6.EndPoint   = new Point(1.0, 1.0);
                    linearGradientBrush6.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 60, 94, 114), 0.0));
                    linearGradientBrush6.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 60, 94, 114), 0.1));
                    linearGradientBrush6.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 195, 228, 245), 1.0));
                    linearGradientBrush6.Freeze();
                    CacheFreezable(linearGradientBrush6, 14);
                }
                dc.DrawGeometry(linearGradientBrush6, null, pathGeometry);
                LinearGradientBrush linearGradientBrush7 = (LinearGradientBrush)GetCachedFreezable(15);
                if (linearGradientBrush7 == null)
                {
                    linearGradientBrush7            = new LinearGradientBrush();
                    linearGradientBrush7.StartPoint = default(Point);
                    linearGradientBrush7.EndPoint   = new Point(1.0, 1.0);
                    linearGradientBrush7.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 97, 150, 182), 0.0));
                    linearGradientBrush7.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 97, 150, 182), 0.1));
                    linearGradientBrush7.GradientStops.Add(new GradientStop(Color.FromArgb(byte.MaxValue, 202, 230, 245), 1.0));
                    linearGradientBrush7.Freeze();
                    CacheFreezable(linearGradientBrush7, 15);
                }
                ScaleTransform scaleTransform = (ScaleTransform)GetCachedFreezable(16);
                if (scaleTransform == null)
                {
                    scaleTransform = new ScaleTransform(0.75, 0.75, 3.5, 4.0);
                    scaleTransform.Freeze();
                    CacheFreezable(scaleTransform, 16);
                }
                dc.PushTransform(scaleTransform);
                dc.DrawGeometry(linearGradientBrush7, null, pathGeometry);
                dc.Pop();
                dc.Pop();
            }
            if (flag)
            {
                dc.Pop();
            }
        }