Exemple #1
0
        /// <summary>
        /// Gets the overlay icon.
        /// </summary>
        /// <param name="dispatcher">The dispatcher.</param>
        /// <param name="icon">The icon information.</param>
        /// <returns>
        /// The overlay icon.
        /// </returns>
        public static ImageSource GetOverlay(
            Dispatcher dispatcher, IconData icon)
        {
            if (icon == null)
                throw new ArgumentNullException("icon");

            ImageSource source;
            if (!string.IsNullOrEmpty(icon.Custom) &&
                Database.Icons.TryGetValue(icon.Custom, out source))
                return source;

            var id = icon.Standard;
            if (!_standards.TryGetValue(id, out source))
            {
                lock (_lckStandards)
                {
                    if (!_standards.TryGetValue(id, out source))
                    {
                        var wait = new ManualResetEvent(false);

                        dispatcher.BeginInvoke(() =>
                        {
                            var uri = string.Format(
                                "/Images/KeePass/{0:00}.png", id);
                            source = new BitmapImage(new Uri(
                                uri, UriKind.Relative));
                            _standards.Add(id, source);

                            wait.Set();
                        });

                        wait.WaitOne();
                    }
                }
            }

            return source;
        }
Exemple #2
0
        private static IconData ParseIcon(XmlReader reader)
        {
            var data = new IconData();

            if (reader.Name != "IconID")
                reader.ReadToNextSibling("IconID");

            data.Standard = reader
                .ReadElementContentAsInt();

            if (reader.Name == "CustomIconUUID")
            {
                data.Custom = reader
                    .ReadElementContentAsString();
            }

            return data;
        }