예제 #1
0
		public override void Initialize(DrawArgs drawArgs)
		{
			try
			{
				GraphicsStream adj;
				this.mesh = Mesh.FromFile(this.meshFilePath, MeshFlags.Managed, drawArgs.device, out adj, out this.materials );
				this.meshMaterials = new Material[this.materials.Length];
				//using(StreamWriter sw = new StreamWriter("mat.txt", true, System.Text.Encoding.ASCII))
			{
				//sw.WriteLine(this.meshMaterials.Length.ToString());
				for(int i = 0; i < this.materials.Length; i++)
				{
					this.meshMaterials[i] = this.materials[i].Material3D;
					this.meshMaterials[i].Ambient = this.meshMaterials[i].Diffuse;
				}
			}

				//this.mesh.ComputeNormals();
			}
			catch(Exception caught)
			{
				Log.Write( caught );
			}
			this.isInitialized = true;
		}
예제 #2
0
        public override void Initialize(DrawArgs drawArgs)
        {
            FileInfo boundaryFileInfo = new FileInfo(this._boundaryFilePath);
            if (!boundaryFileInfo.Exists) {
                this.Inited = true;
                return;
            }

            using (FileStream boundaryFileStream = boundaryFileInfo.OpenRead()) {
                using (BinaryReader boundaryFileReader = new BinaryReader(boundaryFileStream, Encoding.ASCII)) {
                    int count = boundaryFileReader.ReadInt32();
                    this.vertices = new CustomVertex.PositionColored[count];

                    for (int i = 0; i < count; i++) {
                        double lat = boundaryFileReader.ReadDouble();
                        double lon = boundaryFileReader.ReadDouble();
                        Vector3 v = MathEngine.SphericalToCartesian((float) lat, (float) lon, (float) (this._parentWorld.EquatorialRadius + this._distanceAboveSurface));
                        this.vertices[i].X = v.X;
                        this.vertices[i].Y = v.Y;
                        this.vertices[i].Z = v.Z;
                        this.vertices[i].Color = this._color;
                    }
                }
            }
            this.Inited = true;
        }
예제 #3
0
 public override void Render(DrawArgs drawArgs)
 {
     if (!m_widget.Visible)
     {
         SetPushed(false);
     }
 }
예제 #4
0
 public override void Render(DrawArgs drawArgs)
 {
     if (this.Inited) {
         drawArgs.Device.VertexFormat = CustomVertex.PositionColored.Format;
         drawArgs.Device.TextureState[0].ColorOperation = TextureOperation.Disable;
         drawArgs.Device.DrawUserPrimitives(PrimitiveType.LineStrip, this.vertices.Length - 1, this.vertices);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.DownloadableImageFromIconSet"/> class.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="drawArgs"></param>
 /// <param name="terrainAccessor"></param>
 public DownloadableImageFromIconSet(string name, World parentWorld, float distanceAboveSurface, DrawArgs drawArgs, TerrainAccessor terrainAccessor)
     : base(name, parentWorld.Position, parentWorld.Orientation)
 {
     this.m_ParentWorld = parentWorld;
     this.layerRadius = (float) parentWorld.EquatorialRadius + distanceAboveSurface;
     this.IsSelectable = true;
     this.drawArgs = drawArgs;
     this._terrainAccessor = terrainAccessor;
 }
예제 #6
0
        public void Draw(DrawArgs args)
        {
            //_gameZonePanel.Draw(args);

            foreach (var panel in _panels)
            {
                panel.Draw(args);
            }
            //todo draw other
        }
예제 #7
0
파일: Tree.cs 프로젝트: lvarvel/aura
 public Tree(Vector3 position, float treeHeight, float angleClamp, float dropOff, int number, 
     int depth, Billboard b)
 {
     args = new DrawArgs(null, new Color4(0, .5f, 0, 1f));
     Root = new TreeBranch();
     Root.Position = position;
     var subr = new TreeBranch(treeHeight * dropOff, angleClamp, dropOff, number, new Vector3(0,1,0),
         position + new Vector3(0, treeHeight, 0), depth, b, Root, this);
     Root.Children.Add(subr);
     Position = position;
 }
		public void Render(DrawArgs drawArgs)
		{
			for(int index = m_ChildWidgets.Count - 1; index >= 0; index--)
			{
				IWidget currentWidget = m_ChildWidgets[index] as IWidget;
				if(currentWidget != null)
				{
					if(currentWidget.ParentWidget == null || currentWidget.ParentWidget != this)
						currentWidget.ParentWidget = this;

					currentWidget.Render(drawArgs);
				}
			}
		}
예제 #9
0
		public override void Initialize(DrawArgs drawArgs)
		{
			FileInfo polygonFileInfo = new FileInfo(this._polygonFilePath);
			if(!polygonFileInfo.Exists)
			{
				this.isInitialized = true;
				return;
			}

			using( FileStream polygonFileStream = polygonFileInfo.OpenRead() )
			using( BinaryReader polygonFileReader = new BinaryReader(polygonFileStream, System.Text.Encoding.ASCII) ) {
				int nodeCount = polygonFileReader.ReadInt32();
				int edgeCount = polygonFileReader.ReadInt32();

				this._vertices = new CustomVertex.PositionColored[nodeCount];
				this._indices = new int[edgeCount * 3];

				for(int i = 0; i < nodeCount; i++) {
					double lat = polygonFileReader.ReadDouble();
					double lon = polygonFileReader.ReadDouble();

					Vector3 curNode = MathEngine.SphericalToCartesian((float)lat, (float)lon, (float)(this._parentWorld.EquatorialRadius + this._distanceAboveSurface));
					this._vertices[i].X = curNode.X;
					this._vertices[i].Y = curNode.Y;
					this._vertices[i].Z = curNode.Z;
					this._vertices[i].Color = this._color.ToArgb();
				}

				for(int i = 0; i < edgeCount; i++) {
					int e0 = polygonFileReader.ReadInt32();
					int e1 = polygonFileReader.ReadInt32();
					int e2 = polygonFileReader.ReadInt32();

					this._indices[i*3] = e0;
					this._indices[i*3 + 1] = e1;
					this._indices[i*3 + 2] = e2;
				}
			}
			this.isInitialized = true;
		}
예제 #10
0
        private void DrawBorders(DrawArgs args)
        {
            Vector topLeftCorner = AbsolutePosition;
            Vector bottomRightCorner = AbsolutePosition + Size;

            for (int y = topLeftCorner.Y; y <= bottomRightCorner.Y; y++)
            {
                if (y == topLeftCorner.Y || y == bottomRightCorner.Y)
                {
                    for (int x = topLeftCorner.X; x <= bottomRightCorner.X; x++)
                    {
                        var point = new Vector(x, y);

                        if (x == topLeftCorner.X)
                        {
                            if (y == topLeftCorner.Y)
                                args.DrawAtAbsolutePoint(point, _leftTopCorner);
                            if (y == bottomRightCorner.Y)
                                args.DrawAtAbsolutePoint(point, _leftBottomCorner);
                        }
                        else if (x == bottomRightCorner.X)
                        {
                            if (y == topLeftCorner.Y)
                                args.DrawAtAbsolutePoint(point, _rightTopCorner);
                            if (y == bottomRightCorner.Y)
                                args.DrawAtAbsolutePoint(point, _rightBottomCorner);
                        }
                        else
                            args.DrawAtAbsolutePoint(point, _topBottonBorder);
                    }
                }
                else
                {
                    args.DrawAtAbsolutePoint(topLeftCorner.X, y, _sideBorders);
                    args.DrawAtAbsolutePoint(bottomRightCorner.X, y, _sideBorders);
                }
            }
        }
예제 #11
0
		public override void Render(DrawArgs drawArgs)
		{
//			Vector3 here = MathEngine.SphericalToCartesian(drawArgs.WorldCamera.Latitude, drawArgs.WorldCamera.Longitude, this.layerRadius);
			Matrix currentWorld = drawArgs.device.Transform.World;
			drawArgs.device.RenderState.Lighting = true;
			drawArgs.device.RenderState.ZBufferEnable = true;
			drawArgs.device.Lights[0].Diffuse = System.Drawing.Color.White; 
			drawArgs.device.Lights[0].Type = LightType.Point; 
			drawArgs.device.Lights[0].Range = 100000;
			drawArgs.device.Lights[0].Position = new Vector3(this.layerRadius, 0, 0);
			drawArgs.device.Lights[0].Enabled = true ; 

			drawArgs.device.RenderState.CullMode = Cull.None;
			drawArgs.device.Transform.World = Matrix.Identity;
			drawArgs.device.Transform.World *= Matrix.Scaling(this.scaleFactor, this.scaleFactor, this.scaleFactor);
			//drawArgs.device.Transform.World *= Matrix.RotationX(MathEngine.RadiansToDegrees(90));
			drawArgs.device.Transform.World *= Matrix.Translation(0,0,-this.layerRadius);
			
			drawArgs.device.Transform.World *= Matrix.RotationY((float)MathEngine.DegreesToRadians(90-this.lat));
			drawArgs.device.Transform.World *= Matrix.RotationZ((float)MathEngine.DegreesToRadians(180+this.lon));
			
			//drawArgs.device.Transform.World *= Matrix.RotationQuaternion(drawArgs.WorldCamera.CurrentOrientation);
		
			drawArgs.device.TextureState[0].ColorOperation = TextureOperation.Disable;
			drawArgs.device.RenderState.NormalizeNormals = true;
		
			
			for( int i = 0; i < this.meshMaterials.Length; i++ )
			{
				drawArgs.device.Material = this.meshMaterials[i];
				this.mesh.DrawSubset(i);
			}
			
			drawArgs.device.Transform.World = currentWorld;
			drawArgs.device.RenderState.CullMode = Cull.Clockwise;
			drawArgs.device.RenderState.Lighting = false;
		}
예제 #12
0
        /// <summary>
        /// Draws the progress bar
        /// </summary>
        /// <param name="x">Center X position of progress.</param>
        /// <param name="y">Center Y position of progress.</param>
        /// <param name="progress">Progress vale, in the range 0..1</param>
        public void Draw(DrawArgs drawArgs, float x, float y, float progress, int color)
        {
            if (x != this.x
                || y != this.y) {
                Initalize(x, y);
            }
            int barlength = (int) (progress*2*halfWidth);

            progressBar[0].X = x - halfWidth;
            progressBar[0].Y = y - halfHeight;
            progressBar[0].Color = color;
            progressBar[1].X = x - halfWidth;
            progressBar[1].Y = y + halfHeight;
            progressBar[1].Color = color;
            progressBar[2].X = x - halfWidth + barlength;
            progressBar[2].Y = y - halfHeight;
            progressBar[2].Color = color;
            progressBar[3].Y = y + halfHeight;
            progressBar[3].X = x - halfWidth + barlength;
            progressBar[3].Color = color;

            progressRight[0].X = x - halfWidth + barlength;
            progressRight[0].Y = y - halfHeight;
            progressRight[1].X = x - halfWidth + barlength;
            progressRight[1].Y = y + halfHeight;
            progressRight[2].X = x + halfWidth;
            progressRight[2].Y = y - halfHeight;
            progressRight[3].X = x + halfWidth;
            progressRight[3].Y = y + halfHeight;

            drawArgs.Device.VertexFormat = CustomVertex.TransformedColored.Format;
            drawArgs.Device.TextureState[0].ColorOperation = TextureOperation.Disable;
            drawArgs.Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, progressBar);
            drawArgs.Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, progressRight);
            drawArgs.Device.DrawUserPrimitives(PrimitiveType.LineStrip, 4, progressBarOutline);
        }
