public xmlElem(XElement source, xmlElem parent) { elementName = source.Name.ToString(); Parent = parent; pElements = new List <xmlElem>(); pAttributes = new List <xmlAttrib>(); if (source.HasElements == false) { elementValue = source.Value; } else { elementValue = ""; } foreach (XElement child in source.Elements()) { this.pElements.Add(new xmlElem(child, this)); } foreach (XAttribute item in source.Attributes()) { this.pAttributes.Add(new xmlAttrib(item)); } }
public bool replaceChildByAttrValue(String attrName, String attrValue, xmlElem replacingNode) { for (int i = 0; i < pElements.Count; i++) { xmlAttrib childAttr = pElements[i].pAttributes.Find( delegate(xmlAttrib attr) { return(attr.Name == attrName); }); try { if (childAttr.Value == attrValue) { this.pElements[i] = new xmlElem(replacingNode); //this.Remove(pElements[i]); //this.Add(replacingNode); OnPropertyChanged("xmlElements"); OnPropertyChanged("childRearingElements"); OnPropertyChanged("dummyElements"); OnPropertyChanged("lonelyElements"); OnPropertyChanged("AttributeElements"); return(true); } } catch { continue; } } return(false); }
public xmlElem() { elementName = ""; elementValue = ""; Parent = null; pElements = new List <xmlElem>(); pAttributes = new List <xmlAttrib>(); }
public xmlElem(String n, String v) { elementName = n; elementValue = v; Parent = null; pElements = new List <xmlElem>(); pAttributes = new List <xmlAttrib>(); }
public xmlElem(ref xmlElem parent) { elementName = ""; elementValue = ""; Parent = parent; pElements = new List <xmlElem>(); pAttributes = new List <xmlAttrib>(); }
public xmlElem(String n, String v, ref xmlElem parent) { elementName = n; elementValue = v; Parent = parent; pElements = new List <xmlElem>(); pAttributes = new List <xmlAttrib>(); }
public xmlElem Element(String elemName) { xmlElem childAttr = pElements.Find( delegate(xmlElem elem) { return(elem.Name == elemName); }); return(childAttr); }
/* ************************************************************************************************************************ *************************************************************************************************************************/ //protected void editData(xmlElem data, int[] selectedIndeces) //{ // //List<xmlElem> temp= new List<xmlElem>(dataContainer.xmlElements); // if (selectedIndeces.Length == 1) // { // foreach (int index in selectedIndeces) // { // //XAttribute childAttribute = temp[index].Attribute("Name"); // oldDataSource.replaceChildByAttrValue("Name", oldDataSource.xmlElements[index].Attribute("Name").Value, data); // } // } // OnPropertyChanged("dataContainer"); //} protected void editData(xmlElem data, int[] selectedIndeces, int fileDataSelector) { //List<xmlElem> temp= new List<xmlElem>(dataContainer.xmlElements); if (selectedIndeces.Length == 1) { foreach (int index in selectedIndeces) { //XAttribute childAttribute = temp[index].Attribute("Name"); dataContainerList[fileDataSelector].replaceChildByAttrValue("Name", dataContainerList[fileDataSelector].xmlElements[index].Attribute("Name").Value, data); } } //OnPropertyChanged("dataContainer"); }
/* ************************************************************************************************************************ *************************************************************************************************************************/ protected void openFile(out CollectionView guiCollectionView, out String shortFileName) { String fileDirectory; guiCollectionView = null; ObservableCollection <FileHandler> fileListHolder = filesOpen; //if (useNewVersion == false) //{ // if (openFileChooser(out shortFileName, out fileDirectory) == true) // { // currentFile = new FileHandler(fileDirectory, shortFileName); // setOrGetSetting(EditorSettings.lastDirectoryOpened, ref fileDirectory, true); // setOrGetSetting(EditorSettings.lastFileOpened, ref shortFileName, true); // oldDataSource = new xmlElem(currentFile.open()); // oldDataView = (CollectionView)CollectionViewSource.GetDefaultView(oldDataContainer.xmlElements); // } // return; //} if (openFileChooser(out shortFileName, out fileDirectory) == true) { FileHandler tempFileHandler = new FileHandler(fileDirectory, shortFileName); setOrGetSetting(EditorSettings.lastDirectoryOpened, ref fileDirectory, true); //setOrGetSetting(EditorSettings.lastFileOpened, ref shortFileName, true); xmlElem tempDataElement = new xmlElem(tempFileHandler.open()); //dataContainerView = (CollectionView)CollectionViewSource.GetDefaultView(dataContainer.xmlElements); filesOpen.Clear(); filesOpen.Add(tempFileHandler); dataContainerList.Clear(); dataContainerList.Add(tempDataElement); bindFunction(out guiCollectionView, 0); return; } filesOpen = fileListHolder; }
/* ************************************************************************************************************************ * if there is a single item selected, it returns that items data, * if there are multiple items, returns an empty item that mimics the structure of the items *************************************************************************************************************************/ //protected void selectData(int[] indices, ref xmlElem itemContainer) //{ // if (indices.Length == 0) // { // return; // } // else if (indices.Length == 1) // { // itemContainer = oldDataSource.xmlElements[indices[0]]; // } // else // { // itemContainer = createItem(oldDataSource.xmlElements[indices[0]]); // } //} protected void selectData(int[] indices, ref xmlElem itemContainer, int fileDataSelector) { if (indices.Length == 0) { return; } else if (indices.Length == 1) { itemContainer = dataContainerList[fileDataSelector].xmlElements[indices[0]]; //itemContainer = oldDataSource.xmlElements[indices[0]]; } else { itemContainer = createItem(dataContainerList[fileDataSelector].xmlElements[indices[0]]); //itemContainer = createItem(oldDataSource.xmlElements[indices[0]]); } }
//list of indeces for all select items in Listbox //private int[] listBoxSelectedItems //{ // get // { // try // { // int[] someArray = new int[windowListbox.SelectedItems.Count]; // for (int i = 0; i < windowListbox.SelectedItems.Count; i++) // { // someArray[i] = windowListbox.Items.IndexOf(windowListbox.SelectedItems[i]); // } // return someArray; // } // catch // { // return null; // } // } //} /* ************************************************************************************************************************ *************************************************************************************************************************/ public MainWindow(controllerDelegateContainer editorFunctions, controllerDataDelegateContainer editorDataFunctions, controllerMiscDelegateContainer editorMiscFunctions) { InitializeComponent(); if (editorFunctions == null) { throw new NullReferenceException("MainWindow Constructor cannot have a null references to editorFunctions, editorDataFunctions, or editorMiscFunctions"); } editorFunctions.retrieveDelegates(out contErrorDisplayer, out contProgramCloser); editorDataFunctions.retrieveDelegates(out contDataGetter, out contItemAdder, out contItemEditor); editorMiscFunctions.retrieveDelegates(out contFileOpener, out contNewFileOpener, out contSettingHandler, out contFileSaver, out contGetFolderContents); //windowListbox.ItemsSource = dataView; dataSourceContainer = new List <CollectionView>(); itemEditorDataElement = new xmlElem(); }
protected void openAnotherFile(out CollectionView guiCollectionView, String fileName) { FileHandler tempFileHandler = new FileHandler(workingDirectory.path, fileName); xmlElem tempDataElement = new xmlElem(tempFileHandler.open()); try { guiCollectionView = (CollectionView)CollectionViewSource.GetDefaultView(tempDataElement.xmlElements); } catch { showErrorMessage("Could not bind to xml"); guiCollectionView = null; } filesOpen.Add(tempFileHandler); dataContainerList.Add(tempDataElement); }
public xmlElem(xmlElem source, xmlElem parent) { elementName = source.elementName; elementValue = source.elementValue; Parent = parent; pElements = new List <xmlElem>(); pAttributes = new List <xmlAttrib>(); foreach (xmlElem child in source.pElements) { this.pElements.Add(new xmlElem(child, this)); } foreach (xmlAttrib item in source.pAttributes) { this.pAttributes.Add(new xmlAttrib(item)); } }
public xmlElem(xmlElem source) { elementName = source.elementName; elementValue = source.elementValue; Parent = null; pElements = new List <xmlElem>(); pAttributes = new List <xmlAttrib>(); //foreach (xmlElem child in source.pElements) //{ // this.pElements.Add(new xmlElem(child)); //} this.AddElements(source.pElements); foreach (xmlAttrib item in source.pAttributes) { this.pAttributes.Add(new xmlAttrib(item)); } }
protected xmlElem recuresiveElementCloner(xmlElem source) { xmlElem temp = new xmlElem(source.Name.ToString(), ""); xmlAttrib tempAttr; temp.Value = ""; foreach (xmlAttrib attr in source.Attributes) { tempAttr = temp.Attribute(attr.Name.ToString()); tempAttr.Value = ""; } foreach (xmlElem item in source.Elements) { try { temp.AddElement(recuresiveElementCloner(item)); } catch { } } return(temp); }
protected void openAnotherFile(out CollectionView guiCollectionView, int fileNameIndex) { //FileHandler tempFileHandler = new FileHandler(workingDirectory.path, filesOpen[fileNameIndex].fileName); String t1 = workingDirectory.path; String t2 = workingDirectory.contents[fileNameIndex].name; //FileHandler tempFileHandler = new FileHandler(workingDirectory.path, workingDirectory.contents[fileNameIndex].name); FileHandler tempFileHandler = new FileHandler(t1, t2); xmlElem tempDataElement = new xmlElem(tempFileHandler.open()); try { guiCollectionView = (CollectionView)CollectionViewSource.GetDefaultView(tempDataElement.xmlElements); } catch { showErrorMessage("Could not bind to xml"); guiCollectionView = null; } filesOpen.Add(tempFileHandler); dataContainerList.Add(tempDataElement); }
public xmlElem(String n, String v, ref xmlElem parent) { elementName = n; elementValue = v; Parent = parent; pElements = new List<xmlElem>(); pAttributes = new List<xmlAttrib>(); }
public xmlElem(xmlElem source) { elementName = source.elementName; elementValue = source.elementValue; Parent = null; pElements = new List<xmlElem>(); pAttributes = new List<xmlAttrib>(); //foreach (xmlElem child in source.pElements) //{ // this.pElements.Add(new xmlElem(child)); //} this.AddElements(source.pElements); foreach (xmlAttrib item in source.pAttributes) { this.pAttributes.Add(new xmlAttrib(item)); } }
public xmlElem(ref xmlElem parent) { elementName = ""; elementValue = ""; Parent = parent; pElements = new List<xmlElem>(); pAttributes = new List<xmlAttrib>(); }
public xmlElem(String n, String v) { elementName = n; elementValue = v; Parent = null; pElements = new List<xmlElem>(); pAttributes = new List<xmlAttrib>(); }
public xmlElem() { elementName = ""; elementValue = ""; Parent = null; pElements = new List<xmlElem>(); pAttributes = new List<xmlAttrib>(); }
/* ************************************************************************************************************************ * a wrapper function for the Xcontainer Add() method that gets passed to other classes through a delegate *************************************************************************************************************************/ //protected void addData(xmlElem source) //{ // oldDataSource.AddElement(source); // //OnPropertyChanged("dataContainer"); //} protected void addData(xmlElem source, int fileDataSelector) { dataContainerList[fileDataSelector].AddElement(source); }
public xmlElem(xmlElem source, xmlElem parent) { elementName = source.elementName; elementValue = source.elementValue; Parent = parent; pElements = new List<xmlElem>(); pAttributes = new List<xmlAttrib>(); foreach (xmlElem child in source.pElements) { this.pElements.Add(new xmlElem(child, this)); } foreach (xmlAttrib item in source.pAttributes) { this.pAttributes.Add(new xmlAttrib(item)); } }
public void AddElement(xmlElem child) { child.Parent= this.Parent; pElements.Add(new xmlElem(child)); }
/* ************************************************************************************************************************ *************************************************************************************************************************/ protected void openFile(out CollectionView guiCollectionView, out String shortFileName) { String fileDirectory; guiCollectionView = null; ObservableCollection<FileHandler> fileListHolder = filesOpen; //if (useNewVersion == false) //{ // if (openFileChooser(out shortFileName, out fileDirectory) == true) // { // currentFile = new FileHandler(fileDirectory, shortFileName); // setOrGetSetting(EditorSettings.lastDirectoryOpened, ref fileDirectory, true); // setOrGetSetting(EditorSettings.lastFileOpened, ref shortFileName, true); // oldDataSource = new xmlElem(currentFile.open()); // oldDataView = (CollectionView)CollectionViewSource.GetDefaultView(oldDataContainer.xmlElements); // } // return; //} if (openFileChooser(out shortFileName, out fileDirectory) == true) { FileHandler tempFileHandler = new FileHandler(fileDirectory, shortFileName); setOrGetSetting(EditorSettings.lastDirectoryOpened, ref fileDirectory, true); //setOrGetSetting(EditorSettings.lastFileOpened, ref shortFileName, true); xmlElem tempDataElement = new xmlElem(tempFileHandler.open()); //dataContainerView = (CollectionView)CollectionViewSource.GetDefaultView(dataContainer.xmlElements); filesOpen.Clear(); filesOpen.Add(tempFileHandler); dataContainerList.Clear(); dataContainerList.Add(tempDataElement); bindFunction(out guiCollectionView, 0); return; } filesOpen = fileListHolder; }
public void setFileContent(xmlElem content) { xmlFile.root = content; }
/* ************************************************************************************************************************ * temporary functions for cloning the structure of an xmlElement, but wiping the data * once functions works well, move to xml classes *************************************************************************************************************************/ protected xmlElem createItem(xmlElem cloneable) { return recuresiveElementCloner(cloneable); }
protected xmlElem recuresiveElementCloner(xmlElem source) { xmlElem temp = new xmlElem(source.Name.ToString(), ""); xmlAttrib tempAttr; temp.Value = ""; foreach (xmlAttrib attr in source.Attributes) { tempAttr = temp.Attribute(attr.Name.ToString()); tempAttr.Value = ""; } foreach (xmlElem item in source.Elements) { try { temp.AddElement(recuresiveElementCloner(item)); } catch { } } return temp; }
public xmlElem(XElement source, xmlElem parent) { elementName = source.Name.ToString(); Parent = parent; pElements = new List<xmlElem>(); pAttributes = new List<xmlAttrib>(); if (source.HasElements == false) { elementValue = source.Value; } else { elementValue = ""; } foreach (XElement child in source.Elements()) { this.pElements.Add(new xmlElem(child, this)); } foreach (XAttribute item in source.Attributes()) { this.pAttributes.Add(new xmlAttrib(item)); } }
public xmlDoc() { xmlDeclaration = new XDeclaration("1.0", "utf-8", "yes"); rootElem = new xmlElem(); }
//list of indeces for all select items in Listbox //private int[] listBoxSelectedItems //{ // get // { // try // { // int[] someArray = new int[windowListbox.SelectedItems.Count]; // for (int i = 0; i < windowListbox.SelectedItems.Count; i++) // { // someArray[i] = windowListbox.Items.IndexOf(windowListbox.SelectedItems[i]); // } // return someArray; // } // catch // { // return null; // } // } //} /* ************************************************************************************************************************ *************************************************************************************************************************/ public MainWindow(controllerDelegateContainer editorFunctions, controllerDataDelegateContainer editorDataFunctions, controllerMiscDelegateContainer editorMiscFunctions) { InitializeComponent(); if (editorFunctions == null) { throw new NullReferenceException("MainWindow Constructor cannot have a null references to editorFunctions, editorDataFunctions, or editorMiscFunctions"); } editorFunctions.retrieveDelegates(out contErrorDisplayer, out contProgramCloser); editorDataFunctions.retrieveDelegates(out contDataGetter, out contItemAdder, out contItemEditor); editorMiscFunctions.retrieveDelegates(out contFileOpener, out contNewFileOpener, out contSettingHandler, out contFileSaver, out contGetFolderContents); //windowListbox.ItemsSource = dataView; dataSourceContainer = new List<CollectionView>(); itemEditorDataElement = new xmlElem(); }
public xmlDoc(xmlDoc source) { xmlDeclaration = new XDeclaration(source.xmlDeclaration); rootElem = new xmlElem(source.root); }
/* ************************************************************************************************************************ * temporary functions for cloning the structure of an xmlElement, but wiping the data * once functions works well, move to xml classes *************************************************************************************************************************/ protected xmlElem createItem(xmlElem cloneable) { return(recuresiveElementCloner(cloneable)); }
public xmlDoc(XDocument source) { xmlDeclaration = new XDeclaration(source.Declaration); rootElem = new xmlElem(source.Root); }
public void Remove(xmlElem child) { pElements.Remove(child); }
public void AddElement(xmlElem child) { child.Parent = this.Parent; pElements.Add(new xmlElem(child)); }
public bool replaceChildByAttrValue(String attrName, String attrValue, xmlElem replacingNode) { for (int i = 0; i < pElements.Count; i++) { xmlAttrib childAttr = pElements[i].pAttributes.Find( delegate(xmlAttrib attr) { return (attr.Name == attrName); }); try { if (childAttr.Value == attrValue) { this.pElements[i] = new xmlElem(replacingNode); //this.Remove(pElements[i]); //this.Add(replacingNode); OnPropertyChanged("xmlElements"); OnPropertyChanged("childRearingElements"); OnPropertyChanged("dummyElements"); OnPropertyChanged("lonelyElements"); OnPropertyChanged("AttributeElements"); return true; } } catch { continue; } } return false; }
public xmlDoc(XDeclaration dec) { xmlDeclaration = new XDeclaration(dec); rootElem = new xmlElem(); }