//---------------------------------------------------------- public static void material_symbol(Document doc, ElementType type, ListView thong_tin_cong_tac_vat_lieu, ObservableCollection <data_materials> my_materials, ObservableCollection <data_material> my_material) { try { List <Parameter> materialDefinition = new List <Parameter>(); List <string> materialDefinitionName = new List <string>(); foreach (Parameter para in type.Parameters) { if (para.Definition.ParameterGroup == BuiltInParameterGroup.PG_MATERIALS) { string ten = "<By Category>"; string ma = ""; if (para.AsElementId().IntegerValue != -1) { ten = doc.GetElement(para.AsElementId()).Name; ma = F_GetSchema.Check_Para_And_Get_Para(doc.GetElement(para.AsElementId()) as Material, Source.MCT[1], Source.MCT[0]); } my_materials.Add(new data_materials() { ten_cong_tac = para.Definition.Name, ten_vat_lieu_list = my_material, ten_vat_lieu = my_material.First(x => x.name == ten), parameter = para }); } } thong_tin_cong_tac_vat_lieu.ItemsSource = my_materials; ListCollectionView view = CollectionViewSource.GetDefaultView(thong_tin_cong_tac_vat_lieu.ItemsSource) as ListCollectionView; view.CustomSort = new sort_data_materials(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
{//---------------------------------------------------------- public static void parameter_and_material_type(Document doc, ElementType type, ListView thong_tin_kich_thuoc, ObservableCollection <data_parameters> my_parameters, ListView thong_tin_cong_tac_vat_lieu, ObservableCollection <data_materials> my_materials, ObservableCollection <data_material> my_material, string unit_length) { try { var TypeOftype = type.GetType(); CompoundStructure compound = null; if (TypeOftype.Name == "WallType") { var wall = type as WallType; compound = wall.GetCompoundStructure(); } if (TypeOftype.Name == "FloorType") { var wall = type as FloorType; compound = wall.GetCompoundStructure(); } if (TypeOftype.Name == "RoofType") { var wall = type as RoofType; compound = wall.GetCompoundStructure(); } if (TypeOftype.Name == "CeilingType") { var wall = type as CeilingType; compound = wall.GetCompoundStructure(); } IList <CompoundStructureLayer> getlayer = compound.GetLayers(); foreach (var layer in getlayer) { my_parameters.Add(new data_parameters() { ten_parameter = layer.Function.ToString(), gia_tri_parameter = Math.Round(layer.Width * Source.units_document.First(x => x.name == unit_length).value, 0).ToString(), group_parameter = "Dimensions", layer = layer, compound = compound }); } thong_tin_kich_thuoc.ItemsSource = my_parameters; ListCollectionView view_kich_thuoc = CollectionViewSource.GetDefaultView(thong_tin_kich_thuoc.ItemsSource) as ListCollectionView; PropertyGroupDescription groupDescription1 = new PropertyGroupDescription("group_parameter"); view_kich_thuoc.GroupDescriptions.Add(groupDescription1); view_kich_thuoc.CustomSort = new sort_data_parameters(); //--------------------------------------------------------------------------------------------------------------------- foreach (var layer in getlayer) { string ten = "<By Category>"; string ma = ""; if (layer.MaterialId.IntegerValue != -1) { ten = doc.GetElement(layer.MaterialId).Name; ma = F_GetSchema.Check_Para_And_Get_Para(doc.GetElement(layer.MaterialId) as Material, Source.MCT[1], Source.MCT[0]); } my_materials.Add(new data_materials() { ten_cong_tac = layer.Function.ToString(), ten_vat_lieu_list = my_material, ten_vat_lieu = my_material.First(x => x.name == ten), layer = layer, compound = compound }); } thong_tin_cong_tac_vat_lieu.ItemsSource = my_materials; CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(thong_tin_cong_tac_vat_lieu.ItemsSource); view.SortDescriptions.Add(new SortDescription("ten_cong_tac", ListSortDirection.Ascending)); } catch (Exception) { thong_tin_kich_thuoc.ItemsSource = new ObservableCollection <data_parameters>(); thong_tin_cong_tac_vat_lieu.ItemsSource = new ObservableCollection <data_materials>(); } }