private void parse(XElement element) { XElement root = element.Element("Appearance"); if (root == null) { Logger.log(Logger.TYPE.DEBUG, "No Appearance element found."); return; } try { setText(root.Element("Text").Value); } catch (NullReferenceException) {} XElement font = root.Element("Font"); if (font != null) { FontFamily family = new FontFamily(font.Value); float size = (float)Convert.ToDouble(Xml.getAttributeValue(font, "size", "12")); GraphicsUnit unit = EnumUtils.parseEnum <GraphicsUnit>(Xml.getAttributeValue(font, "unit", "Point")); FontStyle bold = Convert.ToBoolean(Xml.getAttributeValue(font, "bold", "false")) ? FontStyle.Bold : 0; FontStyle italic = Convert.ToBoolean(Xml.getAttributeValue(font, "italic", "false")) ? FontStyle.Italic : 0; FontStyle strikeout = Convert.ToBoolean(Xml.getAttributeValue(font, "strikeout", "false")) ? FontStyle.Strikeout : 0; FontStyle underline = Convert.ToBoolean(Xml.getAttributeValue(font, "underline", "false")) ? FontStyle.Underline : 0; byte gdicharset = Convert.ToByte(Xml.getAttributeValue(font, "gdicharset", "0")); Boolean gdiverticalfont = Convert.ToBoolean(Xml.getAttributeValue(font, "gdiverticalfont", "false")); setFont(new Font(family, size, (bold | italic | strikeout | underline), unit, gdicharset, gdiverticalfont)); } try { setBackColor(Color.FromName(root.Element("BackColor").Value)); } catch (NullReferenceException) {} try { setActiveBackColor(Color.FromName(root.Element("ActiveBackColor").Value)); } catch (NullReferenceException) { } try { setActiveBorderColor(Color.FromName(root.Element("ActiveBorderColor").Value)); } catch (NullReferenceException) { } try { setBorderColor(Color.FromName(root.Element("BorderColor").Value)); } catch (NullReferenceException) { } try { setStandbyBackColor(Color.FromName(root.Element("StandbyBackColor").Value)); } catch (NullReferenceException) { } try { setHoverBackColor(Color.FromName(root.Element("HoverBackColor").Value)); } catch (NullReferenceException) { } try { setStandbyBorderColor(Color.FromName(root.Element("StandbyBorderColor").Value)); } catch (NullReferenceException) { } try { setHoverBorderColor(Color.FromName(root.Element("HoverBorderColor").Value)); } catch (NullReferenceException) { } try { setBorderStyle(EnumUtils.parseEnum <BorderStyle>(root.Element("BorderStyle").Value)); } catch (NullReferenceException) { } try { setCompositeQuality(EnumUtils.parseEnum <CompositingQuality>(root.Element("CompositeQuality").Value)); } catch (NullReferenceException) { } try { switch (root.Element("Cursor").Value) { case "AppStarting": setCursor(Cursors.AppStarting); break; case "Arrow": setCursor(Cursors.Arrow); break; case "Cross": setCursor(Cursors.Cross); break; case "Default": setCursor(Cursors.Default); break; case "Hand": setCursor(Cursors.Hand); break; case "Help": setCursor(Cursors.Help); break; case "HSplit": setCursor(Cursors.HSplit); break; case "IBeam": setCursor(Cursors.IBeam); break; case "No": setCursor(Cursors.No); break; case "NoMove2D": setCursor(Cursors.NoMove2D); break; case "NoMoveHoriz": setCursor(Cursors.NoMoveHoriz); break; case "NoMoveVert": setCursor(Cursors.NoMoveVert); break; case "PanEast": setCursor(Cursors.PanEast); break; case "PanNE": setCursor(Cursors.PanNE); break; case "PanNorth": setCursor(Cursors.PanNorth); break; case "PanNW": setCursor(Cursors.PanNW); break; case "PanSE": setCursor(Cursors.PanSE); break; case "PanSouth": setCursor(Cursors.PanSouth); break; case "PanSW": setCursor(Cursors.PanSW); break; case "PanWest": setCursor(Cursors.PanWest); break; case "SizeAll": setCursor(Cursors.SizeAll); break; case "SizeNESW": setCursor(Cursors.SizeNESW); break; case "SizeNS": setCursor(Cursors.SizeNS); break; case "SizeNWSE": setCursor(Cursors.SizeNWSE); break; case "SizeWE": setCursor(Cursors.SizeWE); break; case "UpArrow": setCursor(Cursors.UpArrow); break; case "VSplit": setCursor(Cursors.VSplit); break; case "WaitCursor": setCursor(Cursors.WaitCursor); break; } } catch (NullReferenceException) { } try { setDisabledTextColor(Color.FromName(root.Element("DisabledTextColor").Value)); } catch (NullReferenceException) { } try { setFlatStyle(EnumUtils.parseEnum <FlatStyle>(root.Element("FlatStyle").Value)); } catch (NullReferenceException) { } try { setForeColor(Color.FromName(root.Element("ForeColor").Value)); } catch (NullReferenceException) { } try { setImage(root.Element("Image").Value); } catch (NullReferenceException) { } try { setImageIndex(root.Element("ImageIndex").Value); } catch (NullReferenceException) { } try { setImageKey(root.Element("ImageKey").Value); } catch (NullReferenceException) { } try { setImageList(root.Element("ImageList").Value); } catch (NullReferenceException) { } try { setImageAlign(EnumUtils.parseEnum <ContentAlignment>(root.Element("ImageAlign").Value)); } catch (NullReferenceException) { } try { setRightToLeft(EnumUtils.parseEnum <RightToLeft>(root.Element("RightToLeft").Value)); } catch (NullReferenceException) { } try { setSmoothingMode(EnumUtils.parseEnum <SmoothingMode>(root.Element("SmoothingMode").Value)); } catch (NullReferenceException) { } try { setTextAlign(EnumUtils.parseEnum <ContentAlignment>(root.Element("TextAlign").Value)); } catch (NullReferenceException) { } try { setTextRenderHint(EnumUtils.parseEnum <TextRenderingHint>(root.Element("TextRenderHint").Value)); } catch (NullReferenceException) { } try { setUseMnmonic(Convert.ToBoolean(root.Element("UseMnmonic").Value)); } catch (NullReferenceException) { } try { setUseWaitCursor(Convert.ToBoolean(root.Element("UseWaitCursor").Value)); } catch (NullReferenceException) { } }
private void parse(XElement element) { XElement root = element.Element("Layout"); try { setAnchor(root.Element("GenerateMember").Value); } catch (NullReferenceException) { } try { setAutoSize(Convert.ToBoolean(root.Element("AutoSize").Value)); } catch (NullReferenceException) { } try { setDock(root.Element("Dock").Value); } catch (NullReferenceException) { } XElement location = root.Element("Location"); if (location != null) { int x = Convert.ToInt32(Xml.getAttributeValue(location.Attribute("X"), "0")); int y = Convert.ToInt32(Xml.getAttributeValue(location.Attribute("Y"), "0")); setLocation(new Point(x, y)); } XElement margin = root.Element("Margin"); if (margin != null) { int left = Convert.ToInt32(Xml.getAttributeValue(margin.Attribute("Left"), "0")); int top = Convert.ToInt32(Xml.getAttributeValue(margin.Attribute("Top"), "0")); int right = Convert.ToInt32(Xml.getAttributeValue(margin.Attribute("Right"), "0")); int bottom = Convert.ToInt32(Xml.getAttributeValue(margin.Attribute("Bottom"), "0")); setMargin(new Margins(left, right, top, bottom)); } XElement padding = root.Element("Padding"); if (padding != null) { int left = Convert.ToInt32(Xml.getAttributeValue(padding.Attribute("Left"), "0")); int top = Convert.ToInt32(Xml.getAttributeValue(padding.Attribute("Top"), "0")); int right = Convert.ToInt32(Xml.getAttributeValue(padding.Attribute("Right"), "0")); int bottom = Convert.ToInt32(Xml.getAttributeValue(padding.Attribute("Bottom"), "0")); setPadding(new Margins(left, right, top, bottom)); } XElement maxSize = root.Element("MaximumSize"); if (maxSize != null) { int width = Convert.ToInt32(Xml.getAttributeValue(maxSize.Attribute("Width"), "0")); int height = Convert.ToInt32(Xml.getAttributeValue(maxSize.Attribute("Height"), "0")); setMaxSize(new Size(width, height)); } XElement minSize = root.Element("MinimumSize"); if (minSize != null) { int width = Convert.ToInt32(Xml.getAttributeValue(minSize.Attribute("Width"), "0")); int height = Convert.ToInt32(Xml.getAttributeValue(minSize.Attribute("Height"), "0")); setMinSize(new Size(width, height)); } XElement size = root.Element("Size"); if (size != null) { int width = Convert.ToInt32(Xml.getAttributeValue(size.Attribute("Width"), "0")); int height = Convert.ToInt32(Xml.getAttributeValue(size.Attribute("Height"), "0")); setSize(new Size(width, height)); } }
private Update compileUpdate(UpdateNode node, XDocument xml) { Update update = new Update(node); if (isDead()) { return(update); } try { var root = from item in xml.Descendants("Update") select new { changelog = item.Descendants("Changelog"), files = item.Descendants("File"), archives = item.Descendants("Archive"), name = item.Attribute("name"), baseType = item.Attribute("base") }; foreach (var data in root) { // Set Attributes update.setName(data.name.Value); if (data.baseType != null) { update.setBaseType(data.baseType.Value); } // Add the changelog data foreach (var clog in data.changelog) { Changelog changelog = new Changelog(update.getVersion()); foreach (var log in clog.Descendants("Log")) { changelog.addLog(new Changelog.Log(log.Value.Trim())); } update.setChangelog(changelog); break; } // Add the file data foreach (var f in data.files) { String name = Xml.getAttributeValue(f.Attribute("name")); String destination = Xml.getAttributeValue(f.Attribute("destination")); String mime = Xml.getAttributeValue(f.Attribute("mime"), "none"); update.addFile(new GhostFile(name, destination, mime, new Uri(url + "/" + node.getDir() + "/" + name))); } // Add the archive data foreach (var f in data.archives) { String name = Xml.getAttributeValue(f.Attribute("name")); String extractTo = Xml.getAttributeValue(f.Attribute("extractTo")); String mime = Xml.getAttributeValue(f.Attribute("mime"), "none"); Boolean cleanDirs = false; if (f.Attribute("cleanDirs") != null) { cleanDirs = Convert.ToBoolean(f.Attribute("cleanDirs").Value.Trim()); } update.addFile(new Archive(name, extractTo, mime, new Uri(url + "/" + node.getDir() + "/" + name), cleanDirs)); } } } catch (Exception ex) { Logger.log(Logger.TYPE.ERROR, "Problem while compiling updates " + ex.Message + ex.StackTrace); } return(update); }
private void parse(XElement element) { XElement root = element.Element("Layout"); if (root == null) { Logger.log(Logger.TYPE.DEBUG, "No Layout element found."); return; } try { setAnchor(EnumUtils.parseEnum <AnchorStyles>(root.Element("Anchor").Value)); } catch (NullReferenceException) { } try { setAutoSize(Convert.ToBoolean(root.Element("AutoSize").Value)); } catch (NullReferenceException) { } try { setDock(EnumUtils.parseEnum <DockStyle>(root.Element("Dock").Value)); } catch (NullReferenceException) { } XElement location = root.Element("Location"); if (location != null) { int x = Convert.ToInt32(Xml.getAttributeValue(location.Attribute("X"), "0")); int y = Convert.ToInt32(Xml.getAttributeValue(location.Attribute("Y"), "0")); setLocation(new Point(x, y)); } XElement margin = root.Element("Margin"); if (margin != null) { int left = Convert.ToInt32(Xml.getAttributeValue(margin.Attribute("Left"), "0")); int top = Convert.ToInt32(Xml.getAttributeValue(margin.Attribute("Top"), "0")); int right = Convert.ToInt32(Xml.getAttributeValue(margin.Attribute("Right"), "0")); int bottom = Convert.ToInt32(Xml.getAttributeValue(margin.Attribute("Bottom"), "0")); setMargin(new Padding(left, right, top, bottom)); } XElement padding = root.Element("Padding"); if (padding != null) { int left = Convert.ToInt32(Xml.getAttributeValue(padding.Attribute("Left"), "0")); int top = Convert.ToInt32(Xml.getAttributeValue(padding.Attribute("Top"), "0")); int right = Convert.ToInt32(Xml.getAttributeValue(padding.Attribute("Right"), "0")); int bottom = Convert.ToInt32(Xml.getAttributeValue(padding.Attribute("Bottom"), "0")); setPadding(new Padding(left, right, top, bottom)); } XElement maxSize = root.Element("MaximumSize"); if (maxSize != null) { int width = Convert.ToInt32(Xml.getAttributeValue(maxSize.Attribute("Width"), "0")); int height = Convert.ToInt32(Xml.getAttributeValue(maxSize.Attribute("Height"), "0")); setMaxSize(new Size(width, height)); } XElement minSize = root.Element("MinimumSize"); if (minSize != null) { int width = Convert.ToInt32(Xml.getAttributeValue(minSize.Attribute("Width"), "0")); int height = Convert.ToInt32(Xml.getAttributeValue(minSize.Attribute("Height"), "0")); setMinSize(new Size(width, height)); } XElement size = root.Element("Size"); if (size != null) { int width = Convert.ToInt32(Xml.getAttributeValue(size.Attribute("Width"), "0")); int height = Convert.ToInt32(Xml.getAttributeValue(size.Attribute("Height"), "0")); setSize(new Size(width, height)); } }