Ejemplo n.º 1
0
 private static SnippetMenuItem[] LoadSnippets(string group)
 {
     using (var stream = Application.GetResourceStream(ResourcesManager.GetAssemblyResourceUri("Snippets/Snippets.xml")).Stream)
     {
         var cfgElement = XElement.Load(stream);
         return(cfgElement.Elements("Snippet")
                .Where(e => e.Element("Group").Value == group)
                .Select(e => new SnippetMenuItem(e.Element("Code").Value.Replace("\n", "\r\n"), e.Element("Icon").Value))
                .ToArray());
     }
 }
Ejemplo n.º 2
0
            public SnippetMenuItem(string snippet, string iconPath)
            {
                Snippet = snippet;

                IsMultiLine = snippet.Contains('\n');
                Debug.Assert(!IsMultiLine || snippet.StartsWith(Environment.NewLine));

                var iconUri = ResourcesManager.GetAssemblyResourceUri(iconPath);

                using (var stream = Application.GetResourceStream(iconUri).Stream)
                    using (var bmp = new System.Drawing.Bitmap(stream))
                    {
                        Icon = ResourcesManager.CreateBitmapSourceWithCurrentDpi(bmp);
                    }
            }