Esempio n. 1
0
        //*************************************************************************
        //  Constructor: NumericRangeColumnAutoFillUserSettingsDialog()
        //
        /// <overloads>
        /// Initializes a new instance of the <see
        /// cref="NumericRangeColumnAutoFillUserSettingsDialog" /> class.
        /// </overloads>
        ///
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="NumericRangeColumnAutoFillUserSettingsDialog" /> class with a
        /// <see cref="NumericRangeColumnAutoFillUserSettings" /> object.
        /// </summary>
        ///
        /// <param name="numericRangeColumnAutoFillUserSettings">
        /// Object to edit.
        /// </param>
        ///
        /// <param name="dialogCaption">
        /// Dialog caption.
        /// </param>
        ///
        /// <param name="destinationColumnName">
        /// The name of the destination column, suitable for use as the placeholder
        /// in DestinationLabel1 and DestinationLabel2.  Can't be null or empty.
        /// Sample: "vertex opacity".
        /// </param>
        ///
        /// <param name="destinationColumnNamePlural">
        /// Plural and possibly abbreviated form of <paramref
        /// name="destinationColumnName" />, suitable for use as the placeholder in
        /// the "swap destination numbers" button.  Can't be null or empty.
        /// Sample: "Opacities".
        /// </param>
        ///
        /// <param name="minimumDestinationNumber">
        /// Minimum value of a cell in the destination column.
        /// </param>
        ///
        /// <param name="maximumDestinationNumber">
        /// Maximum value of a cell in the destination column.
        /// </param>
        //*************************************************************************

        public NumericRangeColumnAutoFillUserSettingsDialog
        (
            NumericRangeColumnAutoFillUserSettings
            numericRangeColumnAutoFillUserSettings,

            String dialogCaption,
            String destinationColumnName,
            String destinationColumnNamePlural,
            Double minimumDestinationNumber,
            Double maximumDestinationNumber
        )
            : this()
        {
            Debug.Assert(numericRangeColumnAutoFillUserSettings != null);
            Debug.Assert(!String.IsNullOrEmpty(dialogCaption));
            Debug.Assert(!String.IsNullOrEmpty(destinationColumnName));
            Debug.Assert(!String.IsNullOrEmpty(destinationColumnNamePlural));

            m_oNumericRangeColumnAutoFillUserSettings =
                numericRangeColumnAutoFillUserSettings;

            this.Text = dialogCaption;

            lblDestinationNumber1.Text = String.Format(
                DestinationLabel1
                ,
                destinationColumnName
                );

            lblDestinationNumber2.Text = String.Format(
                DestinationLabel2
                ,
                destinationColumnName
                );

            nudDestinationNumber1.Minimum = nudDestinationNumber2.Minimum =
                (Decimal)minimumDestinationNumber;

            nudDestinationNumber1.Maximum = nudDestinationNumber2.Maximum =
                (Decimal)maximumDestinationNumber;

            btnSwapDestinationNumbers.Text = "<- Swap " +
                                             destinationColumnNamePlural + " ->";

            // 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_oNumericRangeColumnAutoFillUserSettingsDialogUserSettings =
                new NumericRangeColumnAutoFillUserSettingsDialogUserSettings(this);

            DoDataExchange(false);

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

            NumericRangeColumnAutoFillUserSettings
                oNumericRangeColumnAutoFillUserSettings =
                new NumericRangeColumnAutoFillUserSettings();

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

            Debug.Assert(asStrings.Length >= 7);

            oNumericRangeColumnAutoFillUserSettings.UseSourceNumber1 =
                Boolean.Parse(asStrings[0]);

            oNumericRangeColumnAutoFillUserSettings.UseSourceNumber2 =
                Boolean.Parse(asStrings[1]);

            oNumericRangeColumnAutoFillUserSettings.SourceNumber1 =
                MathUtil.ParseCultureInvariantDouble(asStrings[2]);

            oNumericRangeColumnAutoFillUserSettings.SourceNumber2 =
                MathUtil.ParseCultureInvariantDouble(asStrings[3]);

            oNumericRangeColumnAutoFillUserSettings.DestinationNumber1 =
                MathUtil.ParseCultureInvariantDouble(asStrings[4]);

            oNumericRangeColumnAutoFillUserSettings.DestinationNumber2 =
                MathUtil.ParseCultureInvariantDouble(asStrings[5]);

            oNumericRangeColumnAutoFillUserSettings.IgnoreOutliers =
                Boolean.Parse(asStrings[6]);

            // The UseLogs property wasn't added until NodeXL version 1.0.1.92.

            oNumericRangeColumnAutoFillUserSettings.UseLogs =
                (asStrings.Length > 7) ? Boolean.Parse(asStrings[7]) : false;

            return(oNumericRangeColumnAutoFillUserSettings);
        }