예제 #13
0
파일: MenuBar.cs 프로젝트: Fav/testww
        public void Render(DrawArgs drawArgs)
        {
            if (m_sprite == null)
            {
                m_sprite = new Sprite(drawArgs.device);
            }

            if (mouseCursor != CursorType.Arrow)
            {
                DrawArgs.MouseCursor = mouseCursor;
            }


            foreach (MenuButton button in m_toolsMenuButtons)
            {
                if (button.IsPushed())
                {
                    // Does not render the button, but the functionality behind the button
                    button.Render(drawArgs);
                }
            }

            foreach (MenuButton button in m_toolsMenuButtons)
            {
                button.Update(drawArgs);
            }

            foreach (MenuButton button in m_layersMenuButtons)
            {
                button.Update(drawArgs);
            }

            if (!World.Settings.showToolbar)
            {
                return;
            }

            if (this._isHideable)
            {
                if (this._visibleState == VisibleState.NotVisible)
                {
                    if (
                        (m_anchor == MenuAnchor.Top && DrawArgs.LastMousePosition.Y < MenuButton.NormalSize) ||
                        (m_anchor == MenuAnchor.Bottom && DrawArgs.LastMousePosition.Y > drawArgs.screenHeight - MenuButton.NormalSize) ||
                        (m_anchor == MenuAnchor.Right && DrawArgs.LastMousePosition.X > drawArgs.screenWidth - MenuButton.NormalSize)
                        )
                    {
                        this._visibleState      = VisibleState.Ascending;
                        this._lastVisibleChange = System.DateTime.Now;
                    }
                }
                else if (
                    (m_anchor == MenuAnchor.Top && DrawArgs.LastMousePosition.Y > 2 * this._outerPadding + MenuButton.NormalSize) ||
                    (m_anchor == MenuAnchor.Bottom && DrawArgs.LastMousePosition.Y < drawArgs.screenHeight - 2 * this._outerPadding - MenuButton.NormalSize) ||
                    (m_anchor == MenuAnchor.Right && DrawArgs.LastMousePosition.X < drawArgs.screenWidth - MenuButton.NormalSize)
                    )
                {
                    if (this._visibleState == VisibleState.Visible)
                    {
                        this._visibleState      = VisibleState.Descending;
                        this._lastVisibleChange = System.DateTime.Now;
                    }
                    else if (this._visibleState == VisibleState.Descending)
                    {
                        if (System.DateTime.Now.Subtract(this._lastVisibleChange) > System.TimeSpan.FromMilliseconds(hideTimeMilliseconds))
                        {
                            this._visibleState      = VisibleState.NotVisible;
                            this._lastVisibleChange = System.DateTime.Now;
                        }
                    }
                }
                else if (this._visibleState == VisibleState.Ascending)
                {
                    if (System.DateTime.Now.Subtract(this._lastVisibleChange) > System.TimeSpan.FromMilliseconds(hideTimeMilliseconds))
                    {
                        this._visibleState      = VisibleState.Visible;
                        this._lastVisibleChange = System.DateTime.Now;
                    }
                }
                else if (this._visibleState == VisibleState.Descending)
                {
                    if (System.DateTime.Now.Subtract(this._lastVisibleChange) > System.TimeSpan.FromMilliseconds(hideTimeMilliseconds))
                    {
                        this._visibleState      = VisibleState.NotVisible;
                        this._lastVisibleChange = System.DateTime.Now;
                    }
                }
            }
            else
            {
                this._visibleState = VisibleState.Visible;
            }

            int totalNumberButtons = m_toolsMenuButtons.Count + m_layersMenuButtons.Count;

            MenuButton.NormalSize = MenuButton.SelectedSize / 2;
            _outerPadding         = MenuButton.NormalSize * padRatio;

            float menuWidth = (MenuButton.NormalSize + _outerPadding) * totalNumberButtons + _outerPadding;

            if (menuWidth > drawArgs.screenWidth)
            {
                MenuButton.NormalSize = (drawArgs.screenWidth) / ((padRatio + 1) * totalNumberButtons + padRatio);
                _outerPadding         = MenuButton.NormalSize * padRatio;

                // recalc menuWidth if we want to center the toolbar
                menuWidth = (MenuButton.NormalSize + _outerPadding) * totalNumberButtons + _outerPadding;
            }

            if (m_anchor == MenuAnchor.Left)
            {
                x = 0;
                y = (int)MenuButton.NormalSize;
            }
            else if (m_anchor == MenuAnchor.Right)
            {
                x = (int)(drawArgs.screenWidth - 2 * _outerPadding - MenuButton.NormalSize);
                y = (int)MenuButton.NormalSize;
            }
            else if (m_anchor == MenuAnchor.Top)
            {
                x = (int)(drawArgs.screenWidth / 2 - totalNumberButtons * MenuButton.NormalSize / 2 - _outerPadding);
                y = 0;
            }
            else if (m_anchor == MenuAnchor.Bottom)
            {
                x = (int)(drawArgs.screenWidth / 2 - totalNumberButtons * MenuButton.NormalSize / 2 - _outerPadding);
                y = (int)(drawArgs.screenHeight - 2 * _outerPadding - MenuButton.NormalSize);
            }

            if (this._visibleState == VisibleState.Ascending)
            {
                TimeSpan t = System.DateTime.Now.Subtract(this._lastVisibleChange);
                if (t.Milliseconds < hideTimeMilliseconds)
                {
                    double percent = (double)t.Milliseconds / hideTimeMilliseconds;
                    int    dx      = (int)((MenuButton.NormalSize + 5) - (percent * (MenuButton.NormalSize + 5)));

                    if (m_anchor == MenuAnchor.Left)
                    {
                        x -= dx;
                    }
                    else if (m_anchor == MenuAnchor.Right)
                    {
                        x += dx;
                    }
                    else if (m_anchor == MenuAnchor.Top)
                    {
                        y -= dx;
                    }
                    else if (m_anchor == MenuAnchor.Bottom)
                    {
                        y += dx;
                    }
                }
            }
            else if (this._visibleState == VisibleState.Descending)
            {
                TimeSpan t = System.DateTime.Now.Subtract(this._lastVisibleChange);
                if (t.Milliseconds < hideTimeMilliseconds)
                {
                    double percent = (double)t.Milliseconds / hideTimeMilliseconds;
                    int    dx      = (int)((percent * (MenuButton.NormalSize + 5)));

                    if (m_anchor == MenuAnchor.Left)
                    {
                        x -= dx;
                    }
                    else if (m_anchor == MenuAnchor.Right)
                    {
                        x += dx;
                    }
                    else if (m_anchor == MenuAnchor.Top)
                    {
                        y -= dx;
                    }
                    else if (m_anchor == MenuAnchor.Bottom)
                    {
                        y += dx;
                    }
                }
            }

            lock (m_toolsMenuButtons.SyncRoot)
            {
                MenuButton selectedButton = null;
                if (_curSelection >= 0 & _curSelection < totalNumberButtons)
                {
                    if (_curSelection < m_toolsMenuButtons.Count)
                    {
                        selectedButton = (MenuButton)m_toolsMenuButtons[_curSelection];
                    }
                    else
                    {
                        selectedButton = (MenuButton)m_layersMenuButtons[_curSelection - m_toolsMenuButtons.Count];
                    }
                }

                //_outerPadding = MenuButton.NormalSize*padRatio;
                //float menuWidth = (MenuButton.NormalSize+_outerPadding)*totalNumberButtons+_outerPadding;
                //if(menuWidth>drawArgs.screenWidth)
                //{
                //    //MessageBox.Show(drawArgs.screenWidth.ToString());
                //    MenuButton.NormalSize = (drawArgs.screenWidth)/((padRatio+1)*totalNumberButtons+padRatio);
                //    //MessageBox.Show(MenuButton.NormalSize.ToString());
                //    _outerPadding = MenuButton.NormalSize*padRatio;
                //}

                if (this._visibleState != VisibleState.NotVisible)
                {
                    if (m_anchor == MenuAnchor.Top)
                    {
                        MenuUtils.DrawBox(0, 0, drawArgs.screenWidth, (int)(MenuButton.NormalSize + 2 * _outerPadding), 0.0f,
                                          World.Settings.toolBarBackColor, drawArgs.device);
                    }
                    else if (m_anchor == MenuAnchor.Bottom)
                    {
                        MenuUtils.DrawBox(0, (int)(y - _outerPadding), drawArgs.screenWidth, (int)(MenuButton.NormalSize + 4 * _outerPadding), 0.0f,
                                          World.Settings.toolBarBackColor, drawArgs.device);
                    }
                }

                float total = 0;
                float extra = 0;
                for (int i = 0; i < totalNumberButtons; i++)
                {
                    MenuButton button;
                    if (i < m_toolsMenuButtons.Count)
                    {
                        button = (MenuButton)m_toolsMenuButtons[i];
                    }
                    else
                    {
                        button = (MenuButton)m_layersMenuButtons[i - m_toolsMenuButtons.Count];
                    }
                    total += button.CurrentSize;
                    extra += button.CurrentSize - MenuButton.NormalSize;
                }

                float pad     = ((float)_outerPadding * (totalNumberButtons + 1) - extra) / (totalNumberButtons + 1);
                float buttonX = pad;

                // TODO - to center the menubar set the buttonX to center-half toolbar width
                // float buttonX = (drawArgs.screenWidth - menuWidth) / 2;

                m_sprite.Begin(SpriteFlags.AlphaBlend);
                for (int i = 0; i < totalNumberButtons; i++)
                {
                    MenuButton button;
                    if (i < m_toolsMenuButtons.Count)
                    {
                        button = (MenuButton)m_toolsMenuButtons[i];
                    }
                    else
                    {
                        button = (MenuButton)m_layersMenuButtons[i - m_toolsMenuButtons.Count];
                    }

                    if (button.IconTexture == null)
                    {
                        button.InitializeTexture(drawArgs.device);
                    }

                    if (this._visibleState != VisibleState.NotVisible)
                    {
                        int centerX = (int)(buttonX + button.CurrentSize * 0.5f);
                        buttonX += button.CurrentSize + pad;
                        float buttonTopY = y + _outerPadding;

                        if (m_anchor == MenuAnchor.Bottom)
                        {
                            buttonTopY = (int)(drawArgs.screenHeight - _outerPadding - button.CurrentSize);
                        }

                        if (button.IsPushed())
                        {
                            // Draw the chevron
                            float chevronSize = button.CurrentSize * padRatio;

                            enabledChevron[0].Color = chevronColor;
                            enabledChevron[1].Color = chevronColor;
                            enabledChevron[2].Color = chevronColor;

                            if (m_anchor == MenuAnchor.Bottom)
                            {
                                enabledChevron[2].X = centerX - chevronSize;
                                enabledChevron[2].Y = y - 2;
                                enabledChevron[2].Z = 0.0f;

                                enabledChevron[0].X = centerX;
                                enabledChevron[0].Y = y - 2 + chevronSize;
                                enabledChevron[0].Z = 0.0f;

                                enabledChevron[1].X = centerX + chevronSize;
                                enabledChevron[1].Y = y - 2;
                                enabledChevron[1].Z = 0.0f;
                            }
                            else
                            {
                                enabledChevron[2].X = centerX - chevronSize;
                                enabledChevron[2].Y = y + 2;
                                enabledChevron[2].Z = 0.0f;

                                enabledChevron[0].X = centerX;
                                enabledChevron[0].Y = y + 2 + chevronSize;
                                enabledChevron[0].Z = 0.0f;

                                enabledChevron[1].X = centerX + chevronSize;
                                enabledChevron[1].Y = y + 2;
                                enabledChevron[1].Z = 0.0f;
                            }

                            drawArgs.device.VertexFormat = CustomVertex.TransformedColored.Format;
                            drawArgs.device.TextureState[0].ColorOperation = TextureOperation.Disable;
                            drawArgs.device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, enabledChevron);
                            drawArgs.device.TextureState[0].ColorOperation = TextureOperation.SelectArg1;
                        }

                        button.RenderEnabledIcon(
                            m_sprite,
                            drawArgs,
                            centerX,
                            buttonTopY,
                            i == this._curSelection,
                            m_anchor);
                    }
                }
                m_sprite.End();
            }
        }
