Ошибка cs0115 form1 dispose bool не найден метод пригодный для переопределения

50 / 35 / 15

Регистрация: 23.03.2020

Сообщений: 226

1

Не найден метод, пригодный для переопределения

19.03.2021, 17:47. Показов 1520. Ответов 2


Студворк — интернет-сервис помощи студентам

Здравствуйте! Помогите, пожалуйста, разобраться с тонной ошибок. Пишу маленький графический редактор, получаю ошибку CS0115 ‘»Form1.Dispose(bool)»: не найден метод, пригодный для переопределения, пробовала менять имя неймспейса, добавлять дополнительные элементы, дополнительные атрибуты классов partial, initialized, ошибки не уходят. Прилагаю код и файл Designer

C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Windows.Forms;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Text;
 
namespace wineditor
{
    public partial class Form1 : Form
    {
 
        TextBox t0 = new TextBox();
        TextBox t1 = new TextBox();
 
        public Form1()
        {
            t0.Location = new Point(10, 20);
            t0.Size = new Size(400, 20);
 
            t1.Location = new Point(10, 50);
            t1.Size = new Size(00, 400);
 
            this.Size = new Size(550, 500);
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Controls.Add(t0);
            this.Controls.Add(t1);
 
            t1.Multiline = true;
            t1.ScrollBars = ScrollBars.Vertical; //полоса прокрутки изначально неактивна; можно выбрать и вертикальную, и горизонтальную.
            t1.AcceptsReturn = true;
            t1.AcceptsTab = true; //вставим несколько пробелов
            t1.WordWrap = true; //перенос по словам
            t1.Font = new Font(t1.Font.Name, t1.Font.Size + 3, t1.Font.Style);
 
            Console.WriteLine(t1.Font.Name);
            Console.WriteLine("size {0} in units {1}", t1.Font.Size, Font.Unit);
            Console.WriteLine("style{0}", t1.Font.Style);
 
        }
 
    }
 
    class Program
    {
        [STAThread]
        static void Main()
        {
            Form1 f = new Form1();
            Application.Run(f);
        }
    }
}

Designer:

C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
namespace WindowsFormsApp6
{
    partial class Form1
    {
        /// <summary>
        /// Обязательная переменная конструктора.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
 
        /// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        /// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
 
        #region Код, автоматически созданный конструктором форм Windows
 
        /// <summary>
        /// Требуемый метод для поддержки конструктора — не изменяйте 
        /// содержимое этого метода с помощью редактора кода.
        /// </summary>
        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(800, 450);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);
 
        }
 
        #endregion
    }
}



0



