public IScoreBuilder <T> GetBuilder <T>(BaseScore score) { string builderType = score.GetType().Name + "Builder"; Type bt = Type.GetType("MediaPortal.Plugin.ScoreCenter." + builderType + "`1"); Type gbt = bt.MakeGenericType(typeof(T)); string name = gbt.Name; if (!m_builders.ContainsKey(name)) { m_builders[name] = (IScoreBuilder <T>)Activator.CreateInstance(gbt); } //return (IScoreBuilder<T>)Activator.CreateInstance(gbt); return((IScoreBuilder <T>)m_builders[name]); }
private void tsbApplySettings_Click(object sender, EventArgs e) { if (m_scoreSettings == null) { return; } if (tvwScores.SelectedNode == null || tvwScores.SelectedNode.Tag == null) { return; } BaseScore score = tvwScores.SelectedNode.Tag as BaseScore; if (score != m_scoreSettings && score.GetType() == m_scoreSettings.GetType()) { score.ApplySettings(m_scoreSettings); BaseScoreEditor editor = GetEditor(); if (editor != null) { editor.LoadScore(score, m_center); } } }
public string GetParserType(BaseScore score) { return(score.GetType().Name + "Parser"); }
public string GetEditorType(BaseScore score) { return(score.GetType().Name + "Editor"); }
private void tvwScores_AfterSelect(object sender, TreeViewEventArgs e) { if (tvwScores.SelectedNode == null) { return; } // always clear ClearIcon(); BaseScore bscore = tvwScores.SelectedNode.Tag as BaseScore; BaseScoreEditor prevEditor = GetEditor(); BaseScoreEditor editor = null; string editorType = ScoreFactory.Instance.GetEditorType(bscore); if (prevEditor != null) { if (editorType != prevEditor.GetType().Name) { pnlEditor.Controls.Clear(); prevEditor.SetIcon -= new EventHandler <BaseScoreEditor.SetIconIconEventArgs>(editor_SetIcon); (prevEditor as Control).Dispose(); } else { editor = prevEditor; } } if (editor == null) { var zeditor = ScoreFactory.Instance.CreateEditor(editorType, pnlTest); zeditor.SetIcon += new EventHandler <BaseScoreEditor.SetIconIconEventArgs>(editor_SetIcon); pnlEditor.Controls.Add(zeditor); zeditor.Dock = DockStyle.Fill; editor = zeditor as BaseScoreEditor; } editor.LoadScore(bscore, m_center); SetIcon(bscore.Image); ClearTestGrid(); btnTest.Enabled = editor.HasTest; tsbMoveUp.Enabled = tvwScores.SelectedNode.PrevNode != null; tsbMoveDown.Enabled = tvwScores.SelectedNode.NextNode != null; tsbMoveBack.Enabled = tvwScores.SelectedNode.Parent != null; tsbMoveRight.Enabled = tsbMoveUp.Enabled; tsbCopySettings.Enabled = bscore.CanApplySettings(); tsbApplySettings.Enabled = tsbCopySettings.Enabled && m_scoreSettings != null && bscore.GetType() == m_scoreSettings.GetType(); }