Example #1
0
        /// <summary>
        /// Add color to the unique list.
        /// </summary>
        private void SaveColor()
        {
            // Don't add the new color if color already exists.
            var isExist = UniqueColorsList.FirstOrDefault(x => x.UniqueColor.Equals(SelectedColorcode));

            if (isExist != null)
            {
                return;
            }

            if (!mIsEdit)
            {
                UniqueColorsList.Add(new UniqueColors {
                    UniqueColor = mSelectedColorCode
                });
            }
            else
            {
                mIsEdit = false;

                // Replacing the old value with the new.
                var item = UniqueColorsList.FirstOrDefault(i => i.UniqueColor.Equals(SelectedUniqueColor));
                if (item == null)
                {
                    return;
                }
                item.UniqueColor    = SelectedColorcode;
                SelectedUniqueColor = SelectedColorcode;
            }

            File.WriteAllText(JsonUnique, JsonConvert.SerializeObject(UniqueColorsList, Formatting.Indented));
        }
Example #2
0
        /// <summary>
        /// Remove the selected unique color.
        /// </summary>
        private void RemoveColor()
        {
            if (string.IsNullOrEmpty(SelectedUniqueColor))
            {
                return;
            }

            var itemRemove = UniqueColorsList.FirstOrDefault(item => item.UniqueColor.Equals(SelectedUniqueColor));

            if (itemRemove == null)
            {
                return;
            }

            UniqueColorsList.Remove(itemRemove);
            File.WriteAllText(JsonUnique, JsonConvert.SerializeObject(UniqueColorsList, Formatting.Indented));

            SelectedUniqueColor = "#ffffff";
        }