Exemple #1
0
            //=--------------------------------------------------------------=
            // blendFillFromString
            //=--------------------------------------------------------------=
            /// <summary>
            ///   Given a string that we serialized out using
            ///   blendFillToString, this function attempts to parse in the
            ///   given input and regenerate a  BlendFill object.
            /// </summary>
            ///
            /// <param name="in_bf">
            ///   What to parse back into a BlendFill.
            /// </param>
            ///
            /// <param name="in_culture">
            ///   What cultural information to use for this parse.
            /// </param>
            ///
            /// <returns>
            ///   A BlendFill representing the data from the string.
            /// </returns>
            ///
            private static BlendFill blendFillFromString
            (
                string in_bf,
                CultureInfo in_culture
            )
            {
                TypeConverter tcc;
                BlendStyle    style;

                string[] pieces;
                Color    c1, c2;
                string   sep;

                //
                // Get the various type converters and culture info we need
                //
                if (in_culture == null)
                {
                    in_culture = CultureInfo.CurrentCulture;
                }
                sep = in_culture.TextInfo.ListSeparator;
                tcc = TypeDescriptor.GetConverter(typeof(Color));

                //
                // Explode the string.  Unfortunately, we can't use
                // String.Split() since we need to preserve ()s around
                // the colors.
                //
                pieces = MiscFunctions.ExplodePreservingSubObjects(in_bf,
                                                                   sep, '(', ')');

                if (pieces.Length != 3)
                {
                    throw new ArgumentException(TaskPaneMain.GetResourceManager().GetString("excBlendFillParse"), "value");
                }

                style = parseBlendStyle(pieces[0]);
                c1    = (Color)tcc.ConvertFromString(pieces[1]);
                c2    = (Color)tcc.ConvertFromString(pieces[2]);

                if ((int)style == -1 ||
                    c1.Equals(Color.Empty) ||
                    c2.Equals(Color.Empty))
                {
                    throw new ArgumentException(TaskPaneMain.GetResourceManager().GetString("excBlendFillParse"), "value");
                }

                return(new BlendFill(style, c1, c2));
            }
Exemple #2
0
        //=------------------------------------------------------------------=
        //=------------------------------------------------------------------=
        //=------------------------------------------------------------------=
        //=------------------------------------------------------------------=
        //               Public Members/Methods/Functions/etc...
        //=------------------------------------------------------------------=
        //=------------------------------------------------------------------=
        //=------------------------------------------------------------------=
        //=------------------------------------------------------------------=


        //=------------------------------------------------------------------=
        // Constructor
        //=------------------------------------------------------------------=
        /// <summary>
        ///   Goes and initializes a new instance of this class given the XML key
        ///   to find for the actual localized description text.
        /// </summary>
        ///
        /// <param name="in_key">
        ///   Key for which to search in the resources.
        /// </param>
        ///
        public LocalisableDescriptionAttribute(string in_key)
            : base(TaskPaneMain.GetResourceManager().GetString(in_key))
        {
        }