コード例 #1
0
    bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
    {
        switch (drawPhase)
        {
        case DrawPhase.BeforeDrawImage:
            ImageUIElement imageElement    = (ImageUIElement)drawParams.Element;
            Image          image           = imageElement.Image;
            int            availableHeight = drawParams.Element.RectInsideBorders.Height;
            float          ratio           = (float)availableHeight / (float)image.Height;
            float          newHeight       = image.Height * ratio;
            float          newWidth        = image.Width * ratio;
            Rectangle      rect            = new Rectangle(
                imageElement.Rect.X,
                imageElement.Rect.Y,
                (int)(newWidth),
                (int)(newHeight)

                );
            // Draw the scaled image.
            drawParams.Graphics.DrawImage(image, rect);
            // This tells the grid not to draw the image (since we've already drawn it).
            return(true);
        }
        return(false);
    }
コード例 #2
0
 /// <summary>
 /// Called after an element's ChildElements have been
 /// created. The child element's can be repositioned here
 /// and/or new element's can be added.
 /// </summary>
 /// <param name="parent">The <see cref="T:Infragistics.Win.UIElement" /> whose child elements have been created/positioned.</param>
 /// <exception cref="System.NotImplementedException"></exception>
 public void AfterCreateChildElements(UIElement parent)
 {
     if (parent is MoreActivityIndicatorUIElement)
     {
         ImageUIElement imageElement = parent.GetDescendant(typeof(ImageUIElement)) as ImageUIElement;
         if (imageElement != null)
         {
             imageElement.Image = Properties.Resources.MoreActivityIndicator_Down;
         }
     }
 }