in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

Gauge Sizing

Last post 9/8/2008 12:44 PM by Dmitry G (Developer Express). 3 replies.
Page 1 of 1 (4 items)
Sort Posts:
Previous Next
  • 9/5/2008 11:54 AM

    Gauge Sizing

    I'm experimenting with the gauges and I need a little help when it comes to getting them sized properly.

    Some of the gauges seem to resize differently than others.   If I add a standard Digital gauge or a LinearHorizontal gauge, then shrink its vertical size, the top and bottom whitespace (margins) disappear the way I would expect.  However, when I add a CircularWide gauge, I would expect that sizing it vertically would remove the whitespace, but it instead sizes the whole gauge.

    The result is when I create some gauges in a standard box size, they are the size I expect, filling the box, while other types of gauges in that same box size are really tiny.

    gauges.png

    How would I fix this?

     

  • 9/8/2008 4:18 AM In reply to

    Re: Gauge Sizing

    Hello Brandon!

      Currently, this Auto-Layout feature mechanism behavior is by default.
    Each gauge is positioned within a specific layout area - cell, which has its own relative coordinate system. Layout cells have some real bounds within the gauge control. For most gauge types, a cell's relative width and height are fixed, and these values are dependant upon the gauge type. Note that these values do not depend upon the real bounds of a cell. For circular gauges, a cell has the same width and height.

    Related help-topics:
      Coordinate System
      Auto-Layout Feature

    P.S. I have registered suggestion S30556 (Improve the auto-layout feature: arrange gauges based on its actual bounds) and we'll consider introducing this capability in the future.

    Thanks, Dmitry

    R&D, .NET Team
    Developer Express Inc.
  • 9/8/2008 9:55 AM In reply to

    Re: Gauge Sizing

    Do you know of a quick work-around that I could do to simulate this behavior?  I tried turning off auto layout and setting the Y to a negative number and the height to a value larger than the Control's height to negate the effect of the whitespace margin around the gauge.  It works but it is difficult and unreliable (I can set it at design time by manually guessing the coordinates but the gauge can't resize with the form).

    Gauge

    Thanks

  • 9/8/2008 12:44 PM In reply to

    Re: Gauge Sizing

    To simulate expected behaviour set the AutoLayout property to false and use the Resize event of GaugeControl:

    using System;
    using System.Drawing;
    using System.Windows.Forms;

    namespace GaugeResizeApp {
      public partial class TestForm : Form {
        public TestForm() {
            InitializeComponent();
            gaugeControl1.Resize += OnGaugeControlResize;
            OnGaugeControlResize(null, EventArgs.Empty);
        }
        void OnGaugeControlResize(object sender, EventArgs e) {
            RectangleF bounds = CalcGaugeBounds(
                  gaugeControl1.ClientRectangle, new SizeF(250f, 106f), new SizeF(15f, 15f)
              );
           gaugeControl1.Gauges[0].Bounds = Rectangle.Round(bounds);
        }
        //
        readonly float DefaultLayoutCellSize = 250f;
        protected RectangleF CalcGaugeBounds(RectangleF layoutArea, SizeF gaugeSize, SizeF spacing) {
            RectangleF contentRect = new RectangleF(
                 spacing.Width, spacing.Height,
                 layoutArea.Width - spacing.Width * 2, layoutArea.Height - spacing.Height * 2
              );
            float layoutCellSize = Math.Max(contentRect.Width, contentRect.Height);
            SizeF absoluteCellSize = new SizeF(
                  layoutCellSize * DefaultLayoutCellSize / gaugeSize.Width,
                  layoutCellSize * DefaultLayoutCellSize / gaugeSize.Height
              );
            return new RectangleF(
                  contentRect.Left + (contentRect.Width - absoluteCellSize.Width) * 0.5f,
                  contentRect.Top + (contentRect.Height - absoluteCellSize.Height) * 0.5f,
                  absoluteCellSize.Width,
                  absoluteCellSize.Height
              );
            }
        }
    }

    Thanks, Dmitry

    R&D, .NET Team
    Developer Express Inc.
Page 1 of 1 (4 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED