protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Window.SetFormat(Format.Rgba8888); SetContentView(Resource.Layout.activity_color_picker); var prefs = PreferenceManager.GetDefaultSharedPreferences(this); var initialColor = new Color(prefs.GetInt("color_3", Color.Black.ToArgb())); _colorPickerView = FindViewById <ColorPickerView>(Resource.Id.cpv_color_picker_view); var colorPanelView = FindViewById <ColorPanelView>(Resource.Id.cpv_color_panel_old); _newColorPanelView = FindViewById <ColorPanelView>(Resource.Id.cpv_color_panel_new); var btnOK = FindViewById <Button>(Resource.Id.okButton); var btnCancel = FindViewById <Button>(Resource.Id.cancelButton); ((LinearLayout)colorPanelView.Parent).SetPadding(_colorPickerView.PaddingLeft, 0, _colorPickerView.PaddingRight, 0); _colorPickerView.SetOnColorChangedListener(this); _colorPickerView.SetColor(initialColor, true); colorPanelView.SetColor(initialColor); btnOK.SetOnClickListener(this); btnCancel.SetOnClickListener(this); }
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; }
private async void colorChange_Clicked(object sender, EventArgs e) { var c = new ColorPickerView(this.editorPage.GetData()); c.BackgroundTapped += colorPicker_Background_Tapped; this.editorPage.backgroundGrid.Children.Add(c); this.editorPage.UpdateView(); }
// Send back the user's color selection to the paint activity private void HandleColorSelection(object sender, System.EventArgs e) { ColorPickerView Wheel = FindViewById <ColorPickerView>(Resource.Id.ColorPickerView); Intent ToReturn = new Intent(); ToReturn.PutExtra("color", Wheel.SelectedColor); SetResult(Result.Ok, ToReturn); Finish(); }
public override void onCreate(Bundle savedInstanceState) { base.onCreate(savedInstanceState); OnColorChangedListener l = new OnColorChangedListenerAnonymousInnerClassHelper(this); ContentView = new ColorPickerView(this, Context, l, mInitialColor); Title = "Pick a Color"; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.pickerlayout); _okButton = FindViewById <Button>(Resource.Id.okbutton); _colorPickerView = FindViewById <ColorPickerView>(Resource.Id.color_picker_view); _socket = ConnectionPageActivity._socket; }
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); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var cPickerView = new ColorPickerView(Context, _initialColor); cPickerView.ColorChanged += delegate(object sender, ColorChangedEventArgs args) { if (ColorChanged != null) { ColorChanged(this, args); } Dismiss(); }; SetContentView(cPickerView); SetTitle("Pick a Color"); }
public Task <Color?> GetColorAsync(string title, string message, params Color[] colors) { var cts = new TaskCompletionSource <Color?>(); if (colors == null || colors.Length == 0) { colors = defaultColors; } var _dialogView = new ColorPickerView(title, message, colors); _dialogView.Picked += (s, e) => { cts.SetResult(e); PopupNavigation.PopAsync(); }; PopupNavigation.PushAsync(new Rg.Plugins.Popup.Pages.PopupPage { Content = _dialogView }); return(cts.Task); }
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(); }; }