コード例 #1
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            // Anderenfalls wird die Liste mit den gezeichneten Objekten von hinten (damit
            // das oberste Objekte gefunden wird) durchgegangen und geprüft, über welchem
            // Objekt die Maus sich befindet.
            for (int i = fpArray.Count - 1; i >= 0; i--)
            {
                FieldPanel fp = fpArray[i];
                if (fp.Hit(e.Location))
                {
                    if (_movingGraphicObject != null)
                    {
                        controller.View.status = _movingGraphicObject.Key;
                    }
                    else
                    {
                        controller.View.status = 0;
                    }

                    fp.OnMouseUp(this, e);
                    _movingGraphicObject = null;
                    return;
                }
            }
            if (_movingGraphicObject != null)
            {
                _movingGraphicObject.Move(_movingGraphicObject.Start.X - _lastMouseLocation.X + 25, _movingGraphicObject.Start.Y - _lastMouseLocation.Y + 50);
                //_movingGraphicObject.Reset();
                this.Invalidate();
            }
            _movingGraphicObject = null;
        }
コード例 #2
0
        public DrawPanel()
        {
            penGelb = new Pen(Color.Yellow, 1);
            penRot  = new Pen(Color.Red, 1);
            penBlau = new Pen(Color.Blue, 1);
            setGraphicObjects();
            FieldPanel p0 = new FieldPanel(0, new Point(508, 30));
            FieldPanel p1 = new FieldPanel(1, new Point(654, 30));
            FieldPanel p2 = new FieldPanel(2, new Point(800, 30));
            FieldPanel p3 = new FieldPanel(3, new Point(508, 176));
            FieldPanel p4 = new FieldPanel(4, new Point(654, 176));
            FieldPanel p5 = new FieldPanel(5, new Point(800, 176));
            FieldPanel p6 = new FieldPanel(6, new Point(508, 322));
            FieldPanel p7 = new FieldPanel(7, new Point(654, 322));
            FieldPanel p8 = new FieldPanel(8, new Point(800, 322));

            this.Controls.Add(p0);
            this.Controls.Add(p1);
            this.Controls.Add(p2);
            this.Controls.Add(p3);
            this.Controls.Add(p4);
            this.Controls.Add(p5);
            this.Controls.Add(p6);
            this.Controls.Add(p7);
            this.Controls.Add(p8);
            fpArray.Add(p0);
            fpArray.Add(p1);
            fpArray.Add(p2);
            fpArray.Add(p3);
            fpArray.Add(p4);
            fpArray.Add(p5);
            fpArray.Add(p6);
            fpArray.Add(p7);
            fpArray.Add(p8);

            foreach (FieldPanel fp in fpArray)
            {
                fp.DrawPanel = this;
            }


            this.DoubleBuffered = true;
            this.Invalidate();
        }