示例#1
0
        AutoFillNumericComparisonColumn
        (
            ListObject oTable,
            String sSourceColumnName,
            String sDestinationColumnName,
            NumericComparisonColumnAutoFillUserSettings oDetails
        )
        {
            Debug.Assert(oTable != null);
            Debug.Assert(!String.IsNullOrEmpty(sDestinationColumnName));
            Debug.Assert(oDetails != null);

            if (String.IsNullOrEmpty(sSourceColumnName))
            {
                return;
            }

            TableColumnMapper.MapToTwoStrings(
                oTable, sSourceColumnName, sDestinationColumnName,
                oDetails.ComparisonOperator,
                oDetails.SourceNumberToCompareTo,
                oDetails.DestinationString1,
                oDetails.DestinationString2
                );
        }
        ConvertTo
        (
            ITypeDescriptorContext context,
            CultureInfo culture,
            Object value,
            Type destinationType
        )
        {
            Debug.Assert(value != null);
            Debug.Assert(value is NumericComparisonColumnAutoFillUserSettings);
            Debug.Assert(destinationType == typeof(String));
            AssertValid();

            NumericComparisonColumnAutoFillUserSettings
                oNumericComparisonColumnAutoFillUserSettings =
                (NumericComparisonColumnAutoFillUserSettings)value;

            // Use a simple tab-delimited format.  Sample string:
            //
            // "GreaterThan\t0\tDV1\tDV2"

            return(String.Format(CultureInfo.InvariantCulture,

                                 "{0}\t{1}\t{2}\t{3}"
                                 ,
                                 oNumericComparisonColumnAutoFillUserSettings.ComparisonOperator,

                                 oNumericComparisonColumnAutoFillUserSettings.
                                 SourceNumberToCompareTo,

                                 oNumericComparisonColumnAutoFillUserSettings.DestinationString1,
                                 oNumericComparisonColumnAutoFillUserSettings.DestinationString2
                                 ));
        }
        //*************************************************************************
        //  Constructor: NumericComparisonColumnAutoFillUserSettingsDialog()
        //
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="NumericComparisonColumnAutoFillUserSettingsDialog" /> class.
        /// </summary>
        ///
        /// <param name="numericComparisonColumnAutoFillUserSettings">
        /// Object to edit.
        /// </param>
        ///
        /// <param name="populateComboBox">
        /// Method that populates a ComboBox with strings.
        /// </param>
        ///
        /// <param name="columnDescription">
        /// Description of the column that is being autofilled.  Sample: "Edge
        /// Visibility".
        /// </param>
        //*************************************************************************

        public NumericComparisonColumnAutoFillUserSettingsDialog
        (
            NumericComparisonColumnAutoFillUserSettings
            numericComparisonColumnAutoFillUserSettings,

            ComboBoxPopulator populateComboBox,
            String columnDescription
        )
        {
            Debug.Assert(numericComparisonColumnAutoFillUserSettings != null);
            Debug.Assert(populateComboBox != null);
            Debug.Assert(!String.IsNullOrEmpty(columnDescription));

            InitializeComponent();

            m_oNumericComparisonColumnAutoFillUserSettings =
                numericComparisonColumnAutoFillUserSettings;

            this.Text = String.Format(this.Text, columnDescription);

            cbxComparisonOperator.PopulateWithObjectsAndText(
                ComparisonOperator.LessThan, "Less than",
                ComparisonOperator.LessThanOrEqual, "Less than or equal to",
                ComparisonOperator.Equal, "Equal to",
                ComparisonOperator.NotEqual, "Not equal to",
                ComparisonOperator.GreaterThan, "Greater than",
                ComparisonOperator.GreaterThanOrEqual, "Greater than or equal to"
                );

            String sColumnDescriptionLower = columnDescription.ToLower();

            lblDestination1.Text = String.Format(lblDestination1.Text,
                                                 sColumnDescriptionLower);

            chkDestination2.Text = String.Format(chkDestination2.Text,
                                                 sColumnDescriptionLower);

            populateComboBox(cbxDestination1);
            populateComboBox(cbxDestination2);

            // Instantiate an object that saves and retrieves the position of this
            // dialog.  Note that the object automatically saves the settings when
            // the form closes.

            m_oNumericComparisonColumnAutoFillUserSettingsDialogUserSettings =
                new NumericComparisonColumnAutoFillUserSettingsDialogUserSettings(
                    this);

            DoDataExchange(false);

            AssertValid();
        }
    //*************************************************************************
    //  Constructor: NumericComparisonColumnAutoFillUserSettingsDialog()
    //
    /// <summary>
    /// Initializes a new instance of the <see
    /// cref="NumericComparisonColumnAutoFillUserSettingsDialog" /> class.
    /// </summary>
    ///
    /// <param name="numericComparisonColumnAutoFillUserSettings">
    /// Object to edit.
    /// </param>
    ///
    /// <param name="populateComboBox">
    /// Method that populates a ComboBox with strings.
    /// </param>
    ///
    /// <param name="columnDescription">
    /// Description of the column that is being autofilled.  Sample: "Edge
    /// Visibility".
    /// </param>
    //*************************************************************************

    public NumericComparisonColumnAutoFillUserSettingsDialog
    (
        NumericComparisonColumnAutoFillUserSettings
            numericComparisonColumnAutoFillUserSettings,

        ComboBoxPopulator populateComboBox,
        String columnDescription
    )
    {
        Debug.Assert(numericComparisonColumnAutoFillUserSettings != null);
        Debug.Assert(populateComboBox != null);
        Debug.Assert( !String.IsNullOrEmpty(columnDescription) );

        InitializeComponent();

        m_oNumericComparisonColumnAutoFillUserSettings =
            numericComparisonColumnAutoFillUserSettings;

        this.Text = String.Format(this.Text, columnDescription);

        cbxComparisonOperator.PopulateWithObjectsAndText(
            ComparisonOperator.LessThan, "Less than",
            ComparisonOperator.LessThanOrEqual, "Less than or equal to",
            ComparisonOperator.Equal, "Equal to",
            ComparisonOperator.NotEqual, "Not equal to",
            ComparisonOperator.GreaterThan, "Greater than",
            ComparisonOperator.GreaterThanOrEqual, "Greater than or equal to"
            );

        String sColumnDescriptionLower = columnDescription.ToLower();

        lblDestination1.Text = String.Format(lblDestination1.Text,
            sColumnDescriptionLower);

        chkDestination2.Text = String.Format(chkDestination2.Text,
            sColumnDescriptionLower);

        populateComboBox(cbxDestination1);
        populateComboBox(cbxDestination2);

        // Instantiate an object that saves and retrieves the position of this
        // dialog.  Note that the object automatically saves the settings when
        // the form closes.

        m_oNumericComparisonColumnAutoFillUserSettingsDialogUserSettings =
            new NumericComparisonColumnAutoFillUserSettingsDialogUserSettings(
                this);

        DoDataExchange(false);

        AssertValid();
    }
        ConvertFrom
        (
            ITypeDescriptorContext context,
            CultureInfo culture,
            Object value
        )
        {
            Debug.Assert(value != null);
            Debug.Assert(value is String);
            AssertValid();

            NumericComparisonColumnAutoFillUserSettings
                oNumericComparisonColumnAutoFillUserSettings =
                new NumericComparisonColumnAutoFillUserSettings();

            String [] asStrings = ((String)value).Split(new Char[] { '\t' });

            Debug.Assert(asStrings.Length == 4);

            oNumericComparisonColumnAutoFillUserSettings.ComparisonOperator =
                (ComparisonOperator)Enum.Parse(
                    typeof(ComparisonOperator), asStrings[0]);

            oNumericComparisonColumnAutoFillUserSettings.SourceNumberToCompareTo =
                MathUtil.ParseCultureInvariantDouble(asStrings[1]);

            oNumericComparisonColumnAutoFillUserSettings.DestinationString1 =
                asStrings[2];

            String sDestinationString2 = asStrings[3];

            oNumericComparisonColumnAutoFillUserSettings.DestinationString2 =
                String.IsNullOrEmpty(sDestinationString2) ? null
            : sDestinationString2;

            return(oNumericComparisonColumnAutoFillUserSettings);
        }
    ConvertFrom
    (
        ITypeDescriptorContext context,
        CultureInfo culture,
        Object value
    )
    {
        Debug.Assert(value != null);
        Debug.Assert(value is String);
        AssertValid();

        NumericComparisonColumnAutoFillUserSettings
            oNumericComparisonColumnAutoFillUserSettings =
            new NumericComparisonColumnAutoFillUserSettings();

        String [] asStrings = ( (String)value ).Split( new Char[] {'\t'} );

        Debug.Assert(asStrings.Length == 4);

        oNumericComparisonColumnAutoFillUserSettings.ComparisonOperator =
            (ComparisonOperator)Enum.Parse(
                typeof(ComparisonOperator), asStrings[0] );

        oNumericComparisonColumnAutoFillUserSettings.SourceNumberToCompareTo =
            MathUtil.ParseCultureInvariantDouble( asStrings[1] );

        oNumericComparisonColumnAutoFillUserSettings.DestinationString1 =
            asStrings[2];

        String sDestinationString2 = asStrings[3];

        oNumericComparisonColumnAutoFillUserSettings.DestinationString2 =
            String.IsNullOrEmpty(sDestinationString2) ? null
            : sDestinationString2;

        return (oNumericComparisonColumnAutoFillUserSettings);
    }
    AutoFillNumericComparisonColumn
    (
        ListObject oTable,
        String sSourceColumnName,
        String sDestinationColumnName,
        NumericComparisonColumnAutoFillUserSettings oDetails
    )
    {
        Debug.Assert(oTable != null);
        Debug.Assert( !String.IsNullOrEmpty(sDestinationColumnName) );
        Debug.Assert(oDetails != null);

        if ( String.IsNullOrEmpty(sSourceColumnName) )
        {
            return;
        }

        TableColumnMapper.MapToTwoStrings(
            oTable, sSourceColumnName, sDestinationColumnName,
            oDetails.ComparisonOperator,
            oDetails.SourceNumberToCompareTo,
            oDetails.DestinationString1,
            oDetails.DestinationString2
            );
    }