Пример #1
0
        private static IEnumerable <Entry> LoadIds(OfficeVersion officeVersion, OfficeApplication officeApplication)
        {
            var folder = Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                "OfficeData",
                officeVersion.ToString());

            var files = new DirectoryInfo(folder).GetFiles("*.xlsx")
                        .Where(f => f.Name.StartsWith(officeApplication.ToString(), StringComparison.OrdinalIgnoreCase));

            foreach (var file in files)
            {
                using (var package = new ExcelPackage(file))
                {
                    var ws = package.Workbook.Worksheets.First();
                    for (var r = 2; r <= ws.Dimension.End.Row; r++)
                    {
                        yield return(new Entry
                        {
                            Completion = new Completion(ws.Cells[r, 1].GetValue <string>()),
                            ControlType = ws.Cells[r, 2].GetValue <string>(),
                            TabSet = ws.Cells[r, 3].GetValue <string>(),
                            Tab = ws.Cells[r, 4].GetValue <string>(),
                            Group = ws.Cells[r, 5].GetValue <string>(),
                            ParentControl = ws.Cells[r, 6].GetValue <string>(),
                        });
                    }
                }
            }
        }
Пример #2
0
    internal static string ToFormattedString(this OfficeVersion version)
    {
        if (version == OfficeVersion.None)
        {
            return("None");
        }

        return((version == OfficeVersion.Microsoft365 ? string.Empty : "Office ") + version.ToString().Substring(version == OfficeVersion.Microsoft365 ? 0 : "Office".Length));
    }
Пример #3
0
        private static IEnumerable <Completion> LoadGlyphsFromFile(OfficeVersion officeVersion)
        {
            var folder = Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                "OfficeData",
                officeVersion.ToString());

            var files = new DirectoryInfo(folder).GetFiles("*.zip");

            foreach (var file in files)
            {
                using (var stream = File.OpenRead(file.FullName))
                    using (var zip = new ZipArchive(stream))
                    {
                        // Iterate through all of the glyphs in this dictionary
                        foreach (var glyph in zip.Entries)
                        {
                            var name = Path.GetFileNameWithoutExtension(glyph.Name);

                            using (var glyphStream = glyph.Open())
                                using (var ms = new MemoryStream())
                                {
                                    glyphStream.CopyTo(ms);

                                    // Generate the Glyph
                                    var bitmap = new BitmapImage();
                                    bitmap.BeginInit();
                                    bitmap.StreamSource = ms;
                                    bitmap.CacheOption  = BitmapCacheOption.OnLoad;
                                    bitmap.EndInit();
                                    bitmap.Freeze();

                                    // Add it to the collection (under the specific library)
                                    yield return(new Completion(name, name, name, bitmap, name));
                                }
                        }
                    }
            }
        }