示例#1
0
        /// <summary>
        /// When overridden in a derived class, measures the size in layout required for child elements and determines a size for the <see cref="T:System.Windows.FrameworkElement" />-derived class.
        /// </summary>
        /// <param name="availableSize">The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.</param>
        /// <returns>The size that this element determines it needs during layout, based on its calculations of child element sizes.</returns>
        protected override Size MeasureOverride(Size availableSize)
        {
            if (HeaderRenderer == null)
            {
                HeaderRenderer = new TabItemsHeaderRenderer();
            }

            var widest            = 0d;
            var tallest           = 0d;
            var availableItemSize = HeaderRenderer.GetClientRect(this, availableSize).Size;

            foreach (var element in Children.OfType <UIElement>().Where(e => e.Visibility == Visibility.Visible))
            {
                element.Measure(availableItemSize);
                widest  = Math.Max(widest, element.DesiredSize.Width);
                tallest = Math.Max(tallest, element.DesiredSize.Height);
            }

            base.MeasureOverride(availableSize);

            if (!double.IsInfinity(availableSize.Width) && !double.IsInfinity(availableSize.Height))
            {
                return(availableSize);
            }
            return(new Size(widest, tallest));
        }
示例#2
0
        /// <summary>
        /// Draws the content of a <see cref="T:System.Windows.Media.DrawingContext" /> object during the render pass of a <see cref="T:System.Windows.Controls.Panel" /> element.
        /// </summary>
        /// <param name="dc">The <see cref="T:System.Windows.Media.DrawingContext" /> object to draw.</param>
        protected override void OnRender(DrawingContext dc)
        {
            base.OnRender(dc);

            if (HeaderRenderer == null)
            {
                HeaderRenderer = new TabItemsHeaderRenderer();
            }
            HeaderRenderer.Render(dc, this);
        }
示例#3
0
        /// <summary>
        /// Invoked when an unhandled <see cref="E:System.Windows.UIElement.MouseLeftButtonDown" /> routed event is raised on this element. Implement this method to add class handling for this event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs" /> that contains the event data. The event data reports that the left mouse button was pressed.</param>
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if (HeaderRenderer == null)
            {
                HeaderRenderer = new TabItemsHeaderRenderer();
            }
            var position = e.GetPosition(this);

            HeaderRenderer.MouseClick(position, e, this);
            base.OnMouseLeftButtonDown(e);
        }
        /// <summary>
        /// Invoked when an unhandled Mouse Down attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs" /> that contains the event data. This event data reports details about the mouse button that was pressed and the handled state.</param>
        protected override void OnMouseDown(MouseButtonEventArgs e)
        {
            if (HeaderRenderer != null)
            {
                if (HeaderRenderer.Click(e.GetPosition(this), _currentPrimaryArea, _currentSecondaryArea, this))
                {
                    e.Handled = true;
                    return;
                }
            }

            base.OnMouseDown(e);
        }
 public GameProcessor(IEnumerable <IProcessor> processors, ImageConverter imageConverter,
                      MusicConverter musicConverter,
                      HeaderRenderer headerRenderer,
                      IWriter writer, ItemManager items, BobConverter bobConverter, SpriteRenderer spriteRenderer)
 {
     _processors     = processors;
     _imageConverter = imageConverter;
     _musicConverter = musicConverter;
     _headerRenderer = headerRenderer;
     _writer         = writer;
     _items          = items;
     _bobConverter   = bobConverter;
     _spriteRenderer = spriteRenderer;
 }
