protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.PaintActivity); string thisJsonData = Intent.GetStringExtra("JSON") ?? ""; LearningTask = JsonConvert.DeserializeObject <LearningTask>(thisJsonData, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }); // Used if the task requires drawing on top of // a photo taken in another task PreviousImage = Intent.GetStringExtra("PREVIOUS_PHOTO"); SupportActionBar.Title = LearningTask.Description; mPaint = new Paint { AntiAlias = true, Color = Color.Black }; mPaint.SetStyle(Paint.Style.Stroke); mPaint.StrokeJoin = (Paint.Join.Round); mPaint.StrokeCap = (Paint.Cap.Round); mPaint.StrokeWidth = 20; mv = FindViewById <PaintView>(Resource.Id.paintview); mv.MPaint = mPaint; mv.DrawingCacheEnabled = true; bgImage = FindViewById <ImageViewAsync>(Resource.Id.paintBackground); if (LearningTask.TaskType.IdName == "DRAW_PHOTO") { //used for accessing cache folder int activityId = Intent.GetIntExtra("ACTIVITY_ID", -1); if (string.IsNullOrWhiteSpace(PreviousImage)) { AndroidUtils.LoadActivityImageIntoView(bgImage, LearningTask.JsonData, activityId, 500); } else { ImageService.Instance.LoadFile(PreviousImage) .DownSample(500) .Into(bgImage); } } else { bgImage.SetBackgroundColor(Color.White); } colorPickerView = FindViewById <ColorPickerView>(Resource.Id.color_picker_view); colorPickerView.setOnColorChangedListener(this); ImageButton saveBtn = FindViewById <ImageButton>(Resource.Id.saveBtn); saveBtn.Click += SaveBtn_Click; }
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); }
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(); }; }