Exemplo n.º 1
0
        public void InitializeTextOnlyColorModel(ITextOnlyColorModel colorModel, bool silentSet)
        {
            _altColorModel = colorModel;

            if (!silentSet)
            {
                // now update components
                var components = _altColorModel.GetComponentsForColor(_currentColor, Altaxo.Settings.GuiCulture.Instance);

                for (int i = 0; i < components.Length; ++i)
                {
                    _guiAltComponents[i].Text = components[i];
                }

                // update labels
                var labels = _altColorModel.GetNamesOfComponents();
                for (int i = 0; i < labels.Length; ++i)
                {
                    _guiLabelForAltComponents[i].Content = labels[i];
                }

                // update visibility
                for (int i = 0; i < 4; ++i)
                {
                    _guiLabelForAltComponents[i].Visibility = _guiAltComponents[i].Visibility = i < components.Length ? Visibility.Visible : Visibility.Hidden;
                }
            }
        }
Exemplo n.º 2
0
        public void ChangeCurrentColor(AxoColor newColor, bool update1D, bool update2D, bool updateComponents, bool updateAltComponents)
        {
            _currentColor = newColor;

            if (update1D || update2D)
            {
                var(pos1D, pos2D) = _colorModel.GetRelativePositionsFor1Dand2DColorSurfaceFromColor(_currentColor);

                _gui1DColorControl.SelectionRectangleRelativePositionChanged -= Eh1DColorControl_ValueChanged;
                _gui2DColorControl.SelectionRectangleRelativePositionChanged -= Eh2DColorControl_ValueChanged;

                _gui1DColorControl.SelectionRectangleRelativePosition = pos1D;
                _gui2DColorControl.SelectionRectangleRelativePosition = pos2D;

                _gui1DColorControl.SelectionRectangleRelativePositionChanged += Eh1DColorControl_ValueChanged;
                _gui2DColorControl.SelectionRectangleRelativePositionChanged += Eh2DColorControl_ValueChanged;
            }

            if (updateComponents)
            {
                // now calculate components
                var components = _colorModel.GetComponentsForColor(_currentColor);

                UpdateComponentValues(() =>
                {
                    for (int i = 0; i < components.Length; ++i)
                    {
                        _guiComponents[i].Value = (decimal)components[i];
                    }
                }
                                      );
            }

            if (updateAltComponents)
            {
                // update alternative components
                var altComponents = _altColorModel.GetComponentsForColor(_currentColor, Altaxo.Settings.GuiCulture.Instance);
                for (int i = 0; i < altComponents.Length; ++i)
                {
                    _guiAltComponents[i].Text = altComponents[i];
                }
            }

            CurrentColorChanged?.Invoke(_currentColor);
        }
Exemplo n.º 3
0
        public void ChangeCurrentColor(AxoColor newColor, bool updateCircle, bool updateVariations, bool updateComponents, bool updateAltComponents)
        {
            _currentColor = newColor;

            if (updateCircle)
            {
                _guiColorCircleSurface.SetHueBaseValue(_currentColor.GetHue(), false);
            }

            if (updateComponents)
            {
                // now calculate components
                var components = _colorModel.GetComponentsForColor(_currentColor);

                UpdateComponentValues(() =>
                {
                    for (int i = 0; i < components.Length; ++i)
                    {
                        _guiComponents[i].Value = (decimal)components[i];
                    }

                    if (_colorModel.IsUsingByteComponents)
                    {
                        _guiAlphaValue.Value = _currentColor.A;
                    }
                    else
                    {
                        _guiAlphaValue.Value = (decimal)_currentColor.ScA;
                    }
                }
                                      );
            }

            if (updateAltComponents)
            {
                // update alternative components
                var altComponents = _altColorModel.GetComponentsForColor(_currentColor, Altaxo.Settings.GuiCulture.Instance);
                for (int i = 0; i < altComponents.Length; ++i)
                {
                    _guiAltComponents[i].Text = altComponents[i];
                }
            }

            CurrentColorChanged?.Invoke(_currentColor);
        }