private void mnu_OpenDataFrom(object sender, RoutedEventArgs e) { //string name = ""; try { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "carboLife Materials (*.cml)|*.cml"; var path = openFileDialog.ShowDialog(); FileInfo finfo = new FileInfo(openFileDialog.FileName); if (openFileDialog.FileName != "") { string filePath = openFileDialog.FileName; CarboDatabase newMaterialDatabase = new CarboDatabase(); if (File.Exists(filePath)) { newMaterialDatabase = newMaterialDatabase.DeSerializeXML(filePath); if (newMaterialDatabase != null) { UserMaterials = newMaterialDatabase; } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btn_ReplaceProject_Click(object sender, RoutedEventArgs e) { try { MessageBoxResult result = System.Windows.MessageBox.Show("Do you want to replace all materials in the PROJECT with template materials?", "Warning", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { CarboDatabase buffer = new CarboDatabase(); buffer = templateDatabase.Copy(); if (buffer.CarboMaterialList.Count == templateDatabase.CarboMaterialList.Count) { projectDatabase.CarboMaterialList.Clear(); projectDatabase.CarboMaterialList = new List <CarboMaterial>(); projectDatabase = buffer; } } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString()); } refreshTemplateMaterials(); refreshProjectMaterials(); }
private void mnu_ExportUser_Click(object sender, RoutedEventArgs e) { try { MessageBoxResult result = MessageBox.Show("Do you want to update the DEFAULT USER MATERIALS based on these PROJECT settings ?" + Environment.NewLine + "Materials with IDENTICAL names will be OVERWRITTEN, NON-EXISTING materials will be ADDED", "Warning", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { string name = "db\\UserMaterials"; CarboDatabase buffer = UserMaterials.DeSerializeXML(name); bool syncResult = buffer.SyncMaterials(UserMaterials); if (syncResult == true) { buffer.SerializeXML(name); Utils.WriteToLog("Database saved to: " + name); } MessageBox.Show("Dataset saved"); } else { MessageBox.Show("Dataset not saved"); } } catch (Exception ex) { MessageBox.Show(ex.Message); Utils.WriteToLog(ex.Message); } RefreshTable(); }
public MaterialEditor(string materialName, CarboDatabase database) { //originalMaterial = material; //selectedMaterial = material; try { //originalDatabase = database; returnedDatabase = database; selectedMaterial = database.GetExcactMatch(materialName); if (selectedMaterial == null) { MessageBox.Show("This material could not be found in the database, the closest match will now be found"); selectedMaterial = database.getClosestMatch(materialName); } baseMaterials = new CarboDatabase(); baseMaterials = baseMaterials.DeSerializeXML("db\\BaseMaterials"); acceptNew = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } InitializeComponent(); }
public ReinforcementWindow(CarboDatabase materialDatabase, CarboGroup myConcreteGroup) { isAccepted = false; materials = materialDatabase; concreteGroup = myConcreteGroup; reinforcementGroup = new CarboGroup(); InitializeComponent(); }
public CaboDatabaseManager(CarboDatabase userMaterials) { UserMaterials = userMaterials; //BaseMaterials = new CarboDatabase(); //BaseMaterials = BaseMaterials.DeSerializeXML("db\\BaseMaterials"); isOk = false; InitializeComponent(); }
public MaterialBasePicker(CarboDatabase baseMaterials, string selection = "") { basematerials = baseMaterials; isAccepted = false; selectedBaseMaterial = basematerials.GetExcactMatch(selection); InitializeComponent(); }
public GroupWindow(ObservableCollection <CarboElement> elementList, CarboDatabase userMaterialData, CarboSettings groupSettings) { dialogOk = false; carboElementList = elementList; carboGroupList = new ObservableCollection <CarboGroup>(); carboGroupSettings = groupSettings; materialData = userMaterialData; InitializeComponent(); }
public MaterialAddMix(CarboDatabase materialDatabase, double basematerialDensity) { isAccepted = false; materials = materialDatabase; valueToBeMixed = 0; selectedMaterialDescription = ""; baseMaterialDensity = basematerialDensity; InitializeComponent(); }
public MaterialBasePicker(string selection = "") { isAccepted = false; basematerials = new CarboDatabase(); basematerials = basematerials.DeSerializeXML(""); selectedBaseMaterial = basematerials.GetExcactMatch(selection); InitializeComponent(); }
private void Button_Click_1(object sender, RoutedEventArgs e) { CarboDatabase cd = new CarboDatabase(); cd.DeSerializeXML(""); CaboDatabaseManager dataBaseManager = new CaboDatabaseManager(cd); dataBaseManager.ShowDialog(); }
public ProfileWindow(CarboDatabase materialDatabase, CarboGroup myConcreteGroup) { isAccepted = false; materials = materialDatabase; concreteGroup = myConcreteGroup; profileGroup = new CarboGroup(); profileGroup.Category = "Floor"; profileGroup.Description = "Metal deck / Profile"; InitializeComponent(); }
public SyncMaterialsWindow(CarboDatabase returnedDatabase) { this.projectDatabase = returnedDatabase; isAccepted = false; sourcePath = ""; //CarboProject templateProject = new CarboProject(); //templateDatabase = templateProject.CarboDatabase; InitializeComponent(); }
private void btn_Sync_Click(object sender, RoutedEventArgs e) { SyncMaterialsWindow materialnsSyncWindow = new SyncMaterialsWindow(returnedDatabase.Copy()); materialnsSyncWindow.ShowDialog(); if (materialnsSyncWindow.isAccepted == true) { returnedDatabase = materialnsSyncWindow.projectDatabase; } RefreshMaterialList(); }
private void Mnu_ImportNew_Click(object sender, RoutedEventArgs e) { string name = ""; //Get the profile from a cvs: if (cbb_ViewableTable.Text == "User Materials") { name = "db\\UserMaterials"; } else if (cbb_ViewableTable.Text == "Base Materials") { name = "db\\BaseMaterials"; } try { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "cvs files (*.csv)|*.csv|All files (*.*)|*.*"; var path = openFileDialog.ShowDialog(); FileInfo finfo = new FileInfo(openFileDialog.FileName); if (openFileDialog.FileName != "") { string filePath = openFileDialog.FileName; DataTable dt = CarboLifeAPI.Utils.LoadCSV(filePath); CarboDatabase newMaterialDatabase = tryParseData(dt); //dgv_Data.ItemsSource = dt.DefaultView; dgv_Data.ItemsSource = newMaterialDatabase.getData(); newMaterialDatabase.SerializeXML(name); if (name == "BaseMaterials") { BaseMaterials = newMaterialDatabase; } else if (name == "UserMaterials") { UserMaterials = newMaterialDatabase; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void loadTemplateMaterials() { try { if (File.Exists(sourcePath)) { templateDatabase = new CarboDatabase(); CarboDatabase buffer = new CarboDatabase(); templateDatabase = buffer.DeSerializeXML(sourcePath).Copy(); } refreshTemplateMaterials(); } catch { } }
private void btn_OpenFrom_Click(object sender, RoutedEventArgs e) { string name = ""; try { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Carbo Material Data Files (*.cxml)|*.cxml"; var path = openFileDialog.ShowDialog(); if (openFileDialog.FileName != "") { FileInfo finfo = new FileInfo(openFileDialog.FileName); if (openFileDialog.FileName != "") { name = openFileDialog.FileName; CarboDatabase userprojects = new CarboDatabase(); CarboDatabase buffer = userprojects.DeSerializeXML(name); if (buffer != null) { templateDatabase = buffer; } } cbb_DataBases.Items.Add(name); cbb_DataBases.Text = name; setPath(); } else { } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString()); } refreshTemplateMaterials(); //txt_path.Text = sourcePath; }
private void btn_Materials_Click(object sender, RoutedEventArgs e) { CarboProject newProject = new CarboProject(); CarboDatabase cd = newProject.CarboDatabase; cd.DeSerializeXML(""); if (newProject != null && cd != null && cd.CarboMaterialList.Count > 0) { MaterialEditor mateditor = new MaterialEditor(cd.CarboMaterialList[0].Name, cd); mateditor.ShowDialog(); if (mateditor.acceptNew == true) { CarboDatabase database = mateditor.returnedDatabase; database.SerializeXML(""); } } else { MessageBox.Show("Template Database not found"); } }
private void Mnu_UpdateUserMaterials(object sender, RoutedEventArgs e) { string name = ""; //Get the profile from a cvs: try { MessageBoxResult result = MessageBox.Show("Do you want to update the base set of usermaterials based on these project settings ?" + Environment.NewLine + "Materials with excact same names will be overwritten", "Warning", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*"; var path = openFileDialog.ShowDialog(); FileInfo finfo = new FileInfo(openFileDialog.FileName); if (openFileDialog.FileName != "") { name = openFileDialog.FileName; CarboDatabase buffer = UserMaterials.DeSerializeXML(name); bool syncResult = UserMaterials.SyncMaterials(buffer); if (syncResult == true) { buffer.SerializeXML(name); Utils.WriteToLog("Database saved to: " + name); MessageBox.Show("Dataset saved"); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void mnu_SyncToTemplate_Click(object sender, RoutedEventArgs e) { string name = ""; try { MessageBoxResult result = MessageBox.Show("Do you want to update the material template with the current project materials ?" + Environment.NewLine + "Materials with excact same names will be overwritten with new values", "Warning", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "xml files (*.cxml)|*.cxml|All files (*.*)|*.*"; var path = openFileDialog.ShowDialog(); FileInfo finfo = new FileInfo(openFileDialog.FileName); if (openFileDialog.FileName != "") { name = openFileDialog.FileName; CarboDatabase buffer = UserMaterials.DeSerializeXML(name); bool syncResult = UserMaterials.SyncMaterials(buffer); if (syncResult == true) { buffer.SerializeXML(name); Utils.WriteToLog("Database saved to: " + name); MessageBox.Show("Dataset saved"); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public MaterialSelector(string selectedMaterialName, CarboDatabase database) { isAccepted = false; try { //originalDatabase = database; materialDatabase = database; currentMaterial = database.GetExcactMatch(selectedMaterialName); if (currentMaterial == null) { MessageBox.Show("This material could not be found in the database, a closest match will now be found for comparison"); currentMaterial = database.getClosestMatch(selectedMaterialName); } selectedMaterial = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } InitializeComponent(); }
private void btn_SyncFrom_Click(object sender, RoutedEventArgs e) { if (liv_TemplateMaterials.SelectedItems.Count > 0) { try { MessageBoxResult result = System.Windows.MessageBox.Show("Do you want to update the project materials with the selected materials from the template?" + Environment.NewLine + "Materials with excact same name will be overwritten, others will be added to the project", "Warning", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { CarboDatabase buffer = new CarboDatabase(); foreach (object item in liv_TemplateMaterials.SelectedItems) { CarboMaterial cm = item as CarboMaterial; if (cm != null) { buffer.AddMaterial(cm); } } projectDatabase.SyncMaterials(buffer); } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString()); } } else { MessageBoxResult result = System.Windows.MessageBox.Show("Please select a material to syncronise", "Computer says no", MessageBoxButton.YesNo); } refreshTemplateMaterials(); refreshProjectMaterials(); }
private CarboDatabase tryParseData(DataTable dt) { CarboDatabase result = new CarboDatabase(); //List<String> fieldNameList = new List<string>(); List <CarboMaterial> resultList = new List <CarboMaterial>(); //Reach row is one element //Loop through datatab;e //int newIdNr = 10000; //int columncount = 0; PropertyInfo[] propertyValues = typeof(CarboMaterial).GetProperties(); List <PropertyInfo> fullPropertyList = propertyValues.ToList(); int propertyValuesCount = propertyValues.Length; foreach (DataRow dr in dt.Rows) { CarboMaterial newMaterial = new CarboMaterial(); List <PropertyInfo> propertyList = new List <PropertyInfo>(); foreach (PropertyInfo prInf in fullPropertyList) { propertyList.Add(prInf); } //Set Id; //newMaterial.Id = newIdNr; //columncount = 0; bool valueisParameter = false;; foreach (DataColumn dc in dt.Columns) { string ccolumnName = dc.ColumnName.ToString().Trim(); string messageString = ""; for (int i = 0; i < propertyList.Count; i++) { PropertyInfo property = propertyList[i]; string propertyName = property.Name.ToString(); if (propertyName == ccolumnName) { string value = dr[dc].ToString(); //The column is a propery value, thus it need to be added as such try { //Improved: if (property.PropertyType == typeof(bool)) { int parcedIntValue; bool isInt = false; isInt = int.TryParse(value, out parcedIntValue); if (isInt == false) { parcedIntValue = 0; } bool boolValue = Convert.ToBoolean(Convert.ToInt32(parcedIntValue)); property.SetValue(newMaterial, boolValue); } else if (property.PropertyType == typeof(int)) { int parcedIntValue; bool isInt = false; isInt = int.TryParse(value, out parcedIntValue); if (isInt == false) { parcedIntValue = 0; } //must be int property.SetValue(newMaterial, parcedIntValue); } else if (property.PropertyType == typeof(double)) { double parsedDoubleValue = 0; bool isDouble = false; isDouble = double.TryParse(value, out parsedDoubleValue); if (isDouble == false) { parsedDoubleValue = 0; } property.SetValue(newMaterial, parsedDoubleValue); } else if (property.PropertyType == typeof(string)) { if (value == null) { value = ""; } property.SetValue(newMaterial, value); } else { //Skip } //OLD /* * if (isDouble == true) * { * //Handle as number or bolean * * if (property.PropertyType == typeof(bool)) * { * bool boolValue = Convert.ToBoolean(Convert.ToInt32(value)); * property.SetValue(newMaterial, boolValue); * } * else * { * if (property.PropertyType == typeof(int)) * { * //must be int * property.SetValue(newMaterial, parcedIntValue); * } * else * { * //must be double * //parsedDoubleValue = Math.Round(parsedDoubleValue, 2); * property.SetValue(newMaterial, parsedDoubleValue); * } * //see if is int or double * } * } * else * { * //is string * property.SetValue(newMaterial, value); * } */ //Value Successfully added valueisParameter = false; //removethePropertyFromlistToSpeedThingsUpNextRound; propertyList.Remove(property); //End the loop and go to next column break; } catch (Exception ex) { messageString += value + " : " + ex.Message; } } else { valueisParameter = true; } } if (valueisParameter == true) { // If its not a property it will be added as a free parameter. /* * try * { * * CarboProperty newProperty = new CarboProperty(); * * string propertyValue = dr[dc].ToString(); * string propertyName = ccolumnName; * * newProperty.PropertyName = propertyName; * newProperty.Value = propertyValue; * * if (ccolumnName.StartsWith("_")) * { * //This is a material * newProperty.PropertyName = propertyName.TrimStart('_'); * newMaterial.Properties.Add(newProperty); * } * else * { * //This is a property * newMaterial.Properties.Add(newProperty); * } * } * catch (Exception ex) * { * messageString += ex.Message; * } */ } //columncount++; } newMaterial.CalculateTotals(); resultList.Add(newMaterial); //lbl_Status.Text = newOption.Name; //lbl_Status.Refresh(); //this.Refresh(); //Next Id Nr: //newIdNr++; } //result.Floortype = -1; //result.FloorTypeName = txt_TypeName.Text; //result.FloorTypeDescription = txt_Description.Text; result.setData(resultList); return(result); }
public GroupAdvancedEditor(CarboGroup carboGroup, CarboDatabase dataBase) { this.group = carboGroup; this.database = dataBase; InitializeComponent(); }