private ObservableCollection <ColorInfo> Load_Colors()
        {
            var        result     = new ObservableCollection <ColorInfo>();
            EntryCodes entryCodes = new EntryCodes();

            foreach (var meaning in Enum.GetValues(entryCodes.GetType()))
            {
                result.Add(new ColorInfo
                {
                    Mean = GetCode.GetCodeMeaning((EntryCodes)meaning),
                    Name = GetColor.GetColorByCode((EntryCodes)meaning).Name
                });
            }
            return(result);
        }
예제 #2
0
        private List <EntryModel> JoinSameEntries()
        {
            List <EntryModel> newModels = new List <EntryModel>(_entryModels.Count);
            List <EntryModel> entries   = new List <EntryModel>(_entryModels.Count);

            for (int i = 0; i < _entryModels.Count; i++)
            {
                EntryModel currentModel = _entryModels[i];
                for (int j = i + 1; j < _entryModels.Count; j++)
                {
                    if (_entryModels[i].StartIndex == _entryModels[j].StartIndex)
                    {
                        entries.Add(_entryModels[j]);
                    }
                    else
                    {
                        break;
                    }
                }
                if (entries.Count > 0)
                {
                    int r = currentModel.TextColor.R,
                        g = currentModel.TextColor.G,
                        b = currentModel.TextColor.B;
                    StringBuilder newMeaning = new StringBuilder(GetCode.GetCodeMeaning(GetCode.GetCodeByColor(currentModel.TextColor)));
                    foreach (var entry in entries)
                    {
                        newMeaning.Append($", {GetCode.GetCodeMeaning(GetCode.GetCodeByColor(entry.TextColor))}");
                        r += entry.TextColor.R;
                        g += entry.TextColor.G;
                        b += entry.TextColor.B;
                    }
                    r %= 255;
                    g %= 255;
                    b %= 255;
                    currentModel.TextColor = Color.FromArgb(r, g, b);
                    NewColorCreated?.Invoke(currentModel.TextColor, newMeaning.ToString());
                    i += entries.Count;
                }
                newModels.Add(currentModel);
                entries.Clear();
            }
            return(newModels);
        }