Exemplo n.º 1
0
        protected virtual void ApplyIconChange()
        {
            this.ApplyTemplate();
            IconMockupBase chrome = this.FindObject(this, "IconMockupChrome") as IconMockupBase;

            if (chrome != null)
            {
                Style style = IconMockup.GetIconImageResource(this.IconImage) as Style;

                if (style != null)
                {
                    chrome.Style = style;
                }

                this.OriginLocation  = chrome.OriginLocation;
                this.OverlayLocation = chrome.OverlayLocation;
            }
        }
Exemplo n.º 2
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            FrameworkElement placementGrid = this.GetTemplateChild("PlacementGrid") as FrameworkElement;
            IconMockup       cursorImage   = this.GetTemplateChild("cursorImage") as IconMockup;

            if (placementGrid != null && cursorImage != null)
            {
                double translateX = 0.0;
                double translateY = 0.0;

                switch (cursorImage.OriginLocation)
                {
                case OriginLocation.Left:
                case OriginLocation.TopLeft:
                case OriginLocation.BottomLeft:
                    translateX = 0;
                    break;

                case OriginLocation.Right:
                case OriginLocation.TopRight:
                case OriginLocation.BottomRight:
                    translateX = -finalSize.Width;
                    break;

                case OriginLocation.Top:
                case OriginLocation.Bottom:
                case OriginLocation.Center:
                default:
                    translateX = -finalSize.Width / 2;
                    break;
                }

                switch (cursorImage.OriginLocation)
                {
                case OriginLocation.Top:
                case OriginLocation.TopLeft:
                case OriginLocation.TopRight:
                    translateY = 0;
                    break;

                case OriginLocation.Bottom:
                case OriginLocation.BottomLeft:
                case OriginLocation.BottomRight:
                    translateY = -finalSize.Height;
                    break;

                case OriginLocation.Left:
                case OriginLocation.Right:
                case OriginLocation.Center:
                default:
                    translateY = -finalSize.Height / 2;
                    break;
                }

                TranslateTransform transform = placementGrid.RenderTransform as TranslateTransform;
                if (transform == null)
                {
                    transform = new TranslateTransform();
                    placementGrid.RenderTransform = transform;
                }

                transform.X = translateX;
                transform.Y = translateY;

                FrameworkElement highlightsGrid = this.GetTemplateChild("HighlightsGrid") as FrameworkElement;
                if (highlightsGrid != null)
                {
                    TranslateTransform highlightsTransform = highlightsGrid.RenderTransform as TranslateTransform;
                    if (highlightsTransform == null)
                    {
                        highlightsTransform            = new TranslateTransform();
                        highlightsGrid.RenderTransform = highlightsTransform;
                    }

                    highlightsTransform.X = -finalSize.Width / 2 - translateX;
                    highlightsTransform.Y = -finalSize.Height / 2 - translateY;
                }

                IconMockup cursorOverlay = this.GetTemplateChild("cursorOverlay") as IconMockup;
                if (cursorOverlay != null && cursorOverlay.IconImage != IconImage.None)
                {
                    TranslateTransform overlayTransform = cursorOverlay.RenderTransform as TranslateTransform;
                    if (overlayTransform == null)
                    {
                        overlayTransform = new TranslateTransform();
                        cursorOverlay.RenderTransform = overlayTransform;
                    }

                    overlayTransform.X = cursorImage.OverlayLocation.X * finalSize.Width;
                    overlayTransform.Y = cursorImage.OverlayLocation.Y * finalSize.Height;
                }
            }

            return(base.ArrangeOverride(finalSize));
        }