For an assignment I’ve had to convert a fractal rendering program from Java to C# and I think I’ve done it but when i try to run it I get the error that is present in the title and I have no idea why it is happening. This is the code for the renderer itself which presents me with no errors:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Form1
{
public partial class Form1 : Form
{
    public Form1()
    {


        init();
        start();
        this.DoubleBuffered = true;


    }
    //code to convert HSB to RGB from HSB.cs. All your code so i made it take up less space. 
    public struct HSBColor
    {
        float h;
        float s;
        float b;
        int a;
        public HSBColor(float h, float s, float b) { this.a = 0xff; this.h = Math.Min(Math.Max(h, 0), 255); this.s = Math.Min(Math.Max(s, 0), 255); this.b = Math.Min(Math.Max(b, 0), 255); }
        public HSBColor(int a, float h, float s, float b) { this.a = a; this.h = Math.Min(Math.Max(h, 0), 255); this.s = Math.Min(Math.Max(s, 0), 255); this.b = Math.Min(Math.Max(b, 0), 255); }
        public float H { get { return h; } }
        public float S { get { return s; } }
        public float B { get { return b; } }
        public int A { get { return a; } }
        public Color Color { get { return FromHSB(this); } }
        public static Color FromHSB(HSBColor hsbColor)
        {
            float r = hsbColor.b;
            float g = hsbColor.b;
            float b = hsbColor.b;
            if (hsbColor.s != 0)
            {
                float max = hsbColor.b; float dif = hsbColor.b * hsbColor.s / 255f; float min = hsbColor.b - dif; float h = hsbColor.h * 360f / 255f;
                if (h < 60f) { r = max; g = h * dif / 60f + min; b = min; }
                else if (h < 120f) { r = -(h - 120f) * dif / 60f + min; g = max; b = min; }
                else if (h < 180f) { r = min; g = max; b = (h - 120f) * dif / 60f + min; }
                else if (h < 240f) { r = min; g = -(h - 240f) * dif / 60f + min; b = max; }
                else if (h < 300f) { r = (h - 240f) * dif / 60f + min; g = min; b = max; }
                else if (h <= 360f) { r = max; g = min; b = -(h - 360f) * dif / 60 + min; }
                else { r = 0; g = 0; b = 0; }
            }
            return Color.FromArgb(hsbColor.a, (int)Math.Round(Math.Min(Math.Max(r, 0), 255)), (int)Math.Round(Math.Min(Math.Max(g, 0), 255)), (int)Math.Round(Math.Min(Math.Max(b, 0), 255)));
        }
    }
    private const int MAX = 256;      // max iterations
    private const double SX = -2.025; // start value real
    private const double SY = -1.125; // start value imaginary
    private const double EX = 0.6;    // end value real
    private const double EY = 1.125;  // end value imaginary
    private static int x1, y1, xs, ys, xe, ye;
    private static double xstart, ystart, xende, yende, xzoom, yzoom;
    private static float xy;
    private int c = 0;
    //private Image picture; Taken out, not needed
    // create rectangle variable JGB
    Rectangle rec;
    private Graphics g1;
    //private Cursor c1, c2; Taken out, not needed
    private System.Drawing.Bitmap bitmap;
    public void init()
    {
        //setSize(640, 480); changed this code to JGB:
        this.Size = new Size(640, 480);
        // Taken all lines out below. Not needed.
        /*finished = false; 
        addMouseListener(this);
        addMouseMotionListener(this);
        c1 = new Cursor(Cursor.WAIT_CURSOR);
        c2 = new Cursor(Cursor.CROSSHAIR_CURSOR); */
        x1 = 640;
        y1 = 480;
        xy = (float)x1 / (float)y1;
        //picture = createImage(x1, y1); Taken out and replaced with JGB:
        bitmap = new Bitmap(x1, y1);
        //g1 = picture.getGraphics(); changed to get my bitmap 
        g1 = Graphics.FromImage(bitmap);
        //finished = true; Finished variable deleted so not needed
    }
    //Code below didnt appear to do anything so i deleted it
    /*public void destroy() // delete all instances 
    {
        if (finished)
        {
            removeMouseListener(this);
            removeMouseMotionListener(this);
            picture = null;
            g1 = null;
            c1 = null;
            c2 = null;
            System.gc(); // garbage collection
        }
    } */

    public void start()
    {
        //action = false;
        //rectangle = false;


        initvalues();

        // added dialog box for instance loading and save varaibles needed for position and zoom to text file
        DialogResult dialog = MessageBox.Show("Would You Like to Load Your Last Instance?", "Load Instance?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
        if (dialog == DialogResult.Yes)
        {

            string[] lines = System.IO.File.ReadAllLines(@"C:UsersPublicWritelines.txt");
            xzoom = System.Convert.ToDouble(lines[0]);
            yzoom = System.Convert.ToDouble(lines[1]);
            xstart = System.Convert.ToDouble(lines[2]);
            ystart = System.Convert.ToDouble(lines[3]);
        }
        else
        {
            xzoom = (xende - xstart) / (double)x1;
            yzoom = (yende - ystart) / (double)y1;
        }

        mandelbrot();
    }
    public void stop()
    {
    }
    /*public void paint(Graphics g, PaintEventArgs e)
    {
        update(g);
    }
   public void update(Graphics g)
    {
        //g.DrawImage(picture, 0, 0);

    }*/
    private void mandelbrot()
    {
        int x, y;
        float h, b, alt = 0.0f;
        Color color;


        Pen pen = new Pen(Color.Black);
        for (x = 0; x < x1; x += 2)
            for (y = 0; y < y1; y++)
            {
                h = pointcolour(xstart + xzoom * (double)x, ystart + yzoom * (double)y, c);
                if (h != alt)
                {


                    b = 1.0f - h * h;

                    color = HSBColor.FromHSB(new HSBColor(h * 255, 0.8f * 255, b * 255));
                    pen = new Pen(color);
                    alt = h;

                }
                g1.DrawLine(pen, x, y, x + 1, y);
            }


    }

    private float pointcolour(double xwert, double ywert, int j)
    {
        double r = 0.0, i = 0.0, m = 0.0;

        // int j = 0;

        while ((j < MAX) && (m < 4.0))
        {
            j++;
            m = r * r - i * i;
            i = 2.0 * r * i + ywert;
            r = m + xwert;
        }
        return (float)j / (float)MAX;
    }
    private void initvalues()
    {
        xstart = SX;
        ystart = SY;
        xende = EX;
        yende = EY;
        if ((float)((xende - xstart) / (yende - ystart)) != xy)
            xstart = xende - (yende - ystart) * (double)xy;
    }

    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        Graphics g1 = e.Graphics;
        g1.DrawImage(bitmap, 0, 0, x1, y1);
        using (Pen pen = new Pen(Color.White, 2))
        {
            e.Graphics.DrawRectangle(pen, rec);
        }
        Invalidate();


    }
    //added load method

    private void Form1_MouseMove(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left)
        {
            xe = e.X;
            ye = e.Y;
            if (xs < xe)
            {
                if (ys < ye) rec = new Rectangle(xs, ys, (xe - xs), (ye - ys));
                else rec = new Rectangle(xs, ye, (xe - xs), (ys - ye));
            }
            else
            {
                if (ys < ye) rec = new Rectangle(xe, ys, (xs - xe), (ye - ys));
                else rec = new Rectangle(xe, ye, (xs - xe), (ys - ye));
            }


            this.Invalidate();
        }



    }

    private void Form1_MouseDown(object sender, MouseEventArgs e)
    {

        if (e.Button == MouseButtons.Left)
        {
            // e.consume();  
            xs = e.X;
            ys = e.Y; // starting point y
            this.Invalidate();
        }

    }

    private void Form1_MouseUp(object sender, MouseEventArgs e)
    {


        rec = new Rectangle(0, 0, 0, 0);
        if (e.Button == MouseButtons.Left)
        {
            int z, w;
            //e.consume();

            //xe = e.X;
            //ye = e.Y;
            if (xs > xe)
            {
                z = xs;
                xs = xe;
                xe = z;
            }
            if (ys > ye)
            {
                z = ys;
                ys = ye;
                ye = z;
            }
            w = (xe - xs);
            z = (ye - ys);
            if ((w < 2) && (z < 2)) initvalues();
            else
            {
                if (((float)w > (float)z * xy)) ye = (int)((float)ys + (float)w / xy);
                else xe = (int)((float)xs + (float)z * xy);
                xende = xstart + xzoom * (double)xe;
                yende = ystart + yzoom * (double)ye;
                xstart += xzoom * (double)xs;
                ystart += yzoom * (double)ys;
            }
            xzoom = (xende - xstart) / (double)x1;
            yzoom = (yende - ystart) / (double)y1;

            mandelbrot();

            string stringxzoom = xzoom.ToString();
            string stringyzoom = yzoom.ToString();
            string stringystart = ystart.ToString();
            string stringxstart = xstart.ToString();
            string[] lines = { stringxzoom, stringyzoom, stringxstart, stringystart };

            System.IO.File.WriteAllLines(@"C:UsersPublicWritelines.txt", lines);
            this.Invalidate();
            //Repaint();

        }

    }


    private void restartToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Application.Restart();
    }
    private void exitToolStripMenuItem1_Click(object sender, EventArgs e)
    {



        Application.Exit();
    }




    private void menuToolStripMenuItem_Click(object sender, EventArgs e)
    {

    }


    private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
    {

    }




}
}

