示例#1
0
        public void CalculateTransforms_BeforeCollisionCheck()
        {
            SceneGraph graph          = BuildSceneGraph();
            Vector2    parentPosition = new Vector2(32, 64);
            GameObject obj            = new GameObject();

            obj.Position = parentPosition;
            obj.NoClip   = false;
            obj.SetCollisionSize(16, 16);

            Vector2    childPosition = new Vector2(96, 128);
            GameObject childObj      = new GameObject();

            childObj.Position = childPosition;
            childObj.NoClip   = false;
            childObj.SetCollisionSize(16, 16);

            obj.AddChild(childObj);

            GameObjectCounter collisionObj = new GameObjectCounter();

            collisionObj.Position = parentPosition + childPosition;
            collisionObj.NoClip   = false;
            collisionObj.SetCollisionSize(16, 16);

            graph.Add(obj);
            graph.Add(collisionObj);
            graph.Update();

            Assert.That(collisionObj.Stats.CollisionCount, Is.EqualTo(1));
        }
示例#2
0
        public void IgnoreCollision_NoClip()
        {
            SceneGraph graph = BuildSceneGraph();

            GameObjectCounter obj1 = new GameObjectCounter()
            {
                NoClip = true
            };

            obj1.SetCollisionSize(32, 32);
            graph.Add(obj1);

            GameObjectCounter obj2 = new GameObjectCounter()
            {
                NoClip = false
            };

            obj2.SetCollisionSize(32, 32);
            graph.Add(obj2);

            graph.Update();

            Assert.That(GetObjectTotals(graph).CollisionTestCount, Is.EqualTo(0));
            Assert.That(GetObjectTotals(graph).CollisionCount, Is.EqualTo(0));
        }
示例#3
0
        public void Collision_InjectObject()
        {
            SceneGraph graph = BuildSceneGraph();

            GameObjectCollisionSpawn obj1 = new GameObjectCollisionSpawn(graph)
            {
                NoClip = false, SceneGraph = graph
            };

            obj1.SetCollisionSize(32, 32);
            graph.Add(obj1);

            GameObjectCollisionSpawn obj2 = new GameObjectCollisionSpawn(graph)
            {
                NoClip = false, SceneGraph = graph
            };

            obj2.SetCollisionSize(32, 32);
            graph.Add(obj2);

            graph.Update();
            graph.Draw(null);

            Assert.That(graph.RootGraph.Count, Is.EqualTo(4));
            Assert.That(GetObjectTotals(graph).CollisionTestCount, Is.EqualTo(2));
            Assert.That(GetObjectTotals(graph).CollisionCount, Is.EqualTo(2));
            Assert.That(GetObjectTotals(graph).UpdateCount, Is.EqualTo(2));
            Assert.That(GetObjectTotals(graph).DrawCount, Is.EqualTo(4));
        }
        public void SpawnAtMe_Position()
        {
            SceneGraph        graph       = BuildSceneGraph();
            Vector2           objPosition = new Vector2(32, 64);
            GameObjectCounter obj         = new GameObjectCounter();

            obj.Position = objPosition;

            GameObject childObj = new GameObject();

            childObj.Position   = new Vector2(16, 16);
            childObj.SceneGraph = graph;
            obj.AddChild(childObj);

            graph.Add(obj);
            graph.Update();

            GameObjectCounter spawn = new GameObjectCounter();

            childObj.SpawnAtMe(spawn);

            graph.Update();

            Assert.That(spawn.Position, Is.EqualTo(childObj.AbsolutePosition));
            Assert.That(spawn.Position, Is.EqualTo(new Vector2(48f, 80f)));
        }
示例#5
0
    protected void FillSceneGraphFloatingBars(SceneGraph scene)
    {
        int    rowCount  = this.Data.GetRowCount();
        double boxHeight = ((this.YAxis.MapMaximum - this.YAxis.MapMinimum) / rowCount) / 2;

        for (int r = 0; r < rowCount; r++)
        {
            DateTime  start    = (DateTime)this.Data.GetObjectValue(r, this.StartDateTimeColumnNumber);
            DateTime  end      = (DateTime)this.Data.GetObjectValue(r, this.EndDateTimeColumnNumber);
            int       boxX     = (int)this.XAxis.Map(start);
            int       boxY     = (int)this.YAxis.Map(r) + (int)(boxHeight / 2);
            int       boxWidth = (int)(this.XAxis.Map(end) - this.XAxis.Map(start));
            Rectangle boxRect  = new Rectangle(boxX, boxY, boxWidth, (int)boxHeight);
            Box       b        = new Box(boxRect);
            b.PE.Fill = this.ChartColorModel.getFillColor(r, r, (double)start.Ticks);

            b.Caps   = PCaps.HitTest | PCaps.Skin | PCaps.Tooltip;
            b.Column = this.StartDateTimeColumnNumber;
            b.Row    = r;
            b.Chart  = ChartType.BarChart;
            b.Layer  = this.ChartCore.GetChartLayer();
            b.Value  = 12345;
            scene.Add(b);
        }
    }
示例#6
0
 protected void FillSceneGraphXAxis(SceneGraph scene)
 {
     #region X axis
     this.XAxis.FillSceneGraph(scene);
     Line l = new Line(new Point((int)XAxis.MapMinimum, (int)YAxis.MapMinimum), new Point((int)XAxis.MapMinimum, (int)YAxis.MapMaximum), new LineStyle());
     scene.Add(l);
     #endregion
 }
示例#7
0
    protected void FillSceneGraphYAxis(SceneGraph scene)
    {
        int    rowCount    = this.Data.GetRowCount();
        int    labelWidth  = (int)this.XAxis.MapMinimum;
        double labelHeight = (this.YAxis.MapMaximum - this.YAxis.MapMinimum) / rowCount;        //(YAxis.MapMinimum / YAxis.MapMaximum)*rowCount;

        for (int r = 0; r < rowCount; r++)
        {
            Rectangle labelRect = new Rectangle(YAxis.OuterBound.X, (int)YAxis.Map(r), labelWidth, (int)labelHeight);
            Text      t1        = new Text(labelRect, (string)this.Data.GetObjectValue(r, this.ItemLabelColumnNumber), new LabelStyle());
            t1.labelStyle.VerticalAlign = StringAlignment.Center;
            scene.Add(t1);
        }
        Line l = new Line(new Point((int)XAxis.MapMinimum, (int)YAxis.MapMaximum), new Point((int)XAxis.MapMaximum, (int)YAxis.MapMaximum), new LineStyle());

        scene.Add(l);
    }
示例#8
0
        // NEW NODE
        private void CineGraphNewNode(object sender, EventArgs e)
        {
            EditNode = new GraphNode();
            TreeNode nt = new TreeNode();

            nt.Text = "New Node";
            GraphNode nn = EditNode;

            nn.Name = "New Node";
            NodeMap.Add(nt, nn);
            //SceneTree.Nodes[0].Nodes.Add(nt);
            EditGraph.Add(nn);
            SyncUI();



            PropGrid.SelectedObject = nn;
        }
示例#9
0
        public void NewScene()
        {
            EditGraph = new SceneGraph();
            var l = new GraphLight();

            l.Diffuse = new OpenTK.Vector3(1, 1, 1);
            l.Range   = 600;
            EditGraph.Add(l);
        }
示例#10
0
        public override void GameObject_ObjectCollision(GameObject sender, GameObjectCollisionEventArgs e)
        {
            GameObjectCounter obj = new GameObjectCounter();

            obj.NoClip   = true;
            obj.Position = this.Position;
            SceneGraph.Add(obj);

            base.GameObject_ObjectCollision(sender, e);
        }
示例#11
0
        protected override void LoadContent()
        {
            ContentManager Content = GameRef.Content;

            CharacterTexture = Content.Load <Texture2D>(@"Sprites\malepriest");
            NPCTexture       = Content.Load <Texture2D>(@"Sprites\malefighter");
            SunTexture       = Content.Load <Texture2D>(@"Sprites\sun_32");
            FireBallTexture  = Content.Load <Texture2D>(@"Sprites\FireBall");
            ExplosionTexture = Content.Load <Texture2D>(@"Sprites\explosions");
            fontArial        = Content.Load <SpriteFont>(@"Fonts\Arial");

            FpsCounter.Font = fontArial;

            aCharacter          = GetCharacter();
            aCharacter.Position = new Vector2(70f, 50f);

            Sprite sprite = GetSun();

            aCharacter.AddChild(sprite);

            map = Content.Load <Map>("Map");

            Camera camera = new Camera(ScreenRectangle);

            camera.CameraMode   = CameraMode.Follow;
            camera.FollowTarget = aCharacter;

            SceneGraph = new SceneGraph(camera, map);

            SceneGraph.Map = map;
            SceneGraph.Add(aCharacter);

            Character npc = GetNPC();

            npc.Position = new Vector2(512f, 512f);
            SceneGraph.Add(npc);

            base.LoadContent();
        }
示例#12
0
        public void LockToMap_BeforeCollisionCheck()
        {
            SceneGraph        graph = BuildSceneGraph();
            GameObjectCounter obj   = new GameObjectCounter();

            obj.NoClip   = false;
            obj.Position = new Vector2(0, 0);
            obj.SetCollisionSize(16, 16);
            graph.Add(obj);

            GameObject offScreen = new GameObject();

            offScreen.NoClip   = false;
            offScreen.Position = new Vector2(-32, -32);
            offScreen.SetCollisionSize(16, 16);
            graph.Add(offScreen);

            //LockToMap should be called before collision checking
            graph.Update();

            Assert.That(obj.Stats.CollisionCount, Is.EqualTo(1));
        }
示例#13
0
        private void RenderLabel(SceneGraph scene, Rectangle bubbleRect)
        {
            var label = new Text(bubbleRect, this.Text, this.TextStyle.Clone());
            this.SetTextSetting(label);
            if (bubbleRect.Width <= 0 || bubbleRect.Height <= 0)
            {
                return;
            }
            label.labelStyle.SetNoUpdate(true);
            label.labelStyle.Orientation = TextOrientation.Horizontal;
            label.labelStyle.SetNoUpdate(false);

            scene.Add(label);
        }
示例#14
0
        public void Draw_SkipOffScreen()
        {
            SceneGraph graph = BuildSceneGraph();
            GameObject obj   = new GameObjectCounter();

            obj.Position = new Vector2(-33f, -33f);
            graph.Add(obj);

            graph.Update();
            graph.Draw(null);

            Assert.That(GetObjectTotals(graph).DrawCount, Is.EqualTo(0));
            Assert.That(graph.NodesCulled, Is.EqualTo(1));
        }
示例#15
0
        public void Draw_InjectObject()
        {
            SceneGraph graph = BuildSceneGraph();

            graph.Add(new GameObjectInjector()
            {
                SceneGraph = graph
            });

            graph.Update();
            graph.Draw(null);

            Assert.That(graph.RootGraph.Count, Is.EqualTo(3));
            Assert.That(GetObjectTotals(graph).DrawCount, Is.EqualTo(3));
        }
示例#16
0
    // FillSceneGraph is where you draw on your layer or manipulate the existing (graphics) Primitives.
    public void FillSceneGraph(SceneGraph scene)
    {
        #region reset bounds to entire chart area
        this.OuterBound = this.ChartCore.GetBorderLayer().GetOuterBounds();
        this.ChartCore.GetAdornmentLayer().OuterBound = this.OuterBound;
        GraphicsContext gC = new GraphicsContext();
        gC.ResetClip();
        scene.Add(gC);
        #endregion
        #region include columns which would have been excluded in a typical ChartDataFilter
        IChartDataFilter filter = this.Data as IChartDataFilter;
        int colCount            = filter.GetRawData().GetColumnCount();
        for (int c = 0; c < colCount; c++)
        {
            filter.IncludeColumn(c, true);
        }
        #endregion
        foreach (Primitive p in scene)
        {
            #region remove existing primitives
            Text t = p as Text;
            if (t != null)             // labels
            {
                t.SetTextString("");
                t.bounds = new Rectangle(-1, -1, -1, -1);
            }
            else
            {
                Line l = p as Line;
                if (l != null)
                {
                    l.p1 = new Point(-1, -1);
                    l.p2 = new Point(-1, -1);
                }
            }

            #endregion
        }
        this.InitializeColumns();
        this.InitializeAxes();
        this.FillSceneGraphXAxis(scene);
        this.FillSceneGraphYAxis(scene);
        this.FillSceneGraphFloatingBars(scene);
    }
示例#17
0
        public void Update_BeforeLockToMap()
        {
            SceneGraph graph = BuildSceneGraph();
            GameObject obj   = new GameObject();

            obj.NoClip   = false;
            obj.Position = new Vector2(32, 0);
            obj.Speed    = 100;
            obj.Velocity = -Vector2.UnitX;

            graph.Add(obj);

            //If update is called before lock, the object will move off the map and
            //then be placed back on the map after one update
            graph.Update();

            Assert.That(obj.AbsolutePosition, Is.EqualTo(Vector2.Zero));
            Assert.That(obj.Position, Is.EqualTo(Vector2.Zero));
        }
示例#18
0
        public void CalculateTransforms()
        {
            SceneGraph graph          = BuildSceneGraph();
            Vector2    parentPosition = new Vector2(32, 64);
            GameObject obj            = new GameObject();

            obj.Position = parentPosition;

            Vector2    childPosition = new Vector2(96, 128);
            GameObject childObj      = new GameObject();

            childObj.Position = childPosition;

            obj.AddChild(childObj);
            graph.Add(obj);
            graph.Update();

            Assert.That(childObj.Position, Is.EqualTo(childPosition));
            Assert.That(childObj.AbsolutePosition, Is.EqualTo(parentPosition + childPosition));
        }
示例#19
0
        public PointSelectionHandler(InputHandler inputHandler, SceneGraph sceneGraph, Camera camera)
        {
            _inputHandler = inputHandler;
            _sceneGraph   = sceneGraph;
            _camera       = camera;

            inputHandler.MouseDown += MouseDown;
            inputHandler.MouseUp   += MouseUp;
            inputHandler.MouseMove += MouseMove;

            selectionRectangle = new ScreenQuadGeometry(rectangleColor, rectangleColor, rectangleColor, rectangleColor)
            {
                Depth = -0.9999f
            };
            selectionRectangleNode = new SceneNode(selectionRectangle, "Selection Rectangle")
            {
                Visible = false, Transparent = true
            };
            sceneGraph.Add(selectionRectangleNode);
        }
示例#20
0
        public void LockToMap_OnlyFirstLevelNodes()
        {
            SceneGraph graph = BuildSceneGraph();
            GameObject obj   = new GameObject();

            obj.NoClip   = false;
            obj.Position = new Vector2(32, 32);
            obj.SetCollisionSize(16, 16);
            graph.Add(obj);

            Vector2    offScreenPosition = new Vector2(-300, -300);
            GameObject offScreen         = new GameObject();

            offScreen.NoClip   = false;
            offScreen.Position = offScreenPosition;
            offScreen.SetCollisionSize(16, 16);

            obj.AddChild(offScreen);

            graph.Update();

            Assert.That(offScreen.AbsolutePosition, Is.EqualTo(offScreenPosition + obj.Position));
            Assert.That(offScreen.Position, Is.EqualTo(offScreenPosition));
        }
示例#21
0
        public override void Update()
        {
            SceneGraph.Add(new GameObjectCounter());

            base.Update();
        }
示例#22
0
        protected override void LoadContent()
        {
            ContentManager Content = GameRef.Content;

            ShipTexture         = Content.Load <Texture2D>(@"Sprites\block_64");
            LaserTexture        = Content.Load <Texture2D>(@"Sprites\laser");
            Asteriod64          = Content.Load <Texture2D>(@"Sprites\asteriod_64");
            Asteriod32          = Content.Load <Texture2D>(@"Sprites\asteriod_32");
            StarTexture         = Content.Load <Texture2D>(@"Sprites\Star_256");
            PlanetBlueTexture   = Content.Load <Texture2D>(@"Sprites\Planet_Blue_128");
            PlanetPurpleTexture = Content.Load <Texture2D>(@"Sprites\Planet_Purple_128");
            CreatureTexture     = Content.Load <Texture2D>(@"Sprites\Creature_32");
            LaserTurretTexture  = Content.Load <Texture2D>(@"Sprites\Weapon_16");
            SpaceTexture        = Content.Load <Texture2D>(@"Backgrounds\Nebula_1920X1200");
            fontArial           = Content.Load <SpriteFont>(@"Fonts\Arial");

            LaserFireTexture = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            LaserFireTexture.SetData(new[] { Color.Yellow });

            FpsCounter.Font = fontArial;
            RNG             = new Random(3); //TODO: Randomize seed

            SolarSystem solarSystem = new SolarSystem();

            solarSystem.Generate(RNG, 1000000);

            Camera2D camera = new Camera2D(ScreenRectangle);

            SceneGraph     = new SceneGraph(camera, null);
            SceneGraph.Sky = SpaceTexture;

            foreach (GameObject obj in solarSystem.Stars)
            {
                SceneGraph.Add(obj);
            }
            foreach (GameObject obj in solarSystem.Planets)
            {
                SceneGraph.Add(obj);
            }
            foreach (GameObject obj in solarSystem.Asteroids)
            {
                SceneGraph.Add(obj);
            }

            Ship          = GetShip();
            Ship.Position = Vector2.Zero;


            SceneGraph.Add(Ship);
            camera.CameraMode   = CameraMode.Follow;
            camera.FollowTarget = Ship;

            SpaceCreature creature = new SpaceCreature();

            creature.Position = new Vector2(600f, 600f);
            creature.AI       = new SimpleFollowAI();
            creature.Target   = Ship;
            SceneGraph.Add(creature);

            //SpaceCreature creature2 = new SpaceCreature();
            //creature2.Position = new Vector2(400f, 300f);
            //creature2.AI = new SimpleFollowAI();
            //creature2.Target = Ship;
            //SceneGraph.Add(creature2);

            base.LoadContent();
        }
示例#23
0
        public override void GameObject_ObjectCollision(GameObject sender, GameObjectCollisionEventArgs e)
        {
            base.GameObject_ObjectCollision(sender, e);

            SceneGraph.Add(new GameObjectCounter());
        }
示例#24
0
        public override void Draw(SpriteBatch batch)
        {
            SceneGraph.Add(new GameObjectCounter());

            base.Draw(batch);
        }
示例#25
0
        private void starButton2_ClickButton(object sender, EventArgs e)
        {
            Random r      = new Random(int.Parse(SeedBox.Text));
            int    uw     = 2048;
            int    uh     = 2048;
            int    pg     = (uw + uh) / 120;
            int    numgal = r.Next(pg / 2, pg);

            var uniscene = new SceneGraph();

            uniscene.Root.Name = "Universe Root";
            int bs = r.Next(100, 200);

            var ul = new GraphLight();

            ul.Name    = "Universe Light 1";
            ul.Range   = 3000;
            ul.Diffuse = new OpenTK.Vector3(3, 3, 3);
            uniscene.Add(ul);

            for (int i = 0; i < bs; i++)
            {
                int x  = r.Next(-uw / 2, uw / 2);
                int y  = r.Next(-uh / 2, uh / 2);
                var sn = new GraphNode();
                sn.X        = x;
                sn.Y        = y;
                sn.Rot      = r.Next(0, 360);
                sn.Z        = 0.1f + (float)r.NextDouble() * 1.2f;
                sn.Name     = "BgStar" + i.ToString();
                sn.ImgFrame = BgStarImg[r.Next(0, BgStarImg.Length - 1)];
                uniscene.Root.Nodes.Add(sn);
                sn.Root  = uniscene.Root;
                sn.Graph = uniscene;
            }

            for (int i = 0; i < numgal; i++)
            {
                int x  = r.Next(-uw / 2, uw / 2);
                int y  = r.Next(-uh / 2, uh / 2);
                var gn = new GraphNode();
                gn.X        = x;
                gn.Y        = y;
                gn.Z        = 0.3f + (float)r.NextDouble() * 1.5f;
                gn.Rot      = r.Next(0, 360);
                gn.Name     = "Galaxy:" + i;
                gn.ImgFrame = GalImg[r.Next(0, GalImg.Length - 1)];
                uniscene.Root.Nodes.Add(gn);
                gn.Root  = uniscene.Root;
                gn.Graph = uniscene;
            }

            if (new FileInfo("Data/Uni/UniGraph.graph").Exists)
            {
                File.Delete("Data/Uni/UniGraph.graph");
            }

            var ufs = new VirtualFileSystem();

            ufs.Add(uniscene);
            ufs.Save("Data/Uni/UniGraph", true);
            Console.WriteLine("Wrote unifs");

            //uniscene.Save("Data/Uni/UniGraph.graph");
            Console.WriteLine("Universed created and saved.");
        }
示例#26
0
            public override void InitApp() 
            {
               
                Img1 = new Tex2D("Data/ship1.png", true);
                fx = new FXLitImage();
                G1 = new SceneGraph();
                S1 = new GraphSprite("Data/ship1.png", 128, 128);
                var t1 = new Tex2D("Data/tile1.jpg");

                for (int y = 0; y < 32; y++)
                {
                    for (int x = 0; x < 32; x++)
                    {

                        var ns = new GraphSprite(t1, 128, 128);
                        G1.Add(ns);
                        ns.X = -(128 * 16) + x * 128;
                        ns.Y = -(128 * 16) + y * 128;
                        ns.Z = 1.0f;
                    }
                }
                G1.Add(S1);
                S1.X = 0;
                S1.Y = 0;

                // G1.X = -16 * 32;
                //  G1.Y = 16 * 32;
                S1.X = 0;
                S1.Y = 0;
                S1.Z = 1.3f;
                // G1.Add(S1);

                var rnd = new Random();
                for (int i = 0; i < 25; i++)
                {

                    var ns = new GraphSprite(S1.ImgFrame, 128, 128);
                    ns.X = rnd.Next(-500, 500);
                    ns.Y = rnd.Next(-500, 500);
                    ns.Z = 0.1f + (float)rnd.NextDouble() * 3;
                    //    G1.Add(ns);

                }

                l1 = new GraphLight()
                {
                    Range = 650,
                    X = -100,
                    Y = -100,
                    Diffuse = new Vector3(0.4f, 1, 0.5f)
                };
                l2 = new GraphLight()
                {
                    Range = 640,
                    X = 0,
                    Y = 0,
                    Diffuse = new Vector3(1.8f, 1.2f, 1.2f)
                };
                G1.X = 0;
                G1.Y = 0;
                G1.Add(l1);
                l2.X = 300;
                VisualFX.Init();
                PS1 = new VFXParticleSystem();
                VisualFX.Add(PS1);
                VisualFX.Graph = G1;

                Part1 = new Tex2D("Data/part1.png", true);

               // var b1 = new
                    
                
                var b1 = new SoftParticle(Part1);
                b1.XDrag = 0.95f;
                b1.YDrag = 0.95f;
                b1.ZDrag = 0.95f;
                b1.RDrag = 0.95f;
                PS1.XIJit = 5;
                PS1.YIJit = 2;

                PS1.PowerSmall = 1;
                PS1.PowerBig = 5;

                PS1.AddBase(b1);
                

            }
