public CharacterRow(CharacterGroup group, CharacterContext context, uint min, uint max) : base(context.ServiceProvider) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (min >= max) { throw new ArgumentOutOfRangeException(nameof(min), $"{Resources.Exception_MinLessMax}: '{min} < {max}'"); } var itemList = new List <Character>(0x10); for (var i = 0u; i < itemList.Capacity; i++) { var item = new Character(this, context, i + min); itemList.Add(item); item.PropertyChanged += Item_PropertyChanged; } this.Group = group ?? throw new ArgumentOutOfRangeException(nameof(group)); this.Index = (min & 0xfffffff0) >> 4; this.Items = itemList.ToArray(); this.ActiveItems = itemList.Where(item => item.IsEnabled).ToArray(); this.IsEnabled = this.ActiveItems.Length > 0; }
public CharacterGroup(CharacterContext context, string name, uint min, uint max) : base(context.ServiceProvider) { this.context = context ?? throw new ArgumentNullException(nameof(context)); this.Name = name; this.Min = min; this.Max = max; this.Items = this.CreateItems(min, max); this.ActiveItems = this.Items.Where(item => item.IsEnabled).ToArray(); this.IsVisible = this.Items.Any(item => item.TestVisible()); }
public Character(CharacterRow row, CharacterContext context, uint id) : base(context.ServiceProvider) { this.context = context ?? throw new ArgumentNullException(nameof(context)); this.Row = row; this.ID = id; this.IsEnabled = this.context.Glyphs.ContainsKey(id); if (this.context.Glyphs.ContainsKey(id)) { this.glyph = this.context.Glyphs[id]; this.glyphMetrics = this.context.Glyphs[id].Metrics; } else { this.glyphMetrics.VerticalAdvance = this.context.Height; } this.context.Register(this); }
private static CharacterGroup[] CreateGroups(CharacterContext context, string name, uint min, uint max) { if (max - min <= 0xff) { return(new CharacterGroup[] { new CharacterGroup(context, name, min, max) }); } else { var groupList = new List <CharacterGroup>(); var index = 0; while (max - min > 0xff) { groupList.Add(new CharacterGroup(context, $"{name} {index++}", min, min + 0xff)); min += 0xff + 1; } if (max - min <= 0xff) { groupList.Add(new CharacterGroup(context, $"{name} {index++}", min, max)); } return(groupList.ToArray()); } }