コード例 #1
0
ファイル: layoutEditor.cs プロジェクト: skaulana/eflash
        /// <summary>
        /// Applies a template into this flashcard
        /// </summary>
        /// <param name="template">Template to use</param>
        public void loadTemplate(Template template)
        {
            Card card = new Card("", ProfileManager.getCurrentUserID());

            if (currentCard.cardID == -1)
            {
                card.cardID = NEW_TEMPLATE_CARD;
            }
            else
            {
                card.cardID = currentCard.cardID;
            }

            eObject curEObj;
            TemplateObject curObj;
            // Fill the sides with objects
            for (int i = 0; i < template.objects.Count; i++)
            {
                curObj = template.objects[i];
                curEObj = new eObject(-1, curObj.side, curObj.type, curObj.x1, curObj.x2, curObj.y1, curObj.y2, curObj.quizType + "noFile.txt");
                card.eObjectList.Add(curEObj);
            }

            if (deck.cardList.Count == 0)
            {
                deck.cardList.Add(card);
                setFlashcard(card, 0);
            }
            else if (currentCard.index == -1)
            {
                deck.cardList.Add(card);
                setFlashcard(card, deck.cardList.Count - 1);
            }
            else
            {
                //deck.cardList[currentCard.index] = card;
                setFlashcard(card, currentCard.index);
            }

            templateChanged = true;
            changed = false;
            promptAtTemplateChange = false;
        }
コード例 #2
0
ファイル: templateSelector.cs プロジェクト: skaulana/eflash
        private Bitmap makeImage(Template template)
        {
            Bitmap bmp;

            Panel panel = new Panel();
            Panel panel0 = new Panel();
            Panel panel1 = new Panel();
            Label label0 = new Label();
            Label label1 = new Label();

            panel.Size = new Size(OBJ_WIDTH, OBJ_HEIGHT);
            panel.BorderStyle = BorderStyle.None;
            panel.BackColor = Color.Black;
            panel.Margin = new Padding(0, 0, 0, 0);
            panel.Location = new Point(0, 0);

            panel0.Size = new Size(OBJ_WIDTH, OBJ_HEIGHT);
            panel0.BorderStyle = BorderStyle.None;
            panel0.BackColor = Color.White;
            panel0.Margin = new Padding(0, 0, 0, 0);
            panel0.Location = new Point(0, 0);

            panel1.Size = new Size(OBJ_WIDTH, OBJ_HEIGHT);
            panel1.BorderStyle = BorderStyle.None;
            panel1.BackColor = Color.White;
            panel1.Margin = new Padding(0, 0, 0, 0);
            panel1.Location = new Point(0, 0);

            label0.Margin = new Padding(0, 0, 0, 0);
            label0.Padding = new Padding(0, 0, 0, 0);
            label0.Location = new Point(1, 1);
            label0.Size = new Size(10, 10);
            label0.BackColor = Color.White;
            label0.Font = new Font(FontFamily.GenericSansSerif, 6);
            label0.Text = "1";

            label1.Margin = new Padding(0, 0, 0, 0);
            label1.Padding = new Padding(0, 0, 0, 0);
            label1.Location = new Point(1, 1);
            label1.Size = new Size(10, 10);
            label1.BackColor = Color.White;
            label1.Font = new Font(FontFamily.GenericSansSerif, 6);
            label1.Text = "2";

            Panel curBmpObj;
            bool hasSide2 = false;

            foreach (TemplateObject curObj in template.objects)
            {
                curBmpObj = new Panel();
                if (curObj.quizType == Constant.answerPrefix)
                {
                    curBmpObj.BackColor = Color.Green;
                }
                else if (curObj.quizType == Constant.questionPrefix)
                {
                    curBmpObj.BackColor = Color.Red;
                }
                else
                {
                    curBmpObj.BackColor = Color.Gray;
                }
                curBmpObj.BorderStyle = BorderStyle.FixedSingle;
                curBmpObj.Location = new Point(Convert.ToInt32(curObj.x1 / 100.0 * OBJ_WIDTH), Convert.ToInt32(curObj.y1 / 100.0 * OBJ_HEIGHT));
                curBmpObj.Size = new Size(Convert.ToInt32((curObj.x2 - curObj.x1) / 100.0 * OBJ_WIDTH), Convert.ToInt32((curObj.y2 - curObj.y1) / 100.0 * OBJ_HEIGHT));

                if (curObj.side == 0)
                {
                    panel0.Controls.Add(curBmpObj);
                }
                else if (curObj.side == 1)
                {
                    panel1.Controls.Add(curBmpObj);
                    hasSide2 = true;
                }
            }

            panel0.Controls.Add(label0);
            panel1.Controls.Add(label1);

            if (hasSide2)
            {
                panel.Height = (OBJ_HEIGHT * 2) + 1;
                panel1.Location = new Point(0, OBJ_HEIGHT + 1);
                panel.Controls.Add(panel1);
            }

            panel.Controls.Add(panel0);

            bmp = new Bitmap(panel.Width, panel.Height);
            panel.DrawToBitmap(bmp, new Rectangle(0, 0, panel.Width, panel.Height));

            return bmp;
        }
