示例#1
0
        private void ImgMain_MouseMove(object sender, MouseEventArgs e)
        {
            try
            {
                Refresh();


                //Console.WriteLine(@" debut moseMove ");

                UIElement element = sender as UIElement;

                if (element != null)
                {
                    UIElement ele = element;

                    MouseDevice mouse = e.MouseDevice;
                    Point       point = mouse.GetPosition(ele);


                    //Console.WriteLine(@" emouse.GetPosition : " + point);


                    using (DrawingContext dc = this.m_drawingGroup.Open())
                    {
                        m_goHInterface.AddVisualInterface(dc, this.ZoneDessinRectangle);

                        if (mouse.LeftButton.Equals(MouseButtonState.Pressed))
                        {
                            this.m_bw = m_goHInterface.AddMainFermer(point, dc, this.ZoneDessinRectangle);
                            this.m_bw.RunWorkerCompleted += Bw_RunWorkerCompleted;
                        }
                        else
                        {
                            m_goHInterface.AddMainOuverte(point, dc, ImageSource.Width, ImageSource.Height);
                        }
                    }

                    this.ImgMain.Source = this.ImageSource;
                }
                else
                {
                    Console.WriteLine(@" element <=> null ");
                }

                //Console.WriteLine(@" fin mouseMove ");
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.ToString());
                Console.ForegroundColor = ConsoleColor.Gray;
            }
        }
        /// <summary>
        /// Draws a hand symbol if the hand is tracked: red circle = closed, green circle = opened; blue circle = lasso
        /// </summary>
        /// <param name="handState">state of the hand</param>
        /// <param name="handPosition">position of the hand</param>
        /// <param name="drawingContext">drawing context to draw to</param>
        private void DrawHand(HandState handState, Point handPosition, DrawingContext drawingContext)
        {
            try
            {
                switch (handState)
                {
                case HandState.Closed:
                    drawingContext.DrawEllipse(this.m_handClosedBrush, null, handPosition, HAND_SIZE, HAND_SIZE);

                    m_goHInterface.AddMainFermer(handPosition, drawingContext, this.m_rect);

                    break;

                case HandState.Open:
                    drawingContext.DrawEllipse(this.m_handOpenBrush, null, handPosition, HAND_SIZE, HAND_SIZE);

                    m_goHInterface.AddMainOuverte(handPosition, drawingContext, this.m_displayWidth, this.m_displayHeight);

                    break;

                case HandState.Lasso:
                    drawingContext.DrawEllipse(this.m_handLassoBrush, null, handPosition, HAND_SIZE, HAND_SIZE);

                    m_goHInterface.AddMainLasso(handPosition, drawingContext);

                    break;

                case HandState.Unknown:

                    m_goHInterface.AddMainLasso(handPosition, drawingContext);

                    break;

                case HandState.NotTracked:

                    m_goHInterface.AddMainLasso(handPosition, drawingContext);

                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(handState), handState, null);
                }
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.ToString());
                Console.ForegroundColor = ConsoleColor.Gray;
            }
        }
示例#3
0
        private void ImgMain_MouseMove(object sender, MouseEventArgs e)
        {
            //Console.WriteLine(@" debut moseMove ");

            UIElement element = sender as UIElement;

            if (element != null)
            {
                UIElement ele = element;

                MouseDevice mouse = e.MouseDevice;
                Point       point = mouse.GetPosition(ele);


                //Console.WriteLine(@" emouse.GetPosition : " + point);


                using (DrawingContext dc = this.m_drawingGroup.Open())
                {
                    m_goHInterface.AddVisualInterface(dc, this.ZoneDessinRectangle);

                    if (mouse.LeftButton.Equals(MouseButtonState.Pressed))
                    {
                        m_goHInterface.AddMainFermer(point, dc, this.ZoneDessinRectangle);
                    }
                    else
                    {
                        m_goHInterface.AddMainOuverte(point, dc, ImageSource.Width, ImageSource.Height);
                    }
                }
            }
            else
            {
                Console.WriteLine(@" element <=> null ");
            }

            Refresh();


            //Console.WriteLine(@" fin mouseMove ");
        }