Ejemplo n.º 1
0
        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();
        }