예제 #1
0
        ObservableCollection <LevelItem> CreateLevels(string key, int enabledLevels)
        {
            var levels = new ObservableCollection <LevelItem>();

            for (var i = 0; i < MaxLevels; i++)
            {
                var level = new LevelItem(i);
                level.Name    = GetLevelNameFromLevelId(i);
                level.Enabled = (enabledLevels & (1 << i)) > 0;

                level.PropertyChanged += (sender, args) =>
                {
                    if (args.PropertyName != "Enabled")
                    {
                        return;
                    }

                    var levelItem = (LevelItem)sender;
                    var e         = new LevelItemChangedEventArgs(key, levelItem.LevelId, levelItem.Enabled);
                    OnLevelItemChanged(e);
                };

                levels.Add(level);
            }

            return(levels);
        }
예제 #2
0
        protected virtual void OnLevelItemChanged(LevelItemChangedEventArgs e)
        {
            var handler = LevelItemChanged;

            if (handler != null)
            {
                handler(this, e);
            }
        }