public DataTable GetRenderInfo() { DataTable table = null; DataRow row = null; table = new DataTable(); table.Columns.Add("Name", typeof(string)); table.Columns.Add("Thumbnail", typeof(object)); table.Columns.Add("Comment", typeof(string)); table.Columns.Add("Info", typeof(object)); try { if (this._renderType == RenderType.Color) { ColorClass colorClass = null; if (this._textureRoof != null) { colorClass = GetColorClass(this._textureRoof.ToString()); if (colorClass != null) { row = table.NewRow(); row["Name"] = "顶面"; row["Thumbnail"] = colorClass.Thumbnail; row["Comment"] = colorClass.Name; row["Info"] = colorClass.ObjectId; table.Rows.Add(row); } else { row = table.NewRow(); row["Name"] = "顶面"; row["Thumbnail"] = null; row["Comment"] = ""; row["Info"] = null; table.Rows.Add(row); } } if (this._textureFacade != null) { colorClass = GetColorClass(this._textureFacade.ToString()); if (colorClass != null) { row = table.NewRow(); row["Name"] = "侧面"; row["Thumbnail"] = colorClass.Thumbnail; row["Comment"] = colorClass.Name; row["Info"] = colorClass.ObjectId; table.Rows.Add(row); return(table); } row = table.NewRow(); row["Name"] = "侧面"; row["Thumbnail"] = null; row["Comment"] = ""; row["Info"] = null; table.Rows.Add(row); } return(table); } TextureClass textureClass = null; if (this._textureRoof != null) { textureClass = GetTextureClass(this._textureRoof.ToString()); if (textureClass != null) { row = table.NewRow(); row["Name"] = "顶面"; row["Thumbnail"] = textureClass.Thumbnail; row["Comment"] = textureClass.Name; row["Info"] = textureClass.ObjectId; table.Rows.Add(row); } else { row = table.NewRow(); row["Name"] = "顶面"; row["Thumbnail"] = null; row["Comment"] = ""; row["Info"] = null; table.Rows.Add(row); } } if (this._textureFacade == null) { return(table); } textureClass = GetTextureClass(this._textureFacade.ToString()); if (textureClass != null) { row = table.NewRow(); row["Name"] = "侧面"; row["Thumbnail"] = textureClass.Thumbnail; row["Comment"] = textureClass.Name; row["Info"] = textureClass.ObjectId; table.Rows.Add(row); return(table); } row = table.NewRow(); row["Name"] = "侧面"; row["Thumbnail"] = null; row["Comment"] = ""; row["Info"] = null; table.Rows.Add(row); } catch (Exception exception) { table.Rows.Clear(); row = table.NewRow(); row["Name"] = "顶面"; row["Thumbnail"] = null; row["Comment"] = "顶面"; row["Info"] = null; table.Rows.Add(row); row = table.NewRow(); row["Name"] = "侧面"; row["Thumbnail"] = null; row["Comment"] = "侧面"; row["Info"] = null; table.Rows.Add(row); } return(table); }
private TextureClass GetTextureClass(string objectId) { IFdeCursor cursor = null; IRowBuffer row = null; try { IDataSource ds = DF3DPipeCreateApp.App.TemplateLib; if (ds == null) { return(null); } IFeatureDataSet fds = ds.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_TextureInfo"); if (oc == null) { return(null); } IQueryFilter filter = new QueryFilterClass { WhereClause = "ObjectId = '" + objectId + "'" }; cursor = oc.Search(filter, true); if ((row = cursor.NextRow()) != null) { int id = -1; string name = "", objectid = "", groupid = "", code = "", comment = ""; Image thumbnail = null; int index = row.FieldIndex("oid"); if (index != -1 && !row.IsNull(index)) { id = Convert.ToInt32(row.GetValue(index).ToString()); } index = row.FieldIndex("Name"); if (index != -1 && !row.IsNull(index)) { name = row.GetValue(index).ToString(); } index = row.FieldIndex("ObjectId"); if (index != -1 && !row.IsNull(index)) { objectid = row.GetValue(index).ToString(); } index = row.FieldIndex("GroupId"); if (index != -1 && !row.IsNull(index)) { groupid = row.GetValue(index).ToString(); } index = row.FieldIndex("Code"); if (index != -1 && !row.IsNull(index)) { code = row.GetValue(index).ToString(); } index = row.FieldIndex("Comment"); if (index != -1 && !row.IsNull(index)) { comment = row.GetValue(index).ToString(); } index = row.FieldIndex("Thumbnail"); if (index != -1 && !row.IsNull(index)) { IBinaryBuffer b = row.GetValue(index) as IBinaryBuffer; if (row != null) { MemoryStream stream = new MemoryStream(b.AsByteArray()); thumbnail = Image.FromStream(stream); } } if (id != -1 && thumbnail != null) { TextureClass cc = new TextureClass(); cc.Id = id; cc.Name = name; cc.Group = groupid; cc.ObjectId = objectid; cc.Code = code; cc.Comment = comment; cc.Thumbnail = thumbnail; return(cc); } } return(null); } catch (Exception exception) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }