Пример #1
0
        private void Form_Load(object sender, EventArgs e)
        {
            {
                var camera = new Camera(
                    new vec3(0, 0, 1), new vec3(0, 0, 0), new vec3(0, 1, 0),
                    CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
                var rotator = new SatelliteRotator(camera);
                this.rotator = rotator;
                this.scene = new Scene(camera);
            }
            {
                var glText = new UIText(AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right,
                    new Padding(10, 10, 10, 10), new Size(550, 50), -100, 100);
                glText.Initialize();
                glText.SwitchList.Add(new ClearColorSwitch());// show black back color to indicate glText's area.
                glText.SetText("The quick brown fox jumps over the lazy dog!");
                this.glText = glText;
                this.scene.UIRoot.Children.Add(glText);

                var glAxis = new UIAxis(AnchorStyles.Right | AnchorStyles.Bottom,
                    new Padding(3, 3, 3, 3), new Size(70, 70), -100, 100);
                glAxis.Initialize();
                this.scene.UIRoot.Children.Add(glAxis);

                this.UpdateLabel();
            }
            {
                var frmPropertyGrid = new FormProperyGrid();
                frmPropertyGrid.DisplayObject(this.glText);
                frmPropertyGrid.Show();
                this.formPropertyGrid = frmPropertyGrid;
            }
        }
Пример #2
0
        private void glCanvas1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 'b')
            {
                BlendingSourceFactor source;
                BlendingDestinationFactor dest;
                this.blendFactorHelper.GetNext(out source, out dest);
                this.glText.BlendSwitch.SourceFactor = source;
                this.glText.BlendSwitch.DestFactor = dest;
                this.UpdateLabel();
            }
            else if (e.KeyChar == 'o')
            {
                if (this.openTextureDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string ttfFilename = this.openTextureDlg.FileName;
                    this.glText.Dispose();
                    FontResource fontResouce = FontResource.Load(ttfFilename, ' ', (char)126);
                    var glText = new UIText(AnchorStyles.Left | AnchorStyles.Top,
                        new Padding(3, 3, 3, 3), new Size(850, 50), -100, 100, fontResouce);
                    glText.Initialize();
                    glText.SwitchList.Add(new ClearColorSwitch());// show black back color to indicate glText's area.
                    glText.SetText("The quick brown fox jumps over the lazy dog!");
                    this.glText = glText;

                    uiRoot.Children.Add(glText);

                    this.formPropertyGrid.DisplayObject(glText);
                }
            }
        }
Пример #3
0
 public void ExecuteOnTarget(UIText uiText, Text text, Color endColor, float duration)
 {
     // set up script
     uiText.textAction  = UIText.TextAction.changeColor;
     uiText.text        = text;
     uiText.targetColor = endColor;
     uiText.speed       = duration;
     uiText.Initialize();
 }
Пример #4
0
        private void Form_Load(object sender, EventArgs e)
        {
            {
                this.glCanvas1.ShowSystemCursor = false;
            }
            {
                var camera = new Camera(
                    new vec3(0, 0, 1), new vec3(0, 0, 0), new vec3(0, 1, 0),
                    CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
                var rotator = new SatelliteManipulater();
                rotator.Bind(camera, this.glCanvas1);
                this.rotator           = rotator;
                this.scene             = new Scene(camera, this.glCanvas1);
                this.glCanvas1.Resize += this.scene.Resize;
            }
            {
                var glText = new UIText(AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right,
                                        new Padding(10, 10, 10, 10), new Size(550, 50), -100, 100);
                glText.Initialize();
                glText.SwitchList.Add(new ClearColorSwitch());// show black back color to indicate glText's area.
                glText.Text = "The quick brown fox jumps over the lazy dog!";
                this.glText = glText;
                this.scene.UIRoot.Children.Add(glText);
            }
            {
                var uiAxis = new UIAxis(AnchorStyles.Left | AnchorStyles.Bottom,
                                        new Padding(3, 3, 3, 3), new Size(128, 128), -100, 100);
                uiAxis.Initialize();
                this.scene.UIRoot.Children.Add(uiAxis);

                this.UpdateLabel();
            }
            {
                var frmPropertyGrid = new FormProperyGrid(this.glText);
                frmPropertyGrid.Show();
                this.formPropertyGrid = frmPropertyGrid;
            }
        }
Пример #5
0
        /// <summary>
        /// </summary>
        /// <param name="anchor"></param>
        /// <param name="margin"></param>
        /// <param name="size"></param>
        /// <param name="zNear"></param>
        /// <param name="zFar"></param>
        public UIColorPaletteRenderer(int maxMarkerCount,
                                      CodedColor[] codedColors,
                                      System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin,
                                      System.Drawing.Size size, int zNear, int zFar)
            : base(anchor, margin, size, zNear, zFar)
        {
            this.maxMarkerCount      = maxMarkerCount;
            this.currentMarkersCount = maxMarkerCount;

            //// display this UI control's area.
            //this.SwitchList.Add(new ClearColorSwitch());

            // color bar using texture.
            {
                var bar = new UIColorPaletteBarRenderer(
                    codedColors,
                    System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right,
                    new System.Windows.Forms.Padding(marginLeft, 1, marginRight, 0),
                    new System.Drawing.Size(size.Width - marginLeft - marginRight, size.Height / 3),
                    zNear, zFar);
                //this.SwitchList.Add(new ClearColorSwitch(Color.Blue));
                this.Children.Add(bar);
                this.colorPaletteBar = bar;
            }
            // color bar using vec3 color(hidden as default state)
            // just to compare with color bar using texture.
            {
                var bar = new UIColorPaletteColoredBarRenderer(
                    maxMarkerCount, codedColors,
                    System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right,
                    new System.Windows.Forms.Padding(marginLeft, 1 + size.Height / 3, marginRight, 0),
                    new System.Drawing.Size(size.Width - marginLeft - marginRight, size.Height / 3),
                    zNear, zFar);
                //this.SwitchList.Add(new ClearColorSwitch(Color.Blue));
                this.Children.Add(bar);
                this.colorPaletteBar2 = bar;
                bar.Enabled           = false;
            }
            // white vertical lines.
            {
                var markers = new UIColorPaletteMarkersRenderer(maxMarkerCount,
                                                                System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right,
                                                                new System.Windows.Forms.Padding(marginLeft, 1, marginRight, 0),
                                                                new System.Drawing.Size(size.Width - marginLeft - marginRight, size.Height / 2),
                                                                zNear, zFar);
                //markers.SwitchList.Add(new ClearColorSwitch(Color.Red));
                this.Children.Add(markers);
                this.markers = markers;
            }
            // labels that display values(float values)
            {
                int length = maxMarkerCount;
                var font   = new Font("Arial", 32);
                for (int i = 0; i < length; i++)
                {
                    const int width    = 100;
                    float     distance = marginLeft;
                    distance += 2.0f * (float)i / (float)length * (float)(this.Size.Width - marginLeft - marginRight);
                    distance -= width / 2;
                    var label = new UIText(
                        System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Bottom,
                        new System.Windows.Forms.Padding((int)distance, 0, 0, 0),
                        new System.Drawing.Size(width, size.Height / 2), zNear, zFar,
                        font.GetFontBitmap("0123456789.eE+-").GetFontTexture(), 100);
                    label.Initialize();
                    //label.SwitchList.Add(new ClearColorSwitch(Color.Green));
                    label.Text          = ((float)i).ToShortString();
                    label.BeforeLayout += label_beforeLayout;
                    this.Children.Add(label);
                    this.labelList.Add(label);
                }
                this.currentMarkersCount = 2;
            }
        }