public RoundKnobButton(Context context, int back, Bitmap bmpRotorOn, Bitmap bmpRotorOff, int w, int h) : base(context) { Console.WriteLine("RoundKnobButton :: ctor :: Start"); // We won't wait for our size to be calculated, we'll just store our fixed size m_Width = w; m_Height = h; m_BmpRotorOn = bmpRotorOn; m_BmpRotorOff = bmpRotorOff; // // Create stator // ImageView ivBack = new ImageView(context); ivBack.SetImageResource(back); RelativeLayout.LayoutParams lp_ivBack = new RelativeLayout.LayoutParams(w, h); lp_ivBack.AddRule(LayoutRules.CenterInParent); AddView(ivBack, lp_ivBack); // // Create Rotor // m_RotorImaveView = new ImageView(context); m_RotorImaveView.SetImageBitmap(bmpRotorOff); RelativeLayout.LayoutParams lp_ivKnob = new RelativeLayout.LayoutParams(w, h);//LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp_ivKnob.AddRule(LayoutRules.CenterInParent); AddView(m_RotorImaveView, lp_ivKnob); SetState(true); // // Create Current Value Text // m_CurrentValueTextView = new TextView(context); m_CurrentValueTextView.SetTextSize(Android.Util.ComplexUnitType.Dip, 20); m_CurrentValueTextView.Gravity = GravityFlags.Center; RelativeLayout.LayoutParams lp_cvKnob = new RelativeLayout.LayoutParams(LayoutParams.WrapContent, h / 2); lp_cvKnob.AddRule(LayoutRules.CenterInParent); AddView(m_CurrentValueTextView, lp_cvKnob); // Border for TextView GradientDrawable gd = new GradientDrawable(); gd.SetColor(20); // Changes this drawbale to use a single color instead of a gradient gd.SetCornerRadius(5); gd.SetStroke(1, Color.LightGray); // m_CurrentValueTextView.Background = gd; // // Circles // m_InnerCircle = new CircleView(context, w, h, w / 8); m_InnerCircle.Visibility = (m_ShowTouchPath) ? ViewStates.Visible : ViewStates.Invisible; RelativeLayout.LayoutParams lp_circle = new RelativeLayout.LayoutParams(w, h); lp_circle.AddRule(LayoutRules.CenterInParent); AddView(m_InnerCircle, lp_circle); m_OuterCircle = new CircleView(context, w, h, w / 3); m_OuterCircle.Visibility = (m_ShowTouchPath) ? ViewStates.Visible : ViewStates.Invisible; RelativeLayout.LayoutParams lp_circle2 = new RelativeLayout.LayoutParams(w, h); lp_circle2.AddRule(LayoutRules.CenterInParent); AddView(m_OuterCircle, lp_circle2); // Enable Gesture Detector gestureDetector = new GestureDetector(Context, this); }
public RoundKnobButton(Context context, int back, Bitmap bmpRotorOn, Bitmap bmpRotorOff, int w, int h) : base(context) { Console.WriteLine("RoundKnobButton :: ctor :: Start"); // We won't wait for our size to be calculated, we'll just store our fixed size m_Width = w; m_Height = h; m_BmpRotorOn = bmpRotorOn; m_BmpRotorOff = bmpRotorOff; // // Create stator // ImageView ivBack = new ImageView(context); ivBack.SetImageResource(back); RelativeLayout.LayoutParams lp_ivBack = new RelativeLayout.LayoutParams(w, h); lp_ivBack.AddRule(LayoutRules.CenterInParent); AddView(ivBack, lp_ivBack); // // Create Rotor // m_RotorImaveView = new ImageView(context); m_RotorImaveView.SetImageBitmap(bmpRotorOff); RelativeLayout.LayoutParams lp_ivKnob = new RelativeLayout.LayoutParams(w, h); //LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp_ivKnob.AddRule(LayoutRules.CenterInParent); AddView(m_RotorImaveView, lp_ivKnob); SetState(true); // // Create Current Value Text // m_CurrentValueTextView = new TextView(context); m_CurrentValueTextView.SetTextSize(Android.Util.ComplexUnitType.Dip, 20); m_CurrentValueTextView.Gravity = GravityFlags.Center; RelativeLayout.LayoutParams lp_cvKnob = new RelativeLayout.LayoutParams(LayoutParams.WrapContent, h / 2); lp_cvKnob.AddRule(LayoutRules.CenterInParent); AddView(m_CurrentValueTextView, lp_cvKnob); // Border for TextView GradientDrawable gd = new GradientDrawable(); gd.SetColor(20); // Changes this drawbale to use a single color instead of a gradient gd.SetCornerRadius(5); gd.SetStroke(1, Color.LightGray); // m_CurrentValueTextView.Background = gd; // // Circles // m_InnerCircle = new CircleView(context, w, h, w / 8); m_InnerCircle.Visibility = (m_ShowTouchPath) ? ViewStates.Visible : ViewStates.Invisible; RelativeLayout.LayoutParams lp_circle = new RelativeLayout.LayoutParams(w, h); lp_circle.AddRule(LayoutRules.CenterInParent); AddView(m_InnerCircle, lp_circle); m_OuterCircle = new CircleView(context, w, h, w / 3); m_OuterCircle.Visibility = (m_ShowTouchPath) ? ViewStates.Visible : ViewStates.Invisible; RelativeLayout.LayoutParams lp_circle2 = new RelativeLayout.LayoutParams(w, h); lp_circle2.AddRule(LayoutRules.CenterInParent); AddView(m_OuterCircle, lp_circle2); // Enable Gesture Detector gestureDetector = new GestureDetector(Context, this); }