예제 #14
0
        public void Render(DrawArgs drawArgs)
        {
            try
            {
                if (m_Visible)
                {
                    if (m_localFont != null && m_drawingFont == null)
                    {
                        m_drawingFont = new Font(drawArgs.device, m_localFont);
                    }

                    DrawTextFormat drawTextFormat = DrawTextFormat.Center;

                    Angle startLatitude  = Angle.NaN;
                    Angle startLongitude = Angle.NaN;

                    Angle endLatitude  = Angle.NaN;
                    Angle endLongitude = Angle.NaN;

                    string displayString = "";

                    drawArgs.WorldCamera.PickingRayIntersection(
                        AbsoluteLocation.X,
                        AbsoluteLocation.Y + ClientSize.Height,
                        out startLatitude,
                        out startLongitude);

                    drawArgs.WorldCamera.PickingRayIntersection(
                        AbsoluteLocation.X + ClientSize.Width,
                        AbsoluteLocation.Y + ClientSize.Height,
                        out endLatitude,
                        out endLongitude);

                    if (startLatitude == Angle.NaN ||
                        startLongitude == Angle.NaN ||
                        endLatitude == Angle.NaN ||
                        endLongitude == Angle.NaN)
                    {
                        //displayString = "Out of Range";
                    }
                    else
                    {
                        double distance = getDistance(startLatitude, startLongitude, endLatitude, endLongitude, drawArgs.CurrentWorld.EquatorialRadius);
                        if (distance > double.MinValue && distance < double.MaxValue)
                        {
                            displayString = GetDisplayString(distance);
                        }
                    }

                    drawArgs.device.TextureState[0].ColorOperation = TextureOperation.SelectArg1;
                    drawArgs.device.TextureState[0].ColorArgument1 = TextureArgument.Diffuse;
                    drawArgs.device.TextureState[0].AlphaOperation = TextureOperation.SelectArg1;
                    drawArgs.device.TextureState[0].AlphaArgument1 = TextureArgument.Diffuse;


                    renderBackbone(drawArgs);

                    if (m_drawingFont == null)
                    {
                        drawArgs.defaultDrawingFont.DrawText(
                            null,
                            displayString,
                            new System.Drawing.Rectangle(AbsoluteLocation.X, AbsoluteLocation.Y, m_Size.Width, m_Size.Height),
                            drawTextFormat,
                            m_ForeColor);
                    }
                    else
                    {
                        m_drawingFont.DrawText(
                            null,
                            displayString,
                            new System.Drawing.Rectangle(AbsoluteLocation.X, AbsoluteLocation.Y, m_Size.Width, m_Size.Height),
                            drawTextFormat,
                            m_ForeColor);
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.Log.Write(ex);
            }
        }
예제 #15
0
 protected override void GetBrush(DrawArgs dArgs)
 {
     string[] args = dArgs.Message.SplitSpaces(3);
     dArgs.BrushName = args[1];
     dArgs.BrushArgs = args.Length > 2 ? args[2] : "";
 }
예제 #16
0
 protected abstract DrawOp GetDrawOp(DrawArgs dArgs);
예제 #17
0
        /// <summary>
        /// This is where we do our rendering
        /// Called from UI thread = UI code safe in this function
        /// </summary>
        public override void Render(DrawArgs drawArgs)
        {
            if (!IsInitialized)
            {
                Initialize(drawArgs);
            }

            // Camera & Device shortcuts ;)
            CameraBase camera = drawArgs.WorldCamera;
            Device     device = drawArgs.device;

            if (camera.Altitude > 200e3)
            {
                return;
            }

            double distToCenterOfPlanet = (camera.Altitude + camera.WorldRadius);
            double tangentalDistance    = Math.Sqrt(distToCenterOfPlanet * distToCenterOfPlanet - camera.WorldRadius * camera.WorldRadius);
            double domeRadius           = tangentalDistance * 0.5;
            double domeToCenterOfPlanet = Math.Sqrt(camera.WorldRadius * camera.WorldRadius - domeRadius * domeRadius) - 2e3;

            // Create sky dome
            Mesh skyMesh = TexturedDome(device, (float)domeRadius, 24, 12);

            // set texture
            device.SetTexture(0, texture);
            device.TextureState[0].ColorOperation          = TextureOperation.BlendCurrentAlpha;
            drawArgs.device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
            drawArgs.device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;
            drawArgs.device.TextureState[0].AlphaOperation = TextureOperation.SelectArg1;
            drawArgs.device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
            device.VertexFormat = CustomVertex.PositionTextured.Format;

            // save world and projection transform
            Matrix origWorld      = device.Transform.World;
            Matrix origProjection = device.Transform.Projection;

            // move sky dome
            Matrix skyTrans;
            Angle  camLat = camera.Latitude;
            Angle  camLon = camera.Longitude;

            //Vector3 groundPos = MathEngine.SphericalToCartesian(camLat, camLon, this.world.EquatorialRadius);
            skyTrans = Matrix.Translation(0, 0, (float)domeToCenterOfPlanet);
            skyTrans = Matrix.Multiply(skyTrans, Matrix.RotationY(-(float)camLat.Radians + (float)Math.PI / 2));
            skyTrans = Matrix.Multiply(skyTrans, Matrix.RotationZ((float)camLon.Radians));

            device.Transform.World = skyTrans;

            // Recenter world
            Recenter(drawArgs);

            // Save fog status
            bool origFog = device.RenderState.FogEnable;

            device.RenderState.FogEnable = false;

            // Set new one (to avoid being clipped) - probably better ways of doing this?
            float aspectRatio = (float)device.Viewport.Width / device.Viewport.Height;

            device.Transform.Projection = Matrix.PerspectiveFovRH((float)camera.Fov.Radians, aspectRatio, 1, float.MaxValue);

            // draw
            skyMesh.DrawSubset(0);

            // Restore device states
            device.Transform.World       = origWorld;
            device.Transform.Projection  = origProjection;
            device.RenderState.FogEnable = origFog;
            // dispose of sky - for now
            skyMesh.Dispose();
        }
예제 #18
0
        /// <summary>
        /// Draws a tropic line at specified latitude with specified label
        /// </summary>
        /// <param name="drawArgs"></param>
        /// <param name="latitude">Latitude in degrees</param>
        /// <param name="label"></param>
        private void RenderTropicLine(DrawArgs drawArgs, float latitude, string label)
        {
            int vertexIndex = 0;
            Vector3 referenceCenter = new Vector3((float) drawArgs.WorldCamera.ReferenceCenter.X, (float) drawArgs.WorldCamera.ReferenceCenter.Y, (float) drawArgs.WorldCamera.ReferenceCenter.Z);

            for (float longitude = MinVisibleLongitude; longitude <= MaxVisibleLongitude; longitude = longitude + LongitudeInterval) {
                Vector3 pointXyz = MathEngine.SphericalToCartesian(latitude, longitude, radius);

                lineVertices[vertexIndex].X = pointXyz.X;
                lineVertices[vertexIndex].Y = pointXyz.Y;
                lineVertices[vertexIndex].Z = pointXyz.Z;
                lineVertices[vertexIndex].Color = World.Settings.tropicLinesColor;
                vertexIndex++;
            }
            drawArgs.Device.DrawUserPrimitives(PrimitiveType.LineStrip, LongitudePointCount - 1, lineVertices);

            Vector3 t1 = MathEngine.SphericalToCartesian(Angle.FromDegrees(latitude), drawArgs.WorldCamera.Longitude - drawArgs.WorldCamera.TrueViewRange*0.3f*0.5f, radius);
            if (drawArgs.WorldCamera.ViewFrustum.ContainsPoint(t1)) {
                t1 = drawArgs.WorldCamera.Project(t1 - referenceCenter);
                drawArgs.DefaultDrawingFont.DrawText(null, label, new Rectangle((int) t1.X, (int) t1.Y, drawArgs.ScreenWidth, drawArgs.ScreenHeight), DrawTextFormat.NoClip, World.Settings.tropicLinesColor);
            }
        }
예제 #19
0
        static bool UsesHeight(DrawArgs args)
        {
            DrawMode mode = args.Mode;

            return(!(mode == DrawMode.sphere || mode == DrawMode.hsphere));
        }
예제 #20
0
        protected override void GetBrush(DrawArgs dArgs)
        {
            int argsUsed = UsesHeight(dArgs) ? 3 : 2;

            dArgs.BrushArgs = dArgs.Message.Splice(argsUsed, 0);
        }
예제 #21
0
        /// <summary>
        /// Raises the <see cref="EventBroker.ImageDrawing"/> event and
        /// renders the <see cref="PresentationImage"/>.
        /// </summary>
        /// <param name="drawArgs"></param>
        /// <remarks>
        /// For internal Framework use only.
        /// </remarks>
        /// <exception cref="RenderingException">Thrown if any <see cref="Exception"/> is encountered while rendering the image.</exception>
        public override void Draw(DrawArgs drawArgs)
        {
            base.Draw(drawArgs);

            CheckRendererInitializationError();
        }
예제 #22
0
        public override void Render(DrawArgs drawArgs)
        {
            if (errorMsg != null)
            {
                //System.Windows.Forms.MessageBox.Show( errorMsg, "Model failed to load.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                errorMsg      = null;
                IsOn          = false;
                isInitialized = false;
                return;
            }

            if (!IsVisible(drawArgs.WorldCamera))
            {
                // Mesh is not in view, unload it to save memory
                if (isInitialized)
                {
                    Dispose();
                }
                return;
            }

            if (!isInitialized)
            {
                return;
            }

            //Donot render for other planets
            if (!drawArgs.CurrentWorld.IsEarth)
            {
                return;
            }



            drawArgs.device.RenderState.CullMode         = Cull.None;
            drawArgs.device.RenderState.Lighting         = true;
            drawArgs.device.RenderState.AmbientColor     = 0x808080;
            drawArgs.device.RenderState.NormalizeNormals = true;

            drawArgs.device.Lights[0].Diffuse   = Color.FromArgb(255, 255, 255);
            drawArgs.device.Lights[0].Type      = LightType.Directional;
            drawArgs.device.Lights[0].Direction = new Vector3(1f, 1f, 1f);
            drawArgs.device.Lights[0].Enabled   = true;

            drawArgs.device.SamplerState[0].AddressU = TextureAddress.Wrap;
            drawArgs.device.SamplerState[0].AddressV = TextureAddress.Wrap;

            drawArgs.device.RenderState.AlphaBlendEnable   = true;
            drawArgs.device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
            drawArgs.device.TextureState[0].ColorOperation = TextureOperation.SelectArg1;

            // Put the light somewhere up in space
            drawArgs.device.Lights[0].Position = new Vector3(
                (float)worldXyz.X * 2f,
                (float)worldXyz.Y * 1f,
                (float)worldXyz.Z * 1.5f);

            Matrix currentWorld = drawArgs.device.Transform.World;

            drawArgs.device.Transform.World  = Matrix.RotationX((float)MathEngine.DegreesToRadians(RotX));
            drawArgs.device.Transform.World *= Matrix.RotationZ((float)MathEngine.DegreesToRadians(RotY));
            drawArgs.device.Transform.World *= Matrix.RotationZ((float)MathEngine.DegreesToRadians(RotZ));
            drawArgs.device.Transform.World *= Matrix.Scaling(Scale, Scale, Scale);

            // Move the mesh to desired location on earth
            if (IsVertExaggerable)
            {
                vertExaggeration = World.Settings.VerticalExaggeration;
            }
            else
            {
                vertExaggeration = 1;
            }
            drawArgs.device.Transform.World *= Matrix.Translation(0, 0, (float)drawArgs.WorldCamera.WorldRadius + Altitude * vertExaggeration);
            drawArgs.device.Transform.World *= Matrix.RotationY((float)MathEngine.DegreesToRadians(90 - Latitude));
            drawArgs.device.Transform.World *= Matrix.RotationZ((float)MathEngine.DegreesToRadians(Longitude));


            drawArgs.device.Transform.World *= Matrix.Translation(
                (float)-drawArgs.WorldCamera.ReferenceCenter.X,
                (float)-drawArgs.WorldCamera.ReferenceCenter.Y,
                (float)-drawArgs.WorldCamera.ReferenceCenter.Z
                );

            Device device = drawArgs.device;

            // Draw the mesh with effect
            if (isBumpmapped)
            {
                setupBumpEffect(drawArgs);
            }
            else
            {
                setupReflectionEffect(drawArgs);
            }

            //render the effect
            bool alphastate = device.RenderState.AlphaBlendEnable;

            device.RenderState.AlphaBlendEnable = true;
            effect.Begin(0);
            effect.BeginPass(0);

            //drawArgs.device.SetTexture(0, texture);
            m_meshElems[0].mesh.DrawSubset(0);

            effect.EndPass();
            effect.End();
            device.RenderState.AlphaBlendEnable = alphastate;


            drawArgs.device.Transform.World      = currentWorld;
            drawArgs.device.RenderState.Lighting = false;
        }
예제 #23
0
 protected override DrawOp GetDrawOp(DrawArgs dArgs)
 {
     return(new BezierDrawOp());
 }
예제 #24
0
 public override void Render(DrawArgs drawArgs)
 {
 }
예제 #25
0
 protected virtual void GetMarks(DrawArgs dArgs, ref Vec3S32[] m)
 {
 }
예제 #26
0
 protected override DrawOp GetDrawOp(DrawArgs dArg)
 {
     return(new FillDrawOp());
 }
예제 #27
0
        /// <summary>
        /// Render the grid lines
        /// </summary>
        public override void Render(DrawArgs drawArgs)
        {
            if (!World.Settings.showLatLonLines) {
                return;
            }

            ComputeGridValues(drawArgs);

            float offsetDegrees = (float) drawArgs.WorldCamera.TrueViewRange.Degrees/6;

            drawArgs.Device.RenderState.ZBufferEnable = useZBuffer;

            drawArgs.Device.TextureState[0].ColorOperation = TextureOperation.Disable;
            drawArgs.Device.VertexFormat = CustomVertex.PositionColored.Format;
            drawArgs.Device.Transform.World = Matrix.Translation((float) -drawArgs.WorldCamera.ReferenceCenter.X, (float) -drawArgs.WorldCamera.ReferenceCenter.Y, (float) -drawArgs.WorldCamera.ReferenceCenter.Z);

            Vector3 referenceCenter = new Vector3((float) drawArgs.WorldCamera.ReferenceCenter.X, (float) drawArgs.WorldCamera.ReferenceCenter.Y, (float) drawArgs.WorldCamera.ReferenceCenter.Z);

            // Draw longitudes
            for (float longitude = MinVisibleLongitude; longitude < MaxVisibleLongitude; longitude += LongitudeInterval) {
                // Draw longitude lines
                int vertexIndex = 0;
                for (float latitude = MinVisibleLatitude; latitude <= MaxVisibleLatitude; latitude += LatitudeInterval) {
                    Vector3 pointXyz = MathEngine.SphericalToCartesian(latitude, longitude, radius);
                    lineVertices[vertexIndex].X = pointXyz.X;
                    lineVertices[vertexIndex].Y = pointXyz.Y;
                    lineVertices[vertexIndex].Z = pointXyz.Z;
                    lineVertices[vertexIndex].Color = World.Settings.latLonLinesColor;
                    vertexIndex++;
                }
                drawArgs.Device.DrawUserPrimitives(PrimitiveType.LineStrip, LatitudePointCount - 1, lineVertices);

                // Draw longitude label
                float lat = (float) (drawArgs.WorldCamera.Latitude).Degrees;
                if (lat > 70) {
                    lat = 70;
                }
                Vector3 v = MathEngine.SphericalToCartesian(lat, longitude, radius);
                if (drawArgs.WorldCamera.ViewFrustum.ContainsPoint(v)) {
                    // Make sure longitude is in -180 .. 180 range
                    int longitudeRanged = (int) longitude;
                    if (longitudeRanged <= -180) {
                        longitudeRanged += 360;
                    }
                    else if (longitudeRanged > 180) {
                        longitudeRanged -= 360;
                    }

                    string s = Math.Abs(longitudeRanged).ToString();
                    if (longitudeRanged < 0) {
                        s += "W";
                    }
                    else if (longitudeRanged > 0
                             && longitudeRanged < 180) {
                        s += "E";
                    }

                    v = drawArgs.WorldCamera.Project(v - referenceCenter);
                    Rectangle rect = new Rectangle((int) v.X + 2, (int) v.Y, 10, 10);
                    drawArgs.DefaultDrawingFont.DrawText(null, s, rect.Left, rect.Top, World.Settings.latLonLinesColor);
                }
            }

            // Draw latitudes
            for (float latitude = MinVisibleLatitude; latitude <= MaxVisibleLatitude; latitude += LatitudeInterval) {
                // Draw latitude label
                float longitude = (float) (drawArgs.WorldCamera.Longitude).Degrees + offsetDegrees;

                Vector3 v = MathEngine.SphericalToCartesian(latitude, longitude, radius);
                if (drawArgs.WorldCamera.ViewFrustum.ContainsPoint(v)) {
                    v = drawArgs.WorldCamera.Project(v - referenceCenter);
                    float latLabel = latitude;
                    if (latLabel > 90) {
                        latLabel = 180 - latLabel;
                    }
                    else if (latLabel < -90) {
                        latLabel = -180 - latLabel;
                    }
                    string s = ((int) Math.Abs(latLabel)).ToString();
                    if (latLabel > 0) {
                        s += "N";
                    }
                    else if (latLabel < 0) {
                        s += "S";
                    }
                    Rectangle rect = new Rectangle((int) v.X, (int) v.Y, 10, 10);
                    drawArgs.DefaultDrawingFont.DrawText(null, s, rect.Left, rect.Top, World.Settings.latLonLinesColor);
                }

                // Draw latitude line
                int vertexIndex = 0;
                for (longitude = MinVisibleLongitude; longitude <= MaxVisibleLongitude; longitude += LongitudeInterval) {
                    Vector3 pointXyz = MathEngine.SphericalToCartesian(latitude, longitude, radius);
                    lineVertices[vertexIndex].X = pointXyz.X;
                    lineVertices[vertexIndex].Y = pointXyz.Y;
                    lineVertices[vertexIndex].Z = pointXyz.Z;

                    if (latitude == 0) {
                        lineVertices[vertexIndex].Color = World.Settings.equatorLineColor;
                    }
                    else {
                        lineVertices[vertexIndex].Color = World.Settings.latLonLinesColor;
                    }

                    vertexIndex++;
                }
                drawArgs.Device.DrawUserPrimitives(PrimitiveType.LineStrip, LongitudePointCount - 1, lineVertices);
            }

            if (World.Settings.showTropicLines && IsEarth) {
                RenderTropicLines(drawArgs);
            }

            // Restore state
            drawArgs.Device.Transform.World = drawArgs.WorldCamera.WorldMatrix;
            if (!useZBuffer) {
                // Reset Z buffer setting
                drawArgs.Device.RenderState.ZBufferEnable = true;
            }
        }
예제 #28
0
        protected override DrawOp GetDrawOp(DrawArgs dArgs)
        {
            DrawOp op = null;

            switch (dArgs.Mode)
            {
            case DrawMode.cone:   op = new ConeDrawOp(); break;

            case DrawMode.hcone:  op = new AdvHollowConeDrawOp(); break;

            case DrawMode.icone:  op = new ConeDrawOp(true); break;

            case DrawMode.hicone: op = new AdvHollowConeDrawOp(true); break;

            case DrawMode.pyramid:   op = new AdvPyramidDrawOp(); break;

            case DrawMode.hpyramid:  op = new AdvHollowPyramidDrawOp(); break;

            case DrawMode.ipyramid:  op = new AdvPyramidDrawOp(true); break;

            case DrawMode.hipyramid: op = new AdvHollowPyramidDrawOp(true); break;

            case DrawMode.sphere:  op = new AdvSphereDrawOp(); break;

            case DrawMode.hsphere: op = new AdvHollowSphereDrawOp(); break;

            case DrawMode.volcano: op = new AdvVolcanoDrawOp(); break;

            case DrawMode.hollow:  op = new CylinderDrawOp(); break;
            }
            if (op == null)
            {
                Help(dArgs.Player); return(null);
            }

            AdvDrawMeta meta    = new AdvDrawMeta();
            bool        success = false;

            string[] args = dArgs.Message.SplitSpaces();
            Player   p    = dArgs.Player;

            if (UsesHeight(dArgs))
            {
                if (args.Length < 3)
                {
                    p.Message("You need to provide the radius and the height for the {0}.", args[0]);
                }
                else
                {
                    success = CommandParser.GetInt(p, args[1], "radius", ref meta.radius, 0, 2000) &&
                              CommandParser.GetInt(p, args[2], "height", ref meta.height, 0, 2000);
                }
            }
            else
            {
                if (args.Length < 2)
                {
                    p.Message("You need to provide the radius for the {0}.", args[0]);
                }
                else
                {
                    success = CommandParser.GetInt(p, args[1], "radius", ref meta.radius, 0, 2000);
                }
            }

            if (!success)
            {
                return(null);
            }
            dArgs.Meta = meta;
            return(op);
        }
예제 #29
0
        public void Draw(Graphics g, Rectangle rcClient, DrawArgs drwa, Point ptOffset)
        {
            int xCenter = rcClient.Width / 2;
            int yCenter = rcClient.Height / 2;

            int cxT = ((rcClient.Width + drwa.nScale - 1) / drwa.nScale) + 2;
            int cyT = ((rcClient.Height + drwa.nScale - 1) / drwa.nScale) + 2;
            int xCenterT = cxT / 2;
            int yCenterT = cyT / 2;

            // NOTE: these 'using' statements (a 'shortcut' for calling .Dispose()) are
            // absolutely necessary or we chew up all virtual memory while animating

            // Create a temporary bitmap for compositing the grid, frames, origin indicator, etc into

            using (Bitmap bmT = new Bitmap(cxT, cyT)) {

                // Draw the frame and its indicators (grid, center point, special point, etc)

                DrawUnscaled(bmT, cxT, cyT, drwa, ptOffset);

                // Force a nice simple fast old-school stretchblt

                InterpolationMode imOld = g.InterpolationMode;
                g.InterpolationMode = InterpolationMode.NearestNeighbor;

                // NOTE: _without_ this the first row and column are only scaled by half!

                PixelOffsetMode pomOld = g.PixelOffsetMode;
                g.PixelOffsetMode = PixelOffsetMode.Half;

                // StretchBlt the temporary composite to the passed-in Graphic

                g.DrawImage(bmT, rcClient.Left - ((xCenterT * drwa.nScale) - xCenter),
                        rcClient.Top - ((yCenterT * drwa.nScale) - yCenter),
                        cxT * drwa.nScale, cyT * drwa.nScale);

                g.PixelOffsetMode = pomOld;
                g.InterpolationMode = imOld;
            }
        }
예제 #30
0
 public void Render(DrawArgs drawArgs)
 {
     if (this.m_Visible)
     {
         if (this.m_HandleTexture == null)
         {
             this.Initialize(drawArgs);
         }
         if (((DrawArgs.LastMousePosition.X > (this.AbsoluteLocation.X - 10)) && (DrawArgs.LastMousePosition.X < ((this.AbsoluteLocation.X + this.ClientSize.Width) + 10))) && ((DrawArgs.LastMousePosition.Y > (this.AbsoluteLocation.Y + 5)) && (DrawArgs.LastMousePosition.Y < ((this.AbsoluteLocation.Y + this.ClientSize.Height) + 5))))
         {
             if (!this.m_isMouseInside)
             {
                 this.m_isMouseInside = true;
                 this.OnMouseEnter(null);
                 if (this.OnMouseEnterEvent != null)
                 {
                     this.OnMouseEnterEvent(this, null);
                 }
             }
         }
         else if (this.m_isMouseInside)
         {
             this.m_isMouseInside = false;
             this.OnMouseLeave(null);
             if (this.OnMouseLeaveEvent != null)
             {
                 this.OnMouseLeaveEvent(this, null);
             }
         }
         if (DateTime.Now.Subtract(this.frameTime) > frameTimeSpan)
         {
             if (!this.m_isMouseInside)
             {
                 if (this.m_Opacity > m_MinimumOpacity)
                 {
                     this.m_Opacity       = (byte)(this.m_Opacity - m_OpacityRate);
                     this.m_HandleOpacity = this.m_Opacity;
                 }
                 else
                 {
                     this.m_HandleOpacity = 0;
                     this.m_Opacity       = m_MinimumOpacity;
                 }
             }
             else
             {
                 if (this.m_Opacity < (0xff - m_OpacityRate))
                 {
                     this.m_Opacity = (byte)(this.m_Opacity + m_OpacityRate);
                 }
                 else
                 {
                     this.m_Opacity = 0xff;
                 }
                 this.m_HandleOpacity = this.m_Opacity;
             }
             this.frameTime = DateTime.Now;
         }
         if ((((this.m_HandleTexture != null) && (this.m_currentHandleUri != this.m_HandleUri)) || ((this.m_LowImageTexture != null) && (this.m_currentLowImageUri != this.m_LowImageUri))) || ((this.m_HighImageTexture != null) && (this.m_currentHighImageUri != this.m_HighImageUri)))
         {
             this.Initialize(drawArgs);
         }
         Utilities.DrawBox(this.AbsoluteLocation.X, this.AbsoluteLocation.Y, this.ClientSize.Width, this.ClientSize.Height, 0f, this.m_BackgroundColor.ToArgb(), drawArgs.device);
         Utilities.DrawBox(this.AbsoluteLocation.X + this.m_StickLocation.X, this.AbsoluteLocation.Y + this.m_StickLocation.Y, this.m_StickSize.Width, this.m_StickSize.Height, 0f, this.m_StickBackgroundColor.ToArgb(), drawArgs.device);
         Microsoft.DirectX.Vector2[] linePoints = new Microsoft.DirectX.Vector2[5];
         linePoints[0].X = this.AbsoluteLocation.X + this.m_StickLocation.X;
         linePoints[0].Y = this.AbsoluteLocation.Y + this.m_StickLocation.Y;
         linePoints[1].X = (this.AbsoluteLocation.X + this.m_StickLocation.X) + this.m_StickSize.Width;
         linePoints[1].Y = this.AbsoluteLocation.Y + this.m_StickLocation.Y;
         linePoints[2].X = (this.AbsoluteLocation.X + this.m_StickLocation.X) + this.m_StickSize.Width;
         linePoints[2].Y = (this.AbsoluteLocation.Y + this.m_StickLocation.Y) + this.m_StickSize.Height;
         linePoints[3].X = this.AbsoluteLocation.X + this.m_StickLocation.X;
         linePoints[3].Y = (this.AbsoluteLocation.Y + this.m_StickLocation.Y) + this.m_StickSize.Height;
         linePoints[4].X = this.AbsoluteLocation.X + this.m_StickLocation.X;
         linePoints[4].Y = this.AbsoluteLocation.Y + this.m_StickLocation.Y;
         Utilities.DrawLine(linePoints, Color.FromArgb(this.m_Opacity, this.m_ForeColor.R, this.m_ForeColor.G, this.m_ForeColor.B).ToArgb(), drawArgs.device);
         if ((this.m_HandleTexture != null) && !this.isLoading)
         {
             drawArgs.device.SetTexture(0, this.m_HandleTexture);
             drawArgs.device.RenderState.ZBufferEnable = false;
             Point point  = new Point(this.AbsoluteLocation.X + this.m_HandleLocation.X, this.AbsoluteLocation.Y + this.m_HandleLocation.Y);
             Point point2 = new Point((this.AbsoluteLocation.X + this.m_HandleLocation.X) + this.m_HandleSize.Width, this.AbsoluteLocation.Y + this.m_HandleLocation.Y);
             new Point(this.AbsoluteLocation.X + this.m_HandleLocation.X, (this.AbsoluteLocation.Y + this.m_HandleLocation.Y) + this.m_HandleSize.Height);
             Point point3 = new Point((this.AbsoluteLocation.X + this.m_HandleLocation.X) + this.m_HandleSize.Width, (this.AbsoluteLocation.Y + this.m_HandleLocation.Y) + this.m_HandleSize.Height);
             if (this.m_HandleSprite == null)
             {
                 this.m_HandleSprite = new Sprite(drawArgs.device);
             }
             this.m_HandleSprite.Begin(SpriteFlags.AlphaBlend);
             float x = ((float)(point2.X - point.X)) / ((float)this.m_HandlesurfaceDescription.Width);
             float y = ((float)(point3.Y - point2.Y)) / ((float)this.m_HandlesurfaceDescription.Height);
             this.m_HandleSprite.Transform  = Microsoft.DirectX.Matrix.Scaling(x, y, 0f);
             this.m_HandleSprite.Transform *= Microsoft.DirectX.Matrix.Translation(0.5f * (point.X + point2.X), 0.5f * (point2.Y + point3.Y), 0f);
             this.m_HandleSprite.Draw(this.m_HandleTexture, new Microsoft.DirectX.Vector3((float)(this.m_HandlesurfaceDescription.Width / 2), (float)(this.m_HandlesurfaceDescription.Height / 2), 0f), Microsoft.DirectX.Vector3.Empty, Color.FromArgb(this.m_HandleOpacity, 0xff, 0xff, 0xff).ToArgb());
             this.m_HandleSprite.Transform = Microsoft.DirectX.Matrix.Identity;
             this.m_HandleSprite.End();
         }
         if ((this.m_LowImageTexture != null) && !this.isLoading)
         {
             drawArgs.device.SetTexture(0, this.m_LowImageTexture);
             drawArgs.device.RenderState.ZBufferEnable = false;
             Point point4 = new Point(this.AbsoluteLocation.X + this.m_LowImageLocation.X, this.AbsoluteLocation.Y + this.m_LowImageLocation.Y);
             Point point5 = new Point((this.AbsoluteLocation.X + this.m_LowImageLocation.X) + this.m_LowImageSize.Width, this.AbsoluteLocation.Y + this.m_LowImageLocation.Y);
             new Point(this.AbsoluteLocation.X + this.m_LowImageLocation.X, (this.AbsoluteLocation.Y + this.m_LowImageLocation.Y) + this.m_LowImageSize.Height);
             Point point6 = new Point((this.AbsoluteLocation.X + this.m_LowImageLocation.X) + this.m_LowImageSize.Width, (this.AbsoluteLocation.Y + this.m_LowImageLocation.Y) + this.m_LowImageSize.Height);
             if (this.m_LowImageSprite == null)
             {
                 this.m_LowImageSprite = new Sprite(drawArgs.device);
             }
             this.m_LowImageSprite.Begin(SpriteFlags.AlphaBlend);
             float num3 = ((float)(point5.X - point4.X)) / ((float)this.m_LowImagesurfaceDescription.Width);
             float num4 = ((float)(point6.Y - point5.Y)) / ((float)this.m_LowImagesurfaceDescription.Height);
             this.m_LowImageSprite.Transform  = Microsoft.DirectX.Matrix.Scaling(num3, num4, 0f);
             this.m_LowImageSprite.Transform *= Microsoft.DirectX.Matrix.Translation(0.5f * (point4.X + point5.X), 0.5f * (point5.Y + point6.Y), 0f);
             this.m_LowImageSprite.Draw(this.m_LowImageTexture, new Microsoft.DirectX.Vector3((float)(this.m_LowImagesurfaceDescription.Width / 2), (float)(this.m_LowImagesurfaceDescription.Height / 2), 0f), Microsoft.DirectX.Vector3.Empty, Color.FromArgb(this.m_Opacity, 0xff, 0xff, 0xff).ToArgb());
             this.m_LowImageSprite.Transform = Microsoft.DirectX.Matrix.Identity;
             this.m_LowImageSprite.End();
         }
         if ((this.m_HighImageTexture != null) && !this.isLoading)
         {
             drawArgs.device.SetTexture(0, this.m_HighImageTexture);
             drawArgs.device.RenderState.ZBufferEnable = false;
             Point point7 = new Point(this.AbsoluteLocation.X + this.m_HighImageLocation.X, this.AbsoluteLocation.Y + this.m_HighImageLocation.Y);
             Point point8 = new Point((this.AbsoluteLocation.X + this.m_HighImageLocation.X) + this.m_HighImageSize.Width, this.AbsoluteLocation.Y + this.m_HighImageLocation.Y);
             new Point(this.AbsoluteLocation.X + this.m_HighImageLocation.X, (this.AbsoluteLocation.Y + this.m_HighImageLocation.Y) + this.m_HighImageSize.Height);
             Point point9 = new Point((this.AbsoluteLocation.X + this.m_HighImageLocation.X) + this.m_HighImageSize.Width, (this.AbsoluteLocation.Y + this.m_HighImageLocation.Y) + this.m_HighImageSize.Height);
             if (this.m_HighImageSprite == null)
             {
                 this.m_HighImageSprite = new Sprite(drawArgs.device);
             }
             this.m_HighImageSprite.Begin(SpriteFlags.AlphaBlend);
             float num5 = ((float)(point8.X - point7.X)) / ((float)this.m_HighImagesurfaceDescription.Width);
             float num6 = ((float)(point9.Y - point8.Y)) / ((float)this.m_HighImagesurfaceDescription.Height);
             this.m_HighImageSprite.Transform  = Microsoft.DirectX.Matrix.Scaling(num5, num6, 0f);
             this.m_HighImageSprite.Transform *= Microsoft.DirectX.Matrix.Translation(0.5f * (point7.X + point8.X), 0.5f * (point8.Y + point9.Y), 0f);
             this.m_HighImageSprite.Draw(this.m_HighImageTexture, new Microsoft.DirectX.Vector3((float)(this.m_HighImagesurfaceDescription.Width / 2), (float)(this.m_HighImagesurfaceDescription.Height / 2), 0f), Microsoft.DirectX.Vector3.Empty, Color.FromArgb(this.m_Opacity, 0xff, 0xff, 0xff).ToArgb());
             this.m_HighImageSprite.Transform = Microsoft.DirectX.Matrix.Identity;
             this.m_HighImageSprite.End();
         }
     }
 }
예제 #31
0
        /// <summary>
        /// Render the grid lines
        /// </summary>
        public override void Render(DrawArgs drawArgs)
        {
            if (!World.Settings.showLatLonLines)
            {
                return;
            }

            ComputeGridValues(drawArgs);

            float offsetDegrees = (float)drawArgs.WorldCamera.TrueViewRange.Degrees / 6;

            drawArgs.device.RenderState.ZBufferEnable = useZBuffer;

            drawArgs.device.TextureState[0].ColorOperation = TextureOperation.Disable;
            drawArgs.device.VertexFormat    = CustomVertex.PositionColored.Format;
            drawArgs.device.Transform.World = Matrix.Translation(
                (float)-drawArgs.WorldCamera.ReferenceCenter.X,
                (float)-drawArgs.WorldCamera.ReferenceCenter.Y,
                (float)-drawArgs.WorldCamera.ReferenceCenter.Z
                );

            Vector3 referenceCenter = new Vector3(
                (float)drawArgs.WorldCamera.ReferenceCenter.X,
                (float)drawArgs.WorldCamera.ReferenceCenter.Y,
                (float)drawArgs.WorldCamera.ReferenceCenter.Z);

            // Turn off light
            if (World.Settings.EnableSunShading)
            {
                drawArgs.device.RenderState.Lighting = false;
            }

            // Draw longitudes
            for (float longitude = MinVisibleLongitude; longitude < MaxVisibleLongitude; longitude += LongitudeInterval)
            {
                // Draw longitude lines
                int vertexIndex = 0;
                for (float latitude = MinVisibleLatitude; latitude <= MaxVisibleLatitude; latitude += LatitudeInterval)
                {
                    Vector3 pointXyz = MathEngine.SphericalToCartesian(latitude, longitude, radius);
                    lineVertices[vertexIndex].X     = pointXyz.X;
                    lineVertices[vertexIndex].Y     = pointXyz.Y;
                    lineVertices[vertexIndex].Z     = pointXyz.Z;
                    lineVertices[vertexIndex].Color = World.Settings.latLonLinesColor;
                    vertexIndex++;
                }
                drawArgs.device.DrawUserPrimitives(PrimitiveType.LineStrip, LatitudePointCount - 1, lineVertices);

                // Draw longitude label
                float lat = (float)(drawArgs.WorldCamera.Latitude).Degrees;
                if (lat > 70)
                {
                    lat = 70;
                }
                Vector3 v = MathEngine.SphericalToCartesian(lat, (float)longitude, radius);
                if (drawArgs.WorldCamera.ViewFrustum.ContainsPoint(v))
                {
                    // Make sure longitude is in -180 .. 180 range
                    int longitudeRanged = (int)longitude;
                    if (longitudeRanged <= -180)
                    {
                        longitudeRanged += 360;
                    }
                    else if (longitudeRanged > 180)
                    {
                        longitudeRanged -= 360;
                    }

                    string s = Math.Abs(longitudeRanged).ToString();
                    if (longitudeRanged < 0)
                    {
                        s += "W";
                    }
                    else if (longitudeRanged > 0 && longitudeRanged < 180)
                    {
                        s += "E";
                    }

                    v = drawArgs.WorldCamera.Project(v - referenceCenter);
                    System.Drawing.Rectangle rect = new System.Drawing.Rectangle((int)v.X + 2, (int)v.Y, 10, 10);
                    drawArgs.defaultDrawingFont.DrawText(null, s, rect.Left, rect.Top, World.Settings.latLonLinesColor);
                }
            }

            // Draw latitudes
            for (float latitude = MinVisibleLatitude; latitude <= MaxVisibleLatitude; latitude += LatitudeInterval)
            {
                // Draw latitude label
                float longitude = (float)(drawArgs.WorldCamera.Longitude).Degrees + offsetDegrees;

                Vector3 v = MathEngine.SphericalToCartesian(latitude, longitude, radius);
                if (drawArgs.WorldCamera.ViewFrustum.ContainsPoint(v))
                {
                    v = drawArgs.WorldCamera.Project(v - referenceCenter);
                    float latLabel = latitude;
                    if (latLabel > 90)
                    {
                        latLabel = 180 - latLabel;
                    }
                    else if (latLabel < -90)
                    {
                        latLabel = -180 - latLabel;
                    }
                    string s = ((int)Math.Abs(latLabel)).ToString();
                    if (latLabel > 0)
                    {
                        s += "N";
                    }
                    else if (latLabel < 0)
                    {
                        s += "S";
                    }
                    System.Drawing.Rectangle rect = new System.Drawing.Rectangle((int)v.X, (int)v.Y, 10, 10);
                    drawArgs.defaultDrawingFont.DrawText(null, s, rect.Left, rect.Top, World.Settings.latLonLinesColor);
                }

                // Draw latitude line
                int vertexIndex = 0;
                for (longitude = MinVisibleLongitude; longitude <= MaxVisibleLongitude; longitude += LongitudeInterval)
                {
                    Vector3 pointXyz = MathEngine.SphericalToCartesian(latitude, longitude, radius);
                    lineVertices[vertexIndex].X = pointXyz.X;
                    lineVertices[vertexIndex].Y = pointXyz.Y;
                    lineVertices[vertexIndex].Z = pointXyz.Z;

                    if (latitude == 0)
                    {
                        lineVertices[vertexIndex].Color = World.Settings.equatorLineColor;
                    }
                    else
                    {
                        lineVertices[vertexIndex].Color = World.Settings.latLonLinesColor;
                    }

                    vertexIndex++;
                }
                drawArgs.device.DrawUserPrimitives(PrimitiveType.LineStrip, LongitudePointCount - 1, lineVertices);
            }

            if (World.Settings.showTropicLines && IsEarth)
            {
                RenderTropicLines(drawArgs);
            }

            // Restore state
            drawArgs.device.Transform.World = drawArgs.WorldCamera.WorldMatrix;
            if (!useZBuffer)
            {
                // Reset Z buffer setting
                drawArgs.device.RenderState.ZBufferEnable = true;
            }
            if (World.Settings.EnableSunShading)
            {
                drawArgs.device.RenderState.Lighting = true;
            }
        }
예제 #32
0
        public virtual void ComputeChildren(DrawArgs drawArgs)
        {
            float tileSize = (float) (0.5*(m_GeoBB.North - m_GeoBB.South));
            //TODO: Stop children computation at some lower level
            if (tileSize > 0.0001) {
                double CenterLat = 0.5f*(m_GeoBB.North + m_GeoBB.South);
                double CenterLon = 0.5f*(m_GeoBB.East + m_GeoBB.West);

                if (m_NorthWestChild == null && m_NwImageLayer != null && m_Initialized) {
                    m_NorthWestChild = ComputeChild(drawArgs, CenterLat, m_GeoBB.North, m_GeoBB.West, CenterLon, tileSize);
                    m_NorthWestChild.Level = Level++;
                    m_NorthWestChild.Row = 2*Row + 1;
                    m_NorthWestChild.Col = 2*Col;

                    m_NorthWestChild.Initialize(drawArgs);
                }

                if (m_NorthEastChild == null && m_NeImageLayer != null && m_Initialized) {
                    m_NorthEastChild = ComputeChild(drawArgs, CenterLat, m_GeoBB.North, CenterLon, m_GeoBB.East, tileSize);
                    m_NorthEastChild.Level = Level++;
                    m_NorthEastChild.Row = 2*Row + 1;
                    m_NorthEastChild.Col = 2*Col + 1;

                    m_NorthEastChild.Initialize(drawArgs);
                }

                if (m_SouthWestChild == null && m_SwImageLayer != null && m_Initialized) {
                    m_SouthWestChild = ComputeChild(drawArgs, m_GeoBB.South, CenterLat, m_GeoBB.West, CenterLon, tileSize);
                    m_SouthWestChild.Level = Level++;
                    m_SouthWestChild.Row = 2*Row;
                    m_SouthWestChild.Col = 2*Col;

                    m_SouthWestChild.Initialize(drawArgs);
                }

                if (m_SouthEastChild == null && m_SeImageLayer != null && m_Initialized) {
                    m_SouthEastChild = ComputeChild(drawArgs, m_GeoBB.South, CenterLat, CenterLon, m_GeoBB.East, tileSize);
                    m_SouthEastChild.Level = Level++;
                    m_SouthEastChild.Row = 2*Row;
                    m_SouthEastChild.Col = 2*Col + 1;

                    m_SouthEastChild.Initialize(drawArgs);
                }
            }
        }
예제 #33
0
        /// <summary>
        /// Specialized render for tree nodes
        /// </summary>
        /// <param name="drawArgs"></param>
        /// <param name="xOffset">The offset from the left based on how deep this node is nested</param>
        /// <param name="yOffset">The offset from the top based on how many treenodes are above this one</param>
        /// <returns>Total pixels consumed by this widget and its children</returns>
        public override int Render(DrawArgs drawArgs, int xOffset, int yOffset)
        {
            m_ConsumedSize.Height = 0;

            if (m_visible)
            {
                if (!m_isInitialized)
                {
                    this.Initialize(drawArgs);
                }

                m_ConsumedSize.Height = NODE_HEIGHT;

                // This value is dynamic based on the number of expanded nodes above this one
                m_location.Y = yOffset;

                // store this value so the mouse events can figure out where the buttons are
                m_xOffset = xOffset;

                // compute the color
                int color = this.Enabled ? m_itemOnColor : m_itemOffColor;

                // create the bounds of the text draw area
                Rectangle bounds = new Rectangle(this.AbsoluteLocation, new System.Drawing.Size(this.ClientSize.Width, NODE_HEIGHT));

                if (m_isMouseOver)
                {
                    if (!Enabled)
                    {
                        color = m_mouseOverOffColor;
                    }

                    WidgetUtilities.DrawBox(
                        bounds.X,
                        bounds.Y,
                        bounds.Width,
                        bounds.Height,
                        0.0f,
                        m_mouseOverColor,
                        drawArgs.device);
                }

                #region Draw arrow

                bounds.X     = this.AbsoluteLocation.X + xOffset;
                bounds.Width = NODE_ARROW_SIZE;
                // draw arrow if any children
                if (m_subNodes.Count > 0)
                {
                    m_worldwinddingsFont.DrawText(
                        null,
                        (this.m_isExpanded ? "L" : "A"),
                        bounds,
                        DrawTextFormat.None,
                        color);
                }
                #endregion Draw arrow

                #region Draw checkbox

                bounds.Width = NODE_CHECKBOX_SIZE;
                bounds.X    += NODE_ARROW_SIZE;

                // Normal check symbol
                string checkSymbol;

                if (m_isRadioButton)
                {
                    checkSymbol = this.IsChecked ? "O" : "P";
                }
                else
                {
                    checkSymbol = this.IsChecked ? "N" : "F";
                }

                m_worldwinddingsFont.DrawText(
                    null,
                    checkSymbol,
                    bounds,
                    DrawTextFormat.NoClip,
                    color);

                #endregion draw checkbox

                #region Draw name

                // compute the length based on name length
                // TODO: Do this only when the name changes
                Rectangle stringBounds = drawArgs.defaultDrawingFont.MeasureString(null, Name, DrawTextFormat.NoClip, 0);
                m_size.Width         = NODE_ARROW_SIZE + NODE_CHECKBOX_SIZE + 5 + stringBounds.Width;
                m_ConsumedSize.Width = m_size.Width;

                bounds.Y    += 2;
                bounds.X    += NODE_CHECKBOX_SIZE + 5;
                bounds.Width = stringBounds.Width;

                drawArgs.defaultDrawingFont.DrawText(
                    null,
                    Name,
                    bounds,
                    DrawTextFormat.None,
                    color);

                #endregion Draw name

                if (m_isExpanded)
                {
                    int newXOffset = xOffset + NODE_INDENT;

                    for (int i = 0; i < m_subNodes.Count; i++)
                    {
                        if (m_subNodes[i] is TreeNodeWidget)
                        {
                            m_ConsumedSize.Height += ((TreeNodeWidget)m_subNodes[i]).Render(drawArgs, newXOffset, m_ConsumedSize.Height);
                        }
                        else
                        {
                            System.Drawing.Point newLocation = m_subNodes[i].Location;
                            newLocation.Y          = m_ConsumedSize.Height;
                            newLocation.X          = newXOffset;
                            m_ConsumedSize.Height += m_subNodes[i].WidgetSize.Height;
                            m_subNodes[i].Location = newLocation;
                            m_subNodes[i].Render(drawArgs);
                            // render normal widgets as a stack of widgets
                        }

                        // if the child width is bigger than my width save it as the consumed width for widget size calculations
                        if (m_subNodes[i].WidgetSize.Width + newXOffset > m_ConsumedSize.Width)
                        {
                            m_ConsumedSize.Width = m_subNodes[i].WidgetSize.Width + newXOffset;
                        }
                    }
                }
            }
            return(m_ConsumedSize.Height);
        }
예제 #34
0
        public void Render(DrawArgs drawArgs)
        {
            if (m_Initialized) {
                if (m_NorthWestChild != null
                    && m_NorthWestChild.m_Initialized) {
                    m_NorthWestChild.Render(drawArgs);
                }
                else if (m_NwImageLayer != null
                         && m_NwImageLayer.Initialized) {
                    m_NwImageLayer.Render(drawArgs);
                }

                if (m_NorthEastChild != null
                    && m_NorthEastChild.m_Initialized) {
                    m_NorthEastChild.Render(drawArgs);
                }
                else if (m_NeImageLayer != null
                         && m_NeImageLayer.Initialized) {
                    m_NeImageLayer.Render(drawArgs);
                }

                if (m_SouthWestChild != null
                    && m_SouthWestChild.m_Initialized) {
                    m_SouthWestChild.Render(drawArgs);
                }
                else if (m_SwImageLayer != null
                         && m_SwImageLayer.Initialized) {
                    m_SwImageLayer.Render(drawArgs);
                }

                if (m_SouthEastChild != null
                    && m_SouthEastChild.m_Initialized) {
                    m_SouthEastChild.Render(drawArgs);
                }
                else if (m_SeImageLayer != null
                         && m_SeImageLayer.Initialized) {
                    m_SeImageLayer.Render(drawArgs);
                }
            }
        }
예제 #35
0
        /// <summary>
        /// The render method to draw this widget on the screen.
        ///
        /// Called on the GUI thread.
        /// </summary>
        /// <param name="drawArgs">The drawing arguments passed from the WW GUI thread.</param>
        public void Render(DrawArgs drawArgs)
        {
            if ((!m_visible) || (!m_enabled))
            {
                return;
            }

            if (!m_isInitialized)
            {
                Initialize(drawArgs);
            }

            int widgetTop    = this.Top;
            int widgetBottom = this.Bottom;
            int widgetLeft   = this.Left;
            int widgetRight  = this.Right;

            m_currHeaderHeight = 0;

            #region Header Rendering

            // If we should render the header
            if (HeaderEnabled)
            {
                m_currHeaderHeight = m_headerHeight;

                JHU_Utilities.DrawBox(
                    this.AbsoluteLocation.X,
                    this.AbsoluteLocation.Y,
                    m_size.Width,
                    m_currHeaderHeight,
                    0.0f,
                    m_HeaderColor.ToArgb(),
                    drawArgs.device);

                Rectangle nameBounds = m_TitleFont.MeasureString(
                    null,
                    m_name,
                    DrawTextFormat.None,
                    0);

                int widthLeft = m_size.Width;

                m_TitleFont.DrawText(
                    null,
                    m_name,
                    new System.Drawing.Rectangle(this.AbsoluteLocation.X + 2, this.AbsoluteLocation.Y + 2, widthLeft, m_currHeaderHeight),
                    DrawTextFormat.None,
                    m_TextColor.ToArgb());


                // if we don't render the body add whatever is in the text field as annotation
                if (!m_renderBody)
                {
                    widthLeft -= nameBounds.Width + 10;
                    if (widthLeft > 20)
                    {
                        m_TextFont.DrawText(
                            null,
                            Text,
                            new System.Drawing.Rectangle(this.AbsoluteLocation.X + 10 + nameBounds.Width, this.AbsoluteLocation.Y + 3, widthLeft, m_currHeaderHeight),
                            DrawTextFormat.None,
                            m_TextColor.ToArgb());
                    }
                }

                // Render border
                m_OutlineVertsHeader[0].X = AbsoluteLocation.X;
                m_OutlineVertsHeader[0].Y = AbsoluteLocation.Y;

                m_OutlineVertsHeader[1].X = AbsoluteLocation.X + m_size.Width;
                m_OutlineVertsHeader[1].Y = AbsoluteLocation.Y;

                m_OutlineVertsHeader[2].X = AbsoluteLocation.X + m_size.Width;
                m_OutlineVertsHeader[2].Y = AbsoluteLocation.Y + m_currHeaderHeight;

                m_OutlineVertsHeader[3].X = AbsoluteLocation.X;
                m_OutlineVertsHeader[3].Y = AbsoluteLocation.Y + m_currHeaderHeight;

                m_OutlineVertsHeader[4].X = AbsoluteLocation.X;
                m_OutlineVertsHeader[4].Y = AbsoluteLocation.Y;

                JHU_Utilities.DrawLine(m_OutlineVertsHeader, m_BorderColor.ToArgb(), drawArgs.device);
            }

            #endregion

            #region Body Rendering

            if (m_renderBody)
            {
                // Draw the interior background
                JHU_Utilities.DrawBox(
                    this.AbsoluteLocation.X,
                    this.AbsoluteLocation.Y + m_currHeaderHeight,
                    m_size.Width,
                    m_size.Height - m_currHeaderHeight,
                    0.0f,
                    m_BackgroundColor.ToArgb(),
                    drawArgs.device);

                int childrenHeight = 0;
                int childrenWidth  = 0;

                int bodyHeight = m_size.Height - m_currHeaderHeight;
                int bodyWidth  = m_size.Width;

                getChildrenSize(out childrenHeight, out childrenWidth);

                // Render each child widget

                int bodyLeft    = this.BodyLocation.X;
                int bodyRight   = this.BodyLocation.X + this.ClientSize.Width;
                int bodyTop     = this.BodyLocation.Y;
                int bodyBottom  = this.BodyLocation.Y + this.ClientSize.Height;
                int childLeft   = 0;
                int childRight  = 0;
                int childTop    = 0;
                int childBottom = 0;

                for (int index = m_ChildWidgets.Count - 1; index >= 0; index--)
                {
                    jhuapl.util.IWidget currentChildWidget = m_ChildWidgets[index] as jhuapl.util.IWidget;
                    if (currentChildWidget != null)
                    {
                        if (currentChildWidget.ParentWidget == null || currentChildWidget.ParentWidget != this)
                        {
                            currentChildWidget.ParentWidget = this;
                        }
                        System.Drawing.Point childLocation = currentChildWidget.AbsoluteLocation;

                        // if any portion is visible try to render
                        childLeft   = childLocation.X;
                        childRight  = childLocation.X + currentChildWidget.WidgetSize.Width;
                        childTop    = childLocation.Y;
                        childBottom = childLocation.Y + currentChildWidget.WidgetSize.Height;

                        if ((((childLeft >= bodyLeft) && (childLeft <= bodyRight)) ||
                             ((childRight >= bodyLeft) && (childRight <= bodyRight)) ||
                             ((childLeft <= bodyLeft) && (childRight >= bodyRight)))
                            &&
                            (((childTop >= bodyTop) && (childTop <= bodyBottom)) ||
                             ((childBottom >= bodyTop) && (childBottom <= bodyBottom)) ||
                             ((childTop <= bodyTop) && (childBottom >= bodyBottom)))
                            )
                        {
                            currentChildWidget.Visible = true;
                            currentChildWidget.Render(drawArgs);
                        }
                        else
                        {
                            currentChildWidget.Visible = false;
                        }
                    }
                }

                m_OutlineVerts[0].X = AbsoluteLocation.X;
                m_OutlineVerts[0].Y = AbsoluteLocation.Y + m_currHeaderHeight;

                m_OutlineVerts[1].X = AbsoluteLocation.X + m_size.Width;
                m_OutlineVerts[1].Y = AbsoluteLocation.Y + m_currHeaderHeight;

                m_OutlineVerts[2].X = AbsoluteLocation.X + m_size.Width;
                m_OutlineVerts[2].Y = AbsoluteLocation.Y + m_size.Height;

                m_OutlineVerts[3].X = AbsoluteLocation.X;
                m_OutlineVerts[3].Y = AbsoluteLocation.Y + m_size.Height;

                m_OutlineVerts[4].X = AbsoluteLocation.X;
                m_OutlineVerts[4].Y = AbsoluteLocation.Y + m_currHeaderHeight;

                JHU_Utilities.DrawLine(m_OutlineVerts, m_BorderColor.ToArgb(), drawArgs.device);
            }

            #endregion
        }
예제 #36
0
        private ShapeTile ComputeChild(DrawArgs drawArgs, double childSouth, double childNorth, double childWest, double childEast, double tileSize)
        {
            ShapeTile child = new ShapeTile(new GeographicBoundingBox(childNorth, childSouth, childWest, childEast), m_ShapeTileArgs);

            return child;
        }
예제 #37
0
 protected override void DrawCore(DrawArgs args)
 {
     throw new NotImplementedException();
 }
예제 #38
0
        public override void Initialize(DrawArgs drawArgs)
        {
            try {
                m_Sprite = new Sprite(drawArgs.Device);
                if (m_IconFilePath != null
                    && File.Exists(m_IconFilePath)) {
                    m_IconTexture = ImageHelper.LoadIconTexture(m_IconFilePath);
                    m_IconTextureDescription = m_IconTexture.GetLevelDescription(0);
                }
                loadShapeFile(m_ShapeFilePath);

                if ((m_ShapeTileArgs.ShowLabels && m_ShapeTileArgs.DataKey != null)
                    || m_IconTexture != null) {
                    foreach (ShapeFileRecord record in m_ShapeTileArgs.ShapeRecords) {
                        if (record.Value != null) {
                            if (record.Point != null) {
                                Shapefile_Point p = new Shapefile_Point();
                                p.X = record.Point.X;
                                p.Y = record.Point.Y;
                                p.Tag = record.Value;
                                m_LabelList.Add(p);
                            }
                            else if (record.MultiPoint != null) {
                                Shapefile_Point p = new Shapefile_Point();
                                p.X = 0.5*(record.MultiPoint.BoundingBox.West + record.MultiPoint.BoundingBox.East);
                                p.Y = 0.5*(record.MultiPoint.BoundingBox.North + record.MultiPoint.BoundingBox.South);
                                p.Tag = record.Value;
                                m_LabelList.Add(p);
                            }
                            else if (record.PolyLine != null) {
                                Shapefile_Point p = new Shapefile_Point();
                                p.X = 0.5*(record.PolyLine.BoundingBox.West + record.PolyLine.BoundingBox.East);
                                p.Y = 0.5*(record.PolyLine.BoundingBox.North + record.PolyLine.BoundingBox.South);
                                p.Tag = record.Value;
                                m_LabelList.Add(p);
                            }
                            else if (record.Polygon != null) {
                                Shapefile_Point p = new Shapefile_Point();
                                p.X = 0.5*(record.Polygon.BoundingBox.West + record.Polygon.BoundingBox.East);
                                p.Y = 0.5*(record.Polygon.BoundingBox.North + record.Polygon.BoundingBox.South);
                                p.Tag = record.Value;
                                m_LabelList.Add(p);
                            }
                        }
                    }
                }
            }
            catch (Exception ex) {
                Log.Write(ex);
            }
            finally {
                Inited = true;
            }
        }
예제 #39
0
        public override void Update(DrawArgs drawArgs)
        {
            if (drawArgs.WorldCamera.AltitudeAboveTerrain >= m_MinimumViewingAltitude
                && drawArgs.WorldCamera.AltitudeAboveTerrain <= m_MaximumViewingAltitude) {
                if (!Inited) {
                    Initialize(drawArgs);
                }

                foreach (ShapeTile shapeTile in m_RootTiles) {
                    if (shapeTile != null
                        && (shapeTile.m_GeoBB.North - shapeTile.m_GeoBB.South) <= m_lztsd) {
                        shapeTile.Update(drawArgs);
                    }
                }
            }
            else {
                if (Inited) {
                    Dispose();
                }
            }
        }
예제 #40
0
 public override void Initialize(DrawArgs drawArgs)
 {
     this.Inited = true;
 }
예제 #41
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (!Directory.Exists("extra/images/"))
            {
                Directory.CreateDirectory("extra/images/");
            }
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] parts = message.SplitSpaces(5);

            DrawArgs dArgs = new DrawArgs();

            dArgs.Pal = ImagePalette.Find("color");
            if (dArgs.Pal == null)
            {
                dArgs.Pal = ImagePalette.Palettes[0];
            }

            if (parts.Length > 1)
            {
                dArgs.Pal = ImagePalette.Find(parts[1]);
                if (dArgs.Pal == null)
                {
                    p.Message("Palette {0} not found.", parts[1]); return;
                }

                if (dArgs.Pal.Entries == null || dArgs.Pal.Entries.Length == 0)
                {
                    p.Message("Palette {0} does not have any entries", dArgs.Pal.Name);
                    p.Message("Use %T/Palette %Sto add entries to it"); return;
                }
            }

            if (parts.Length > 2)
            {
                string mode = parts[2];
                if (mode.CaselessEq("horizontal"))
                {
                    dArgs.Layer = true;
                }
                if (mode.CaselessEq("vertical2layer"))
                {
                    dArgs.Dual = true;
                }
            }

            if (parts.Length > 4)
            {
                if (!CommandParser.GetInt(p, parts[3], "Width", ref dArgs.Width, 1, 1024))
                {
                    return;
                }
                if (!CommandParser.GetInt(p, parts[4], "Height", ref dArgs.Height, 1, 1024))
                {
                    return;
                }
            }

            if (parts[0].IndexOf('.') != -1)
            {
                dArgs.Data = HttpUtil.DownloadImage(parts[0], p);
                if (dArgs.Data == null)
                {
                    return;
                }
            }
            else
            {
                string path = "extra/images/" + parts[0] + ".bmp";
                if (!File.Exists(path))
                {
                    p.Message("{0} does not exist", path); return;
                }
                dArgs.Data = File.ReadAllBytes(path);
            }

            p.Message("Place or break two blocks to determine direction.");
            p.MakeSelection(2, "Selecting direction for %SImagePrint", dArgs, DoImage);
        }
예제 #42
0
 protected virtual void GetBrush(DrawArgs dArgs)
 {
     dArgs.BrushArgs = dArgs.Message.Splice(dArgs.ModeArgsCount, 0);
 }
예제 #43
0
        public void Initialize(DrawArgs drawArgs)
        {
            try {
                m_Initializing = true;

                double centerLatitude = 0.5*(m_GeoBB.North + m_GeoBB.South);
                double centerLongitude = 0.5*(m_GeoBB.West + m_GeoBB.East);

                m_NwImageLayer = CreateImageLayer(m_GeoBB.North, centerLatitude, m_GeoBB.West, centerLongitude, drawArgs, String.Format("{0}\\{1}\\{2}\\{3:D4}\\{3:D4}_{4:D4}.dds", CachePath, ConfigurationLoader.GetRenderablePathString(m_ShapeTileArgs.ParentShapeFileLayer), Level + 1, 2*Row + 1, 2*Col));

                m_NeImageLayer = CreateImageLayer(m_GeoBB.North, centerLatitude, centerLongitude, m_GeoBB.East, drawArgs, String.Format("{0}\\{1}\\{2}\\{3:D4}\\{3:D4}_{4:D4}.dds", CachePath, ConfigurationLoader.GetRenderablePathString(m_ShapeTileArgs.ParentShapeFileLayer), Level + 1, 2*Row + 1, 2*Col + 1));

                m_SwImageLayer = CreateImageLayer(centerLatitude, m_GeoBB.South, m_GeoBB.West, centerLongitude, drawArgs, String.Format("{0}\\{1}\\{2}\\{3:D4}\\{3:D4}_{4:D4}.dds", CachePath, ConfigurationLoader.GetRenderablePathString(m_ShapeTileArgs.ParentShapeFileLayer), Level + 1, 2*Row, 2*Col));

                m_SeImageLayer = CreateImageLayer(centerLatitude, m_GeoBB.South, centerLongitude, m_GeoBB.East, drawArgs, String.Format("{0}\\{1}\\{2}\\{3:D4}\\{3:D4}_{4:D4}.dds", CachePath, ConfigurationLoader.GetRenderablePathString(m_ShapeTileArgs.ParentShapeFileLayer), Level + 1, 2*Row, 2*Col + 1));

                if (m_NwImageLayer != null) {
                    m_NwImageLayer.Initialize(drawArgs);
                }
                if (m_NeImageLayer != null) {
                    m_NeImageLayer.Initialize(drawArgs);
                }
                if (m_SwImageLayer != null) {
                    m_SwImageLayer.Initialize(drawArgs);
                }
                if (m_SeImageLayer != null) {
                    m_SeImageLayer.Initialize(drawArgs);
                }
            }
            catch (Exception ex) {
                Log.Write(ex);
            }
            finally {
                m_Initializing = false;
                if (m_Disposing) {
                    Dispose();
                    m_Initialized = false;
                }
                else {
                    m_Initialized = true;
                }
            }
        }
예제 #44
0
 /// <summary>
 /// Specialized render for tree nodes
 /// </summary>
 /// <param name="drawArgs"></param>
 /// <param name="xOffset">The offset from the left based on how deep this node is nested</param>
 /// <param name="yOffset">The offset from the top based on how many treenodes are above this one</param>
 /// <returns>Total pixels consumed by this widget and its children</returns>
 public abstract int Render(DrawArgs drawArgs, int xOffset, int yOffset);
예제 #45
0
        public void Update(DrawArgs drawArgs)
        {
            try {
                double centerLatitude = 0.5*(m_GeoBB.North + m_GeoBB.South);
                double centerLongitude = 0.5*(m_GeoBB.West + m_GeoBB.East);
                double tileSize = m_GeoBB.North - m_GeoBB.South;

                if (!m_Initialized) {
                    if (drawArgs.WorldCamera.ViewRange*0.5f < Angle.FromDegrees(ShapeTileArgs.TileDrawDistance*tileSize) && MathEngine.SphericalDistance(Angle.FromDegrees(centerLatitude), Angle.FromDegrees(centerLongitude), drawArgs.WorldCamera.Latitude, drawArgs.WorldCamera.Longitude) < Angle.FromDegrees(ShapeTileArgs.TileSpreadFactor*tileSize*1.25f)
                        && drawArgs.WorldCamera.ViewFrustum.Intersects(BoundingBox)) {
                        Initialize(drawArgs);
                    }
                }

                if (m_Initialized) {
                    if (m_NwImageLayer != null) {
                        m_NwImageLayer.Update(drawArgs);
                    }
                    if (m_NeImageLayer != null) {
                        m_NeImageLayer.Update(drawArgs);
                    }
                    if (m_SwImageLayer != null) {
                        m_SwImageLayer.Update(drawArgs);
                    }
                    if (m_SeImageLayer != null) {
                        m_SeImageLayer.Update(drawArgs);
                    }

                    if (drawArgs.WorldCamera.ViewRange < Angle.FromDegrees(ShapeTileArgs.TileDrawDistance*tileSize) && MathEngine.SphericalDistance(Angle.FromDegrees(centerLatitude), Angle.FromDegrees(centerLongitude), drawArgs.WorldCamera.Latitude, drawArgs.WorldCamera.Longitude) < Angle.FromDegrees(ShapeTileArgs.TileSpreadFactor*tileSize)
                        && drawArgs.WorldCamera.ViewFrustum.Intersects(BoundingBox)) {
                        if (m_NorthEastChild == null && m_NorthWestChild == null && m_SouthEastChild == null
                            && m_SouthWestChild == null) {
                            ComputeChildren(drawArgs);
                        }
                        else {
                            if (m_NorthEastChild != null) {
                                m_NorthEastChild.Update(drawArgs);
                            }

                            if (m_NorthWestChild != null) {
                                m_NorthWestChild.Update(drawArgs);
                            }

                            if (m_SouthEastChild != null) {
                                m_SouthEastChild.Update(drawArgs);
                            }

                            if (m_SouthWestChild != null) {
                                m_SouthWestChild.Update(drawArgs);
                            }
                        }
                    }
                    else {
                        if (m_NorthWestChild != null) {
                            m_NorthWestChild.Dispose();
                            m_NorthWestChild = null;
                        }

                        if (m_NorthEastChild != null) {
                            m_NorthEastChild.Dispose();
                            m_NorthEastChild = null;
                        }

                        if (m_SouthEastChild != null) {
                            m_SouthEastChild.Dispose();
                            m_SouthEastChild = null;
                        }

                        if (m_SouthWestChild != null) {
                            m_SouthWestChild.Dispose();
                            m_SouthWestChild = null;
                        }
                    }
                }

                if (m_Initialized) {
                    if (drawArgs.WorldCamera.ViewRange > Angle.FromDegrees(ShapeTileArgs.TileDrawDistance*tileSize*1.5f)
                        || MathEngine.SphericalDistance(Angle.FromDegrees(centerLatitude), Angle.FromDegrees(centerLongitude), drawArgs.WorldCamera.Latitude, drawArgs.WorldCamera.Longitude) > Angle.FromDegrees(ShapeTileArgs.TileSpreadFactor*tileSize*1.5f)) {
                        //if(this.level != 0)
                        //{
                        Dispose();
                        //}
                    }
                }
            }
            catch (Exception ex) {
                Log.Write(ex);
            }
        }
