/// <summary> /// Fetches the thumbnail of a symbol in a symbol library /// </summary> /// <param name="conn"></param> /// <param name="symbolLibId"></param> /// <param name="symbolName"></param> /// <returns></returns> internal static Image GetSymbol(IServerConnection conn, string symbolLibId, string symbolName) { //NOTE: This could be nasty performance-wise if invoked at lot of times in succession //But these types of symbols are deprecated anyway, so we can live with it, because people //shouldn't be using these anymore (and thus this method by extension) var ds = ImageSymbolConverter.PrepareSymbolDrawingSource(conn, symbolLibId); //Now we should be able to query it via Drawing Service APIs var drawSvc = (IDrawingService)conn.GetService((int)ServiceType.Drawing); //Each section in the symbols.dwf represents a symbol var sectionList = drawSvc.EnumerateDrawingSections(ds.ResourceID); foreach (var sect in sectionList.Section) { if (sect.Title == symbolName) { var sectResources = drawSvc.EnumerateDrawingSectionResources(ds.ResourceID, sect.Name); foreach (var res in sectResources.SectionResource) { if (res.Role.ToUpper() == StringConstants.Thumbnail.ToUpper()) { using (var rs = drawSvc.GetSectionResource(ds.ResourceID, res.Href)) { return(Image.FromStream(rs)); } } } } } return(null); }
private void LoadSymbols(string symResId) { var ds = ImageSymbolConverter.PrepareSymbolDrawingSource(_conn, symResId); //Now we should be able to query it via Drawing Service APIs var drawSvc = (IDrawingService)_conn.GetService((int)ServiceType.Drawing); //Each section in the symbols.dwf represents a symbol var sectionList = drawSvc.EnumerateDrawingSections(ds.ResourceID); lstSymbols.Items.Clear(); int idx = 0; var imgList = new ImageList(); imgList.ImageSize = new Size(32, 32); var symbols = new List <ListViewItem>(); foreach (var sect in sectionList.Section) { var sectResources = drawSvc.EnumerateDrawingSectionResources(ds.ResourceID, sect.Name); foreach (var res in sectResources.SectionResource) { if (res.Role.ToUpper() == StringConstants.Thumbnail.ToUpper()) { using (var rs = drawSvc.GetSectionResource(ds.ResourceID, res.Href)) { Image img = Image.FromStream(rs); imgList.Images.Add(img); var item = new ListViewItem(sect.Title); item.ImageIndex = idx; symbols.Add(item); idx++; } } } } lstSymbols.SmallImageList = imgList; lstSymbols.LargeImageList = imgList; foreach (var sym in symbols) { lstSymbols.Items.Add(sym); } }
private object SymbolExtractionWorker(BackgroundWorker worker, DoWorkEventArgs e, params object[] args) { int processed = 0; IServerConnection conn = (IServerConnection)args[0]; string symbolLib = (string)args[1]; List <string> symbols = (List <string>)args[2]; string targetFolder = (string)args[3]; ImageSymbolConverter conv = new ImageSymbolConverter(conn, symbolLib); conv.ExtractSymbols(targetFolder, symbols, (count, total) => { processed = count; int pc = (int)((double)count / (double)total); worker.ReportProgress(pc); }); return(processed); }