and this is the code that is used for the form designer which was auto generated and I’m not sure why an error is being presented because I’ve never had one before:

namespace WindowsFormsApplication1
{
partial class Form1
{
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows Form Designer generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        this.components = new System.ComponentModel.Container();
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.Text = "Form1";
    }

    #endregion
}
}

I have looked at other questions asking about similar problems, but to my understanding my namespace and form name are correct, but am still giving me the error code

Form1.Dispose(bool): no suitable method found to override

What else can give this problem besides differering names for namespace and form in form1.designer.cs and form1.cs?

public partial class Form1 : Form
{

    public Form1()
    { 
        InitializeComponent();
    }
}


partial class Form1 
{
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows Form Designer generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        this.button2 = new System.Windows.Forms.Button();
        this.textBox1 = new System.Windows.Forms.TextBox();
        this.textBox2 = new System.Windows.Forms.TextBox();
        this.textBox3 = new System.Windows.Forms.TextBox();
        this.textBox4 = new System.Windows.Forms.TextBox();
        this.textBox5 = new System.Windows.Forms.TextBox();
        this.SuspendLayout();
        // 
        // button2
        // 
        this.button2.Location = new System.Drawing.Point(22, 106);
        this.button2.Name = "button2";
        this.button2.Size = new System.Drawing.Size(56, 20);
        this.button2.TabIndex = 1;
        this.button2.Text = "button2";
        this.button2.UseVisualStyleBackColor = true;
        this.button2.Click += new System.EventHandler(this.button2_Click);
        // 
        // textBox1
        // 
        this.textBox1.Location = new System.Drawing.Point(123, 31);
        this.textBox1.Name = "textBox1";
        this.textBox1.Size = new System.Drawing.Size(131, 20);
        this.textBox1.TabIndex = 2;
        this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged_1);
        // 
        // textBox2
        // 
        this.textBox2.Location = new System.Drawing.Point(123, 67);
        this.textBox2.Name = "textBox2";
        this.textBox2.Size = new System.Drawing.Size(130, 20);
        this.textBox2.TabIndex = 3;
        // 
        // textBox3
        // 
        this.textBox3.Location = new System.Drawing.Point(123, 106);
        this.textBox3.Name = "textBox3";
        this.textBox3.Size = new System.Drawing.Size(129, 20);
        this.textBox3.TabIndex = 4;
        this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged_1);
        // 
        // textBox4
        // 
        this.textBox4.Location = new System.Drawing.Point(23, 176);
        this.textBox4.Multiline = true;
        this.textBox4.Name = "textBox4";
        this.textBox4.Size = new System.Drawing.Size(230, 71);
        this.textBox4.TabIndex = 5;
        this.textBox4.TextChanged += new System.EventHandler(this.textBox4_TextChanged_1);
        // 
        // textBox5
        // 
        this.textBox5.Location = new System.Drawing.Point(146, 149);
        this.textBox5.Name = "textBox5";
        this.textBox5.Size = new System.Drawing.Size(105, 20);
        this.textBox5.TabIndex = 6;
        this.textBox5.TextChanged += new System.EventHandler(this.textBox5_TextChanged);
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(292, 270);
        this.Controls.Add(this.textBox5);
        this.Controls.Add(this.textBox4);
        this.Controls.Add(this.textBox3);
        this.Controls.Add(this.textBox2);
        this.Controls.Add(this.textBox1);
        this.Controls.Add(this.button2);
        this.Name = "Form1";
        this.Text = "Form1";
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    #endregion

    private System.Windows.Forms.Button button2;
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.TextBox textBox2;
    private System.Windows.Forms.TextBox textBox3;
    private System.Windows.Forms.TextBox textBox4;
    private System.Windows.Forms.TextBox textBox5;
}

