// <WindowPos titleregexp=".*?\s-\sNotepad" rect="10,50,300,200" screen="1" keep="1" />
        void parseXml(XElement xml)
        {
            pos = new WindowPos();

            if (xml != null)
            {
                var xrect = X.Attribute(xml, "Rect", true);
                if (xrect != null)
                {
                    var myRegex = new Regex(@"\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*(-?\d+)\s*");
                    var m       = myRegex.Match((string)xrect);
                    if (m != null && m.Success)
                    {
                        pos.Rect = new System.Drawing.Rectangle(
                            int.Parse(m.Groups[1].Value),
                            int.Parse(m.Groups[2].Value),
                            int.Parse(m.Groups[3].Value),
                            int.Parse(m.Groups[4].Value)
                            );
                    }
                }

                pos.Screen       = X.getIntAttr(xml, "Screen", 0, ignoreCase: true);
                pos.TitleRegExp  = X.getStringAttr(xml, "TitleRegExp", null, ignoreCase: true);
                pos.Keep         = X.getBoolAttr(xml, "Keep", false, ignoreCase: true);
                pos.Topmost      = X.getBoolAttr(xml, "TopMost", false, ignoreCase: true);
                pos.BringToFront = X.getBoolAttr(xml, "BringToFront", false, ignoreCase: true);
                pos.SendToBack   = X.getBoolAttr(xml, "SendToBack", false, ignoreCase: true);
                //pos.SetFocus = X.getBoolAttr(xml, "SetFocus", false, ignoreCase:true);

                string wsstr = X.getStringAttr(xml, "WindowStyle", null, ignoreCase: true);
                if (wsstr != null)
                {
                    if (wsstr.ToLower() == "minimized")
                    {
                        pos.WindowStyle = EWindowStyle.Minimized;
                    }
                    else
                    if (wsstr.ToLower() == "maximized")
                    {
                        pos.WindowStyle = EWindowStyle.Maximized;
                    }
                    else
                    if (wsstr.ToLower() == "normal")
                    {
                        pos.WindowStyle = EWindowStyle.Normal;
                    }
                    else
                    if (wsstr.ToLower() == "hidden")
                    {
                        pos.WindowStyle = EWindowStyle.Hidden;
                    }
                }
            }
        }
Пример #2
0
        // <WindowPos titleregexp=".*?\s-\sNotepad" rect="10,50,300,200" screen="1" keep="1" />
        void parseXml( XElement xml )
        {
            pos = new WindowPos();

            if( xml != null )
            {
                var xrect = X.Attribute( xml, "Rect", true );
                if( xrect != null )
                {
                    var myRegex = new Regex(@"\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*(-?\d+)\s*");
                    var m = myRegex.Match( (string) xrect );
                    if( m != null && m.Success)
                    {
                        pos.Rect = new System.Drawing.Rectangle(
                            int.Parse(m.Groups[1].Value),
                            int.Parse(m.Groups[2].Value),
                            int.Parse(m.Groups[3].Value),
                            int.Parse(m.Groups[4].Value)
                        );
                    }
                }

                pos.Screen = X.getIntAttr(xml, "Screen", 0, ignoreCase:true);
                pos.TitleRegExp = X.getStringAttr(xml, "TitleRegExp", null, ignoreCase:true);
                pos.Keep = X.getBoolAttr(xml, "Keep", false, ignoreCase:true);
                pos.Topmost = X.getBoolAttr(xml, "TopMost", false, ignoreCase:true);
                pos.BringToFront = X.getBoolAttr(xml, "BringToFront", false, ignoreCase:true);
                pos.SendToBack = X.getBoolAttr(xml, "SendToBack", false, ignoreCase:true);
                //pos.SetFocus = X.getBoolAttr(xml, "SetFocus", false, ignoreCase:true);

                string wsstr = X.getStringAttr(xml, "WindowStyle", null, ignoreCase:true);
                if( wsstr != null )
                {
                    if (wsstr.ToLower() == "minimized") pos.WindowStyle = EWindowStyle.Minimized;
                    else
                    if (wsstr.ToLower() == "maximized") pos.WindowStyle = EWindowStyle.Maximized;
                    else
                    if (wsstr.ToLower() == "normal") pos.WindowStyle = EWindowStyle.Normal;
                    else
                    if (wsstr.ToLower() == "hidden") pos.WindowStyle = EWindowStyle.Hidden;
                }
            }
        }