예제 #1
0
        public IModule CreateModule()
        {
            DanmakuShowModule displayModule = new DanmakuShowModule();

            displayModule.Init(this);
            return(displayModule);
        }
예제 #2
0
        public DanmakuShowControl(DanmakuShowModule displayModule)
        {
            InitializeComponent();

            Module = displayModule;

            foreach (DanmakuShowConfig.DisplayFilterOptions filterOption in Enum.GetValues(typeof(DanmakuShowConfig.DisplayFilterOptions)))
            {
                bool initValue = true;
                if (displayModule.OptionDict.ContainsKey(filterOption))
                {
                    initValue = displayModule.OptionDict[filterOption];
                }
                else
                {
                    displayModule.OptionDict.Add(filterOption, initValue);
                }

                DescriptionAttribute[] attributes = (DescriptionAttribute[])filterOption
                                                    .GetType()
                                                    .GetField(filterOption.ToString())
                                                    .GetCustomAttributes(typeof(DescriptionAttribute), false);
                string description = attributes.Length > 0 ? attributes[0].Description : string.Empty;

                CheckBox checkBox = new CheckBox
                {
                    Content           = description,
                    IsChecked         = initValue,
                    Margin            = new Thickness(4),
                    VerticalAlignment = VerticalAlignment.Center,
                    Tag = filterOption
                };
                checkBox.Checked   += ShowOptionCkb_Checked;
                checkBox.Unchecked += ShowOptionCkb_Unchecked;
                OptionPanel.Children.Add(checkBox);
            }
        }