I tried to compile this code but it won’t work, getting this error upon compilation:

PongForm1.Designer.cs(14,33,14,40): error CS0115: ‘Pong.Form1.Dispose(bool)’: no suitable method found to override

using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;

namespace Pong
{
    public partial class gameArea : Form
    {
        PictureBox picBoxPlayer, picBoxAI, picBoxBall;
        Timer gameTime; // also the game loop

        const int SCREEN_WIDTH = 800;
        const int SCREEN_HEIGHT = 600;

        Size sizePlayer = new Size(25, 100);
        Size sizeAI = new Size(25, 100);
        Size sizeBall = new Size(20, 20);

        const int gameTimeInterval = 1;

        const int ballStartSpeed = 2;
        const int ballIncreaseSpeedRate = 1;
        const int ballSpeedLimited = 15;

        const int aiOffSetLoops = 15;

        int ballSpeedX = ballStartSpeed;
        int ballSpeedY = ballStartSpeed;


        Random rad;
        int aiOffSet;
        int aiOffSetCounter;

        Dictionary<string, SoundPlayer> sounds;

        public gameArea()
        {
            InitializeComponent();

            this.DoubleBuffered = true;

            picBoxPlayer = new PictureBox();
            picBoxAI = new PictureBox();
            picBoxBall = new PictureBox();

            gameTime = new Timer();
            gameTime.Interval = gameTimeInterval;

            gameTime.Tick += new EventHandler(gameTime_Tick);

            this.Width = SCREEN_WIDTH;
            this.Height = SCREEN_HEIGHT;
            this.StartPosition = FormStartPosition.CenterScreen;
            this.BackColor = Color.Black;

            picBoxPlayer.Size = sizePlayer;
            picBoxPlayer.Location = new Point(picBoxPlayer.Width / 2, ClientSize.Height / 2 - picBoxPlayer.Height / 2);
            picBoxPlayer.BackColor = Color.Blue;
            this.Controls.Add(picBoxPlayer);

            picBoxAI.Size = sizeAI;
            picBoxAI.Location = new Point(ClientSize.Width - (picBoxAI.Width + picBoxAI.Width / 2), ClientSize.Height / 2 - picBoxPlayer.Height / 2); // TODO: why picBoxPlayer and not picBoxAI?
            picBoxAI.BackColor = Color.Red;
            this.Controls.Add(picBoxAI);

            rad = new Random();
            aiOffSet = 0;
            aiOffSetCounter = 1;

            picBoxBall.Size = sizeBall;
            picBoxBall.Location = new Point(ClientSize.Width / 2 - picBoxBall.Width / 2, ClientSize.Height / 2 - picBoxBall.Height / 2);
            picBoxBall.BackColor = Color.Green;
            this.Controls.Add(picBoxBall);

            // Load Sounds
            sounds = new Dictionary<string, SoundPlayer>();
            for (int k = 1; k <= 10; k++)
            {
                sounds.Add(String.Format(@"pong{0}", k), new SoundPlayer(String.Format(@"pong{0}.wav", k)));
            }

            // Start Game loop
            gameTime.Enabled = true;
        }