示例#27
0
        /// <summary>
        /// Layer's main piece of code that does the drawing. This method calculates and
        /// populates a scene graph with various primitive that constitue the chart.
        /// </summary>
        /// <param name="scene">Collection of Scene items (primitives) to hold items that draw chart.</param>
        public void FillSceneGraph(SceneGraph scene)
        {
            //Draw the axes, use the settings from the y axis properties.
            AxisAppearance YApp = (AxisAppearance)this.ChartComponent.GetChartAppearance(ChartAppearanceTypes.AxisY);

            // Check if appearance and Y-axis appearance are defined.
            if (_Appearance != null && YApp != null)
            {
                #region Initialization

                // initilize the variable.
                // Minimum value a needle can have.
                double min = 0;
                // Maximum value a needle can have.
                double max = 100;
                // Tick increments.
                double delta = 10;

                // Check to see if the Gauge should assume size and layout automatically
                // centering the dial and assuming available width as its size.
                if (this._Appearance.Layout == DialLayout.Automatic)
                {
                    this._Appearance.Radius = Math.Min(this.innerBounds.Width / 3, this.innerBounds.Height / 3);
                    this._Appearance.Center = new Point(this.innerBounds.X + this.innerBounds.Width / 2, this.innerBounds.Y + this.innerBounds.Height / 2);
                }

                // check for axis settings
                // If cutom rage is specified use custom range.
                if (YApp.RangeType == AxisRangeType.Custom)
                {
                    min = YApp.RangeMin;
                    max = YApp.RangeMax;
                }
                else
                {
                    // Automatic: add up the specified sections.
                    if (this._Appearance.Sections.Count > 0)
                    {
                        min = 0;
                        max = 0;
                        foreach (GaugeSection sec in this._Appearance.Sections)
                        {
                            max += sec.Value;
                        }
                    }
                }

                // Assume and calculate the default increment.
                delta = (max - min) / 10;

                // check for y-axis appearance for specified data interval.
                if (YApp.TickmarkStyle == AxisTickStyle.DataInterval)
                {
                    // Actual value is specified.
                    delta = YApp.TickmarkInterval;
                }
                else
                {
                    // Convert the percentage value in actual value.
                    delta = (max - min) * YApp.TickmarkPercentage / 100;
                }

                // set up ruler with value. This will be used for measurement purposes.
                _Ruler.Maximum = max;
                _Ruler.Minimum = min;

                // Check the direction of the dial ticks.
                if (this.Appearance.Direction == Direction.RightToLeft)
                {
                    _Ruler.MapMinimum = _Appearance.StartAngle;
                    _Ruler.MapMaximum = _Appearance.EndAngle;
                }
                else
                {
                    _Ruler.MapMinimum = _Appearance.EndAngle;
                    _Ruler.MapMaximum = _Appearance.StartAngle;
                }

                // copy scoll-scale.
                _Ruler.Scale  = YApp.ScrollScale.Scale;
                _Ruler.Scroll = YApp.ScrollScale.Scroll;

                #endregion

                #region Draw dial and sections
                // start from the minimum
                double d_i = (double)_Ruler.WindowMinimum;

                // calculate various radii.
                int r1 = this._Appearance.TickStart * this._Appearance.Radius / 100;
                int r2 = this._Appearance.TickEnd * this._Appearance.Radius / 100;
                int r3 = this._Appearance.TextLoc * this._Appearance.Radius / 100;

                // draw dial or background.
                Ellipse dial = new Ellipse(this._Appearance.Center, this._Appearance.Radius);
                dial.PE = this.Appearance.DialPE;

                // add dial background.
                scene.Add(dial);

                // draw the sections
                // variable to hold present value.
                double presentVal = 0;
                // start the section from the window minimum.
                double lastVal = (double)_Ruler.WindowMinimum;

                // foreach section, draw a section.
                foreach (GaugeSection sec in this._Appearance.Sections)
                {
                    presentVal = lastVal + sec.Value;

                    // section start angle.
                    int ang0 = -(int)_Ruler.Map(lastVal);
                    // section end angle.
                    int ang1 = -(int)_Ruler.Map(presentVal);

                    // create the wedge
                    Wedge w = new Wedge(this._Appearance.Center, sec.EndWidth * this._Appearance.Radius / 100, ang0, (ang1 - ang0));
                    w.PE          = sec.PE;
                    w.RadiusInner = Math.Max(0, Math.Min(w.Radius - 1, sec.StartWidth * this._Appearance.Radius / 100));
                    scene.Add(w);

                    lastVal = presentVal;
                }
                #endregion

                #region Draw axis' tick marks on dial
                // sanity check for increment. Without this it will go into infinite loop.
                if (delta < 2 * double.Epsilon)
                {
                    delta = 5 * double.Epsilon;
                }

                // loop thru and add the items.
                while (d_i < (double)_Ruler.WindowMaximum + 2 * double.Epsilon + delta)
                {
                    // convert the tickmark value to angle
                    int ang = (int)_Ruler.Map(d_i);

                    // see if major grid lines are visible.
                    if (YApp.MajorGridLines.Visible)
                    {
                        // Convert polar co-ordinates into cartiesian.
                        // In simple words: Convert a pair of (radius, angle) in a point (x and y).
                        Point p1 = Infragistics.UltraChart.Core.Util.Geometry.AngularToCartesian(this._Appearance.Center, r1, -Geometry.DegreeToRadian(ang));
                        Point p2 = Infragistics.UltraChart.Core.Util.Geometry.AngularToCartesian(this._Appearance.Center, r2, -Geometry.DegreeToRadian(ang));

                        // Draw the line for tick marks. Use Y-axis's properties to color and style it.
                        Line l = new Line(p1, p2);
                        l.PE.Stroke           = YApp.MajorGridLines.Color;
                        l.PE.StrokeOpacity    = YApp.MajorGridLines.Color.A;
                        l.lineStyle.DrawStyle = YApp.MajorGridLines.DrawStyle;
                        l.PE.StrokeWidth      = YApp.MajorGridLines.Thickness;

                        // add to scene.
                        scene.Add(l);
                    }

                    // see if minor grid lines are visible. If yes draw them half
                    // a tick far from major grid line. It will use Y-axis's minor
                    // grid lines appearance for color and style.
                    if (YApp.MinorGridLines.Visible)
                    {
                        if (d_i + delta / 2 < (double)_Ruler.WindowMaximum)
                        {
                            // convert the tickmark value to angle
                            int ang1 = (int)_Ruler.Map(d_i + delta / 2);

                            int tfp = Math.Abs((r2 - r1) / 4);
                            // Convert a pair of (radius, angle) in a point (x and y).
                            Point p1 = Infragistics.UltraChart.Core.Util.Geometry.AngularToCartesian(this._Appearance.Center, r1 + tfp, -Geometry.DegreeToRadian(ang1));
                            Point p2 = Infragistics.UltraChart.Core.Util.Geometry.AngularToCartesian(this._Appearance.Center, r2 - tfp, -Geometry.DegreeToRadian(ang1));

                            // draw a minor tick line
                            Line l = new Line(p1, p2);
                            l.PE.Stroke           = YApp.MinorGridLines.Color;
                            l.PE.StrokeOpacity    = YApp.MinorGridLines.Color.A;
                            l.lineStyle.DrawStyle = YApp.MinorGridLines.DrawStyle;
                            l.PE.StrokeWidth      = YApp.MinorGridLines.Thickness;

                            // add to scene.
                            scene.Add(l);
                        }
                    }

                    // see if labels are visible.
                    if (YApp.Labels.Visible)
                    {
                        // Draw the labels: Convert the angle and radius into point location for the label.
                        Point p3 = Infragistics.UltraChart.Core.Util.Geometry.AngularToCartesian(this._Appearance.Center, r3, -Geometry.DegreeToRadian(ang));
                        _Labels["DATA_VALUE"] = d_i;

                        // Use the label formatter and use Y-axis label format.
                        Text t = new Text(p3, LabelFormatter.replaceKeywords(_Labels, YApp.Labels.ItemFormatString), YApp.Labels.LabelStyle.Copy());
                        t.labelStyle.VerticalAlign   = StringAlignment.Center;
                        t.labelStyle.HorizontalAlign = StringAlignment.Center;

                        // Use custom orienation as we need to rotate them to
                        // place them on angular axis.
                        t.labelStyle.Orientation = TextOrientation.Custom;

                        // rotate with respect to present tick angle.
                        t.labelStyle.RotationAngle = ang - 90;

                        // add to scene.
                        scene.Add(t);
                    }

                    // increment current value of tick by the data interval: delta.
                    d_i += delta;
                }

                // See if axis line is visible.
                if (YApp.Visible)
                {
                    // create new line style
                    LineStyle ls = new LineStyle();

                    // use y-axis's draw style.
                    ls.DrawStyle = YApp.LineDrawStyle;

                    // draw an arc that looks takes place of axis line.
                    Arc el = new Arc(this._Appearance.Center, (r1 + r2) / 2, (float)this._Appearance.StartAngle, -(float)Math.Abs(this._Appearance.EndAngle - this._Appearance.StartAngle), ls);
                    // use the axes line's color and thickness.
                    el.PE.Stroke        = YApp.LineColor;
                    el.PE.StrokeOpacity = YApp.LineColor.A;
                    el.PE.StrokeWidth   = YApp.LineThickness;

                    // add to scene.
                    scene.Add(el);
                }

                #endregion

                #region Draw needles
                // sort needles according to needle length. shortest comes on the top.
                double[] ar = new Double[this.Appearance.Needles.Count];
                for (int i = 0; i < this.Appearance.Needles.Count; i++)
                {
                    // store the length of needle in temporary array.
                    ar[i] = this.Appearance.Needles[i].Length;
                }

                // sort the order. This function takes the length of
                // needle array and get the sorted order.
                int[] order = null;
                if (ar.Length > 0)
                {
                    order = MiscFunctions.GetSortedOrderDouble(ar);
                }
                // draw the needles on the dials
                for (int i = 0; i < this.Appearance.Needles.Count; i++)
                {
                    // get n-th needle.
                    Needle nd = this.Appearance.Needles[order[i]];

                    // depending upon needle's present value find out the
                    // angle at which it should be inclined.
                    int theta_i = (int)_Ruler.Map(nd.Value);

                    // convert, angle of needle and its length into a point location.
                    Point p = Infragistics.UltraChart.Core.Util.Geometry.AngularToCartesian(this._Appearance.Center, nd.Length * this._Appearance.Radius / 100, Geometry.DegreeToRadian(-theta_i));

                    // draw a line from the center of dial to location of needle's head.
                    Line l = new Line(this._Appearance.Center, p);
                    l.lineStyle.EndStyle   = LineCapStyle.ArrowAnchor;
                    l.lineStyle.StartStyle = LineCapStyle.RoundAnchor;

                    // attach the paint element from needle to the line primitive.
                    l.PE = nd.PE;

                    // add to scene.
                    scene.Add(l);
                }
                #endregion
            }
        }