public void Initialize(string projectId, string fileName) { ProjectId = projectId; FileName = fileName; MyRollPaths = new RollPaths(); JobSpecPath = MyRollPaths.GetJobSpec() + @"\" + ProjectId + @"\" + FileName; if (File.Exists(JobSpecPath)) RootElement = XElement.Load(JobSpecPath); AutoCropElement = RootElement.Element("Roll").Element("ImageProcessing").Element("ProcessSequence").Element("AutoCrop"); DeskewElement = RootElement.Element("Roll").Element("ImageProcessing").Element("ProcessSequence").Element("Deskew"); if (AutoCropElement != null) { if (AutoCropElement.Attribute("xDirection").Value == "true" && AutoCropElement.Attribute("yDirection").Value == "true") AutoCrop = true; else AutoCrop = false; if (AutoCropElement.Attribute("AggressiveFactor").Value == "true") AggressiveFactor = true; else AggressiveFactor = false; CropPadding = Convert.ToInt32(AutoCropElement.Attribute("CropPadding").Value); } if (DeskewElement != null) DeskewMaxAngle = Convert.ToInt32(DeskewElement.Attribute("MaxAngle").Value); }
public JobSpecUpdates(Roll myRoll, RollPaths myRollPaths) { MyRoll = myRoll; MyRollPaths = myRollPaths; JobSpecDataReturn = MyRollPaths.GetJobSpec(); if (File.Exists(JobSpecDataReturn + @"\" + MyRoll.ProjectId + @"\" + MyRoll.RollName + ".xml")) JobSpecPath = JobSpecDataReturn + @"\" + MyRoll.ProjectId + @"\" + MyRoll.RollName + ".xml"; else if (File.Exists(JobSpecDataReturn + @"\" + MyRoll.RollName.Substring(0, 5) + @"\" + MyRoll.RollName + ".xml")) JobSpecPath = JobSpecDataReturn + @"\" + MyRoll.RollName.Substring(0, 5) + @"\" + MyRoll.RollName + ".xml"; RefreshRootElement(); if (RootElement != null) { if (RootElement.Descendants("Roll") .Where(roll => roll.Elements("ImageProcessing").Any()).Any()) { if (RootElement.Element("Roll").Descendants("ImageProcessing") .Where(roll => roll.Elements("ProcessSequence").Any()).Any()) { if (RootElement.Element("Roll").Element("ImageProcessing").Descendants("ProcessSequence") .Where(roll => roll.Elements("AutoCrop").Any()).Any()) { AutoCropElement = RootElement.Element("Roll").Element("ImageProcessing").Element("ProcessSequence").Element("AutoCrop"); AutoCropExists = true; } else AutoCropExists = false; DeskewElement = RootElement.Element("Roll").Element("ImageProcessing").Element("ProcessSequence").Element("Deskew"); } } if (AutoCropElement != null) { if (AutoCropElement.Attribute("xDirection").Value == "true" && AutoCropElement.Attribute("yDirection").Value == "true") AutoCrop = true; else AutoCrop = false; if (AutoCropElement.Attribute("AggressiveFactor").Value == "true") AggressiveFactor = true; else AggressiveFactor = false; CropPadding = Convert.ToInt32(AutoCropElement.Attribute("CropPadding").Value); } if (DeskewElement != null) DeskewMaxAngle = Convert.ToInt32(DeskewElement.Attribute("MaxAngle").Value); } }