예제 #46
0
파일: PictureBox.cs 프로젝트: Fav/testww
 public void Initialize(DrawArgs drawArgs)
 {
 }
예제 #47
0
        private ImageLayer CreateImageLayer(double north, double south, double west, double east, DrawArgs drawArgs, string imagePath)
        {
            Bitmap b = null;
            Graphics g = null;
            ImageLayer imageLayer = null;
            GeographicBoundingBox geoBB = new GeographicBoundingBox(north, south, west, east);

            int numberPolygonsInTile = 0;

            FileInfo imageFile = new FileInfo(imagePath);
            FileInfo shapeFile = new FileInfo(m_ShapeTileArgs.ParentShapeFileLayer.ShapeFilePath);
            FileInfo shapeXmlFile = null;
            if (m_ShapeTileArgs.ParentShapeFileLayer.MetaData.Contains("SourceXml")) {
                string sourceXml = (string) m_ShapeTileArgs.ParentShapeFileLayer.MetaData["SourceXml"];
                if (!sourceXml.ToLower().StartsWith("http://")) {
                    shapeXmlFile = new FileInfo(sourceXml);
                }
            }

            if (!m_ShapeTileArgs.ParentShapeFileLayer.EnableCaching || !imageFile.Exists || shapeXmlFile == null || shapeXmlFile.LastWriteTimeUtc > imageFile.LastWriteTimeUtc
                || shapeFile.LastWriteTimeUtc > imageFile.LastWriteTimeUtc) {
                for (int i = 0; i < m_ShapeTileArgs.ShapeRecords.Count; i++) {
                    ShapeFileRecord currentRecord = (ShapeFileRecord) m_ShapeTileArgs.ShapeRecords[i];

                    if (currentRecord.Null != null || currentRecord.Point != null || currentRecord.MultiPoint != null
                        || !isShapeRecordInBounds(geoBB, currentRecord)) {
                        continue;
                    }
                    else {
                        if (b == null) {
                            b = new Bitmap(m_ShapeTileArgs.TilePixelSize.Width, m_ShapeTileArgs.TilePixelSize.Height, PixelFormat.Format32bppArgb);
                        }

                        if (g == null) {
                            g = Graphics.FromImage(b);
                        }

                        Color color = m_ShapeTileArgs.PolygonColor;

                        //Fix Black Tiles
                        g.DrawLine(new Pen(color), 0, 0, 1, 1);

                        if (m_ShapeTileArgs.UseScalar
                            && m_ShapeTileArgs.ScaleColors) {
                            double red = 1.0;
                            double green = 1.0;
                            double blue = 1.0;

                            try {
                                //TODO: make this a function and abstract to allow multiple gradient mappings
                                double dv;

                                double curScalar = double.Parse(currentRecord.Value.ToString());

                                if (curScalar < m_ShapeTileArgs.ScaleMin) {
                                    curScalar = m_ShapeTileArgs.ScaleMin;
                                }
                                if (curScalar > m_ShapeTileArgs.ScaleMax) {
                                    curScalar = m_ShapeTileArgs.ScaleMax;
                                }

                                dv = m_ShapeTileArgs.ScaleMax - m_ShapeTileArgs.ScaleMin;

                                if (curScalar < (m_ShapeTileArgs.ScaleMin + 0.25*dv)) {
                                    red = 0;
                                    green = 4*(curScalar - m_ShapeTileArgs.ScaleMin)/dv;
                                }
                                else if (curScalar < (m_ShapeTileArgs.ScaleMin + 0.5*dv)) {
                                    red = 0;
                                    blue = 1 + 4*(m_ShapeTileArgs.ScaleMin + 0.25*dv - curScalar)/dv;
                                }
                                else if (curScalar < (m_ShapeTileArgs.ScaleMin + 0.75*dv)) {
                                    red = 4*(curScalar - m_ShapeTileArgs.ScaleMin - 0.5*dv)/dv;
                                    blue = 0;
                                }
                                else {
                                    green = 1 + 4*(m_ShapeTileArgs.ScaleMin + 0.75*dv - curScalar)/dv;
                                    blue = 0;
                                }

                                color = Color.FromArgb((int) (255*red), (int) (255*green), (int) (255*blue));
                            }
                            catch (Exception) {
                                //	Utility.Log.Write((string)currentPoly.ScalarHash[m_ShapeTileArgs.ColorKey]);
                                //	Utility.Log.Write(String.Format("Min: {0}, Max: {1}", m_ShapeTileArgs.ScaleMin, m_ShapeTileArgs.ScaleMax));
                                //	Utility.Log.Write(String.Format("{0},{1},{2}", red, green, blue));
                                //	Utility.Log.Write(ex);
                            }
                        }
                        else {
                            if (m_ShapeTileArgs.ColorAssignments.Count > 0
                                && m_ShapeTileArgs.ScaleColors) {
                                try {
                                    string colorAssignmentKey = (string) currentRecord.Value;
                                    foreach (string cak in m_ShapeTileArgs.ColorAssignments.Keys) {
                                        if (String.Compare(cak, colorAssignmentKey, true) == 0) {
                                            color = (Color) m_ShapeTileArgs.ColorAssignments[cak];
                                            break;
                                        }
                                    }
                                }
                                catch (Exception) {}
                            }
                        }

                        if (currentRecord.Polygon != null) {
                            drawPolygon(currentRecord.Polygon, g, color, geoBB, b.Size);
                        }

                        if (m_ShapeTileArgs.ColorAssignments.Count == 0
                            || !m_ShapeTileArgs.ScaleColors) {
                            color = m_ShapeTileArgs.LineColor;
                        }

                        if (currentRecord.PolyLine != null) {
                            drawPolyLine(currentRecord.PolyLine, g, color, geoBB, b.Size);
                        }
                        numberPolygonsInTile++;
                    }
                }
            }

            if (!m_ShapeTileArgs.ParentShapeFileLayer.EnableCaching) {
                string id = DateTime.Now.Ticks.ToString();

                if (b != null) {
                    MemoryStream ms = new MemoryStream();

                    //must copy original stream into new stream, if not, error occurs, not sure why
                    m_ImageStream = new MemoryStream(ms.GetBuffer());

                    imageLayer = new ImageLayer(id, m_ShapeTileArgs.ParentWorld, 0, m_ImageStream, Color.Black.ToArgb(), (float) south, (float) north, (float) west, (float) east, (float) m_ShapeTileArgs.ParentShapeFileLayer.Opacity/255.0f, m_ShapeTileArgs.ParentWorld.TerrainAccessor);

                    ms.Close();
                }
            }
            else if (imageFile.Exists
                     || numberPolygonsInTile > 0) {
                string id = DateTime.Now.Ticks.ToString();

                if (b != null) {
                    MemoryStream ms = new MemoryStream();
                    b.Save(ms, ImageFormat.Bmp);
                    if (!imageFile.Directory.Exists) {
                        imageFile.Directory.Create();
                    }

                    //must copy original stream into new stream, if not, error occurs, not sure why
                    m_ImageStream = new MemoryStream(ms.GetBuffer());
                    ImageHelper.ConvertToDxt3(m_ImageStream, imageFile.FullName);

                    ms.Close();
                }

                imageLayer = new ImageLayer(id, m_ShapeTileArgs.ParentWorld, 0, // should be distance above surface
                                            imageFile.FullName, //m_ImageStream,
                                            //0,//System.Drawing.Color.Black.ToArgb(),
                                            (float) south, (float) north, (float) west, (float) east, (float) m_ShapeTileArgs.ParentShapeFileLayer.Opacity/255.0f, m_ShapeTileArgs.ParentWorld.TerrainAccessor);
            }

            if (b != null) {
                b.Dispose();
            }
            if (g != null) {
                g.Dispose();
            }

            b = null;
            g = null;

            //might not be necessary
            //GC.Collect();

            return imageLayer;
        }
예제 #48
0
파일: PictureBox.cs 프로젝트: Fav/testww
        public void Render(DrawArgs drawArgs)
        {
            if (m_Visible)
            {
                if (m_ImageTexture == null)
                {
                    if (!m_RefreshTimer.Enabled)
                    {
                        displayText = "Loading Image...";
                        if (m_RefreshTime > 0)
                        {
                            m_RefreshTimer.Elapsed += new System.Timers.ElapsedEventHandler(m_RefreshTimer_Elapsed);
                            m_RefreshTimer.Start();
                        }
                        else
                        {
                            m_RefreshTimer_Elapsed(null, null);
                        }
                    }
                }

                if (DrawArgs.LastMousePosition.X > AbsoluteLocation.X + clickBuffer &&
                    DrawArgs.LastMousePosition.X < AbsoluteLocation.X + ClientSize.Width - clickBuffer &&
                    DrawArgs.LastMousePosition.Y > AbsoluteLocation.Y + clickBuffer &&
                    DrawArgs.LastMousePosition.Y < AbsoluteLocation.Y + ClientSize.Height - clickBuffer)
                {
                    if (!m_isMouseInside)
                    {
                        m_isMouseInside = true;
                        if (OnMouseEnterEvent != null)
                        {
                            OnMouseEnterEvent(this, null);
                        }
                    }
                }
                else
                {
                    if (m_isMouseInside)
                    {
                        m_isMouseInside = false;
                        if (OnMouseLeaveEvent != null)
                        {
                            OnMouseLeaveEvent(this, null);
                        }
                    }
                }

                if (m_ImageTexture != null && m_currentImageUri != m_ImageUri)
                {
                    m_RefreshTimer_Elapsed(null, null);
                }

                if (displayText != null)
                {
                    drawArgs.defaultDrawingFont.DrawText(
                        null,
                        displayText,
                        new System.Drawing.Rectangle(AbsoluteLocation.X, AbsoluteLocation.Y, m_Size.Width, m_Size.Height),
                        DrawTextFormat.None,
                        m_ForeColor);
                }

                if (m_ImageTexture != null && !isLoading)
                {
                    drawArgs.device.SetTexture(0, m_ImageTexture);

                    drawArgs.device.RenderState.ZBufferEnable = false;

                    System.Drawing.Point ul = new System.Drawing.Point(AbsoluteLocation.X, AbsoluteLocation.Y);
                    System.Drawing.Point ur = new System.Drawing.Point(AbsoluteLocation.X + m_Size.Width, AbsoluteLocation.Y);
                    System.Drawing.Point ll = new System.Drawing.Point(AbsoluteLocation.X, AbsoluteLocation.Y + m_Size.Height);
                    System.Drawing.Point lr = new System.Drawing.Point(AbsoluteLocation.X + m_Size.Width, AbsoluteLocation.Y + m_Size.Height);

                    if (m_sprite == null)
                    {
                        m_sprite = new Sprite(drawArgs.device);
                    }

                    m_sprite.Begin(SpriteFlags.AlphaBlend);

                    float xscale = (float)(ur.X - ul.X) / (float)m_surfaceDescription.Width;
                    float yscale = (float)(lr.Y - ur.Y) / (float)m_surfaceDescription.Height;
                    m_sprite.Transform  = Matrix.Scaling(xscale, yscale, 0);
                    m_sprite.Transform *= Matrix.Translation(0.5f * (ul.X + ur.X), 0.5f * (ur.Y + lr.Y), 0);
                    m_sprite.Draw(m_ImageTexture,
                                  new Vector3(m_surfaceDescription.Width / 2, m_surfaceDescription.Height / 2, 0),
                                  Vector3.Empty,
                                  System.Drawing.Color.FromArgb(m_Opacity, 255, 255, 255).ToArgb()
                                  );

                    // Reset transform to prepare for text rendering later
                    m_sprite.Transform = Matrix.Identity;
                    m_sprite.End();
                }
            }
        }
예제 #49
0
        public override void Render(DrawArgs drawArgs)
        {
            if (!Inited || drawArgs.WorldCamera.AltitudeAboveTerrain < m_MinimumViewingAltitude
                || drawArgs.WorldCamera.AltitudeAboveTerrain > m_MaximumViewingAltitude) {
                return;
            }

            try {
                foreach (ShapeTile shapeTile in m_RootTiles) {
                    if (shapeTile != null
                        && (shapeTile.m_GeoBB.North - shapeTile.m_GeoBB.South) <= m_lztsd) {
                        shapeTile.Render(drawArgs);
                    }
                }

                Vector3 referenceCenter = new Vector3((float) drawArgs.WorldCamera.ReferenceCenter.X, (float) drawArgs.WorldCamera.ReferenceCenter.Y, (float) drawArgs.WorldCamera.ReferenceCenter.Z);

                if (m_PointList.Count > 0) {
                    drawArgs.Device.VertexFormat = CustomVertex.PositionColored.Format;

                    float curPointSize = drawArgs.Device.RenderState.PointSize;

                    drawArgs.Device.RenderState.PointSize = 5.0f;
                    drawArgs.Device.RenderState.ZBufferEnable = false;
                    CustomVertex.PositionColored[] verts = new CustomVertex.PositionColored[1];
                    Vector3 camPoint = MathEngine.SphericalToCartesian(drawArgs.WorldCamera.Latitude.Degrees, drawArgs.WorldCamera.Longitude.Degrees, m_ShapeTileArgs.LayerRadius);

                    drawArgs.Device.Transform.World = Matrix.Translation(-referenceCenter);

                    foreach (Vector3 v in m_PointList) {
                        if (Vector3.Subtract(v, camPoint).Length()
                            < m_ShapeTileArgs.LayerRadius) {
                            verts[0].Color = m_ShapeTileArgs.LabelColor.ToArgb();
                            verts[0].X = v.X;
                            verts[0].Y = v.Y;
                            verts[0].Z = v.Z;

                            drawArgs.Device.TextureState[0].ColorOperation = TextureOperation.Disable;
                            drawArgs.Device.DrawUserPrimitives(PrimitiveType.PointList, 1, verts);
                        }
                    }

                    drawArgs.Device.Transform.World = drawArgs.WorldCamera.WorldMatrix;

                    drawArgs.Device.RenderState.PointSize = curPointSize;
                    drawArgs.Device.RenderState.ZBufferEnable = true;
                }

                if (m_LabelList.Count > 0) {
                    Color iconColor = Color.FromArgb(m_IconOpacity, 255, 255, 255);
                    foreach (Shapefile_Point p in m_LabelList) {
                        Vector3 cartesianPoint = MathEngine.SphericalToCartesian(p.Y, p.X, drawArgs.WorldCamera.WorldRadius + drawArgs.WorldCamera.TerrainElevation);

                        if (!drawArgs.WorldCamera.ViewFrustum.ContainsPoint(cartesianPoint)
                            || MathEngine.SphericalDistanceDegrees(p.Y, p.X, drawArgs.WorldCamera.Latitude.Degrees, drawArgs.WorldCamera.Longitude.Degrees) > 90.0) {
                            continue;
                        }

                        Vector3 projectedPoint = drawArgs.WorldCamera.Project(cartesianPoint - referenceCenter);

                        /*if(isMouseOver)
                        {
                            // Mouse is over
                            isMouseOver = true;

                            if(icon.isSelectable)
                                DrawArgs.MouseCursor = CursorType.Hand;

                            string description = icon.Description;
                            if(description==null)
                                description = icon.ClickableActionURL;
                            if(description!=null)
                            {
                                // Render description field
                                DrawTextFormat format = DrawTextFormat.NoClip | DrawTextFormat.WordBreak | DrawTextFormat.Bottom;
                                int left = 10;
                                if(World.Settings.showLayerManager)
                                    left += World.Settings.layerManagerWidth;
                                Rectangle rect = Rectangle.FromLTRB(left, 10, drawArgs.ScreenWidth - 10, drawArgs.ScreenHeight - 10 );

                                // Draw outline
                                drawArgs.DefaultDrawingFont.DrawText(
                                    m_sprite, description,
                                    rect,
                                    format, 0xb0 << 24 );

                                rect.Offset(2,0);
                                drawArgs.DefaultDrawingFont.DrawText(
                                    m_sprite, description,
                                    rect,
                                    format, 0xb0 << 24 );

                                rect.Offset(0,2);
                                drawArgs.DefaultDrawingFont.DrawText(
                                    m_sprite, description,
                                    rect,
                                    format, 0xb0 << 24 );

                                rect.Offset(-2,0);
                                drawArgs.DefaultDrawingFont.DrawText(
                                    m_sprite, description,
                                    rect,
                                    format, 0xb0 << 24 );

                                // Draw description
                                rect.Offset(1,-1);
                                drawArgs.DefaultDrawingFont.DrawText(
                                    m_sprite, description,
                                    rect,
                                    format, descriptionColor );
                            }
                        }*/
                        m_Sprite.Begin(SpriteFlags.AlphaBlend);

                        if (m_IconTexture != null) {
                            float xscale = (float) m_IconWidth/m_IconTextureDescription.Width;
                            float yscale = (float) m_IconHeight/m_IconTextureDescription.Height;
                            m_Sprite.Transform = Matrix.Scaling(xscale, yscale, 0);
                            m_Sprite.Transform *= Matrix.Translation(projectedPoint.X, projectedPoint.Y, 0);
                            m_Sprite.Draw(m_IconTexture, new Vector3(m_IconWidth >> 1, m_IconHeight >> 1, 0), Vector3.Empty, iconColor.ToArgb());

                            // Reset transform to prepare for text rendering later
                            m_Sprite.Transform = Matrix.Identity;
                        }

                        if (m_ShapeTileArgs.ShowLabels
                            && m_ShapeTileArgs.DataKey != null) {
                            // Render label
                            if (p.Tag != null) {
                                // Render name field
                                const int labelWidth = 1000; // Dummy value needed for centering the text
                                if (m_IconTexture == null) {
                                    // Center over target as we have no bitmap
                                    Rectangle rect = new Rectangle((int) projectedPoint.X - (labelWidth >> 1), (int) (projectedPoint.Y - (drawArgs.DefaultDrawingFont.Description.Height >> 1)), labelWidth, drawArgs.ScreenHeight);

                                    drawArgs.DefaultDrawingFont.DrawText(m_Sprite, p.Tag.ToString(), rect, DrawTextFormat.Center, m_ShapeTileArgs.LabelColor);
                                }
                                else {
                                    // Adjust text to make room for icon
                                    int spacing = (int) (m_IconWidth*0.3f);
                                    if (spacing > 10) {
                                        spacing = 10;
                                    }
                                    int offsetForIcon = (m_IconWidth >> 1) + spacing;

                                    Rectangle rect = new Rectangle((int) projectedPoint.X + offsetForIcon, (int) (projectedPoint.Y - (drawArgs.DefaultDrawingFont.Description.Height >> 1)), labelWidth, drawArgs.ScreenHeight);

                                    drawArgs.DefaultDrawingFont.DrawText(m_Sprite, p.Tag.ToString(), rect, DrawTextFormat.WordBreak, m_ShapeTileArgs.LabelColor);
                                }
                            }
                        }

                        m_Sprite.End();
                    }
                }
            }
            catch (Exception ex) {
                Log.Write(ex);
            }
        }
예제 #50
0
 protected override void GetBrush(DrawArgs dArgs)
 {
     dArgs.BrushName = "Normal";
 }
예제 #51
0
        /// <summary>
        /// Recalculates the grid bounds + interval values
        /// </summary>
        public void ComputeGridValues(DrawArgs drawArgs)
        {
            double vr = drawArgs.WorldCamera.TrueViewRange.Radians;

            // Compensate for closer grid towards poles
            vr *= 1 + Math.Abs(Math.Sin(drawArgs.WorldCamera.Latitude.Radians));

            if (vr < 0.17) {
                LatitudeInterval = 1;
            }
            else if (vr < 0.6) {
                LatitudeInterval = 2;
            }
            else if (vr < 1.0) {
                LatitudeInterval = 5;
            }
            else {
                LatitudeInterval = 10;
            }

            LongitudeInterval = LatitudeInterval;

            if (drawArgs.WorldCamera.ViewFrustum.ContainsPoint(MathEngine.SphericalToCartesian(90, 0, radius))
                || drawArgs.WorldCamera.ViewFrustum.ContainsPoint(MathEngine.SphericalToCartesian(-90, 0, radius))) {
                // Pole visible, 10 degree longitude spacing forced
                LongitudeInterval = 10;
            }

            MinVisibleLongitude = LongitudeInterval >= 10 ? -180 : (int) drawArgs.WorldCamera.Longitude.Degrees/LongitudeInterval*LongitudeInterval - 18*LongitudeInterval;
            MaxVisibleLongitude = LongitudeInterval >= 10 ? 180 : (int) drawArgs.WorldCamera.Longitude.Degrees/LongitudeInterval*LongitudeInterval + 18*LongitudeInterval;
            MinVisibleLatitude = (int) drawArgs.WorldCamera.Latitude.Degrees/LatitudeInterval*LatitudeInterval - 9*LatitudeInterval;
            MaxVisibleLatitude = (int) drawArgs.WorldCamera.Latitude.Degrees/LatitudeInterval*LatitudeInterval + 9*LatitudeInterval;

            if (MaxVisibleLatitude - MinVisibleLatitude >= 180
                || LongitudeInterval == 10) {
                MinVisibleLatitude = -90;
                MaxVisibleLatitude = 90;
            }
            LongitudePointCount = (MaxVisibleLongitude - MinVisibleLongitude)/LongitudeInterval + 1;
            LatitudePointCount = (MaxVisibleLatitude - MinVisibleLatitude)/LatitudeInterval + 1;
            int vertexPointCount = Math.Max(LatitudePointCount, LongitudePointCount);
            if (lineVertices == null
                || vertexPointCount > lineVertices.Length) {
                lineVertices = new CustomVertex.PositionColored[Math.Max(LatitudePointCount, LongitudePointCount)];
            }

            radius = WorldRadius;
            if (drawArgs.WorldCamera.Altitude
                < 0.10f*WorldRadius) {
                useZBuffer = false;
            }
            else {
                useZBuffer = true;
                double bRadius = WorldRadius*1.01f;
                double nRadius = WorldRadius + 0.015f*drawArgs.WorldCamera.Altitude;

                radius = Math.Min(nRadius, bRadius);
            }
        }
예제 #52
0
        bool DoSPlace(Player p, Vec3S32[] m, object state, BlockID block)
        {
            DrawArgs dArgs = (DrawArgs)state;
            ushort   distance = dArgs.distance, interval = dArgs.interval;

            if (m[0] == m[1])
            {
                p.Message("No direction was selected"); return(false);
            }

            int dirX = 0, dirY = 0, dirZ = 0;
            int dx = Math.Abs(m[1].X - m[0].X), dy = Math.Abs(m[1].Y - m[0].Y), dz = Math.Abs(m[1].Z - m[0].Z);

            if (dy > dx && dy > dz)
            {
                dirY = m[1].Y > m[0].Y ? 1 : -1;
            }
            else if (dx > dz)
            {
                dirX = m[1].X > m[0].X ? 1 : -1;
            }
            else
            {
                dirZ = m[1].Z > m[0].Z ? 1 : -1;
            }

            ushort endX = (ushort)(m[0].X + dirX * distance);
            ushort endY = (ushort)(m[0].Y + dirY * distance);
            ushort endZ = (ushort)(m[0].Z + dirZ * distance);

            BlockID held = p.GetHeldBlock();

            if (!CommandParser.IsBlockAllowed(p, "place", held))
            {
                return(false);
            }
            p.level.UpdateBlock(p, endX, endY, endZ, held, BlockDBFlags.Drawn, true);

            if (interval > 0)
            {
                int x = m[0].X, y = m[0].Y, z = m[0].Z;
                int delta = 0;
                while (p.level.IsValidPos(x, y, z) && delta < distance)
                {
                    p.level.UpdateBlock(p, (ushort)x, (ushort)y, (ushort)z, held, BlockDBFlags.Drawn, true);
                    x    += dirX * interval; y += dirY * interval; z += dirZ * interval;
                    delta = Math.Abs(x - m[0].X) + Math.Abs(y - m[0].Y) + Math.Abs(z - m[0].Z);
                }
            }
            else
            {
                p.level.UpdateBlock(p, (ushort)m[0].X, (ushort)m[0].Y, (ushort)m[0].Z, held, BlockDBFlags.Drawn, true);
            }

            if (!p.Ignores.DrawOutput)
            {
                p.Message("Placed {1} blocks {0} apart.",
                          interval > 0 ? interval : distance, Block.GetName(p, held));
            }
            return(true);
        }
예제 #53
0
 public override bool PerformSelectionAction(DrawArgs drawArgs)
 {
     return false;
 }
예제 #54
0
 public override void Initialize(DrawArgs drawArgs)
 {
     this.isInitialized = true;
 }
예제 #55
0
 public override void Update(DrawArgs drawArgs)
 {
 }
예제 #56
0
 public override bool PerformSelectionAction(DrawArgs drawArgs)
 {
     return(false);
 }
예제 #57
0
 /// <summary>
 /// Draw Tropic of Cancer, Tropic of Capricorn, Arctic and Antarctic lines 
 /// </summary>
 private void RenderTropicLines(DrawArgs drawArgs)
 {
     RenderTropicLine(drawArgs, 23.439444f, "Tropic Of Cancer");
     RenderTropicLine(drawArgs, -23.439444f, "Tropic Of Capricorn");
     RenderTropicLine(drawArgs, 66.560556f, "Arctic Circle");
     RenderTropicLine(drawArgs, -66.560556f, "Antarctic Circle");
 }
예제 #58
0
 public override void Update(DrawArgs drawArgs)
 {
 }
예제 #59
0
        public void DrawUnscaled(Bitmap bmDst, int cx, int cy, DrawArgs drwa, Point ptOffset)
        {
            Graphics gDst = Graphics.FromImage(bmDst);

            int xCenter = cx / 2;
            int yCenter = cy / 2;

            // Draw background (if enabled)

            if (drwa.fDrawBackground)
                gDst.Clear(drwa.clrBackground);

            #if false
            // Draw background bitmap, if any

            if (m_bmBackground != null)
                gT.DrawImage(m_bmBackground, xCenter - (m_bmBackground.Width / 2) + m_ptBackgroundOffset.X,
                        yCenter - (m_bmBackground.Height / 2) + m_ptBackgroundOffset.Y,
                        m_bmBackground.Width, m_bmBackground.Height);
            #endif
            // Draw grid (if enabled)
            // UNDONE: use alpha to draw grid (e.g., brighten or darken)

            if (drwa.fShowGrid) {
                int cxGrid = drwa.cxGrid;
                int cyGrid = drwa.cyGrid;
            //						Brush br = new SolidBrush(Color.FromKnownColor(KnownColor.LightGray));
                Brush br = new SolidBrush(Color.FromArgb(256 / 3, 255, 255, 255));
                for (int x = (xCenter + ptOffset.X) % cxGrid; x < cx; x += cxGrid)
                    gDst.FillRectangle(br, x, 0, 1, cy);

                for (int y = (yCenter + ptOffset.Y) % cyGrid; y < cy; y += cyGrid)
                    gDst.FillRectangle(br, 0, y, cx, 1);
            }

            BitmapData bmdDst = bmDst.LockBits(
                    new Rectangle(0, 0, bmDst.Width, bmDst.Height),
                    ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

            // Draw bitmaps from bottom up

            for (int i = BitmapPlacers.Count - 1; i >= 0; i--) {
                BitmapPlacer plc = BitmapPlacers[i];
                XBitmap xbm = plc.XBitmap;
                xbm.SuperBlt(0, 0, bmdDst,
                        xCenter - plc.X + ptOffset.X,
                        yCenter - plc.Y + ptOffset.Y,
                        xbm.Bitmap.Width, xbm.Bitmap.Height,
                        drwa.fMapSideColors);
            }

            bmDst.UnlockBits(bmdDst);

            // Draw origin point (if enabled)

            if (drwa.fShowOrigin) {

                // This is really weird but if we don't do our own clipping then SetPixel will
                // raise an exception!

                int x = xCenter + ptOffset.X;
                int y = yCenter + ptOffset.Y;
                if (x >= 0 && y >= 0 && x < bmDst.Width && y < bmDst.Height)
                    bmDst.SetPixel(x, y, Color.FromKnownColor(KnownColor.Orange));
            }

            // Draw special point (if enabled)

            if (drwa.fShowSpecialPoint) {

                // This is really weird but if we don't do our own clipping then SetPixel will
                // raise an exception!

                int x = xCenter + ptOffset.X + m_ptSpecial.X;
                int y = yCenter + ptOffset.Y + m_ptSpecial.Y;
                if (x >= 0 && y >= 0 && x < bmDst.Width && y < bmDst.Height)
                    bmDst.SetPixel(x, y, Color.FromArgb(0, 255, 0));
            }

            gDst.Dispose();
        }
예제 #60
0
        /// <summary>
        /// Recalculates the grid bounds + interval values
        /// </summary>
        public void ComputeGridValues(DrawArgs drawArgs)
        {
            double vr = drawArgs.WorldCamera.TrueViewRange.Radians;

            // Compensate for closer grid towards poles
            vr *= 1 + Math.Abs(Math.Sin(drawArgs.WorldCamera.Latitude.Radians));

            if (vr < 0.17)
            {
                LatitudeInterval = 1;
            }
            else if (vr < 0.6)
            {
                LatitudeInterval = 2;
            }
            else if (vr < 1.0)
            {
                LatitudeInterval = 5;
            }
            else
            {
                LatitudeInterval = 10;
            }

            LongitudeInterval = LatitudeInterval;

            if (drawArgs.WorldCamera.ViewFrustum.ContainsPoint(MathEngine.SphericalToCartesian(90, 0, radius)) ||
                drawArgs.WorldCamera.ViewFrustum.ContainsPoint(MathEngine.SphericalToCartesian(-90, 0, radius)))
            {
                // Pole visible, 10 degree longitude spacing forced
                LongitudeInterval = 10;
            }

            MinVisibleLongitude = LongitudeInterval >= 10 ? -180 : (int)drawArgs.WorldCamera.Longitude.Degrees / LongitudeInterval * LongitudeInterval - 18 * LongitudeInterval;
            MaxVisibleLongitude = LongitudeInterval >= 10 ? 180 : (int)drawArgs.WorldCamera.Longitude.Degrees / LongitudeInterval * LongitudeInterval + 18 * LongitudeInterval;
            MinVisibleLatitude  = (int)drawArgs.WorldCamera.Latitude.Degrees / LatitudeInterval * LatitudeInterval - 9 * LatitudeInterval;
            MaxVisibleLatitude  = (int)drawArgs.WorldCamera.Latitude.Degrees / LatitudeInterval * LatitudeInterval + 9 * LatitudeInterval;

            if (MaxVisibleLatitude - MinVisibleLatitude >= 180 || LongitudeInterval == 10)
            {
                MinVisibleLatitude = -90;
                MaxVisibleLatitude = 90;
            }
            LongitudePointCount = (MaxVisibleLongitude - MinVisibleLongitude) / LongitudeInterval + 1;
            LatitudePointCount  = (MaxVisibleLatitude - MinVisibleLatitude) / LatitudeInterval + 1;
            int vertexPointCount = Math.Max(LatitudePointCount, LongitudePointCount);

            if (lineVertices == null || vertexPointCount > lineVertices.Length)
            {
                lineVertices = new CustomVertex.PositionColored[Math.Max(LatitudePointCount, LongitudePointCount)];
            }

            radius = WorldRadius;
            if (drawArgs.WorldCamera.Altitude < 0.10f * WorldRadius)
            {
                useZBuffer = false;
            }
            else
            {
                useZBuffer = true;
                double bRadius = WorldRadius * 1.01f;
                double nRadius = WorldRadius + 0.015f * drawArgs.WorldCamera.Altitude;

                radius = Math.Min(nRadius, bRadius);
            }
        }