예제 #1
0
 private void RemoveAllColors()
 {
     while (ColorsHistory.Count > 0)
     {
         ColorsHistory.RemoveAt(0);
     }
 }
예제 #2
0
        private void DeleteSelectedColor()
        {
            // select new color on the same index if possible, otherwise the last one
            var indexToSelect = SelectedColorIndex == ColorsHistory.Count - 1 ? ColorsHistory.Count - 2 : SelectedColorIndex;

            ColorsHistory.RemoveAt(SelectedColorIndex);
            SelectedColorIndex = indexToSelect;
        }
예제 #3
0
        private void DeleteSelectedColor()
        {
            // select new color on the same index if possible, otherwise the last one
            var indexToSelect = SelectedColorIndex == ColorsHistory.Count - 1 ? ColorsHistory.Count - 2 : SelectedColorIndex;

            ColorsHistory.RemoveAt(SelectedColorIndex);
            SelectedColorIndex = indexToSelect;
            SessionEventHelper.Event.EditorHistoryColorRemoved = true;
        }
        private void DeleteSelectedColors(object selectedColors)
        {
            var colorsToRemove  = ((IList)selectedColors).OfType <Color>().ToList();
            var indicesToRemove = colorsToRemove.Select(color => ColorsHistory.IndexOf(color)).ToList();

            foreach (var color in colorsToRemove)
            {
                ColorsHistory.Remove(color);
            }

            SelectedColorIndex = ComputeWhichIndexToSelectAfterDeletion(colorsToRemove.Count + ColorsHistory.Count, indicesToRemove);
            SessionEventHelper.Event.EditorHistoryColorRemoved = true;
        }
예제 #5
0
        public ColorEditorViewModel(IUserSettings userSettings)
        {
            OpenColorPickerCommand = new RelayCommand(() => OpenColorPickerRequested?.Invoke(this, EventArgs.Empty));
            RemoveColorCommand     = new RelayCommand(DeleteSelectedColor);

            SelectedColorChangedCommand = new RelayCommand((newColor) =>
            {
                ColorsHistory.Insert(0, (Color)newColor);
                SelectedColorIndex = 0;
            });
            ColorsHistory.CollectionChanged += ColorsHistory_CollectionChanged;
            _userSettings = userSettings;
            SetupAllColorRepresentations();
            SetupAvailableColorRepresentations();
        }
예제 #6
0
        public void Initialize()
        {
            _initializing = true;

            ColorsHistory.Clear();

            foreach (var item in _userSettings.ColorHistory)
            {
                var parts = item.Split('|');
                ColorsHistory.Add(new Color()
                {
                    A = byte.Parse(parts[0], NumberStyles.Integer, CultureInfo.InvariantCulture),
                    R = byte.Parse(parts[1], NumberStyles.Integer, CultureInfo.InvariantCulture),
                    G = byte.Parse(parts[2], NumberStyles.Integer, CultureInfo.InvariantCulture),
                    B = byte.Parse(parts[3], NumberStyles.Integer, CultureInfo.InvariantCulture),
                });
                SelectedColorIndex = 0;
            }

            _initializing = false;
        }
        public ColorEditorViewModel(IUserSettings userSettings)
        {
            OpenColorPickerCommand = new RelayCommand(() => OpenColorPickerRequested?.Invoke(this, EventArgs.Empty));
            OpenSettingsCommand    = new RelayCommand(() => OpenSettingsRequested?.Invoke(this, EventArgs.Empty));

            RemoveColorsCommand = new RelayCommand(DeleteSelectedColors);
            ExportColorsGroupedByColorCommand  = new RelayCommand(ExportSelectedColorsByColor);
            ExportColorsGroupedByFormatCommand = new RelayCommand(ExportSelectedColorsByFormat);
            SelectedColorChangedCommand        = new RelayCommand((newColor) =>
            {
                if (ColorsHistory.Contains((Color)newColor))
                {
                    ColorsHistory.Remove((Color)newColor);
                }

                ColorsHistory.Insert(0, (Color)newColor);
                SelectedColorIndex = 0;
            });
            ColorsHistory.CollectionChanged += ColorsHistory_CollectionChanged;
            _userSettings = userSettings;
            SetupAllColorRepresentations();
            SetupAvailableColorRepresentations();
        }