public bool equalsExceptType(KritaPresetParam param) { if (this.name.Equals(param.name) && this.value.Equals(param.value)) { return(true); } return(false); }
/// <summary> /// Reorders the attributes in the Element of the given KritaPresetParam. /// </summary> /// <param name="param"></param> private void reorderAttributes(KritaPresetParam param) { // Check if it an element XElement element; try { element = XElement.Parse(param.Value); } catch (Exception) { return; } if (!element.HasAttributes) { return; } reorderAllAttributes(element); // Replace the param.Value, removing newlines that may have been added // (Helps with formatting the output) param.Value = element.ToString().Replace(System.Environment.NewLine, ""); }
public int Compare(KritaPresetParam x, KritaPresetParam y) { return(((KritaPresetParam)x).name.CompareTo(((KritaPresetParam)y).name)); }
/// <summary> /// Processes the preset text. /// </summary> /// <param name="presetText is the presetText."></param> /// <param name="print">Whether to print progress to the output TextBox.</param> private void processXml(String presetText, bool print) { if (presetText == null || presetText.Length == 0) { if (print) { textBoxInfo.AppendText("\nThe preset element is not defined"); } return; } #if debugging // DEBUG textBoxInfo.AppendText(xmlString + NL + NL); #endif // Calculate the KritaPresetParam's XDocument doc = XDocument.Parse(presetText); XElement preset = doc.Element("Preset"); // Get the attributes of Preset if (preset != null && preset.HasAttributes) { IEnumerable <XAttribute> attributes = preset.Attributes(); foreach (XAttribute attribute in attributes) { attributesCur.Add(attribute.ToString()); } attributesCur.Sort(); // Reset the heading if (print) { textBoxInfo.Clear(); printHeading(fileTypeCur); } } // Get the param elements of Preset KritaPresetParam param = null; foreach (XElement element in doc.Descendants("param")) { param = new KritaPresetParam(element); // Parse inside the param paramsCur.Add(param); if (!param.Err) { //// DEBUG //if (print) { // textBoxInfo.AppendText("B " + param.info()); //} if (checkBoxReorderAttr.Checked) { reorderAttributes(param); } if (print) { textBoxInfo.AppendText(param.info()); } } else { if (print) { textBoxInfo.AppendText(param.ErrorMessage); } } } // Print the raw XML if (print && checkBoxPrintRaw.Checked) { processRawXml(presetText); } // Check for other elements than param if (print) { processCheckForNonParamElements(presetText); } }
/// <summary> /// Compares the two files and displays the output. /// </summary> private void compare() { // Process 1 process1(false); if (params1.Count == 0) { Utils.Utils.errMsg("Did not get params for Brush 1"); return; } // Process 2 process2(false); if (params2.Count == 0) { Utils.Utils.errMsg("Did not get params for Brush 2"); return; } // Write heading to textBoxInfo textBoxInfo.Text = "1: "; if (checkBoxBundle1.Checked) { printHeading(FileType.Bundle1); } else { printHeading(FileType.File1); } textBoxInfo.AppendText("2: "); if (checkBoxBundle2.Checked) { printHeading(FileType.Bundle2); } else { printHeading(FileType.File2); } // Look for items in 2 that are in 1 bool found; KritaPresetParam foundParam = null; foreach (KritaPresetParam param1 in params1) { found = false; // Look for the same name foreach (KritaPresetParam param2 in params2) { if (param1.Name.Equals(param2.Name)) { found = true; foundParam = param2; break; } } if (!found) { textBoxInfo.AppendText(param1.Name + NL); textBoxInfo.AppendText(" 1: " + param1.Value + NL); textBoxInfo.AppendText(" 2: Not found in 2" + NL); continue; } if (found && !param1.equalsExceptType(foundParam)) { textBoxInfo.AppendText(param1.Name + NL); textBoxInfo.AppendText(" 1: " + param1.Value + NL); textBoxInfo.AppendText(" 2: " + foundParam.Value + NL); } } // Look for items in 2 that are not in 1 textBoxInfo.AppendText(NL); foreach (KritaPresetParam param2 in params2) { found = false; // Look for the same name foreach (KritaPresetParam param1 in params1) { if (param1.Name.Equals(param2.Name)) { found = true; foundParam = param2; break; } } if (!found) { textBoxInfo.AppendText(param2.Name + NL); textBoxInfo.AppendText(" 1: Not found in 1" + NL); textBoxInfo.AppendText(" 2: " + param2.Value + NL); break; } } }