コード例 #1
0
        SaveVertexCategoryResults
        (
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            String sVertexCategoryColumnName,
            Dictionary <String, Int32> oCategoryDictionary
        )
        {
            Debug.Assert(oWorkbook != null);
            Debug.Assert(!String.IsNullOrEmpty(sVertexCategoryColumnName));

            // Convert the dictionary keys to an array ordered by scheme index.

            Int32 iCategories = oCategoryDictionary.Count;

            String [] asVertexCategoryNames = new String[iCategories];

            foreach (KeyValuePair <String, Int32> oKeyValuePair in
                     oCategoryDictionary)
            {
                Debug.Assert(asVertexCategoryNames[oKeyValuePair.Value] == null);

                asVertexCategoryNames[oKeyValuePair.Value] = oKeyValuePair.Key;
            }

            AutoFillWorkbookWithSchemeResults oAutoFillWorkbookWithSchemeResults =
                new AutoFillWorkbookWithSchemeResults();

            oAutoFillWorkbookWithSchemeResults.SetVertexCategoryResults(
                sVertexCategoryColumnName, asVertexCategoryNames);

            (new PerWorkbookSettings(oWorkbook)).
            AutoFillWorkbookWithSchemeResults =
                oAutoFillWorkbookWithSchemeResults;
        }
コード例 #2
0
        //*************************************************************************
        //  Method: SaveVertexCategoryResults()
        //
        /// <summary>
        /// Stores the results of a vertex category autofill as an <see
        /// cref="AutoFillWorkbookWithSchemeResults" /> using <see
        /// cref="PerWorkbookSettings" />.
        /// </summary>
        ///
        /// <param name="oWorkbook">
        /// The workbook to autofill.
        /// </param>
        ///
        /// <param name="sVertexCategoryColumnName">
        /// The name of the vertex table column containing vertex categories.
        /// </param>
        ///
        /// <param name="oCategoryDictionary">
        /// The key is a unique category name and the value is a scheme index.
        /// </param>
        //*************************************************************************
        private static void SaveVertexCategoryResults(
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            String sVertexCategoryColumnName,
            Dictionary<String, Int32> oCategoryDictionary
            )
        {
            Debug.Assert(oWorkbook != null);
            Debug.Assert( !String.IsNullOrEmpty(sVertexCategoryColumnName) );

            // Convert the dictionary keys to an array ordered by scheme index.

            Int32 iCategories = oCategoryDictionary.Count;

            String [] asVertexCategoryNames = new String[iCategories];

            foreach (KeyValuePair<String, Int32> oKeyValuePair in
            oCategoryDictionary)
            {
            Debug.Assert(asVertexCategoryNames[oKeyValuePair.Value] == null);

            asVertexCategoryNames[oKeyValuePair.Value] = oKeyValuePair.Key;
            }

            AutoFillWorkbookWithSchemeResults oAutoFillWorkbookWithSchemeResults =
            new AutoFillWorkbookWithSchemeResults();

            oAutoFillWorkbookWithSchemeResults.SetVertexCategoryResults(
            sVertexCategoryColumnName, asVertexCategoryNames);

            ( new PerWorkbookSettings(oWorkbook) ).
            AutoFillWorkbookWithSchemeResults =
                oAutoFillWorkbookWithSchemeResults;
        }
