Exemple #1
0
 /// <summary>
 /// inits the views
 /// </summary>
 private void InitViews()
 {
     picker     = FindViewById <ColorPicker>(Resource.Id.picker);
     svBar      = FindViewById <SVBar>(Resource.Id.svbar);
     opacityBar = FindViewById <OpacityBar>(Resource.Id.opacitybar);
     btnApply   = FindViewById <Button>(Resource.Id.btnApply);
     picker.AddSVBar(svBar);
     picker.AddOpacityBar(opacityBar);
     btnApply.SetOnClickListener(this);
 }
        protected override Dialog OnCreateDialog(int id)
        {
            Console.WriteLine("Opening Color Dialog (" + id + ")");

            AlertDialog.Builder builder  = new AlertDialog.Builder(this);
            LayoutInflater      inflater = LayoutInflater.FromContext(this);

            ViewGroup layout = (ViewGroup)inflater.Inflate(Resource.Layout.ColorDialogView, null);

            builder.SetView(layout);

            var colorPicker = layout.FindViewById <ColorPicker> (Resource.Id.color_picker);

            SVBar sv = layout.FindViewById <SVBar> (Resource.Id.sv_bar);
            var   cb = layout.FindViewById <CheckBox> (Resource.Id.chk_random);

            sv.HorizontalOrientation = false;
            sv.SetBackgroundColor(global::Android.Graphics.Color.Transparent);
            colorPicker.SetBackgroundColor(global::Android.Graphics.Color.Transparent);
            colorPicker.addSVBar(sv);
            colorPicker.ColorChanged += (s, c) => {
                global::Android.Graphics.Color cd = new global::Android.Graphics.Color((int)Util.MakePastel(c));
                layout.SetBackgroundColor(cd);
                sv.SetBackgroundColor(cd);
                colorPicker.SetBackgroundColor(cd);
            };

            AlertDialog d = builder.Create();

            d.KeyPress += (sender, e) => {
                Console.WriteLine(e.KeyCode + " " + e.Handled);
                d.Dismiss();
            };
            d.SetButton("add", (sender, e) => {
                Console.WriteLine(e.Which);
                if (cb.Checked)
                {
                    ViewModel.AddColor(new Color(0, 1, 0, 1, 0, 1));
                }
                else
                {
                    ViewModel.AddColor(colorPicker.CurrentColor);
                }
            });
            d.SetButton2("cancel", (sender, e) => {
                Console.WriteLine(e.Which);
                d.Dismiss();
            });
            return(d);
        }
Exemple #3
0
        protected override void OnViewModelSet()
        {
            base.OnViewModelSet();
            SetContentView(Resource.Layout.ColorChooserView);
            colorPicker = (ColorPicker)FindViewById(Resource.Id.colorPicker);
            View layout = FindViewById(Resource.Id.color_chooser_view);

            SVBar sv = (SVBar)FindViewById(Resource.Id.svBar);

            sv.SetBackgroundColor(global::Android.Graphics.Color.Transparent);
            colorPicker.SetBackgroundColor(global::Android.Graphics.Color.Transparent);
            colorPicker.addSVBar(sv);
            ColorChanged += (s, c) => {
                ViewModel.SetCurrentColor(c);
                global::Android.Graphics.Color cd = new global::Android.Graphics.Color((int)ViewModel.BackgroundColor);
                layout.SetBackgroundColor(cd);
                sv.SetBackgroundColor(cd);
                colorPicker.SetBackgroundColor(cd);
            };
        }