Exemplo n.º 1
0
        /// <summary>
        /// Internal method that applies a previously set layout with a rows per column or
        /// columns per row configuration.  This method is only called by
        /// <see cref="DoLayout(Graphics,MasterPane)" />.
        /// </summary>
        internal void DoLayout( Graphics g, MasterPane master, bool isColumnSpecified, int[] countList,
            float[] proportion)
        {
            // calculate scaleFactor on "normal" pane size (BaseDimension)
            float scaleFactor = master.CalcScaleFactor();

            // innerRect is the area for the GraphPane's
            RectangleF innerRect = master.CalcClientRect( g, scaleFactor );
            master.Legend.CalcRect( g, master, scaleFactor, ref innerRect );

            // scaled InnerGap is the area between the GraphPane.Rect's
            float scaledInnerGap = (float)( master._innerPaneGap * scaleFactor );

            int iPane = 0;

            if ( isColumnSpecified )
            {
                int rows = countList.Length;

                float y = 0.0f;

                for ( int rowNum = 0; rowNum < rows; rowNum++ )
                {
                    float propFactor = _prop == null ? 1.0f / rows : _prop[rowNum];

                    float height = ( innerRect.Height - (float)( rows - 1 ) * scaledInnerGap ) *
                                    propFactor;

                    int columns = countList[rowNum];
                    if ( columns <= 0 )
                        columns = 1;
                    float width = ( innerRect.Width - (float)( columns - 1 ) * scaledInnerGap ) /
                                    (float)columns;

                    if ( iPane >= master._paneList.Count )
                        return;

                    for ( int colNum = 0; colNum < columns; colNum++ )
                    {
                        master[iPane].Rect = new RectangleF(
                                            innerRect.X + colNum * ( width + scaledInnerGap ),
                                            innerRect.Y + y,
                                            width,
                                            height );
                        iPane++;
                    }

                    y += height + scaledInnerGap;
                }
            }
            else
            {
                int columns = countList.Length;

                float x = 0.0f;

                for ( int colNum = 0; colNum < columns; colNum++ )
                {
                    float propFactor = _prop == null ? 1.0f / columns : _prop[colNum];

                    float width = ( innerRect.Width - (float)( columns - 1 ) * scaledInnerGap ) *
                                    propFactor;

                    int rows = countList[colNum];
                    if ( rows <= 0 )
                        rows = 1;
                    float height = ( innerRect.Height - (float)( rows - 1 ) * scaledInnerGap ) / (float)rows;

                    for ( int rowNum = 0; rowNum < rows; rowNum++ )
                    {
                        if ( iPane >= master._paneList.Count )
                            return;

                        master[iPane].Rect = new RectangleF(
                                            innerRect.X + x,
                                            innerRect.Y + rowNum * ( height + scaledInnerGap ),
                                            width,
                                            height );
                        iPane++;
                    }

                    x += width + scaledInnerGap;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Internal method that applies a previously set layout with a rows per column or
        /// columns per row configuration.  This method is only called by
        /// <see cref="DoLayout(Graphics,MasterPane)" />.
        /// </summary>
        internal void DoLayout(Graphics g, MasterPane master, bool isColumnSpecified, int[] countList,
                               float[] proportion)
        {
            // calculate scaleFactor on "normal" pane size (BaseDimension)
            float scaleFactor = master.CalcScaleFactor();

            // innerRect is the area for the GraphPane's
            RectangleF innerRect = master.CalcClientRect(g, scaleFactor);

            master.Legend.CalcRect(g, master, scaleFactor, ref innerRect);

            // scaled InnerGap is the area between the GraphPane.Rect's
            float scaledInnerGap = (float)(master._innerPaneGap * scaleFactor);

            int iPane = 0;

            if (isColumnSpecified)
            {
                int rows = countList.Length;

                float y = 0.0f;

                for (int rowNum = 0; rowNum < rows; rowNum++)
                {
                    float propFactor = _prop == null ? 1.0f / rows : _prop[rowNum];

                    float height = (innerRect.Height - (float)(rows - 1) * scaledInnerGap) *
                                   propFactor;

                    int columns = countList[rowNum];
                    if (columns <= 0)
                    {
                        columns = 1;
                    }
                    float width = (innerRect.Width - (float)(columns - 1) * scaledInnerGap) /
                                  (float)columns;

                    if (iPane >= master._paneList.Count)
                    {
                        return;
                    }

                    for (int colNum = 0; colNum < columns; colNum++)
                    {
                        master[iPane].Rect = new RectangleF(
                            innerRect.X + colNum * (width + scaledInnerGap),
                            innerRect.Y + y,
                            width,
                            height);
                        iPane++;
                    }

                    y += height + scaledInnerGap;
                }
            }
            else
            {
                int columns = countList.Length;

                float x = 0.0f;

                for (int colNum = 0; colNum < columns; colNum++)
                {
                    float propFactor = _prop == null ? 1.0f / columns : _prop[colNum];

                    float width = (innerRect.Width - (float)(columns - 1) * scaledInnerGap) *
                                  propFactor;

                    int rows = countList[colNum];
                    if (rows <= 0)
                    {
                        rows = 1;
                    }
                    float height = (innerRect.Height - (float)(rows - 1) * scaledInnerGap) / (float)rows;

                    for (int rowNum = 0; rowNum < rows; rowNum++)
                    {
                        if (iPane >= master._paneList.Count)
                        {
                            return;
                        }

                        master[iPane].Rect = new RectangleF(
                            innerRect.X + x,
                            innerRect.Y + rowNum * (height + scaledInnerGap),
                            width,
                            height);
                        iPane++;
                    }

                    x += width + scaledInnerGap;
                }
            }
        }