none
Fläche prüfen RRS feed

  • Question

  • Guten Tag,

    Könnte mir vielleicht jemand helfen. Will eine Fläche zeichnen bzw. darstellen in WF und das funktioniert auch. Das ist meine Grundfläche. Will desweiteren auf diese GF weitere kleine Flächen hinzufügen. Habe einen Startpunkt, und wie kann ich nun die länge und breite von einer Fläche bei einer anderen Fläche dazurechnen. Desweiteren wie überprüfe ich ob dieser Platz schon belegt ist.

    Code schaut folgen:

    public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            #region Starpunkte
            private int x = 200;
            private int y = 100;
            #endregion
            #region Länge&Breite der Pakete
            int LaengeP1;
            int BreiteP1;
            int LaengeP2;
            int BreiteP2;
            int LaengeP3;
            int BreiteP3;
            #endregion 

            private void Form1_Load(object sender, EventArgs e)
            {

            }
            private void cmdBE_Click(object sender, EventArgs e)
            {
                #region Palette erstellen
                //Länge und Breite der Palette die Beladen wird
                int LaengeP = 360; 
                int BreiteP = 400;
                
                //Die Palette wird erstellt mit der den Startpunkten x, y & der Länge und Breite 
                System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
                System.Drawing.Graphics formGraphics;
                formGraphics = this.CreateGraphics();
                formGraphics.FillRectangle(myBrush, new Rectangle(x, y, LaengeP, BreiteP));
                myBrush.Dispose();
                formGraphics.Dispose();
                #endregion 
            }


            private void cmdBP_Click(object sender, EventArgs e)
            {
                #region Paket1 erstellen
                //Länge und Breite des 1.Pakets übergeben

                LaengeP1 = Convert.ToInt32(txtP1L.Text);
                BreiteP1 = Convert.ToInt32(txtP1B.Text);

                //Mit den eingegebenen Daten wird ein Paket erstellt und dieses fängt am Starpunkt x, y an
                System.Drawing.SolidBrush myBrush2 = new System.Drawing.SolidBrush(System.Drawing.Color.Blue);
                System.Drawing.Graphics formGraphics2;
                formGraphics2 = this.CreateGraphics();
                formGraphics2.FillRectangle(myBrush2, new Rectangle(x, y, LaengeP1, BreiteP1));
                myBrush2.Dispose();
                formGraphics2.Dispose();
                #endregion 
            }

            private void cmdBP2_Click(object sender, EventArgs e)
            {
                #region Paket2 erstellen
                //Länge und Breite des 2.Pakets übergeben
                
                LaengeP2 = Convert.ToInt32(txtP2L.Text);
                BreiteP2 = Convert.ToInt32(txtP2B.Text);

                //Mit den eingegebenen Daten wird ein Paket erstellt und dieses fängt am Starpunkt x, y an
                System.Drawing.SolidBrush myBrush2 = new System.Drawing.SolidBrush(System.Drawing.Color.Yellow);
                System.Drawing.Graphics formGraphics2;
                formGraphics2 = this.CreateGraphics();
                formGraphics2.FillRectangle(myBrush2, new Rectangle(x, y, LaengeP2, BreiteP2));
                myBrush2.Dispose();
                formGraphics2.Dispose();
                #endregion
            }

    • Moved by Stanly Fan Monday, July 2, 2018 6:48 AM
    Wednesday, June 27, 2018 10:22 AM

All replies

  • Hi,

    Sorry I could not understand what you mean in your question, this forum is discussing and asking questions about the Windows Form in English, so could you please ask your question in English again?

    Thanks for your understanding.

    Regards,

    Frankie


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 28, 2018 1:54 AM
  • Greetings ado_hrn.

    Hier kannst du den Deutsch-sprache Forum finden.

    https://social.msdn.microsoft.com/Forums/de-DE/home?forum=visualcsharpde

    And here is my translation of your question into English. (I am not sure of the translation of the word "Fläche". It usually means "area", but the OP might mean "Form" or "component" or... Not sure. My German isn't great.)

    Good day.

    Can someone perhaps help me? I want to draw an area with its respective components in WF, and that bit is working. That is my base area. I want to add further small areas to the base area. I have a starting point, now how can I find the length and width of one area from another area. And further, how can I tell if this place is occupied?

    Code as follows.



    Thursday, June 28, 2018 4:03 AM