示例#6
0
        /// <summary>
        /// When overridden in a derived class, positions child elements and determines a size for a <see cref="T:System.Windows.FrameworkElement" /> derived class.
        /// </summary>
        /// <param name="finalSize">The final area within the parent that this element should use to arrange itself and its children.</param>
        /// <returns>The actual size used.</returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            if (HeaderRenderer == null)
            {
                HeaderRenderer = new TabItemsHeaderRenderer();
            }
            var clientRect = HeaderRenderer.GetClientRect(this, finalSize);

            foreach (var element in Children.OfType <UIElement>().Where(e => e.Visibility == Visibility.Visible))
            {
                element.Arrange(clientRect);
            }
            base.ArrangeOverride(finalSize);
            return(clientRect.Size);
        }
        /// <summary>
        /// Draws the content of a <see cref="T:System.Windows.Media.DrawingContext" /> object during the render pass of a <see cref="T:System.Windows.Controls.Panel" /> element.
        /// </summary>
        /// <param name="dc">The <see cref="T:System.Windows.Media.DrawingContext" /> object to draw.</param>
        protected override void OnRender(DrawingContext dc)
        {
            base.OnRender(dc);

            if (PrimaryAreaBackground != null)
            {
                dc.DrawRectangle(PrimaryAreaBackground, null, new Rect(_currentPrimaryArea.X, 0, _currentPrimaryArea.Width, ActualHeight));
            }
            if (SecondaryAreaBackground != null)
            {
                dc.DrawRectangle(SecondaryAreaBackground, null, new Rect(_currentSecondaryArea.X, 0, _currentSecondaryArea.Width, ActualHeight));
            }

            if (HeaderRenderer != null)
            {
                HeaderRenderer.Render(dc, _currentPrimaryArea, _currentSecondaryArea, this);
            }
        }
示例#8
0
        /// <summary>
        /// Draws the content of a <see cref="T:System.Windows.Media.DrawingContext"/> object during the render pass of a <see cref="T:System.Windows.Controls.Panel"/> element.
        /// </summary>
        /// <param name="dc">The <see cref="T:System.Windows.Media.DrawingContext"/> object to draw.</param>
        protected override void OnRender(DrawingContext dc)
        {
            base.OnRender(dc);

            if (!RenderHeaders)
            {
                return;
            }

            if (HeaderRenderer == null)
            {
                HeaderRenderer = new AutoLayoutHeaderRenderer();
            }

            var offset = new Point();

            foreach (var header in _headers)
            {
                HeaderRenderer.RenderHeader(dc, header, 1d, offset);
            }
        }
