Exemple #1
0
        void RenderArea_MouseClick(object sender, MouseEventArgs e)
        {
            if(e.Button == System.Windows.Forms.MouseButtons.Left) {
                this.Focus();

                // get the translated points
                Vector.FxVector2f pos;
                TranslatePoint(e.Location, out pos);

                // check that we have selected element and check that we are click inside it
                if(SelectedElement != null && SelectedElement.IsHit(pos)) {

                    // remove the position of the selected element
                    pos.Subtract(ref SelectedElement._Position);

                    // send the event to selected element
                    SelectedElement.MouseClick(pos);
                }

                if(this.OnCanvasMouseClick!= null)
                {
                    CanvasElements elem =  HitElement(pos);

                    // find the internal hit point
                    Vector.FxVector2f inpos = pos;
                    if (elem!=null)
                        inpos.Subtract(ref elem._Position);

                    CanvasMouseClickEventArgs args = new CanvasMouseClickEventArgs(e, elem, pos, inpos);
                    this.OnCanvasMouseClick(this, args);
                }
            }

            ReDraw();
        }
        private void canvas_ellipse_OnCanvasMouseClick(object sender, CanvasMouseClickEventArgs e)
        {
            Console.WriteLine("CanvasHit " + e.hitPoint.ToString() + "  " + e.insidePoint + " ");
            if (e.hitElement != null)
                Console.Write("Hit:" + e.hitElement.ToString());

            // check if we are sub region selection
            if (toolStripButton_eclipse_SelectSubRegion.Checked)
            {
                // check if we are hitting the image
                if (e.hitElement == ieEllipseImage)
                {
                    // init the rectangle
                    if (rect == null)
                    {
                        rect = new FxMaths.Geometry.Rectangle(e.hitPoint, e.hitPoint);
                        gpeEllipseImage.AddGeometry(rect);
                    }
                    else
                    {
                        rect.EndPoint = e.hitPoint;
                        toolStripButton_eclipse_SelectSubRegion.Checked = false;
                    }
                }
            }
        }