Esempio n. 3
0
        TryAutoFillNumericRangeColumn
        (
            ListObject oTable,
            String sSourceColumnName,
            String sDestinationColumnName,
            NumericRangeColumnAutoFillUserSettings oDetails,
            out Double dSourceCalculationNumber1,
            out Double dSourceCalculationNumber2,
            out Int32 iDecimalPlaces
        )
        {
            Debug.Assert(oTable != null);
            Debug.Assert(!String.IsNullOrEmpty(sDestinationColumnName));
            Debug.Assert(oDetails != null);

            dSourceCalculationNumber1 = dSourceCalculationNumber2 =
                Double.MinValue;

            iDecimalPlaces = Int32.MinValue;

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

            return(TableColumnMapper.TryMapToNumericRange(
                       oTable, sSourceColumnName, sDestinationColumnName,
                       oDetails.UseSourceNumber1,
                       oDetails.UseSourceNumber2,
                       oDetails.SourceNumber1,
                       oDetails.SourceNumber2,
                       oDetails.DestinationNumber1,
                       oDetails.DestinationNumber2,
                       oDetails.IgnoreOutliers,
                       oDetails.UseLogs,
                       out dSourceCalculationNumber1,
                       out dSourceCalculationNumber2,
                       out iDecimalPlaces
                       ));
        }
        ConvertTo
        (
            ITypeDescriptorContext context,
            CultureInfo culture,
            Object value,
            Type destinationType
        )
        {
            Debug.Assert(value != null);
            Debug.Assert(value is NumericRangeColumnAutoFillUserSettings);
            Debug.Assert(destinationType == typeof(String));
            AssertValid();

            NumericRangeColumnAutoFillUserSettings
                oNumericRangeColumnAutoFillUserSettings =
                (NumericRangeColumnAutoFillUserSettings)value;

            // Use a simple tab-delimited format.  Sample string:
            //
            // "false\tfalse\t0\t10\t0\t10\tfalse\tfalse"
            //
            // WARNING: If this format is changed, you must also change the
            // DefaultSettingValueAttribute for each property in the
            // AutoFillUserSettings class that is of type
            // NumericRangeColumnAutoFillUserSettings.

            return(String.Format(CultureInfo.InvariantCulture,

                                 "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}"
                                 ,
                                 oNumericRangeColumnAutoFillUserSettings.UseSourceNumber1,
                                 oNumericRangeColumnAutoFillUserSettings.UseSourceNumber2,
                                 oNumericRangeColumnAutoFillUserSettings.SourceNumber1,
                                 oNumericRangeColumnAutoFillUserSettings.SourceNumber2,
                                 oNumericRangeColumnAutoFillUserSettings.DestinationNumber1,
                                 oNumericRangeColumnAutoFillUserSettings.DestinationNumber2,
                                 oNumericRangeColumnAutoFillUserSettings.IgnoreOutliers,
                                 oNumericRangeColumnAutoFillUserSettings.UseLogs
                                 ));
        }