示例#9
0
    public TitleStrip()
    {
        // Check Dock
        this.Dock      = DockStyle.Top;
        this.GripStyle = ToolStripGripStyle.Hidden;

        // Set renderer
        _renderer = new HeaderRenderer();

        // Look for headerText
        // Add children
        _headerText = new ToolStripLabel();

        // Add Label and Image
        _headerText.DisplayStyle = ToolStripItemDisplayStyle.Text;
        _headerText.Text         = "[Enter Text]";

        this.Items.AddRange(new ToolStripItem[] { _headerText });

        // Hook Draw Events
        this.Renderer = _renderer;
    }
 /// <summary>
 /// When overridden in a derived class, positions child elements and determines a size for a <see cref="T:System.Windows.FrameworkElement" /> derived class.
 /// </summary>
 /// <param name="finalSize">The final area within the parent that this element should use to arrange itself and its children.</param>
 /// <returns>The actual size used.</returns>
 protected override Size ArrangeOverride(Size finalSize)
 {
     foreach (UIElement element in Children)
     {
         if (SimpleView.GetUIElementType(element) == UIElementTypes.Primary)
         {
             if (CanCollapseSecondary && IsSecondaryElementCollapsed)
             {
                 var minimumCollapsedWidth = 0d;
                 var mainAreaLeft          = 0d;
                 if (HeaderRenderer != null)
                 {
                     minimumCollapsedWidth = HeaderRenderer.GetMinimumCollapsedAreaWidth(this);
                     if (SecondaryAreaLocation == SecondaryAreaLocation.Left)
                     {
                         mainAreaLeft = minimumCollapsedWidth + (minimumCollapsedWidth > 0d ? ElementSpacing : 0d);
                     }
                 }
                 var primaryArea = new Rect(mainAreaLeft, 0d, finalSize.Width - minimumCollapsedWidth - (minimumCollapsedWidth > 0d ? ElementSpacing : 0d), finalSize.Height);
                 if (HeaderRenderer != null)
                 {
                     primaryArea = HeaderRenderer.GetPrimaryClientArea(primaryArea, this);
                 }
                 _currentPrimaryArea = primaryArea;
                 element.Arrange(primaryArea);
             }
             else
             {
                 var currentX = 0d;
                 if (SecondaryAreaLocation == SecondaryAreaLocation.Left)
                 {
                     currentX = SecondaryElementWidth + ElementSpacing;
                 }
                 var primaryArea = new Rect(currentX, 0d, Math.Max(finalSize.Width - SecondaryElementWidth - ElementSpacing, 0), finalSize.Height);
                 if (HeaderRenderer != null)
                 {
                     primaryArea = HeaderRenderer.GetPrimaryClientArea(primaryArea, this);
                 }
                 _currentPrimaryArea = primaryArea;
                 element.Arrange(primaryArea);
             }
         }
         else
         {
             if (CanCollapseSecondary && IsSecondaryElementCollapsed)
             {
                 _currentSecondaryArea = new Rect(-100000d, -100000d, 0d, finalSize.Height);
                 element.Arrange(_currentSecondaryArea);
             }
             else
             {
                 var secondaryArea = SecondaryAreaLocation == SecondaryAreaLocation.Left ? new Rect(0d, 0d, SecondaryElementWidth, finalSize.Height) : new Rect(finalSize.Width - SecondaryElementWidth, 0d, SecondaryElementWidth, finalSize.Height);
                 if (HeaderRenderer != null)
                 {
                     secondaryArea = HeaderRenderer.GetSecondaryClientArea(secondaryArea, this);
                 }
                 _currentSecondaryArea = secondaryArea;
                 element.Arrange(secondaryArea);
             }
         }
     }
     return(base.ArrangeOverride(finalSize));
 }
        /// <summary>
        /// When overridden in a derived class, measures the size in layout required for child elements and determines a size for the <see cref="T:System.Windows.FrameworkElement" />-derived class.
        /// </summary>
        /// <param name="availableSize">The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.</param>
        /// <returns>The size that this element determines it needs during layout, based on its calculations of child element sizes.</returns>
        protected override Size MeasureOverride(Size availableSize)
        {
            if (HeaderRenderer == null)
            {
                HeaderRenderer = new StandardPrimarySecondaryHorizontalPanelHeaderRenderer();
            }

            foreach (UIElement element in Children)
            {
                if (SimpleView.GetUIElementType(element) == UIElementTypes.Primary)
                {
                    if (CanCollapseSecondary && IsSecondaryElementCollapsed)
                    {
                        var minimumCollapsedWidth = 0d;
                        var mainAreaLeft          = 0d;
                        if (HeaderRenderer != null)
                        {
                            minimumCollapsedWidth = HeaderRenderer.GetMinimumCollapsedAreaWidth(this);
                            if (SecondaryAreaLocation == SecondaryAreaLocation.Left)
                            {
                                mainAreaLeft = minimumCollapsedWidth + (minimumCollapsedWidth > 0d ? ElementSpacing : 0d);
                            }
                        }
                        var primaryArea = new Rect(mainAreaLeft, 0d, availableSize.Width - minimumCollapsedWidth - (minimumCollapsedWidth > 0d ? ElementSpacing : 0d), availableSize.Height);
                        if (HeaderRenderer != null)
                        {
                            primaryArea = HeaderRenderer.GetPrimaryClientArea(primaryArea, this);
                        }
                        element.Measure(primaryArea.Size);
                    }
                    else
                    {
                        var currentX = 0d;
                        if (SecondaryAreaLocation == SecondaryAreaLocation.Left)
                        {
                            currentX = SecondaryElementWidth + ElementSpacing;
                        }
                        var primaryArea = new Rect(currentX, 0d, Math.Max(availableSize.Width - SecondaryElementWidth - ElementSpacing, 0), availableSize.Height);
                        if (HeaderRenderer != null)
                        {
                            primaryArea = HeaderRenderer.GetPrimaryClientArea(primaryArea, this);
                        }
                        element.Measure(primaryArea.Size);
                    }
                }
                else
                {
                    if (CanCollapseSecondary && IsSecondaryElementCollapsed)
                    {
                        element.Measure(new Size(0, availableSize.Height));
                    }
                    else
                    {
                        var secondaryArea = SecondaryAreaLocation == SecondaryAreaLocation.Left ? new Rect(0d, 0d, SecondaryElementWidth, availableSize.Height) : new Rect(availableSize.Width - SecondaryElementWidth, 0d, SecondaryElementWidth, availableSize.Height);
                        if (HeaderRenderer != null)
                        {
                            secondaryArea = HeaderRenderer.GetSecondaryClientArea(secondaryArea, this);
                        }
                        element.Measure(secondaryArea.Size);
                    }
                }
            }
            return(base.MeasureOverride(availableSize));
        }