Beispiel #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            drawPanel.Width  = 1440;
            drawPanel.Height = 900;
            this.Width       = 1280;
            this.Height      = 800;

            absoluteRect = new Rectangle(300, 135, 840, 630);
            safezoneRect = new Rectangle(0, 0, 1440, 900);

            int w = SystemInformation.PrimaryMonitorSize.Width;
            int h = SystemInformation.PrimaryMonitorSize.Height;

            this.Left = (w - this.Width) / 2;
            this.Top  = (h - this.Height) / 2;

            selectedControl = null;
            splitContainer1.Panel1.AutoScrollPosition = new Point((drawPanel.Width - splitContainer1.Panel1.Width) / 2, (drawPanel.Height - splitContainer1.Panel1.Height) / 2);
            gridSize = 20;

            uiClass = new UIClass("New");
        }
Beispiel #2
0
        private void ParseUIConfig(ParseNode node)
        {
            foreach (ParseNode n in node.Nodes)
            {
                string classPattern   = @"class\s+(?<class>[a-zA-Z_]+[a-zA-Z0-9_]*)\s*:*\s*(?<parent>[a-zA-Z_]+[a-zA-Z0-9_]*)*.*?$";
                string properyPattern = @"((?:\w|[\[\]])+)\s*=\s*(.*);";
                Match  match;

                // Class
                if (n.Token.Type == TokenType.CLASS && n.Parent.Token.Type == TokenType.Class)
                {
                    Match m = Regex.Match(n.Token.Text, classPattern);

                    string className   = m.Groups["class"].Value;
                    string classParent = m.Groups["parent"].Value;

                    uiClass = new UIClass(className);
                }

                // Class -> PROPERTY
                if (n.Token.Type == TokenType.PROPERTY && n.Parent.Token.Type == TokenType.Class)
                {
                    match = Regex.Match(n.Token.Text, properyPattern);
                    uiClass.AddProperty(match.Groups[1].Value, match.Groups[2].Value);
                }

                // Class -> fControls -> Control
                if (n.Token.Type == TokenType.CLASS && n.Parent.Token.Type == TokenType.Control && n.Parent.Parent.Token.Type == TokenType.fControls && n.Parent.Parent.Parent.Token.Type == TokenType.Class)
                {
                    Match m = Regex.Match(n.Token.Text, classPattern);

                    string className   = m.Groups["class"].Value;
                    string classParent = m.Groups["parent"].Value;

                    UIControl c = new UIControl(className, classParent);
                    lastControl = c;
                    uiClass.AddForegroundControl(c);
                }

                // Class -> bControls -> Control
                if (n.Token.Type == TokenType.CLASS && n.Parent.Token.Type == TokenType.Control && n.Parent.Parent.Token.Type == TokenType.bControls && n.Parent.Parent.Parent.Token.Type == TokenType.Class)
                {
                    Match m = Regex.Match(n.Token.Text, classPattern);

                    string className   = m.Groups["class"].Value;
                    string classParent = m.Groups["parent"].Value;

                    UIControl c = new UIControl(className, classParent);
                    lastControl = c;
                    uiClass.AddBackgroundControl(c);
                }

                // Class -> fControls -> Control -> PROPERTY
                if (n.Token.Type == TokenType.PROPERTY && n.Parent.Token.Type == TokenType.Control && n.Parent.Parent.Token.Type == TokenType.fControls && n.Parent.Parent.Parent.Token.Type == TokenType.Class)
                {
                    match = Regex.Match(n.Token.Text, properyPattern);
                    lastControl.AddProperty(match.Groups[1].Value, match.Groups[2].Value, absoluteRect, safezoneRect);
                }

                // Class -> bControls -> Control -> PROPERTY
                if (n.Token.Type == TokenType.PROPERTY && n.Parent.Token.Type == TokenType.Control && n.Parent.Parent.Token.Type == TokenType.bControls && n.Parent.Parent.Parent.Token.Type == TokenType.Class)
                {
                    match = Regex.Match(n.Token.Text, properyPattern);
                    lastControl.AddProperty(match.Groups[1].Value, match.Groups[2].Value, absoluteRect, safezoneRect);
                }

                // Class -> fControls -> Control -> fControls -> Control
                if (n.Token.Type == TokenType.CLASS && n.Parent.Token.Type == TokenType.Control && n.Parent.Parent.Token.Type == TokenType.fControls && n.Parent.Parent.Parent.Token.Type != TokenType.Class)
                {
                    Match m = Regex.Match(n.Token.Text, classPattern);

                    string className   = m.Groups["class"].Value;
                    string classParent = m.Groups["parent"].Value;

                    UIControl c = new UIControl(className, classParent);
                    c.Parent = lastControl;
                    lastControl.AddForegroundControl(c);
                }

                // Class -> bControls -> Control -> bControls -> Control
                if (n.Token.Type == TokenType.CLASS && n.Parent.Token.Type == TokenType.Control && n.Parent.Parent.Token.Type == TokenType.bControls && n.Parent.Parent.Parent.Token.Type != TokenType.Class)
                {
                    Match m = Regex.Match(n.Token.Text, classPattern);

                    string className   = m.Groups["class"].Value;
                    string classParent = m.Groups["parent"].Value;

                    UIControl c = new UIControl(className, classParent);
                    c.Parent = lastControl;
                    lastControl.AddBackgroundControl(c);
                }

                // Class -> bControls -> Control -> bControls -> Control -> PROPERTY
                if (n.Token.Type == TokenType.PROPERTY && n.Parent.Token.Type == TokenType.Control && n.Parent.Parent.Token.Type == TokenType.fControls && n.Parent.Parent.Parent.Token.Type != TokenType.Class)
                {
                    match = Regex.Match(n.Token.Text, properyPattern);
                    lastControl.ForegroundControls[lastControl.ForegroundControls.Count - 1].AddProperty(match.Groups[1].Value, match.Groups[2].Value, absoluteRect, safezoneRect);
                }

                // Class -> bControls -> Control -> bControls -> Control -> PROPERTY
                if (n.Token.Type == TokenType.PROPERTY && n.Parent.Token.Type == TokenType.Control && n.Parent.Parent.Token.Type == TokenType.bControls && n.Parent.Parent.Parent.Token.Type != TokenType.Class)
                {
                    match = Regex.Match(n.Token.Text, properyPattern);
                    lastControl.BackgroundControls[lastControl.BackgroundControls.Count - 1].AddProperty(match.Groups[1].Value, match.Groups[2].Value, absoluteRect, safezoneRect);
                }

                ParseUIConfig(n);
            }
        }