Esempio n. 5
0
        //*************************************************************************
        //  Method: TryAutoFillNumericRangeColumn()
        //
        /// <summary>
        /// Runs the application's AutoFill feature on a destination column that
        /// should contain a numeric range.
        /// </summary>
        ///
        /// <param name="oTable">
        /// The table containing the source and destination columns.
        /// </param>
        ///
        /// <param name="sSourceColumnName">
        /// Name of the source column.  If null or empty, this method does nothing.
        /// </param>
        ///
        /// <param name="sDestinationColumnName">
        /// Name of the destination column.
        /// </param>
        ///
        /// <param name="oDetails">
        /// User-specified details for the destination column.
        /// </param>
        ///
        /// <param name="dSourceCalculationNumber1">
        /// Where the actual first source number used in the calculations gets
        /// stored if true is returned.
        /// </param>
        ///
        /// <param name="dSourceCalculationNumber2">
        /// Where the actual second source number used in the calculations gets
        /// stored if true is returned.
        /// </param>
        ///
        /// <param name="iDecimalPlaces">
        /// Where the number of decimal places displayed in the column gets stored.
        /// </param>
        ///
        /// <returns>
        /// true if the autofill was performed.
        /// </returns>
        //*************************************************************************
        private static Boolean TryAutoFillNumericRangeColumn(
            ListObject oTable,
            String sSourceColumnName,
            String sDestinationColumnName,
            NumericRangeColumnAutoFillUserSettings oDetails,
            out Double dSourceCalculationNumber1,
            out Double dSourceCalculationNumber2,
            out Int32 iDecimalPlaces
            )
        {
            Debug.Assert(oTable != null);
            Debug.Assert( !String.IsNullOrEmpty(sDestinationColumnName) );
            Debug.Assert(oDetails != null);

            dSourceCalculationNumber1 = dSourceCalculationNumber2 =
            Double.MinValue;

            iDecimalPlaces = Int32.MinValue;

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

            return (TableColumnMapper.TryMapToNumericRange(
            oTable, sSourceColumnName, sDestinationColumnName,
            oDetails.UseSourceNumber1,
            oDetails.UseSourceNumber2,
            oDetails.SourceNumber1,
            oDetails.SourceNumber2,
            oDetails.DestinationNumber1,
            oDetails.DestinationNumber2,
            oDetails.IgnoreOutliers,
            oDetails.UseLogs,
            out dSourceCalculationNumber1,
            out dSourceCalculationNumber2,
            out iDecimalPlaces
            ) );
        }
        //*************************************************************************
        //  Method: ConvertFrom()
        //
        /// <summary>
        /// Converts the given object to the type of this converter, using the
        /// specified context and culture information.
        /// </summary>
        ///
        /// <param name="context">
        /// An ITypeDescriptorContext that provides a format context. 
        /// </param>
        ///
        /// <param name="culture">
        /// A CultureInfo. If null is passed, the current culture is assumed. 
        /// </param>
        ///
        /// <param name="value">
        /// The Object to convert.
        /// </param>
        ///
        /// <returns>
        /// An Object that represents the converted value.
        /// </returns>
        //*************************************************************************
        public override Object ConvertFrom(
            ITypeDescriptorContext context,
            CultureInfo culture,
            Object value
            )
        {
            Debug.Assert(value != null);
            Debug.Assert(value is String);
            AssertValid();

            NumericRangeColumnAutoFillUserSettings
            oNumericRangeColumnAutoFillUserSettings =
            new NumericRangeColumnAutoFillUserSettings();

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

            Debug.Assert(asStrings.Length >= 7);

            oNumericRangeColumnAutoFillUserSettings.UseSourceNumber1 =
            Boolean.Parse( asStrings[0] );

            oNumericRangeColumnAutoFillUserSettings.UseSourceNumber2 =
            Boolean.Parse( asStrings[1] );

            oNumericRangeColumnAutoFillUserSettings.SourceNumber1 =
            MathUtil.ParseCultureInvariantDouble( asStrings[2] );

            oNumericRangeColumnAutoFillUserSettings.SourceNumber2 =
            MathUtil.ParseCultureInvariantDouble(asStrings[3]);

            oNumericRangeColumnAutoFillUserSettings.DestinationNumber1 =
            MathUtil.ParseCultureInvariantDouble(asStrings[4]);

            oNumericRangeColumnAutoFillUserSettings.DestinationNumber2 =
            MathUtil.ParseCultureInvariantDouble(asStrings[5]);

            oNumericRangeColumnAutoFillUserSettings.IgnoreOutliers =
            Boolean.Parse( asStrings[6] );

            // The UseLogs property wasn't added until NodeXL version 1.0.1.92.

            oNumericRangeColumnAutoFillUserSettings.UseLogs =
            (asStrings.Length > 7) ? Boolean.Parse( asStrings[7] ) : false;

            return (oNumericRangeColumnAutoFillUserSettings);
        }