示例#1
0
        public void SetData(byte[] data)
        {
            MemoryStream mem = new MemoryStream(data);
            BinaryReader b   = new BinaryReader(mem);

            question = b.ReadString();
            hint     = b.ReadString();

            if (b.ReadBoolean())
            {
                MemoryStream temp = new MemoryStream();
                int          len  = b.ReadInt32();
                temp.Write(b.ReadBytes(len), 0, len);
                image = Image.FromStream(temp);
            }

            if (b.ReadBoolean())
            {
                int len = b.ReadInt32();
                example = new List <EpExample> ();
                for (int i = 0; i < len; i++)
                {
                    EpExample ex     = new EpExample();
                    int       lenlen = b.ReadInt32();
                    byte[]    dat    = b.ReadBytes(lenlen);
                    ex.SetData(dat);
                    example.Add(ex);
                }
            }

            qType     = ( QType )b.ReadInt32();
            themeType = ( ThemeType )b.ReadInt32();

            b.Close();
        }
示例#2
0
        private void frmPresent_Paint(object sender, PaintEventArgs e)
        {
            // 인덱스를 가져온다
            int tIn = ( int )eduMan.Question[qIndex].ThemeType;

            g.Clear(Color.White);

            // 배경 그림이 있다면 그린다
            if (eduMan.Theme.Image != null)
            {
                g.DrawImage(eduMan.Theme.Image, new Rectangle(0, 0, 800, 600),
                            new Rectangle(0, 0, eduMan.Theme.Image.Width, eduMan.Theme.Image.Height),
                            GraphicsUnit.Pixel);
            }

            // 제목을 출력한다
            g.DrawString(eduMan.Question[qIndex].Question, new Font(eduMan.Theme.TitleFont, eduMan.Theme.TitleFontSize),
                         new SolidBrush(eduMan.Theme.TitleColor), eduMan.Theme.Title[tIn]);

            // 힌트를 출력한다
            g.DrawString(eduMan.Question[qIndex].Hint, new Font(eduMan.Theme.HintFont, eduMan.Theme.HintFontSize),
                         new SolidBrush(eduMan.Theme.TitleColor), eduMan.Theme.Hint[tIn]);


            Font      font = new Font(eduMan.Theme.ExampleFont, eduMan.Theme.ExampleFontSize);
            Rectangle r    = eduMan.Theme.Example[tIn];

            // 테마 타입에 따라 보기를 다르게 그린다
            switch (eduMan.Question[qIndex].ThemeType)
            {
            case ThemeType.기본_테마_형식:
            {
                if (eduMan.Question[qIndex].QuestionType == QType.객관식)
                {
                    g.Clip = new Region(eduMan.Theme.Example[tIn]);

                    int idx = 0;
                    foreach (EpExample ex in eduMan.Question[qIndex].Examples)
                    {
                        Color clr = eduMan.Theme.ExampleColor;

                        if (eIndex == idx)
                        {
                            clr = Color.Red;
                        }

                        string fmt = String.Format("{0:0}. ", idx + 1);
                        g.DrawString(fmt + ex.Example, font, new SolidBrush(clr),
                                     new Rectangle(r.X, r.Y + (idx * eduMan.Theme.ExampleSpace), r.Width, 120));

                        idx++;
                    }

                    g.Clip = new Region();
                }
                else
                {
                    g.DrawRectangle(new Pen(eduMan.Theme.ExampleColor, 2), eduMan.Theme.Example[tIn]);
                    g.DrawString("주관식 문제입니다. 네모 안쪽을 클릭해주세요.", font,
                                 new SolidBrush(eduMan.Theme.ExampleColor), r);
                }
            }
            break;

            case ThemeType.보기가_그림인_테마:
            {
                if (eduMan.Question[qIndex].QuestionType == QType.객관식)
                {
                    g.Clip = new Region(eduMan.Theme.Example[tIn]);

                    for (int i = 0; i < eduMan.Question[qIndex].Examples.Count; i++)
                    {
                        EpExample ea   = eduMan.Question[qIndex].Examples[i];
                        Rectangle dest = new Rectangle();

                        if (i == 0 || i % 2 == 0)
                        {
                            dest = new Rectangle(
                                eduMan.Theme.Example[tIn].X,
                                eduMan.Theme.Example[tIn].Y + (eduMan.Theme.ImageExampleSize.Height +
                                                               eduMan.Theme.ImageExampleSpace) * (i / 2),
                                eduMan.Theme.ImageExampleSize.Width,
                                eduMan.Theme.ImageExampleSize.Height
                                );
                        }
                        else
                        {
                            dest = new Rectangle(
                                eduMan.Theme.Example[tIn].X + eduMan.Theme.ImageExampleSpace +
                                eduMan.Theme.ImageExampleSize.Width,
                                eduMan.Theme.Example[tIn].Y + (eduMan.Theme.ImageExampleSpace +
                                                               eduMan.Theme.ImageExampleSize.Height) * (i / 2),
                                eduMan.Theme.ImageExampleSize.Width,
                                eduMan.Theme.ImageExampleSize.Height
                                );
                        }

                        if (ea.Image != null)
                        {
                            g.DrawImage(ea.Image, dest, new Rectangle(0, 0, ea.Image.Width, ea.Image.Height),
                                        GraphicsUnit.Pixel);
                        }

                        if (eIndex == i)
                        {
                            g.DrawRectangle(new Pen(Color.Red, 2), dest);
                        }
                    }
                }
                else
                {
                    g.DrawRectangle(new Pen(eduMan.Theme.ExampleColor, 2), eduMan.Theme.Example[tIn]);
                    g.DrawString("주관식 문제입니다. 네모 안쪽을 클릭해주세요.", font,
                                 new SolidBrush(eduMan.Theme.ExampleColor), r);
                }

                g.Clip = new Region();
            }
            break;
            }

            // 이미지를 그린다.
            if (eduMan.Question[qIndex].Image != null)
            {
                Image img = eduMan.Question[qIndex].Image;
                g.DrawImage(img,
                            eduMan.Theme.ImageLocation, new Rectangle(0, 0, img.Width, img.Height),
                            GraphicsUnit.Pixel);
            }

            // 메시지박스를 띄운 상태일 경우 메시지박스를 그린다
            if (msgShow)
            {
                g.DrawImage(Resources.msgBack, backLoc);
                Point btnLoc = new Point(backLoc.X + Resources.msgBack.Width / 2 - Resources.msgButton.Width / 2,
                                         backLoc.Y + 270);
                g.DrawImage(((rollover) ? Resources.msgButtonDown : Resources.msgButton), btnLoc);

                Font msgFont = new Font("맑은 고딕", 24);
                g.DrawString(msgText, msgFont, new SolidBrush(Color.Black),
                             new Rectangle(
                                 backLoc.X + 40,
                                 backLoc.Y + 40,
                                 Resources.msgBack.Width - 80,
                                 Resources.msgBack.Height - 20));
                Font btnFont = new Font("맑은 고딕", 14);
                g.DrawString("OK", btnFont, new SolidBrush(Color.Black),
                             new PointF(
                                 btnLoc.X + Resources.msgButton.Width / 2 - (btnFont.GetHeight() * "OK".Length) / 2,
                                 btnLoc.Y + Resources.msgButton.Height / 2 - btnFont.GetHeight() / 2));
            }

            // 백 버퍼를 화면에 출력한다
            e.Graphics.DrawImage(backBuf, new Rectangle(0, 0, this.Width, this.Height),
                                 new Rectangle(0, 0, 800, 600), GraphicsUnit.Pixel);
        }