Ejemplo n.º 1
0
        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.Attribute("size"), "12"));
                GraphicsUnit unit            = EnumUtils.parseEnum <GraphicsUnit>(Xml.getAttributeValue(font.Attribute("unit"), "Point"));
                FontStyle    bold            = Convert.ToBoolean(Xml.getAttributeValue(font.Attribute("bold"), "false")) ? FontStyle.Bold : 0;
                FontStyle    italic          = Convert.ToBoolean(Xml.getAttributeValue(font.Attribute("italic"), "false")) ? FontStyle.Italic : 0;
                FontStyle    strikeout       = Convert.ToBoolean(Xml.getAttributeValue(font.Attribute("strikeout"), "false")) ? FontStyle.Strikeout : 0;
                FontStyle    underline       = Convert.ToBoolean(Xml.getAttributeValue(font.Attribute("underline"), "false")) ? FontStyle.Underline : 0;
                byte         gdicharset      = Convert.ToByte(Xml.getAttributeValue(font.Attribute("gdicharset"), "0"));
                Boolean      gdiverticalfont = Convert.ToBoolean(Xml.getAttributeValue(font.Attribute("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) { }
        }
Ejemplo n.º 2
0
        protected void setFont(XElement elem, String fontName)
        {
            float size = 0;

            try {
                size = float.Parse(elem.Attribute("size").Value);
            }
            catch (Exception e) {
                Logger.log(Logger.TYPE.ERROR, "FontApply: Unable to parse 'size'. " + e.Message);
                return;
            }

            GraphicsUnit unit;

            try {
                unit = EnumUtils.parseEnum <GraphicsUnit>(elem.Attribute("unit").Value);
            }
            catch (Exception e) {
                Logger.log(Logger.TYPE.ERROR, "FontApply: Unable to parse 'unit'. " + e.Message);
                return;
            }

            bool gdiVerticalFont;

            try {
                gdiVerticalFont = Convert.ToBoolean(elem.Attribute("gdiverticalfont").Value);
            }
            catch (Exception e) {
                Logger.log(Logger.TYPE.ERROR, "FontApply: Unable to parse 'gdiverticalfont'. " + e.Message);
                return;
            }

            byte gdiCharSet;

            try {
                gdiCharSet = Convert.ToByte(elem.Attribute("gdicharset").Value);
            }
            catch (Exception e) {
                Logger.log(Logger.TYPE.ERROR, "FontApply: Unable to parse 'gdicharset'. " + e.Message);
                return;
            }

            bool bold;

            try {
                bold = Convert.ToBoolean(elem.Attribute("bold").Value);
            }
            catch (Exception e) {
                Logger.log(Logger.TYPE.ERROR, "FontApply: Unable to parse 'bold'. " + e.Message);
                return;
            }

            bool italic;

            try {
                italic = Convert.ToBoolean(elem.Attribute("italic").Value);
            }
            catch (Exception e) {
                Logger.log(Logger.TYPE.ERROR, "FontApply: Unable to parse 'italic'. " + e.Message);
                return;
            }

            bool strikeout;

            try {
                strikeout = Convert.ToBoolean(elem.Attribute("strikeout").Value);
            }
            catch (Exception e) {
                Logger.log(Logger.TYPE.ERROR, "FontApply: Unable to parse 'strikeout'. " + e.Message);
                return;
            }

            bool underline;

            try {
                underline = Convert.ToBoolean(elem.Attribute("underline").Value);
            }
            catch (Exception e) {
                Logger.log(Logger.TYPE.ERROR, "FontApply: Unable to parse 'underline'. " + e.Message);
                return;
            }

            FontStyle fontStyle = FontStyle.Regular;

            if (bold)
            {
                fontStyle = FontStyle.Bold;
            }
            if (italic)
            {
                fontStyle |= FontStyle.Italic;
            }
            if (strikeout)
            {
                fontStyle |= FontStyle.Strikeout;
            }
            if (underline)
            {
                fontStyle |= FontStyle.Underline;
            }

            this.font = new Font(fontName, size, fontStyle, unit, gdiCharSet, gdiVerticalFont);
        }
Ejemplo n.º 3
0
        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));
            }
        }