/// <summary> /// Constructor /// </summary> public FormNewCaseOfBoxes(Document document, CaseOfBoxesProperties caseOfBoxProperties) { InitializeComponent(); // save document reference _document = document; // name / description if (null != caseOfBoxProperties) { tbName.Text = caseOfBoxProperties.Name; tbDescription.Text = caseOfBoxProperties.Description; } else { tbName.Text = _document.GetValidNewTypeName(Resources.ID_CASEOFBOXES); tbDescription.Text = tbName.Text; } // save CaseOfBoxesProperties _caseOfBoxesProperties = caseOfBoxProperties; // color : all faces set together / face by face chkAllFaces.Checked = caseOfBoxProperties.UniqueColor; chkAllFaces_CheckedChanged(this, null); // set colors for (int i = 0; i < 6; ++i) _faceColors[i] = caseOfBoxProperties.Colors[i]; // set textures _textures = caseOfBoxProperties.TextureList; // set default face cbFace.SelectedIndex = 0; // disable Ok button UpdateButtonOkStatus(); }
public CaseOfBoxesProperties CreateNewCaseOfBoxes( string name, string description , BoxProperties boxProperties , CaseDefinition caseDefinition , CaseOptimConstraintSet constraintSet) { CaseOfBoxesProperties caseProperties = new CaseOfBoxesProperties(this, boxProperties, caseDefinition, constraintSet); caseProperties.Name = name; caseProperties.Description = description; // insert in list _typeList.Add(caseProperties); // notify listeners NotifyOnNewTypeCreated(caseProperties); Modify(); return caseProperties; }
public void Save(CaseOfBoxesProperties caseOfBoxesProperties, XmlElement parentElement, XmlDocument xmlDoc) { // create xmlBoxProperties element XmlElement xmlBoxProperties = xmlDoc.CreateElement("CaseOfBoxesProperties"); parentElement.AppendChild(xmlBoxProperties); // Id XmlAttribute guidAttribute = xmlDoc.CreateAttribute("Id"); guidAttribute.Value = caseOfBoxesProperties.Guid.ToString(); xmlBoxProperties.Attributes.Append(guidAttribute); // name XmlAttribute nameAttribute = xmlDoc.CreateAttribute("Name"); nameAttribute.Value = caseOfBoxesProperties.Name; xmlBoxProperties.Attributes.Append(nameAttribute); // description XmlAttribute descAttribute = xmlDoc.CreateAttribute("Description"); descAttribute.Value = caseOfBoxesProperties.Description; xmlBoxProperties.Attributes.Append(descAttribute); // weight XmlAttribute weightAttribute = xmlDoc.CreateAttribute("Weight"); weightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", caseOfBoxesProperties.Weight); xmlBoxProperties.Attributes.Append(weightAttribute); // save inside ref to box properties XmlAttribute insideBoxId = xmlDoc.CreateAttribute("InsideBoxId"); insideBoxId.Value = caseOfBoxesProperties.InsideBoxProperties.Guid.ToString(); xmlBoxProperties.Attributes.Append(insideBoxId); // save case definition SaveCaseDefinition(caseOfBoxesProperties.CaseDefinition, xmlBoxProperties, xmlDoc); // save optim constraintset SaveCaseOptimConstraintSet(caseOfBoxesProperties.CaseOptimConstraintSet, xmlBoxProperties, xmlDoc); // colors SaveColors(caseOfBoxesProperties.Colors, xmlBoxProperties, xmlDoc); // texture SaveTextures(caseOfBoxesProperties.TextureList, xmlBoxProperties, xmlDoc); }