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"); }
private void SelectControl(UIControl uiControl) { selectedControl = uiControl; //foreach (TreeNode node in treeView1.Nodes[0].Nodes) //{ // if (node.Text == uiControl.Name) // { // treeView1.SelectedNode = node; // } //} foreach (TreeNode node in treeView1.Nodes) { SelectNode(node, uiControl); } dataGridView1.Columns.Clear(); dataGridView1.Rows.Clear(); dataGridView1.Columns.Add("Properties", "Properties"); dataGridView1.Columns.Add("Values", ""); foreach (DataGridViewColumn column in dataGridView1.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } dataGridView1.Rows.Add("Parent class", uiControl.Inherit); dataGridView1.Rows.Add(1); dataGridView1.Rows[1].ReadOnly = true; foreach (KeyValuePair <string, string> kvp in uiControl.Properties) { dataGridView1.Rows.Add(kvp.Key, kvp.Value); } drawPanel.Invalidate(); }
private void FindControl(UIControl control, Point point) { if (control.Rectangle.Contains(point)) { if (control.Show) { selectedControl = control; } } foreach (UIControl child in control.BackgroundControls) { if (child.Rectangle.Contains(point)) { if (child.Show) { selectedControl = child; } } FindControl(child, point); } foreach (UIControl child in control.ForegroundControls) { if (child.Rectangle.Contains(point)) { if (child.Show) { selectedControl = child; } } FindControl(child, point); } }
private void UpdateControl(UIControl uiControl, Rectangle rectangle) { uiControl.Rectangle = rectangle; }
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); } }
public void AddBackgroundControl(UIControl uiControl) { this.BackgroundControls.Add(uiControl); }
public void AddForegroundControl(UIControl uiControl) { this.ForegroundControls.Add(uiControl); }