        void gameTime_Tick(object sender, EventArgs e)
        {
            picBoxBall.Location = new Point(picBoxBall.Location.X + ballSpeedX, picBoxBall.Location.Y + ballSpeedY);
            gameAreaCollosions();
            padlleCollision();
            playerMovement();
            aiMovement();
        }

        private void iaChangeOffSet()
        {
            if (aiOffSetCounter >= aiOffSetLoops)
            {
                aiOffSet = rad.Next(1, picBoxAI.Height + picBoxBall.Height);
                aiOffSetCounter = 1;
            }
            else
            {
                aiOffSetCounter++;
            }
        }

        private void gameAreaCollosions()
        {
            if (picBoxBall.Location.Y > ClientSize.Height - picBoxBall.Height || picBoxBall.Location.Y < 0)
            {
                iaChangeOffSet();
                ballSpeedY = -ballSpeedY;
                sideCollision();
            }
            else if (picBoxBall.Location.X > ClientSize.Width)
            {
                padlleSideCollision();
                resetBall();
            }
            else if (picBoxBall.Location.X < 0)
            {
                padlleSideCollision();
                resetBall();
            }
        }
        private void resetBall()
        {
            if (ballSpeedX > 0)
                ballSpeedX = -ballStartSpeed;
            else
                ballSpeedX = ballStartSpeed;
            if (ballSpeedY > 0)
                ballSpeedY = -ballStartSpeed;
            else
                ballSpeedY = ballStartSpeed;

            aiOffSet = 0;
            picBoxBall.Location = new Point(ClientSize.Width / 2 - picBoxBall.Width / 2, ClientSize.Height / 2 - picBoxBall.Height / 2);
        }
        private void playerMovement()
        {
            if (this.PointToClient(MousePosition).Y >= picBoxPlayer.Height / 2 && this.PointToClient(MousePosition).Y <= ClientSize.Height - picBoxPlayer.Height / 2)
            {
                int playerX = picBoxPlayer.Width / 2;
                int playerY = this.PointToClient(MousePosition).Y - picBoxPlayer.Height / 2;

                picBoxPlayer.Location = new Point(playerX, playerY);
            }
        }
        private void aiMovement()
        {
            int aiX = ClientSize.Width - (picBoxAI.Width + picBoxAI.Width / 2);
            int aiY = (picBoxBall.Location.Y - picBoxAI.Height / 2) + aiOffSet;

            if (aiY < 0)
                aiY = 0;
            if (aiY > ClientSize.Height - picBoxAI.Height)
                aiY = ClientSize.Height - picBoxAI.Height;

            picBoxAI.Location = new Point(aiX, aiY);
        }
        private void padlleCollision()
        {
            if (picBoxBall.Bounds.IntersectsWith(picBoxAI.Bounds))
            {
                picBoxBall.Location = new Point(picBoxAI.Location.X - picBoxBall.Width, picBoxBall.Location.Y);
                ballSpeedX = -ballSpeedX;
                aiCollision();
            }
            if (picBoxBall.Bounds.IntersectsWith(picBoxPlayer.Bounds))
            {
                picBoxBall.Location = new Point(picBoxPlayer.Location.X + picBoxPlayer.Width, picBoxBall.Location.Y);
                ballSpeedX = -ballSpeedX;
                playerCollision();
            }
        }
        private void playerCollision()
        {
            sounds["pong1"].Play();
            SlowDownBall();
        }
        private void aiCollision()
        {
            sounds["pong2"].Play();
            SlowDownBall();
        }
        private void sideCollision()
        {
            sounds["pong3"].Play();

            SpeedUpBall();
        }
        private void padlleSideCollision()
        {
            sounds["pong9"].Play();
        }
        private void SpeedUpBall()
        {
            if (ballSpeedY > 0)
            {
                ballSpeedY += ballIncreaseSpeedRate;
                if (ballSpeedY >= ballSpeedLimited)
                    ballSpeedY = ballSpeedLimited;
            }
            else
            {
                ballSpeedY -= ballIncreaseSpeedRate;
                if (ballSpeedY <= -ballSpeedLimited)
                    ballSpeedY = -ballSpeedLimited;
            }

            if (ballSpeedX > 0)
            {
                ballSpeedX += ballIncreaseSpeedRate;
                if (ballSpeedX >= ballSpeedLimited)
                    ballSpeedX = ballSpeedLimited;
            }
            else
            {
                ballSpeedX -= ballIncreaseSpeedRate;
                if (ballSpeedX <= -ballSpeedLimited)
                    ballSpeedX = -ballSpeedLimited;
            }
        }
        private void SlowDownBall()
        {
            if (ballSpeedY > 0)
            {
                ballSpeedY -= ballIncreaseSpeedRate;
                if (ballSpeedY <= ballStartSpeed)
                    ballSpeedY = ballStartSpeed;
            }
            else
            {
                ballSpeedY += ballIncreaseSpeedRate;
                if (ballSpeedY >= -ballStartSpeed)
                    ballSpeedY = -ballStartSpeed;
            }

            if (ballSpeedX > 0)
            {
                ballSpeedX -= ballIncreaseSpeedRate;
                if (ballSpeedX <= ballStartSpeed)
                    ballSpeedX = ballStartSpeed;
            }
            else
            {
                ballSpeedX += ballIncreaseSpeedRate;
                if (ballSpeedX >= -ballStartSpeed)
                    ballSpeedX = -ballStartSpeed;
            }
        }
    }
}

  • Remove From My Forums
  • Question

  • namespace DeviceApplication1

    {

    public class Form1

    {

    /// Required designer variable.

    private System.ComponentModel.IContainer components = null;

    private System.Windows.Forms.MainMenu mainMenu;

    /// Clean up any resources being used.

    /// <param name=»disposing»>true if managed resources should be disposed; otherwise, false.</param>

    protected override void Dispose(bool disposing)

    {

    if (disposing && (components != null))

    {

    components.Dispose();

    }

    base.Dispose(disposing);

    }

    Anyone knows how to deal with this??

    error is ‘DeviceApplication1.Form1.Dispose(bool)’: no suitable method found to override

    This is found in the form1.designer.cs

    Thanks in advance

    Shaun

Answers

  • The top of your form1.cd (so not talking about the form1.designer.cs) should look like:

    Code Snippet

    public partial class Form1 : Form

    {


    and I think yours looks like:

    Code Snippet

    public partial class Form1

    {

    In short: your form1 is a class.  The class inherites from the Form class… That means it is in fact a form, but some things might be different.  Like employee and neighbour both inherit from human, but the two will react different if you ask them to work 40h/week.

    In your case of form1, the compiler changed (=> override) the void Dispose(Bool disposing) from the class Form, like it always does.  But because you probably (accidentely) removed the inheritance, it had no method Dispose(Bool disposing), so it can’t find what you are trying to change (=> override) there.

Возможно, вам также будет интересно:

  • Ошибка cs0103 visual studio
  • Ошибка cs0021 не удается применить индексирование через к выражению типа int
  • Ошибка cs0006 не удалось найти файл метаданных dll
  • Ошибка cs0004 pubg на ps4
  • Ошибка cs go exe не отвечает

  • Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии