Пример #1
0
        public void CreateEmptyScore()
        {
            ScoreWriter sw  = new ScoreWriter(22, 3, false, 6, false);
            Image       img = sw.RenderPage(0);

            img.Save("c:\\tmp\\myScore.bmp");
            Assert.IsNotNull(img);
        }
Пример #2
0
 private void LoadImages()
 {
     using (var sw = new ScoreWriter(score))
     {
         Size   musicRect  = new Size(sw.ScoreWidthPixels + 58, sw.ScoreHeightPixels + 80);
         double pageAspect = musicRect.Width
                             / (double)musicRect.Height;
         double pbxAspect = pbxScore.ClientSize.Width
                            / (double)pbxScore.ClientSize.Height;
         Rectangle content = Rectangle.Empty;
         if (pageAspect < pbxAspect)
         {
             double scale = pbxScore.ClientSize.Height
                            / (double)musicRect.Height;
             content.Width  = (int)(scale * musicRect.Width);
             content.Height = pbxScore.ClientSize.Height;
             content.X      = (pbxScore.ClientSize.Width - content.Width) / 2;
             content.Y      = 0;
         }
         else
         {
             double scale = pbxScore.ClientSize.Width
                            / (double)musicRect.Width;
             content.Width  = pbxScore.ClientSize.Width;
             content.Height = (int)(scale * musicRect.Height);
             content.X      = 0;
             content.Y      = (pbxScore.ClientSize.Height - content.Height) / 2;
         }
         var  src       = new Rectangle(Point.Empty, musicRect);
         bool musicPage = false;
         foreach (var page in sw.PageImages)
         {
             Bitmap bmp = new Bitmap
                              (pbxScore.ClientSize.Width, pbxScore.ClientSize.Height);
             using (var g = Graphics.FromImage(bmp))
             {
                 g.FillRectangle(Brushes.Gray, 0, 0, bmp.Width, bmp.Height);
                 g.SmoothingMode      = SmoothingMode.HighQuality;
                 g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                 g.CompositingQuality = CompositingQuality.HighQuality;
                 if (musicPage)
                 {
                     g.DrawImage(page, content, src, GraphicsUnit.Pixel);
                 }
                 else
                 {
                     g.DrawImage(page, content);
                     musicPage = true;
                 }
             }
             pageImages.Items.Add(bmp);
         }
     }
     if (pageImages.Items.Count > 0)
     {
         pbxScore.Image = pageImages.Items[0];
     }
 }
 private void Awake()
 {
     if (_instance != null)
     {
         Destroy(this);
     }
     else
     {
         _instance = this;
     }
 }
Пример #4
0
        public Game(int boardHeight = 20, int boardWidth = 10)
        {
            _inputHandler = new InputHandler(this);
            CurrentBoard  = new Board(boardWidth, boardHeight);
            var bricks = typeof(Brick).Assembly.GetTypes()
                         .Where(t => t.IsSubclassOf(typeof(Brick)))
                         .Select(t => (Brick)Activator.CreateInstance(t));

            _allAvailableBricks = bricks.ToList();
            _scoreWriter        = new ScoreWriter();
        }
Пример #5
0
        public void CreateOddBarScore()
        {
            ScoreFactory sf    = new ScoreFactory();
            IScore       score = sf.CreateScore();

            score.Measures.Add(sf.CreateMeasure(4, false));
            score.Measures.Add(sf.CreateMeasure(3, false));
            score.Measures.Add(sf.CreateMeasure(4, false));
            score.Measures.Add(sf.CreateMeasure(3, false));
            score.Measures.Add(sf.CreateMeasure(3, false));
            score.Measures.Add(sf.CreateMeasure(4, false));
            ScoreWriter sw  = new ScoreWriter(score, 6);
            Image       img = sw.RenderPage(0);

            img.Save("c:\\tmp\\varBarScore.bmp");
            Assert.IsNotNull(img);
        }
Пример #6
0
        public void CreateScoreWithFlats()
        {
            ScoreFactory sf    = new ScoreFactory();
            IScore       score = sf.CreateScore(true);

            score.Measures.Add(sf.CreateMeasure(4, false));
            score.Measures.Add(sf.CreateMeasure(3, false));
            score.Measures[0].Notes.Add(sf.CreateNote(0, 13, 4));
            score.Measures[0].Notes.Add(sf.CreateNote(2, 14, 4));
            score.Measures[0].Notes.Add(sf.CreateNote(4, 15, 4));
            score.Measures[0].Notes.Add(sf.CreateNote(14, 39, 4));
            score.Measures[0].Notes.Add(sf.CreateNote(14, 40, 4));
            score.Measures[1].Notes.Add(sf.CreateNote(0, 42, 4));
            ScoreWriter sw  = new ScoreWriter(score, 6);
            Image       img = sw.RenderPage(0);

            img.Save("c:\\tmp\\flatScore.bmp");
            Assert.IsNotNull(img);
        }
Пример #7
0
        public void Setup()
        {
            _mockWriter = Substitute.For <IStreamWriter>();

            _sut = new ScoreWriter(_mockWriter);
        }
Пример #8
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            double total = Options.Students.Count;
            double count = 0;

            _worker.ReportProgress(0);

            #region 快取資料
            DataCache cache = new DataCache(Options);
            #endregion

            DocumentBuilder templateBuilder = new DocumentBuilder(_template);

            #region 取得學生服務學習時數

            // 取得學生服務學習時數
            Global._SRDict.Clear();
            List <string> sidList = (from data in Options.Students select data.ID).ToList();
            Global._SRDict = Utility.GetServiceLearningDetail(sidList, Options.SchoolYear, Options.Semester);

            //2018.09.16 [ischoolKingdom] Vicky依據[05-02][02]學期成績證明單 服務學習時數顯示處理 項目,新增服務學習學年累計時數。
            Global._SRDict_yrsum = Utility.GetServiceLearningDetail(sidList, Options.SchoolYear);
            #endregion

            #region 節權數顯示
            string pcDisplay   = string.Empty;
            bool   printPeriod = Config.GetBoolean("列印節數", true);
            bool   printCredit = Config.GetBoolean("列印權數", false);
            if (printPeriod && printCredit)
            {
                pcDisplay = "節/權數";
            }
            else if (printPeriod)
            {
                pcDisplay = "節數";
            }
            else if (printCredit)
            {
                pcDisplay = "權數";
            }

            while (templateBuilder.MoveToMergeField("節權數"))
            {
                templateBuilder.Write(pcDisplay);
            }
            #endregion

            #region 產生
            BasicInfoWriter basicIndoWriter = new BasicInfoWriter();
            ScoreWriter     scoreWriter     = new ScoreWriter();
            MoralWriter     moralWriter     = new MoralWriter();
            AssnScoreWriter assnScoreWriter = new AssnScoreWriter();

            foreach (JHStudentRecord student in Options.Students)
            {
                count++;

                Document each = (Document)_template.Clone();

                //基本資料
                basicIndoWriter.Student     = student;
                basicIndoWriter.HistoryItem = cache.GetSemesterHistoryItem(student.ID);
                basicIndoWriter.Write(each);

                //學期成績 & 學習領域文字
                scoreWriter.SemesterScoreRecord = cache.GetSemesterScore(student.ID);
                scoreWriter.Writer(each);

                //德行成績
                moralWriter.AutoSummaryRecord = cache.GetAutoSummary(student.ID);
                moralWriter.Writer(each);

                if (Global.Params["Mode"] == "KaoHsiung")
                {
                    //社團活動
                    assnScoreWriter.Score = cache.GetAssnScore(student.ID);
                    assnScoreWriter.Writer(each);
                }

                foreach (Section sec in each.Sections)
                {
                    _doc.Sections.Add(_doc.ImportNode(sec, true));
                }

                _worker.ReportProgress((int)(count * 100f / total));
            }

            OutsideFieldWriter ofWriter = new OutsideFieldWriter(Options);
            ofWriter.Write(_doc);
            #endregion
        }
Пример #9
0
 // Use this for initialization
 void Start()
 {
     score = scoreboard.GetComponent <ScoreWriter> ();
     System.Random r = new System.Random();
 }