Smrf.NodeXL.ExcelTemplate.LayoutUserSettingsDialog.DoDataExchange C# (CSharp) Method

DoDataExchange() protected method

protected DoDataExchange ( Boolean bFromControls ) : Boolean
bFromControls Boolean
return Boolean
    DoDataExchange
    (
        Boolean bFromControls
    )
    {
        if (bFromControls)
        {
            Int32 iMargin, iFruchtermanReingoldIterations;
            Single fFruchtermanReingoldC;

            if (
                !ValidateNumericUpDown(nudMargin,
                    "a graph margin", out iMargin)
                ||
                !ValidateNumericUpDown(nudFruchtermanReingoldC,
                    "a strength", out fFruchtermanReingoldC)
                ||
                !ValidateNumericUpDown(nudFruchtermanReingoldIterations,
                    "an iteration count", out iFruchtermanReingoldIterations)
                )
            {
                return (false);
            }

            if (radLayoutStyleNormal.Checked)
            {
                m_oLayoutUserSettings.LayoutStyle = LayoutStyle.Normal;
            }
            else if (radLayoutStyleUseGroups.Checked)
            {
                Int32 iGroupRectanglePenWidth;

                if (!ValidateNumericUpDown(nudGroupRectanglePenWidth,
                        "a box outline width", out iGroupRectanglePenWidth))
                {
                    return (false);
                }

                m_oLayoutUserSettings.LayoutStyle = LayoutStyle.UseGroups;

                m_oLayoutUserSettings.GroupRectanglePenWidth =
                    (Double)nudGroupRectanglePenWidth.Value;

                m_oLayoutUserSettings.BoxLayoutAlgorithm =
                    (BoxLayoutAlgorithm)
                    cbxBoxLayoutAlgorithm.SelectedValue;

                m_oLayoutUserSettings.IntergroupEdgeStyle =
                    (IntergroupEdgeStyle)
                    cbxIntergroupEdgeStyle.SelectedValue;

                m_oLayoutUserSettings.ImproveLayoutOfGroups =
                    chkImproveLayoutOfGroups.Checked;
            }
            else
            {
                Int32 iMaximumVerticesPerBin, iBinLength;

                if (
                    !ValidateNumericUpDown(nudMaximumVerticesPerBin,
                        "a maximum component size", out iMaximumVerticesPerBin)
                    ||
                    !ValidateNumericUpDown(nudBinLength,
                        "a box size", out iBinLength)
                    )
                {
                    return (false);
                }

                m_oLayoutUserSettings.LayoutStyle = LayoutStyle.UseBinning;

                m_oLayoutUserSettings.MaximumVerticesPerBin =
                    iMaximumVerticesPerBin;

                m_oLayoutUserSettings.BinLength = iBinLength;
            }

            m_oLayoutUserSettings.Margin = iMargin;
            m_oLayoutUserSettings.FruchtermanReingoldC = fFruchtermanReingoldC;

            m_oLayoutUserSettings.FruchtermanReingoldIterations =
                iFruchtermanReingoldIterations;
        }
        else
        {
            nudMargin.Value = m_oLayoutUserSettings.Margin;

            switch (m_oLayoutUserSettings.LayoutStyle)
            {
                case LayoutStyle.Normal:

                    radLayoutStyleNormal.Checked = true;
                    break;

                case LayoutStyle.UseGroups:

                    radLayoutStyleUseGroups.Checked = true;
                    break;

                case LayoutStyle.UseBinning:

                    radLayoutStyleUseBinning.Checked = true;
                    break;

                default:

                    Debug.Assert(false);
                    break;
            }

            nudGroupRectanglePenWidth.Value =
                       (Decimal)m_oLayoutUserSettings.GroupRectanglePenWidth;
            
            cbxBoxLayoutAlgorithm.SelectedValue =
                m_oLayoutUserSettings.BoxLayoutAlgorithm;

            cbxIntergroupEdgeStyle.SelectedValue =
                m_oLayoutUserSettings.IntergroupEdgeStyle;

            chkImproveLayoutOfGroups.Checked =
                m_oLayoutUserSettings.ImproveLayoutOfGroups;

            nudMaximumVerticesPerBin.Value =
                m_oLayoutUserSettings.MaximumVerticesPerBin;

            nudBinLength.Value = m_oLayoutUserSettings.BinLength;

            nudFruchtermanReingoldC.Value =
                (Decimal)m_oLayoutUserSettings.FruchtermanReingoldC;

            nudFruchtermanReingoldIterations.Value =
                m_oLayoutUserSettings.FruchtermanReingoldIterations;

            EnableControls();
        }

        return (true);
    }