Click here to Skip to main content
15,893,814 members
Articles / Web Development / HTML

An XML Compiler

Rate me:
Please Sign up or sign in to vote.
4.59/5 (25 votes)
13 Sep 2005CPOL9 min read 96.3K   1.3K   72  
Convert your XML object graph to code using CodeDom
//------------------------------------------------------------------------------
// <autogenerated>
//     This code was generated by a tool.
//     Runtime Version: 1.1.4322.573
//
//     Changes to this file may cause incorrect behavior and will be lost if 
//     the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

namespace Clifton.CodeGenTest
{
    using System.Windows.Forms;
    using Clifton.Tools.Data;
    using Events;
    using System.ComponentModel;
    using System.Drawing;
    
    
    public class CodeGenTest
    {
        
        private Form appMainForm;
        
        private TrackbarEvents events;
        
        private TrackBar redScroll;
        
        private TrackBar greenScroll;
        
        private TrackBar blueScroll;
        
        private Label label1;
        
        private Label label2;
        
        private Label label3;
        
        private Label redValue;
        
        private Label greenValue;
        
        private Label blueValue;
        
        private PictureBox colorPanel;
        
        private BindHelper bindHelper1;
        
        private BindHelper bindHelper2;
        
        private BindHelper bindHelper3;
        
        public CodeGenTest()
        {
        }
        
        public virtual object Initialize()
        {
            
            appMainForm = new Form();
            appMainForm.SuspendLayout();
            
            events = new TrackbarEvents();
            
            
            //  Instantiate Trackbars 
            
            redScroll = new TrackBar();
            redScroll.BeginInit();
            redScroll.SuspendLayout();
            
            redScroll.Name = "redScroll";
            redScroll.Orientation = Orientation.Vertical;
            redScroll.TickFrequency = 16;
            redScroll.TickStyle = TickStyle.BottomRight;
            redScroll.Minimum = 0;
            redScroll.Maximum = 255;
            redScroll.Value = 128;
            redScroll.Scroll += new System.EventHandler(events.OnScrolled);
            redScroll.Size = new Size(42, 128);
            redScroll.Location = new Point(10, 30);
            redScroll.Tag = "R";
            redScroll.EndInit();
            redScroll.ResumeLayout();
            appMainForm.Controls.Add(redScroll);
            
            greenScroll = new TrackBar();
            greenScroll.BeginInit();
            greenScroll.SuspendLayout();
            
            greenScroll.Name = "greenScroll";
            greenScroll.Orientation = Orientation.Vertical;
            greenScroll.TickFrequency = 16;
            greenScroll.TickStyle = TickStyle.BottomRight;
            greenScroll.Minimum = 0;
            greenScroll.Maximum = 255;
            greenScroll.Value = 128;
            greenScroll.Scroll += new System.EventHandler(events.OnScrolled);
            greenScroll.Size = new Size(42, 128);
            greenScroll.Location = new Point(55, 30);
            greenScroll.Tag = "G";
            greenScroll.EndInit();
            greenScroll.ResumeLayout();
            appMainForm.Controls.Add(greenScroll);
            
            blueScroll = new TrackBar();
            blueScroll.BeginInit();
            blueScroll.SuspendLayout();
            
            blueScroll.Name = "blueScroll";
            blueScroll.Orientation = Orientation.Vertical;
            blueScroll.TickFrequency = 16;
            blueScroll.TickStyle = TickStyle.BottomRight;
            blueScroll.Minimum = 0;
            blueScroll.Maximum = 255;
            blueScroll.Value = 128;
            blueScroll.Scroll += new System.EventHandler(events.OnScrolled);
            blueScroll.Size = new Size(42, 128);
            blueScroll.Location = new Point(100, 30);
            blueScroll.Tag = "B";
            blueScroll.EndInit();
            blueScroll.ResumeLayout();
            appMainForm.Controls.Add(blueScroll);
            
            //  Instantiate Labels 
            
            label1 = new Label();
            label1.SuspendLayout();
            
            label1.Size = new Size(40, 15);
            label1.TextAlign = ContentAlignment.TopCenter;
            label1.Font = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);
            label1.Location = new Point(10, 10);
            label1.ForeColor = Color.Red;
            label1.Text = "Red";
            label1.ResumeLayout();
            appMainForm.Controls.Add(label1);
            
            label2 = new Label();
            label2.SuspendLayout();
            
            label2.Size = new Size(40, 15);
            label2.TextAlign = ContentAlignment.TopCenter;
            label2.Font = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);
            label2.Location = new Point(55, 10);
            label2.ForeColor = Color.Green;
            label2.Text = "Green";
            label2.ResumeLayout();
            appMainForm.Controls.Add(label2);
            
