コード例 #1
0
        protected override void OnBindDialogView(View view)
        {
            base.OnBindDialogView(view);

            System.Boolean isLandscapeLayout = false;

            mColorPickerView = (ColorPickerView)view.FindViewById(Resource.Id.color_picker_view);

            LinearLayout landscapeLayout = (LinearLayout)view.FindViewById(Resource.Id.dialog_color_picker_extra_layout_landscape);

            if (landscapeLayout != null)
            {
                isLandscapeLayout = true;
            }


            mColorPickerView = (ColorPickerView)view.FindViewById(Resource.Id.color_picker_view);
            mOldColorView    = (ColorPanelView)view.FindViewById(Resource.Id.color_panel_old);
            mNewColorView    = (ColorPanelView)view.FindViewById(Resource.Id.color_panel_new);

            if (!isLandscapeLayout)
            {
                ((LinearLayout)mOldColorView.Parent).SetPadding(
                    (int)System.Math.Round(mColorPickerView.getDrawingOffset()),
                    0,
                    (int)System.Math.Round(mColorPickerView.getDrawingOffset()),
                    0);
            }
            else
            {
                landscapeLayout.SetPadding(0, 0, (int)System.Math.Round(mColorPickerView.getDrawingOffset()), 0);
            }

            mColorPickerView.setAlphaSliderVisible(alphaChannelVisible);
            mColorPickerView.setAlphaSliderText(alphaChannelText);
            mColorPickerView.setSliderTrackerColor(colorPickerSliderColor);

            if (colorPickerSliderColor != -1)
            {
                mColorPickerView.setSliderTrackerColor(colorPickerSliderColor);
            }

            if (colorPickerBorderColor != -1)
            {
                mColorPickerView.setBorderColor(colorPickerBorderColor);
            }


            mColorPickerView.setOnColorChangedListener(this);

            //Log.d("mColorPicker", "setting initial color!");
            mOldColorView.setColor(mColor);
            mColorPickerView.setColor(mColor, true);
        }
コード例 #2
0
        private void init()
        {
            var prefs = PreferenceManager.GetDefaultSharedPreferences(this);
            //TODO : change the 1 as like in native app
            int initialColor = prefs.GetInt("color_3", 1);             //Convert.ToInt32("4278190080"));

            mColorPickerView   = (ColorPickerView)FindViewById(Resource.Id.color_picker_view);
            mOldColorPanelView = (ColorPanelView)FindViewById(Resource.Id.color_panel_old);
            mNewColorPanelView = (ColorPanelView)FindViewById(Resource.Id.color_panel_new);

            mOkButton     = (Button)FindViewById(Resource.Id.okButton);
            mCancelButton = (Button)FindViewById(Resource.Id.cancelButton);

            ((LinearLayout)mOldColorPanelView.Parent).SetPadding(
                (int)Math.Round(mColorPickerView.getDrawingOffset()),
                0,
                (int)Math.Round(mColorPickerView.getDrawingOffset()),
                0);


            mColorPickerView.setOnColorChangedListener(this);
            mColorPickerView.setColor(initialColor, true);
            mOldColorPanelView.setColor(initialColor);

            mOkButton.SetOnClickListener(this);
            mCancelButton.SetOnClickListener(this);

            mOkButton.Click += (sender, e) => {
                var edit = PreferenceManager.GetDefaultSharedPreferences(this).Edit();
                edit.PutInt("color_3", mColorPickerView.getColor());
                edit.Commit();

                Finish();
            };
            mCancelButton.Click += (sender, e) => {
                Finish();
            };
        }