コード例 #3
0
ファイル: template.cs プロジェクト: skaulana/eflash
        public static void initTemplates()
        {
            // Initalize hashtable
            templates = new	Dictionary<string, List<Template>>();

            // Initialize each category of templates
            templates.Add(Constant.textDeck, new List<Template>());
            templates.Add(Constant.imageDeck, new List<Template>());
            templates.Add(Constant.soundDeck, new List<Template>());

            Template curTemplate;

            // Initialize text quiz templates
            // A 1 sided template with both question and answer on first side
            curTemplate = new Template(Constant.textDeck);
            curTemplate.addQuestionObject(0, 30, 70, 20, 40);
            curTemplate.addAnswerObject(0, 20, 80, 50, 90);
            templates[Constant.textDeck].Add(curTemplate);

            // A 2 sided template with question on front and answer on
            // back, with several other non-quiz objects
            // In this case, sides 1 and 2 have the same layout
            curTemplate = new Template(Constant.textDeck);
            curTemplate.addQuestionObject(0, 30, 70, 30, 70);
            curTemplate.addNoneObject(Constant.textFile, 0, 30, 70, 80, 90);
            curTemplate.addAnswerObject(1, 30, 70, 30, 70);
            curTemplate.addNoneObject(Constant.textFile, 1, 30, 70, 80, 90);
            templates[Constant.textDeck].Add(curTemplate);

            // A 2 sided template w/ question on front and answer on
            // back, with two other non-quiz objects (picture and sound
            // In this case, side 1 can have the picture and sound on the front
            // with one question object and side 2 can just have the answer object
            curTemplate = new Template(Constant.textDeck);
            curTemplate.addQuestionObject(0, 10, 30, 30, 70);
            curTemplate.addNoneObject(Constant.imageFile, 0, 40, 60, 30, 70);
            curTemplate.addNoneObject(Constant.soundFile, 0, 70, 90, 30, 70);
            curTemplate.addAnswerObject(1, 30, 70, 30, 70);
            templates[Constant.textDeck].Add(curTemplate);

            // A 2 sided template w/ question on front and answer on
            // back, with 2 other non-quiz objs (pix and sound)
            // In this case, side 1 can have just the question, and side 2
            // can have picture and sound, and the answer object
            curTemplate = new Template(Constant.textDeck);
            curTemplate.addQuestionObject(0, 30, 70, 30, 70);
            curTemplate.addAnswerObject(1, 10, 30, 30, 70);
            curTemplate.addNoneObject(Constant.imageFile, 1, 40, 60, 30, 70);
            curTemplate.addNoneObject(Constant.soundFile, 1, 70, 90, 30, 70);
            templates[Constant.textDeck].Add(curTemplate);

            // A 2 sided template w/ question on front and answer on
            // back, with 4 other non-quiz objs (pix and sound)
            // In this case, side 1 and side 2 both have images and sounds on their cards
            curTemplate = new Template(Constant.textDeck);
            curTemplate.addQuestionObject(0, 10, 30, 30, 70);
            curTemplate.addNoneObject(Constant.imageFile, 0, 40, 60, 30, 70);
            curTemplate.addNoneObject(Constant.soundFile, 0, 70, 90, 30, 70);
            curTemplate.addAnswerObject(1, 10, 30, 30, 70);
            curTemplate.addNoneObject(Constant.imageFile, 1, 40, 60, 30, 70);
            curTemplate.addNoneObject(Constant.soundFile, 1, 70, 90, 30, 70);
            templates[Constant.textDeck].Add(curTemplate);

            // Initialize image quiz templates
            curTemplate = new Template(Constant.imageDeck);
            curTemplate.addQuestionObject(0, 30, 70, 20, 60);
            curTemplate.addAnswerObject(0, 30, 70, 70, 90);
            templates[Constant.imageDeck].Add(curTemplate);

            //a 2-sided image quiz template
            curTemplate = new Template(Constant.imageDeck);
            curTemplate.addQuestionObject(0, 30, 70, 30, 70);
            curTemplate.addAnswerObject(1, 30, 70, 30, 70);
            templates[Constant.imageDeck].Add(curTemplate);

            //a 2-sided image quiz template with text on both sides
            curTemplate = new Template(Constant.imageDeck);
            curTemplate.addQuestionObject(0, 30, 70, 30, 70);
            curTemplate.addNoneObject(Constant.textFile, 0, 30, 70, 80, 90);
            curTemplate.addAnswerObject(1, 30, 70, 30, 70);
            curTemplate.addNoneObject(Constant.textFile, 1, 30, 70, 80, 90);
            templates[Constant.imageDeck].Add(curTemplate);

            //a 2-sided image quiz with 2 text noneobjects on the answer side
            curTemplate = new Template(Constant.imageDeck);
            curTemplate.addQuestionObject(0, 30, 70, 30, 70);
            curTemplate.addAnswerObject(1, 10, 30, 30, 70);
            curTemplate.addNoneObject(Constant.textFile, 1, 40, 60, 30, 70);
            curTemplate.addNoneObject(Constant.textFile, 1, 70, 90, 30, 70);
            templates[Constant.imageDeck].Add(curTemplate);

            //a 2-sided image quiz with 2 text noneobjects on the question side
            curTemplate = new Template(Constant.imageDeck);
            curTemplate.addQuestionObject(0, 10, 30, 30, 70);
            curTemplate.addNoneObject(Constant.textFile, 0, 40, 60, 30, 70);
            curTemplate.addNoneObject(Constant.textFile, 0, 70, 90, 30, 70);
            curTemplate.addAnswerObject(1, 30, 70, 30, 70);
            templates[Constant.imageDeck].Add(curTemplate);

            // Initialize sound quiz templates
            curTemplate = new Template(Constant.soundDeck);
            curTemplate.addQuestionObject(0, 30, 70, 20, 40);
            curTemplate.addAnswerObject(0, 20, 80, 50, 90);
            templates[Constant.soundDeck].Add(curTemplate);

            // a 2-sided sound quiz template
            curTemplate = new Template(Constant.soundDeck);
            curTemplate.addQuestionObject(0, 30, 70, 30, 70);
            curTemplate.addAnswerObject(1, 30, 70, 30, 70);
            templates[Constant.soundDeck].Add(curTemplate);

            //a 2-sided sound quiz template with text on both sides
            curTemplate = new Template(Constant.soundDeck);
            curTemplate.addQuestionObject(0, 30, 70, 30, 70);
            curTemplate.addNoneObject(Constant.textFile, 0, 30, 70, 80, 90);
            curTemplate.addAnswerObject(1, 30, 70, 30, 70);
            curTemplate.addNoneObject(Constant.textFile, 1, 30, 70, 80, 90);
            templates[Constant.soundDeck].Add(curTemplate);

            //a 2-sided sound quiz with 2 text noneobjects on the answer side
            curTemplate = new Template(Constant.soundDeck);
            curTemplate.addQuestionObject(0, 30, 70, 30, 70);
            curTemplate.addAnswerObject(1, 10, 30, 30, 70);
            curTemplate.addNoneObject(Constant.textFile, 1, 40, 60, 30, 70);
            curTemplate.addNoneObject(Constant.textFile, 1, 70, 90, 30, 70);
            templates[Constant.soundDeck].Add(curTemplate);

            //a 2-sided sound quiz with 2 text noneobjects on the question side
            curTemplate = new Template(Constant.soundDeck);
            curTemplate.addQuestionObject(0, 10, 30, 30, 70);
            curTemplate.addNoneObject(Constant.textFile, 0, 40, 60, 30, 70);
            curTemplate.addNoneObject(Constant.textFile, 0, 70, 90, 30, 70);
            curTemplate.addAnswerObject(1, 30, 70, 30, 70);
            templates[Constant.soundDeck].Add(curTemplate);
        }