private void UseTool(MarchingTerrain terrain)
    {
        if (!IsReady())
        {
            return;
        }

        switch (m_terrainEditorUtility.currentProps.currentToolType)
        {
        case ToolType.CircleBrush: CircleBrush.Execute(terrain, m_terrainEditorUtility.currentProps, m_hotkeyUtility.IsInvertedMode()); break;

        case ToolType.SphereBrush: SphereBrush.Execute(terrain, m_terrainEditorUtility.currentProps, m_hotkeyUtility.IsInvertedMode()); break;

        case ToolType.Smooth: SmoothBrush.Execute(terrain, m_terrainEditorUtility.currentProps, m_hotkeyUtility.IsInvertedMode()); break;

        case ToolType.Noise: NoiseBrush.Execute(terrain, m_terrainEditorUtility.currentProps, m_hotkeyUtility.IsInvertedMode()); break;

        case ToolType.Paint: PaintBrush.Execute(terrain, m_terrainEditorUtility.currentProps, m_hotkeyUtility.IsInvertedMode()); break;
        }
    }
Exemple #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics       g      = e.Graphics;
            GraphicsHelper helper = new GraphicsHelper(g);

            if (b1 == null)
            {
                b1 = new NoiseBrush(new WhiteNoise(Width, Height).SetRange(210, 240).Generate(), 0.4f);
            }

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            g.Clear(BackColor);
            g.SmoothingMode = SmoothingMode.AntiAlias;

            Pen p1  = new Pen(Color.FromArgb(24, 24, 24));
            Pen p12 = new Pen(Color.FromArgb(135, 175, 235));
            Pen p2  = new Pen(Color.FromArgb(120, 120, 120));
            Pen p3  = new Pen(Color.FromArgb(123, 205, 254));
            Pen p4  = new Pen(Color.FromArgb(103, 164, 194));
            Pen p5  = new Pen(Color.FromArgb(60, 130, 170));
            Pen p6  = new Pen(Color.FromArgb(30, 70, 90));
            Pen p7  = new Pen(Color.FromArgb(190, 190, 190));

            GraphicsPath gp1 = helper.CreateRound(0, 0, Width - 1, Height - 2, 4);
            GraphicsPath gp2 = helper.CreateRound(1, 1, Width - 3, Height - 4, 4);

            LinearGradientBrush disabled = new LinearGradientBrush(ClientRectangle, Color.FromArgb(170, 170, 170), Color.FromArgb(140, 140, 140), 90f);
            LinearGradientBrush neither  = new LinearGradientBrush(ClientRectangle, Color.FromArgb(120, 190, 250), Color.FromArgb(100, 160, 190), 90f);
            LinearGradientBrush hover    = new LinearGradientBrush(ClientRectangle, Color.FromArgb(66, 190, 255), Color.FromArgb(37, 140, 190), 90f);
            LinearGradientBrush clicked  = new LinearGradientBrush(ClientRectangle, Color.FromArgb(77, 159, 207), Color.FromArgb(21, 103, 151), 90f);

            if (Enabled)
            {
                if (Hover)
                {
                    if (!Clicked)                       //Hovering
                    {
                        g.FillPath(hover, gp1);
                        g.DrawPath(p1, gp1);
                        g.DrawLine(p2, new Point(2, Height - 1), new Point(Width - 3, Height - 1));
                        g.DrawLine(p5, new Point(2, Height - 3), new Point(Width - 3, Height - 3));
                        g.DrawLine(p2, new Point(2, Height - 1), new Point(Width - 3, Height - 1));
                        g.DrawPath(p3, gp2);
                        g.FillPath(b1, gp1);
                    }
                    else                         //Clicked
                    {
                        g.FillPath(clicked, gp1);
                        g.DrawPath(p1, gp1);
                        g.DrawLine(p2, new Point(2, Height - 1), new Point(Width - 3, Height - 1));
                        g.DrawLine(p6, new Point(2, Height - 3), new Point(Width - 3, Height - 3));
                        g.DrawLine(p2, new Point(2, Height - 1), new Point(Width - 3, Height - 1));
                        g.DrawPath(p4, gp2);
                        g.FillPath(b1, gp1);
                    }
                }
                else                     //Neither
                {
                    g.FillPath(neither, gp1);
                    g.DrawPath(p1, gp1);
                    g.DrawPath(p12, gp2);
                    g.DrawLine(p2, new Point(2, Height - 1), new Point(Width - 3, Height - 1));
                    g.FillPath(b1, gp1);
                }
            }
            else
            {
                g.FillPath(disabled, gp1);
                g.DrawPath(p1, gp1);
                g.DrawPath(p7, gp2);
                g.DrawLine(p2, new Point(2, Height - 1), new Point(Width - 3, Height - 1));
                g.FillPath(b1, gp1);
            }
            Font  font = this.Font;
            SizeF sz1  = g.MeasureString(this.Text, font);

            if (Clicked)
            {
                sz1.Height -= 2;
            }

            g.DrawString(this.Text, font, Brushes.Black, new PointF((int)(Width / 2f - sz1.Width / 2f) + 1, (int)(Height / 2f - sz1.Height / 2f) + 1));
            g.DrawString(this.Text, font, Brushes.White, new PointF((int)(Width / 2f - sz1.Width / 2f), (int)(Height / 2f - sz1.Height / 2f)));
        }
