/// <summary> /// Baut aus der Liste von ArcheoObjecten ein XmlDocument /// </summary> /// <param name="archObj"></param> /// <returns>gibt das XmlDocument zurück</returns> public XmlDocument GenerateXMLDocumentFromArcheoObjectList(Dictionary <string, ArcheoObject> archObjCol) { XmlDocument xmlDoc = new XmlDocument(); XmlNode rootNode = xmlDoc.CreateElement("ArcheoObjectsList"); foreach (KeyValuePair <string, ArcheoObject> archObject in archObjCol) { XmlNode archeoNode = xmlDoc.CreateElement("ArcheoObject"); XmlAttribute codeAttribute = xmlDoc.CreateAttribute("code"); codeAttribute.InnerText = archObject.Key; archeoNode.Attributes.Append(codeAttribute); ArcheoObject archeoObject = archObject.Value; Dictionary <string, string> PropertyList = archeoObject.GetArcheoObjectAsDictonary(); foreach (KeyValuePair <string, string> item in PropertyList) { XmlNode node = xmlDoc.CreateElement(item.Key); node.InnerText = item.Value; archeoNode.AppendChild(node); } rootNode.AppendChild(archeoNode); } xmlDoc.AppendChild(rootNode); return(xmlDoc); }
internal void SetArcheoObject(string Id, ArcheoObject archeoObject) { //TODO: Suche das richtige ArcheoObject, wenn keins da, dann mach neuen Eintrag. ArcheoObject archeo = GetArcheoObject(Id); archeo = archeoObject; this.RemoveArcheoObject(Id); this.AddArcheoObject(archeoObject); this.SaveArcheoObjects(); }
internal void SetArcheoObjectInForm(ArcheoObject archeoObject) { this.labelId.Text = archeoObject.IdOut; this.textBoxCode.Text = archeoObject.CodeOut; this.textBoxCoordinate.Text = archeoObject.CoordinatesOut; this.comboBoxTypeOfBuild.Text = archeoObject.TypOfBuildOut; this.textBoxDepth.Text = archeoObject.DepthOut; this.textBoxDescription.Text = archeoObject.DescriptionOut; this.textBoxHeight.Text = archeoObject.HeightOut; this.textBoxSpecialFeatures.Text = archeoObject.SpecialFeaturesOut; this.textBoxWidth.Text = archeoObject.WidthOut; this.textBoxDepth.Text = archeoObject.DepthOut; this.comboBoxRockTyp.Text = archeoObject.RockTypeOut; this.pictureBox1.ImageLocation = archeoObject.PictureLinkOut; this.IsChanged = false; }
public void ExportToWord(ArcheoObject archeoObject, string FullDirectory) { object documentTyp = 0; object visible = true; object fileName = FullDirectory + archeoObject.CodeOut + ".docx"; string fullTemplateName = new FilePaths().GetTemplatePath(); object templateName = fullTemplateName; object missing = System.Reflection.Missing.Value; Application oWordApp = new Application(); oWordApp.Visible = true; Document oWordDoc = oWordApp.Documents.Add(ref templateName, missing, documentTyp, visible); oWordDoc.Activate(); int test = oWordDoc.Bookmarks.Count; bool test1 = oWordDoc.Bookmarks.Exists("Code"); string[] textmarkes = archeoObject.GetObjectProperties(); string[] archeoObjectAsString = archeoObject.GetArcheoObject(true); Dictionary <string, string> archeoObjectAsDict = archeoObject.GetArcheoObjectAsDictonary(); object textmarke = new object(); int i = 0; foreach (string property in textmarkes) { textmarke = property; bool archeoObjectParam = archeoObjectAsDict.TryGetValue(property, out string value); bool textMarkeExists = oWordDoc.Bookmarks.Exists(property); if (archeoObjectParam && textMarkeExists) { oWordDoc.Bookmarks.get_Item(ref textmarke).Range.Text = value; } i++; } //Einfügen Bild Range aRange = oWordDoc.Range(Start: oWordDoc.Paragraphs[12].Range.Start, oWordDoc.Paragraphs[12].Range.End); oWordDoc.InlineShapes.AddPicture(archeoObject.PictureLinkOut, false, true, aRange); oWordDoc.SaveAs2(fileName); oWordDoc.Close(); oWordApp.Quit(); }
private void SaveArcheoObject() { ArcheoObject archeoObject = new ArcheoObject { IdOut = this.labelId.Text, CodeOut = this.textBoxCode.Text, CoordinatesOut = this.textBoxCoordinate.Text, TypOfBuildOut = this.comboBoxTypeOfBuild.Text, DepthOut = this.textBoxDepth.Text, DescriptionOut = this.textBoxDescription.Text, HeightOut = this.textBoxHeight.Text, SpecialFeaturesOut = this.textBoxSpecialFeatures.Text, WidthOut = this.textBoxWidth.Text, RockTypeOut = this.comboBoxRockTyp.Text, PictureLinkOut = this.pictureBox1.ImageLocation }; this.archeoObjectViewCtl.SaveArcheoObjectInList(archeoObject); this.IsChanged = false; archeoObjectViewCtl.SetStatus(archeoObject.CodeOut + " gespeichert.", false); }
/// <summary> /// Gibt ein Liste von ArcheoObjects zurück /// </summary> /// <returns>Dictionary "string, ArcheoObject"</string></returns> public Dictionary <string, ArcheoObject> GetArcheoObjColFromXMLDoc() { Dictionary <string, ArcheoObject> archeoObjects = new Dictionary <string, ArcheoObject>(); XmlDocument xmlDoc = this.ReadXMLDocumentFromFile(new FilePaths().GetXmlDataFilePath()); XmlNodeList elemList = xmlDoc.DocumentElement.SelectNodes("/ArcheoObjectsList/ArcheoObject"); foreach (XmlNode node in elemList) { ArcheoObject archeoObject = new ArcheoObject(); string[] PropertyList = archeoObject.GetObjectProperties(); Dictionary <string, string> keyValuePairs = new Dictionary <string, string>(); string id = node.SelectSingleNode("Id").InnerText; foreach (string property in PropertyList) { keyValuePairs.Add(property, node.SelectSingleNode(property).InnerText); } archeoObject.SetArcheoObject(keyValuePairs); archeoObjects.Add(id, archeoObject); } return(archeoObjects); }
// TODO: Speichern des geladenen Objekts anfordern, oder automatisch speichern. internal void CreateArcheoObjectDetailView(string archeoObjectId) { if (this.archeologCatalogDetail.IsDisposed) { this.archeologCatalogDetail = new ArcheologCatalogDetail(this); } this.archeologCatalogDetail.FillComboFields(); if (archeoObjectId != null) { ArcheoObject archeoObject = this.archeoObjectCtl.GetArcheoObject(archeoObjectId); this.archeologCatalogDetail.SetArcheoObjectInForm(archeoObject); this.archeologCatalogDetail.Activate(); this.archeologCatalogDetail.Visible = true; this.archeologCatalogDetail.Show(); } else { this.archeologCatalogDetail.ClearArcheoObjectInForm(this.archeoObjectCtl.GetRandomId()); this.archeologCatalogDetail.Show(); } }
internal void AddArcheoObject(ArcheoObject archeoObject) { archeoObjects.Add(archeoObject.IdOut, archeoObject); }
internal void SaveArcheoObjectInList(ArcheoObject archeoObject) { this.archeoObjectCtl.SetArcheoObject(archeoObject.IdOut, archeoObject); this.RefreshListInListView(); }