Example #1
0
 /**
  * Zeichnen der Zylinder
  */
 public override void pictureBox_Paint(object sender, PaintEventArgs e)
 {
     if (pinImage != null)
     {
         if (kolben == null)
         {
             kolben          = new Kolben();
             kolben.Location = new Point(this.Location.X + this.pictureBox.Image.Width / 2 - kolben.pictureBox.Image.Width / 2, this.Location.Y);
             kolben.setOrgPosition(this.Location.X + this.pictureBox.Image.Width / 2 - kolben.pictureBox.Image.Width / 2, this.Location.Y);
             Form1.form1.insertControl(kolben, this);
         }
         if (druckVor)
         {
             e.Graphics.DrawImage(pinImage, this.Width - pinImage.Width - 1, 0, pinImage.Width, pinImage.Height);
         }
         if (druckZurueck)
         {
             e.Graphics.DrawImage(pinImage, this.Width - pinImage.Width - 1, this.Height - pinImage.Height, pinImage.Width, pinImage.Height);
         }
         if (kolben.getPosition() == 0)
         {
             e.Graphics.DrawImage(endschalter1Image, 0, 0, endschalter0Image.Width, endschalter1Image.Height);
         }
         else
         {
             e.Graphics.DrawImage(endschalter0Image, 0, 0, endschalter0Image.Width, endschalter1Image.Height);
         }
         if (kolben.getPosition() == 100)
         {
             e.Graphics.DrawImage(endschalter1Image, 0, this.Height - endschalter0Image.Height, endschalter0Image.Width, endschalter1Image.Height);
         }
         else
         {
             e.Graphics.DrawImage(endschalter0Image, 0, this.Height - endschalter0Image.Height, endschalter0Image.Width, endschalter1Image.Height);
         }
     }
 }
Example #2
0
        /**
         * Wenn ein Material verschoben wird, dann muss geprüft werden, ob es andere Materialen verscheibt
         */
        public override void performAction()
        {
            foreach (Control cc in Form1.instance.Controls)
            {
                if (cc.HasChildren)
                {
                    if (cc is KapazitiverNaeherungsschalter)
                    {
                        Sensor mo = (Sensor)cc;
                        mo.performAction();
                    }
                    else if (cc is Kolben)
                    {
                        Kolben z = (Kolben)cc;
                        if (z != this && z.collision(this))
                        {
                            if (this.offsetX < 0 && (z.pointInObject(p1) || z.pointInObject(p4)))
                            {
                                //Console.WriteLine("Kollision Zylinder von rechts");
                                this.offsetX  = 0;
                                this.block    = true;
                                this.Location = new Point(z.Location.X + z.Width, Location.Y);
                                //mo.moving = false;
                            }
                            else if (this.offsetX > 0 && (z.pointInObject(p2) || z.pointInObject(p3)))
                            {
                                //Console.WriteLine("Kollision Zylinder von links");
                                this.offsetX  = 0;
                                this.block    = true;
                                this.Location = new Point(z.Location.X - Width, Location.Y);
                                //mo.moving = false;
                            }
                            else if (this.offsetY < 0 && (z.pointInObject(p1) || z.pointInObject(p2)))
                            {
                                //Console.WriteLine("Kollision Me Me von unten");
                                this.offsetY  = 0;
                                this.Location = new Point(z.Location.X, Location.Y - this.Height);
                                //mo.moving = false;
                            }
                            else if (this.offsetY > 0 && (z.pointInObject(p3) || z.pointInObject(p4)))
                            {
                                //Console.WriteLine("Kollision Me Me von oben offsety=" + offsetY);
                                this.offsetY  = 0;
                                this.Location = new Point(z.Location.X, this.Location.Y + this.Height);
                                //mo.moving = false;
                            }

                            else
                            {
                                block = false;
                            }
                        }
                    }
                    else if (cc is Material)
                    {
                        Material mo = (Material)cc;
                        if (mo != this && mo.collision(this) && !mo.inMagzin)
                        {
                            if (this.offsetX < 0 && (mo.pointInObject(p1) || mo.pointInObject(p4)))
                            {
                                //Console.WriteLine("Kollision Me Me von rechts  selbst="+block+" anderer="+mo.block);
                                if (!mo.block)
                                {
                                    mo.offsetX  = offsetX;
                                    mo.Location = new Point(this.Location.X - mo.Width, mo.Location.Y);
                                }
                                else
                                {
                                    this.offsetX  = 0;
                                    this.block    = true;
                                    this.Location = new Point(mo.Location.X + mo.Width, Location.Y);
                                }
                            }
                            else if (this.offsetX > 0 && (mo.pointInObject(p2) || mo.pointInObject(p3)))
                            {
                                //Console.WriteLine("Kollision Me Me von links selbst="+block+" anderer="+mo.block);
                                if (!mo.block)
                                {
                                    mo.offsetX  = offsetX;
                                    mo.Location = new Point(this.Location.X + this.Width, mo.Location.Y);
                                }
                                else
                                {
                                    this.offsetX  = 0;
                                    this.block    = true;
                                    this.Location = new Point(mo.Location.X - mo.Width, Location.Y);
                                }
                                //mo.moving = false;
                            }
                            else if (this.offsetY < 0 && (mo.pointInObject(p1) || mo.pointInObject(p2)))
                            {
                                //Console.WriteLine("Kollision Me Me von unten");
                                mo.offsetY  = offsetY;
                                mo.Location = new Point(mo.Location.X, Location.Y - mo.Height);
                                //mo.moving = false;
                            }
                            else if (this.offsetY > 0 && (mo.pointInObject(p3) || mo.pointInObject(p4)))
                            {
                                //Console.WriteLine("Kollision Me Me von oben offsety=" + offsetY);
                                mo.offsetY  = offsetY;
                                mo.Location = new Point(mo.Location.X, this.Location.Y + this.Height);
                                //mo.moving = false;
                            }
                        }
                    }
                }
            }
        }