Exemple #3
0
		protected override void OnPaint(PaintEventArgs e) {
			Graphics g = e.Graphics;
			GraphicsHelper helper = new GraphicsHelper(g);

			if (b1 == null) b1 = new NoiseBrush(new WhiteNoise(Width, Height).SetRange(210, 240).Generate(), 0.4f);

			g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

			g.Clear(BackColor);
			g.SmoothingMode = SmoothingMode.AntiAlias;

			Pen p1 = new Pen(Color.FromArgb(24, 24, 24));
			Pen p12 = new Pen(Color.FromArgb(135, 175, 235));
			Pen p2 = new Pen(Color.FromArgb(120, 120, 120));
			Pen p3 = new Pen(Color.FromArgb(123, 205, 254));
			Pen p4 = new Pen(Color.FromArgb(103, 164, 194));
			Pen p5 = new Pen(Color.FromArgb(60, 130, 170));
			Pen p6 = new Pen(Color.FromArgb(30, 70, 90));
			Pen p7 = new Pen(Color.FromArgb(190, 190, 190));

			GraphicsPath gp1 = helper.CreateRound(0, 0, Width - 1, Height - 2, 4);
			GraphicsPath gp2 = helper.CreateRound(1, 1, Width - 3, Height - 4, 4);

			LinearGradientBrush disabled = new LinearGradientBrush(ClientRectangle, Color.FromArgb(170, 170, 170), Color.FromArgb(140, 140, 140), 90f);
			LinearGradientBrush neither = new LinearGradientBrush(ClientRectangle, Color.FromArgb(120, 190, 250), Color.FromArgb(100, 160, 190), 90f);
			LinearGradientBrush hover = new LinearGradientBrush(ClientRectangle, Color.FromArgb(66, 190, 255), Color.FromArgb(37, 140, 190), 90f);
			LinearGradientBrush clicked = new LinearGradientBrush(ClientRectangle, Color.FromArgb(77, 159, 207), Color.FromArgb(21, 103, 151), 90f);

			if (Enabled) {
				if (Hover) {
					if (!Clicked) { //Hovering
						g.FillPath(hover, gp1);
						g.DrawPath(p1, gp1);
						g.DrawLine(p2, new Point(2, Height - 1), new Point(Width - 3, Height - 1));
						g.DrawLine(p5, new Point(2, Height - 3), new Point(Width - 3, Height - 3));
						g.DrawLine(p2, new Point(2, Height - 1), new Point(Width - 3, Height - 1));
						g.DrawPath(p3, gp2);
						g.FillPath(b1, gp1);
					} else { //Clicked
						g.FillPath(clicked, gp1);
						g.DrawPath(p1, gp1);
						g.DrawLine(p2, new Point(2, Height - 1), new Point(Width - 3, Height - 1));
						g.DrawLine(p6, new Point(2, Height - 3), new Point(Width - 3, Height - 3));
						g.DrawLine(p2, new Point(2, Height - 1), new Point(Width - 3, Height - 1));
						g.DrawPath(p4, gp2);
						g.FillPath(b1, gp1);
					}
				} else { //Neither
					g.FillPath(neither, gp1);
					g.DrawPath(p1, gp1);
					g.DrawPath(p12, gp2);
					g.DrawLine(p2, new Point(2, Height - 1), new Point(Width - 3, Height - 1));
					g.FillPath(b1, gp1);
				}
			} else {
				g.FillPath(disabled, gp1);
				g.DrawPath(p1, gp1);
				g.DrawPath(p7, gp2);
				g.DrawLine(p2, new Point(2, Height - 1), new Point(Width - 3, Height - 1));
				g.FillPath(b1, gp1);
			}
			Font font = this.Font;
			SizeF sz1 = g.MeasureString(this.Text, font);

			if (Clicked) {
				sz1.Height -= 2;
			}

			g.DrawString(this.Text, font, Brushes.Black, new PointF((int) (Width / 2f - sz1.Width / 2f) + 1, (int) (Height / 2f - sz1.Height / 2f) + 1));
			g.DrawString(this.Text, font, Brushes.White, new PointF((int) (Width / 2f - sz1.Width / 2f), (int) (Height / 2f - sz1.Height / 2f)));
		}