Exemplo n.º 1
0
        /// <summary>
        /// Attempts to convert the specified property from its string representation in the loaded dictionary
        /// to its typed version. Sets the value to null if conversion fails. Intended for use with System.Drawing.Point
        /// </summary>
        /// <param name="properties"></param>
        /// <param name="property"></param>
        /// <param name="converter"></param>
        private static void ConvertSnapshotPoint(Dictionary <SnapshotMetaPropertyName, object> properties,
                                                 SnapshotMetaPropertyName property, System.Drawing.PointConverter converter)
        {
            object strVal = null;

            if (properties?.TryGetValue(property, out strVal) == true)
            {
                try
                {
                    properties[property] = converter.ConvertFromString((string)strVal);
                }
                catch (NotSupportedException)
                {
                    properties[property] = null;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Attempts to convert the specified property from its string representation in the loaded dictionary
        /// to its typed version. Sets the value to null if conversion fails. Intended for use with System.Windows.Media.Color
        /// </summary>
        /// <param name="properties"></param>
        /// <param name="property"></param>
        private static void ConvertSnapshotColor(Dictionary <SnapshotMetaPropertyName, object> properties, SnapshotMetaPropertyName property)
        {
            object strVal = null;

            if (properties?.TryGetValue(property, out strVal) == true)
            {
                try
                {
                    properties[property] = System.Windows.Media.ColorConverter.ConvertFromString((string)strVal);
                }
                catch (NotSupportedException)
                {
                    properties[property] = null;
                }
            }
        }