Esempio n. 1
0
 public void Dispose()
 {
     OK.Clicked         -= OK_Clicked;
     Cancel.Clicked     -= Cancel_Clicked;
     red.ValueChanged   -= Slider_ValueChanged;
     green.ValueChanged -= Slider_ValueChanged;
     blue.ValueChanged  -= Slider_ValueChanged;
     settings            = null;
     BindingContext      = null;
 }
Esempio n. 2
0
        public async Task <Color> showDialog(Layout <View> parent, ColorPickerSettings settings = null)
        {
            lock (colorLock)
            {
                if (currentlyCalculating)
                {
                    return(settings == null ? Color.Black : settings.defaultColor);
                }

                currentlyCalculating = true;
            }

            if (settings != null)
            {
                this.settings = settings;
                red.Value     = settings.selectedColor.R;
                green.Value   = settings.selectedColor.G;
                blue.Value    = settings.selectedColor.B;
                alpha.Value   = settings.selectedColor.A;
                hex.Text      = settings.selectedColor.ToHex();
            }
            else
            {
                this.settings = new ColorPickerSettings();
                alpha.Value   = 1;
                hex.Text      = this.settings.selectedColor.ToHex();
            }

            lock (colorLock)
            {
                currentlyCalculating = false;
            }

            Color color;

            BindingContext = this.settings;

            if (parent is Grid grid)
            {
                grid.Children.Add(this, 0, grid.ColumnDefinitions.Count == 0 ? 1 : grid.ColumnDefinitions.Count, 0, grid.RowDefinitions.Count == 0 ? 1 : grid.RowDefinitions.Count);
                color = await waiter.Task;
                grid.Children.Remove(this);
            }
            else
            {
                parent.Children.Add(this);
                color = await waiter.Task;
                parent.Children.Remove(this);
            }

            return(color);
        }