Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends, good afternoon, look I have a user control in which I add two circles from code (emulating a Dial) that look like this:

C#
public partial class KnobControl : UserControl
    {
        Canvas CnvCirculoP ;//Contiene al circulo pequeño
        Canvas CnvCirculoG; // Contiene al circulo grande

public KnobControl()
        {
            InitializeComponent();

            CnvCirculoP.MouseMove += new MouseEventHandler(CircularIndicator_MouseMove);

            CnvCirculoP.MouseLeftButtonDown += new MouseButtonEventHandler(CircularIndicator_MouseLeftButtonDown);

            CnvCirculoP.MouseLeftButtonUp += new MouseButtonEventHandler(CircularIndicator_MouseLeftButtonUp);


            Dibujar ();
        }


C#
private void Dibujar()
{
.
.
.
   LayoutGrid.Children.Add(CnvCirculoG);        
   LayoutGrid.Children.Add(CnvCirculoP);
}


The events are as follows:

C#
void CircularIndicator_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            this.isKnobRotating = false;
        }

        void CircularIndicator_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.isKnobRotating = true;
        }

        void CircularIndicator_MouseMove(object sender, MouseEventArgs e)
        {
            if (this.isKnobRotating == true)
            {
                Point p = new Point(e.GetPosition(this).X, e.GetPosition(this).Y);
                int posVal = ObtenerNuevaPosicion(p);
                _Value = posVal;
            }
        }


The problem is that when I use it from the main window and try to drag the small circle, nothing happens ie the "CnvCirculoP", this does not get the focus, how can I fix, please help me.
Posted
Comments
[no name] 19-Dec-12 18:11pm    
the image like this :

http://code.google.com/p/memefx/wiki/knobcontrol

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900