Example #1
0
 public ScoreBuilderLogger(
     ILogger <IScoreBuilder <IEnumerable <int>, int> > logger,
     IScoreBuilder <IEnumerable <int>, int> scoreBuilder)
 {
     _logger       = logger ?? throw new ArgumentNullException("logger");
     _scoreBuilder = scoreBuilder ?? throw new ArgumentNullException("scoreBuilder");
 }
Example #2
0
 public void Initialize()
 {
     _scoreBuilder = new ScoreBuilder();
 }
Example #3
0
        /// <summary>
        /// Create a grid.
        /// </summary>
        /// <param name="labels">The labels to fill the grid with.</param>
        /// <param name="score">The Score to display.</param>
        /// <param name="startLine">The first line to display.</param>
        private void CreateGrid(string[][] labels, BaseScore score, int startLine, int startColumn)
        {
            bool overRight  = false;
            bool overDown   = false;
            int  lineNumber = 0;
            int  colNumber  = 0;

            IScoreBuilder <GUIControl> bld = ScoreFactory.Instance.GetBuilder <GUIControl>(score);

            bld.Styles      = m_center.Styles.ToList().AsReadOnly();
            bld.UseAltColor = m_center.Setup.UseAltColor;

            GUIFont font = GUIFontManager.GetFont(tbxDetails.FontName);
            int     fontSize = font.FontSize;
            int     charHeight = 0, charWidth = 0;

            GetCharFonSize(fontSize, ref charWidth, ref charHeight);
            bld.SetFont(tbxDetails.FontName, tbxDetails.TextColor, tbxDetails.ColourDiffuse, fontSize, charWidth, charHeight);

            // add controls to screen
            try
            {
                m_scoreGroup.Visibility = System.Windows.Visibility.Hidden;
                IList <GUIControl> controls = bld.Build(score, labels,
                                                        startLine, startColumn,
                                                        tbxDetails.XPosition, tbxDetails.YPosition, tbxDetails.Width, tbxDetails.Height,
                                                        this.CreateControl,
                                                        out overRight, out overDown, out lineNumber, out colNumber);

                foreach (GUIControl c in controls)
                {
                    c.AllocResources();
                    m_scoreGroup.AddControl(c);
                }
            }
            catch (Exception exc)
            {
                Tools.LogError(">>>>>>> Error in Create Grid", exc);
            }
            finally
            {
                m_scoreGroup.Visibility = System.Windows.Visibility.Visible;
            }

            #region Set for Next page
            if (overRight)
            {
                // keep current line
                m_currentColumn += tbxDetails.Width;
                ShowNextButton(true);
            }
            else
            {
                // reset current column
                m_currentColumn = 0;

                if (overDown)
                {
                    m_currentLine = lineNumber - 1;
                    ShowNextButton(true);
                }
                else
                {
                    // no more pages
                    m_currentLine = 0;
                }
            }
            #endregion
        }
 public ScoreCard(IScoreConverter <string, IEnumerable <int> > converter, IScoreBuilder <IEnumerable <int>, int> scoreBuilder)
 {
     _converter    = converter ?? throw new ArgumentNullException("converter");
     _scoreBuilder = scoreBuilder ?? throw new ArgumentNullException("scoreBuilder");
 }
Example #5
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;
            }
        }