Exemplo n.º 1
0
 public IEnumerable <BaseScore> ReadChildren(BaseScore parent)
 {
     if (parent != null && parent.IsVirtualFolder() && !parent.IsVirtualResolved())
     {
         IList <BaseScore> scores = parent.GetVirtualScores(this.Parameters);
         parent.SetVirtualResolved();
         this.Scores.Items = this.Scores.Items.Concat(scores).ToArray();
         return(scores);
     }
     else
     {
         string id = parent == null ? "" : parent.Id;
         return(this.Scores.Items.Where(score => score.enable && score.Parent == id));
     }
 }
Exemplo n.º 2
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            pnlTest.Controls.Clear();
            pnlTest.Refresh();

            try
            {
                this.Cursor = Cursors.WaitCursor;

                BaseScoreEditor editor = GetEditor();
                if (editor == null)
                {
                    return;
                }

                Type scoreType = editor.GetScoreType();
                ScoreFactory.Instance.CacheExpiration = m_center.Setup.CacheExpiration;
                BaseScore score = ScoreFactory.Instance.CreateScore(scoreType);
                if (!editor.SaveScore(ref score))
                {
                    return;
                }

                if (score.IsVirtualFolder())
                {
                    var zz = score.GetVirtualScores(m_center.Parameters);
                    using (TestScoreSelector dlg = new TestScoreSelector(zz))
                    {
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            score = dlg.SelectedScore;
                        }
                    }
                }

                // read and parse the score
                string[][] lines = ScoreFactory.Parse(score, ckxReload.Checked, m_center.Parameters);
                if (lines == null)
                {
                    return;
                }

                IScoreBuilder <Control> bld = ScoreFactory.Instance.GetBuilder <Control>(score);
                bld.Styles      = m_center.Styles.ToList().AsReadOnly();
                bld.UseAltColor = m_center.Setup.UseAltColor;

                int fh = pnlTest.Font.Height;
                int fw = (int)pnlTest.Font.SizeInPoints;
                bld.SetFont("", m_center.Setup.DefaultFontColor, m_center.Setup.AltFontColor, 14, fw, fh);

                bool overRight = false;
                bool overDown = false;
                int  lineNumber, colNumber;

                pnlTest.BackColor = Color.FromArgb(m_center.Setup.DefaultSkinColor);

                IList <Control> controls = bld.Build(score, lines,
                                                     0, 0,
                                                     0, 0, pnlTest.Width, 10000,
                                                     this.CreateControl,
                                                     out overRight, out overDown, out lineNumber, out colNumber);
                if (controls == null)
                {
                    return;
                }

                pnlTest.Tag = lines;

                pnlTest.SuspendLayout();
                pnlTest.Controls.AddRange(controls.Cast <Control>().ToArray());
            }
            catch (Exception exc)
            {
                MessageBox.Show(Tools.GetExceptionMessage(exc), Properties.Resources.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pnlTest.ResumeLayout();
                this.Cursor = Cursors.Default;
            }
        }