コード例 #3
0
        ConvertFromString
        (
            String theString
        )
        {
            Debug.Assert(!String.IsNullOrEmpty(theString));

            AutoFillWorkbookWithSchemeResults oAutoFillWorkbookWithSchemeResults =
                new AutoFillWorkbookWithSchemeResults();

            String [] asFields = theString.Split(
                PerWorkbookSettings.FieldSeparator);

            Int32 iFields = asFields.Length;

            if (iFields == 0)
            {
                goto Done;
            }

            AutoFillSchemeType eSchemeType;

            try
            {
                eSchemeType = (AutoFillSchemeType)Enum.Parse(
                    typeof(AutoFillSchemeType), asFields[0]);
            }
            catch (ArgumentException)
            {
                goto Done;
            }

            switch (eSchemeType)
            {
            case AutoFillSchemeType.VertexCategory:

                if (iFields == 3)
                {
                    String [] asVertexCategoryNames = asFields[2].Split(
                        VertexCategoryNameSeparator);

                    oAutoFillWorkbookWithSchemeResults.
                    SetVertexCategoryResults(asFields[1],
                                             asVertexCategoryNames);
                }

                break;

            case AutoFillSchemeType.EdgeWeight:

                if (iFields == 5)
                {
                    oAutoFillWorkbookWithSchemeResults.SetEdgeWeightResults(
                        asFields[1],
                        MathUtil.ParseCultureInvariantDouble(asFields[2]),
                        MathUtil.ParseCultureInvariantDouble(asFields[3]),
                        MathUtil.ParseCultureInvariantInt32(asFields[4])
                        );
                }

                break;

            case AutoFillSchemeType.EdgeTimestamp:

                if (iFields == 5)
                {
                    oAutoFillWorkbookWithSchemeResults.SetEdgeTimestampResults(
                        asFields[1],

                        (ExcelColumnFormat)Enum.Parse(
                            typeof(ExcelColumnFormat), asFields[2]),

                        MathUtil.ParseCultureInvariantDouble(asFields[3]),
                        MathUtil.ParseCultureInvariantDouble(asFields[4])
                        );
                }

                break;

            default:

                break;
            }

Done:

            return(oAutoFillWorkbookWithSchemeResults);
        }
コード例 #4
0
        //*************************************************************************
        //  Method: ConvertFromString()
        //
        /// <summary>
        /// Creates a <see cref="AutoFillWorkbookWithSchemeResults" /> object from
        /// a persisted string.
        /// </summary>
        ///
        /// <param name="theString">
        /// String created by <see cref="ConvertToString()" />.
        /// </param>
        ///
        /// <returns>
        /// A <see cref="AutoFillWorkbookWithSchemeResults" /> object created from
        /// <paramref name="theString" />.
        /// </returns>
        //*************************************************************************
        public static AutoFillWorkbookWithSchemeResults ConvertFromString(
            String theString
            )
        {
            Debug.Assert( !String.IsNullOrEmpty(theString) );

            AutoFillWorkbookWithSchemeResults oAutoFillWorkbookWithSchemeResults =
            new AutoFillWorkbookWithSchemeResults();

            String [] asFields = theString.Split(
            PerWorkbookSettings.FieldSeparator);

            Int32 iFields = asFields.Length;

            if (iFields == 0)
            {
            goto Done;
            }

            AutoFillSchemeType eSchemeType;

            try
            {
            eSchemeType = (AutoFillSchemeType)Enum.Parse(
                typeof(AutoFillSchemeType), asFields[0] );
            }
            catch (ArgumentException)
            {
            goto Done;
            }

            switch (eSchemeType)
            {
            case AutoFillSchemeType.VertexCategory:

                if (iFields == 3)
                {
                    String [] asVertexCategoryNames = asFields[2].Split(
                        VertexCategoryNameSeparator);

                    oAutoFillWorkbookWithSchemeResults.
                        SetVertexCategoryResults(asFields[1],
                            asVertexCategoryNames);
                }

                break;

            case AutoFillSchemeType.EdgeWeight:

                if (iFields == 5)
                {
                    oAutoFillWorkbookWithSchemeResults.SetEdgeWeightResults(
                        asFields[1],
                        MathUtil.ParseCultureInvariantDouble( asFields[2] ),
                        MathUtil.ParseCultureInvariantDouble( asFields[3] ),
                        MathUtil.ParseCultureInvariantInt32( asFields[4] )
                        );
                }

                break;

            case AutoFillSchemeType.EdgeTimestamp:

                if (iFields == 5)
                {
                    oAutoFillWorkbookWithSchemeResults.SetEdgeTimestampResults(
                        asFields[1],

                        (ExcelColumnFormat)Enum.Parse(
                            typeof(ExcelColumnFormat), asFields[2] ),

                        MathUtil.ParseCultureInvariantDouble( asFields[3] ),
                        MathUtil.ParseCultureInvariantDouble( asFields[4] )
                        );
                }

                break;

            default:

                break;
            }

            Done:

            return (oAutoFillWorkbookWithSchemeResults);
        }