            label3 = new Label();
            label3.SuspendLayout();
            
            label3.Size = new Size(40, 15);
            label3.TextAlign = ContentAlignment.TopCenter;
            label3.Font = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);
            label3.Location = new Point(100, 10);
            label3.ForeColor = Color.Blue;
            label3.Text = "Blue";
            label3.ResumeLayout();
            appMainForm.Controls.Add(label3);
            
            redValue = new Label();
            redValue.SuspendLayout();
            
            redValue.Name = "redValue";
            redValue.Size = new Size(40, 15);
            redValue.TextAlign = ContentAlignment.TopCenter;
            redValue.Font = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);
            redValue.Location = new Point(10, 160);
            redValue.ForeColor = Color.Red;
            redValue.Text = "128";
            redValue.ResumeLayout();
            appMainForm.Controls.Add(redValue);
            
            greenValue = new Label();
            greenValue.SuspendLayout();
            
            greenValue.Name = "greenValue";
            greenValue.Size = new Size(40, 15);
            greenValue.TextAlign = ContentAlignment.TopCenter;
            greenValue.Font = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);
            greenValue.Location = new Point(55, 160);
            greenValue.ForeColor = Color.Green;
            greenValue.Text = "128";
            greenValue.ResumeLayout();
            appMainForm.Controls.Add(greenValue);
            
            blueValue = new Label();
            blueValue.SuspendLayout();
            
            blueValue.Name = "blueValue";
            blueValue.Size = new Size(40, 15);
            blueValue.TextAlign = ContentAlignment.TopCenter;
            blueValue.Font = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);
            blueValue.Location = new Point(100, 160);
            blueValue.ForeColor = Color.Blue;
            blueValue.Text = "128";
            blueValue.ResumeLayout();
            appMainForm.Controls.Add(blueValue);
            
            //  Instantiate PictureBox 
            
            colorPanel = new PictureBox();
            colorPanel.SuspendLayout();
            
            colorPanel.Name = "colorPanel";
            colorPanel.Location = new Point(90, 0);
            colorPanel.Size = new Size(200, 100);
            colorPanel.Dock = DockStyle.Right;
            colorPanel.BorderStyle = BorderStyle.Fixed3D;
            colorPanel.BackColor = Color.FromArgb(128, 128, 128);
            colorPanel.ResumeLayout();
            appMainForm.Controls.Add(colorPanel);
            
            //  Set PictureBox instance in event handler. 
            
            events.ColorPanel = colorPanel;
            
            //  Wire up TrackBar.Value to Label.Text 
            
            bindHelper1 = new BindHelper();
            bindHelper1.BeginInit();
            
            bindHelper1.Source = redScroll;
            bindHelper1.SourceProperty = "Value";
            bindHelper1.Destination = redValue;
            bindHelper1.DestinationProperty = "Text";
            bindHelper1.ImmediateMode = true;
            bindHelper1.EndInit();
            
            bindHelper2 = new BindHelper();
            bindHelper2.BeginInit();
            
            bindHelper2.Source = greenScroll;
            bindHelper2.SourceProperty = "Value";
            bindHelper2.Destination = greenValue;
            bindHelper2.DestinationProperty = "Text";
            bindHelper2.ImmediateMode = true;
            bindHelper2.EndInit();
            
            bindHelper3 = new BindHelper();
            bindHelper3.BeginInit();
            
            bindHelper3.Source = blueScroll;
            bindHelper3.SourceProperty = "Value";
            bindHelper3.Destination = blueValue;
            bindHelper3.DestinationProperty = "Text";
            bindHelper3.ImmediateMode = true;
            bindHelper3.EndInit();
            
            appMainForm.Name = "appMainForm";
            appMainForm.Text = "Color Chooser";
            appMainForm.ClientSize = new Size(400, 190);
            appMainForm.BackColor = Color.White;
            appMainForm.FormBorderStyle = FormBorderStyle.FixedSingle;
            appMainForm.StartPosition = FormStartPosition.CenterScreen;
            appMainForm.ResumeLayout();
            
            return this.appMainForm;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Interacx
United States United States
Blog: https://marcclifton.wordpress.com/
Home Page: http://www.marcclifton.com
Research: http://www.higherorderprogramming.com/
GitHub: https://github.com/cliftonm

All my life I have been passionate about architecture / software design, as this is the cornerstone to a maintainable and extensible application. As such, I have enjoyed exploring some crazy ideas and discovering that they are not so crazy after all. I also love writing about my ideas and seeing the community response. As a consultant, I've enjoyed working in a wide range of industries such as aerospace, boatyard management, remote sensing, emergency services / data management, and casino operations. I've done a variety of pro-bono work non-profit organizations related to nature conservancy, drug recovery and women's health.

Comments and Discussions