Example #1
0
        //TODO написать парсер, чтобы читать из файла
        //ColorScheme должен будет передавать строку из файла для распарсивания
        public static ItemColorSchemeEntry Parse(string line)
        {
            ItemColorSchemeEntry ret = ItemColorSchemeEntry.SystemDefault;

            //
            //[category][space][color1][space][color2][space]...[color8][space][mask1][;][mask2][;]...
            //
            try
            {
                string[] items1 = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                ret.Category = (ItemCategory)int.Parse(items1[0]);
                ItemColorState i_state = new ItemColorState();

                string hex_prefix = "0x";

                i_state.DefaultState         = ItemColors.Create(Color.FromArgb(int.Parse(items1[1].Replace(hex_prefix, string.Empty), System.Globalization.NumberStyles.HexNumber)), Color.FromArgb(int.Parse(items1[2].Replace(hex_prefix, string.Empty), System.Globalization.NumberStyles.HexNumber)));
                i_state.FocusedState         = ItemColors.Create(Color.FromArgb(int.Parse(items1[3].Replace(hex_prefix, string.Empty), System.Globalization.NumberStyles.HexNumber)), Color.FromArgb(int.Parse(items1[4].Replace(hex_prefix, string.Empty), System.Globalization.NumberStyles.HexNumber)));
                i_state.SelectedState        = ItemColors.Create(Color.FromArgb(int.Parse(items1[5].Replace(hex_prefix, string.Empty), System.Globalization.NumberStyles.HexNumber)), Color.FromArgb(int.Parse(items1[6].Replace(hex_prefix, string.Empty), System.Globalization.NumberStyles.HexNumber)));
                i_state.SelectedFocusedState = ItemColors.Create(Color.FromArgb(int.Parse(items1[7].Replace(hex_prefix, string.Empty), System.Globalization.NumberStyles.HexNumber)), Color.FromArgb(int.Parse(items1[8].Replace(hex_prefix, string.Empty), System.Globalization.NumberStyles.HexNumber)));
                string[] masks = items1[9].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                ret.ItemColorState = i_state;
                ret.Masks          = masks;
            }
            catch (Exception)
            {
            }

            return(ret);
        }
Example #2
0
        public ItemColors GetColors(string item_name, ItemState state, ItemCategory category)
        {
            ItemColorState finded = ItemColorState.SystemDefault;
            bool           match  = false;

            //Color c = Color.Black;


            foreach (ItemColorSchemeEntry entry in internal_list)
            {
                if ((entry.Category & category) == category)
                {
                    match = false;
                    foreach (string mask in entry.Masks)
                    {
                        if (Wildcard.Match(mask, item_name, false))
                        {
                            finded = entry.ItemColorState;
                            match  = true;
                            break;
                        }
                    }
                    if (match)
                    {
                        break;
                    }
                }
            }

            switch (state)
            {
            case ItemState.None:
                return(finded.DefaultState);

            case ItemState.Focused | ItemState.Selected:
                return(finded.SelectedFocusedState);

            case ItemState.Focused:
                return(finded.FocusedState);

            case ItemState.Selected:
                return(finded.SelectedState);

            default:
                return(finded.DefaultState);
            }
        }