Esempio n. 1
0
 public void objectMovedHandler(CreatorObject movedObj)
 {
     if (movedObj == obj)
     {
         trackObj();
     }
 }
Esempio n. 2
0
        private void initialize()
        {
            alignmentSelector.setCreator(this);
            alignmentSelector.alignmentChangedHandler = new AlignmentSelector.creatorEventHandler(alignmentChanged);

            selectedObject = null;

            initializeDialogs();

            populateFonts();
            populateSizes();

            setCurrentFont(fontDialog.Font, true);
            setCurrentColor(colorDialog.Color, true);
            setCurrentAlignment(alignmentSelector.alignment, true);

            updateSides();

            fChooser = new FileChooser(this);
            Controls.Add(fChooser);

            changed                = false;
            templateChanged        = false;
            promptAtTemplateChange = true;
        }
Esempio n. 3
0
 public void attachTo(CreatorObject newObj)
 {
     path = "";
     obj  = newObj;
     trackObj();
     this.show();
     this.Focus();
 }
Esempio n. 4
0
 private void canvas_DragLeave(object sender, EventArgs e)
 {
     if (draggingObj != null)
     {
         ((TabPage)sender).Controls.Remove(draggingObj);
         draggingObj = null;
     }
 }
Esempio n. 5
0
 public void detachFrom(CreatorObject detachee)
 {
     if (detachee == obj)
     {
         obj = null;
         this.hide();
     }
 }
Esempio n. 6
0
 public void attachTo(CreatorObject newObj)
 {
     path = "";
     obj = newObj;
     trackObj();
     this.show();
     this.Focus();
 }
Esempio n. 7
0
 public void detachFrom(CreatorObject detachee)
 {
     if (detachee == obj)
     {
         obj = null;
         this.hide();
     }
 }
Esempio n. 8
0
 public void removeObject(CreatorObject obj)
 {
     foreach (TabPage curTab in tabSides.TabPages)
     {
         if (curTab.Controls.Contains(obj))
         {
             curTab.Controls.Remove(obj);
         }
     }
 }
Esempio n. 9
0
        private void btnAudio_MouseDown(object sender, MouseEventArgs e)
        {
            eObject eObj = new eObject();

            eObj.type = Constant.soundFile;
            eObj.side = currentSideIndex;
            eObj.data = "[n]noFile.txt";
            CreatorObject draggingObj = new CreatorObject(this, eObj);

            btnTextbox.DoDragDrop(draggingObj, DragDropEffects.Move);
        }
Esempio n. 10
0
        private void btnImage_MouseDown(object sender, MouseEventArgs e)
        {
            eObject eObj = new eObject();

            eObj.type           = Constant.imageFile;
            eObj.side           = currentSideIndex;
            eObj.quizType       = Constant.nonePrefix;
            eObj.actualFilename = "[n]noFile.txt";
            eObj.data           = eObj.quizType + eObj.actualFilename;
            CreatorObject draggingObj = new CreatorObject(this, eObj);

            btnTextbox.DoDragDrop(draggingObj, DragDropEffects.Move);
        }
Esempio n. 11
0
 private void canvas_DragDrop(object sender, DragEventArgs e)
 {
     if (draggingObj != null)
     {
         if (((TabPage)sender).Controls.Count >= 6)
         {
             canvas_DragLeave(sender, e);
             MessageBox.Show("You may have at most 5 objects per side.");
         }
         else
         {
             draggingObj.initialize();
             draggingObj.endInitialDragging();
             currentCard.objects.Add(draggingObj);
             draggingObj = null;
         }
     }
 }
Esempio n. 12
0
        private CreatorCard(LayoutEditor newCreator, int newCardID, int newUID, string newTag, List <eObject> newObjects, int newIndex)
        {
            _cardID  = newCardID;
            _uid     = newUID;
            _tag     = newTag;
            _objects = new List <CreatorObject>();
            index    = newIndex;
            creator  = newCreator;

            originalCard = null;

            CreatorObject curNewObj;

            foreach (eObject curEObj in newObjects)
            {
                curNewObj = CreatorObject.newFromEObject(creator, curEObj, (objects.Count * 2) + 10);

                objects.Add(curNewObj);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Makes a deep copy of deck, duplicating all its cards,
        /// objects, and files, and sets it to be the current deck.
        /// </summary>
        /// <param name="otherDeck">Deck to copy</param>
        /// <returns>Deck object of copy of deck</returns>
        private eFlash.Data.Deck deepCopy(eFlash.Data.Deck otherDeck)
        {
            otherDeck.load();

            _deck = new eFlash.Data.Deck(-1, otherDeck.type, otherDeck.category, otherDeck.subcategory, otherDeck.title, ProfileManager.getCurrentUserID(), ProfileManager.getCurrentNetID());

            // Put deck entry into DB
            saveDeck();

            Card          newCard;
            eObject       newObj;
            CreatorObject newCreatorObj;

            foreach (Card curCard in otherDeck.cardList)
            {
                newCard = new Card(curCard.tag, ProfileManager.getCurrentUserID());

                // Add each card to the DB
                newCard.cardID = dbAccess.insertLocalDB.insertToCards(newCard);
                dbAccess.insertLocalDB.insertToCDRelations(deck.id, newCard.cardID);

                foreach (eObject curObj in curCard.eObjectList)
                {
                    newObj = new eObject(newCard.cardID, curObj.side, curObj.type, curObj.x1, curObj.x2, curObj.y1, curObj.y2, curObj.data);

                    // Make a CreatorObject to let it load up the data file
                    newCreatorObj = CreatorObject.newFromEObject(this, newObj, 0);
                    newCreatorObj.initialize();
                    newObj.actualFilename = newObj.generateFileName();

                    // Save each object to DB and file
                    saveObject(newCreatorObj);
                }
            }

            return(deck);
        }
Esempio n. 14
0
        private void canvas_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(CREATOR_OBJECT_TYPE))
            {
                e.Effect = DragDropEffects.Move;

                draggingObj      = (CreatorObject)(e.Data.GetData(CREATOR_OBJECT_TYPE));
                draggingObj.Name = "draggingObj";
                if (draggingObj.eObj.quizType == Constant.soundFile)
                {
                    draggingObj.Size = new System.Drawing.Size(100, 100);
                }
                else
                {
                    draggingObj.Size = new System.Drawing.Size(100, 100);
                }
                draggingObj.TabIndex = (currentCard.objects.Count * 2) + 10;
                draggingObj.TabStop  = true;

                draggingObj.initialize();
                draggingObj.beginInitialDragging();
                ((TabPage)sender).Controls.Add(draggingObj);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Saves obj to DB and file. Obj MUST have its cid set to a valid value. 
        /// </summary>
        /// <param name="obj">Object to save</param>
        private eObject saveObject(CreatorObject obj)
        {
            string originalSoundFileName = "";
            byte[] data = null;

            if (obj.cid == -1)
            {
                throw new Exception("Trying to save object without first setting cid");
            }

            // Kill off the old bmp file so it doesnt hog the file
            // while we try to delete and overwrite
            if (obj.type == Constant.imageFile)
            {
                Image originalBmp = obj.imageBox.BackgroundImage;
                obj.imageBox.BackgroundImage = new Bitmap(obj.imageBox.BackgroundImage);
                originalBmp.Dispose();
            }
            else if (obj.type == Constant.soundFile)
            {
                originalSoundFileName = obj.playerControl.filePath;
                obj.playerControl.close();

                FileStream userFile = new FileStream(originalSoundFileName, FileMode.Open, FileAccess.Read);
                data = new byte[userFile.Length];
                userFile.Read(data, 0, Convert.ToInt32(userFile.Length));
                userFile.Close();
            }

            // Delete existing file
            FileInfo file = new FileInfo(Constant.ePath + obj.eObj.actualFilename);
            if (file.Exists)
            {
                try
                {
                    file.Delete();
                }
                catch (Exception e)
                {
                    MessageBox.Show("Unable to write to file. It is being used by another application.\n\n" + e.ToString(), "File I/O error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                }
            }

            eObject eObj = obj.toEObject();

            // Insert into DB
            dbAccess.insertLocalDB.insertToObjects(eObj);

            // Save file
            FileStream fs = new FileStream(Constant.ePath + eObj.actualFilename, FileMode.Create, FileAccess.ReadWrite);
            switch (eObj.type)
            {
                case Constant.textFile:
                    obj.textbox.SaveFile(fs, RichTextBoxStreamType.RichText);
                    break;
                case Constant.imageFile:
                    if (obj.imageBox.BackgroundImage != null && obj.imageBox.BackgroundImage != global::eFlash.Properties.Resources.defaultImage)
                    {
                        obj.imageBox.BackgroundImage.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                    break;
                case Constant.soundFile:
                    fs.Write(data, 0, data.Length);
                    obj.playerControl.setFile(Constant.ePath + eObj.actualFilename);
                    break;
                default:
                    throw new Exception("Invalid object type");
            }
            fs.Flush();
            fs.Close();
            fs.Dispose();

            return eObj;
        }
Esempio n. 16
0
 private void btnTextbox_MouseDown(object sender, MouseEventArgs e)
 {
     eObject eObj = new eObject();
     eObj.type = Constant.textFile;
     eObj.side = currentSideIndex;
     eObj.quizType = Constant.nonePrefix;
     eObj.actualFilename = "[n]noFile.txt";
     eObj.data = eObj.quizType + eObj.actualFilename;
     CreatorObject draggingObj = new CreatorObject(this, eObj);
     btnTextbox.DoDragDrop(draggingObj, DragDropEffects.Move);
 }
Esempio n. 17
0
 private void canvas_DragDrop(object sender, DragEventArgs e)
 {
     if (draggingObj != null)
     {
         if (((TabPage) sender).Controls.Count >= 6)
         {
             canvas_DragLeave(sender, e);
             MessageBox.Show("You may have at most 5 objects per side.");
         }
         else
         {
             draggingObj.initialize();
             draggingObj.endInitialDragging();
             currentCard.objects.Add(draggingObj);
             draggingObj = null;
         }
     }
 }
Esempio n. 18
0
 public void selectObject(CreatorObject newObj)
 {
     selectedObject = newObj;
 }
Esempio n. 19
0
 public bool isAttachedTo(CreatorObject that)
 {
     return(that == obj);
 }
Esempio n. 20
0
 public void removeObject(CreatorObject obj)
 {
     foreach (TabPage curTab in tabSides.TabPages)
     {
         if (curTab.Controls.Contains(obj))
         {
             curTab.Controls.Remove(obj);
         }
     }
 }
Esempio n. 21
0
 private void btnAudio_MouseDown(object sender, MouseEventArgs e)
 {
     eObject eObj = new eObject();
     eObj.type = Constant.soundFile;
     eObj.side = currentSideIndex;
     eObj.data = "[n]noFile.txt";
     CreatorObject draggingObj = new CreatorObject(this, eObj);
     btnTextbox.DoDragDrop(draggingObj, DragDropEffects.Move);
 }
Esempio n. 22
0
        private void canvas_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(CREATOR_OBJECT_TYPE))
            {
                e.Effect = DragDropEffects.Move;

                draggingObj = (CreatorObject) (e.Data.GetData(CREATOR_OBJECT_TYPE));
                draggingObj.Name = "draggingObj";
                if (draggingObj.eObj.quizType == Constant.soundFile)
                {
                    draggingObj.Size = new System.Drawing.Size(100, 100);
                }
                else
                {
                    draggingObj.Size = new System.Drawing.Size(100, 100);
                }
                draggingObj.TabIndex = (currentCard.objects.Count * 2) + 10;
                draggingObj.TabStop = true;

                draggingObj.initialize();
                draggingObj.beginInitialDragging();
                ((TabPage) sender).Controls.Add(draggingObj);
            }
        }
Esempio n. 23
0
 private void canvas_DragLeave(object sender, EventArgs e)
 {
     if (draggingObj != null)
     {
         ((TabPage) sender).Controls.Remove(draggingObj);
         draggingObj = null;
     }
 }
Esempio n. 24
0
 public bool isAttachedTo(CreatorObject that)
 {
     return that == obj;
 }
Esempio n. 25
0
        private void initialize()
        {
            alignmentSelector.setCreator(this);
            alignmentSelector.alignmentChangedHandler = new AlignmentSelector.creatorEventHandler(alignmentChanged);

            selectedObject = null;

            initializeDialogs();

            populateFonts();
            populateSizes();

            setCurrentFont(fontDialog.Font, true);
            setCurrentColor(colorDialog.Color, true);
            setCurrentAlignment(alignmentSelector.alignment, true);

            updateSides();

            fChooser = new FileChooser(this);
            Controls.Add(fChooser);

            changed = false;
            templateChanged = false;
            promptAtTemplateChange = true;
        }
Esempio n. 26
0
 public void objectMovedHandler(CreatorObject movedObj)
 {
     if (movedObj == obj)
     {
         trackObj();
     }
 }
Esempio n. 27
0
 public void selectObject(CreatorObject newObj)
 {
     selectedObject = newObj;
 }
Esempio n. 28
0
        /// <summary>
        /// Saves obj to DB and file. Obj MUST have its cid set to a valid value.
        /// </summary>
        /// <param name="obj">Object to save</param>
        private eObject saveObject(CreatorObject obj)
        {
            string originalSoundFileName = "";

            byte[] data = null;

            if (obj.cid == -1)
            {
                throw new Exception("Trying to save object without first setting cid");
            }

            // Kill off the old bmp file so it doesnt hog the file
            // while we try to delete and overwrite
            if (obj.type == Constant.imageFile)
            {
                Image originalBmp = obj.imageBox.BackgroundImage;
                obj.imageBox.BackgroundImage = new Bitmap(obj.imageBox.BackgroundImage);
                originalBmp.Dispose();
            }
            else if (obj.type == Constant.soundFile)
            {
                originalSoundFileName = obj.playerControl.filePath;
                obj.playerControl.close();

                FileStream userFile = new FileStream(originalSoundFileName, FileMode.Open, FileAccess.Read);
                data = new byte[userFile.Length];
                userFile.Read(data, 0, Convert.ToInt32(userFile.Length));
                userFile.Close();
            }

            // Delete existing file
            FileInfo file = new FileInfo(Constant.ePath + obj.eObj.actualFilename);

            if (file.Exists)
            {
                try
                {
                    file.Delete();
                }
                catch (Exception e)
                {
                    MessageBox.Show("Unable to write to file. It is being used by another application.\n\n" + e.ToString(), "File I/O error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                }
            }

            eObject eObj = obj.toEObject();

            // Insert into DB
            dbAccess.insertLocalDB.insertToObjects(eObj);

            // Save file
            FileStream fs = new FileStream(Constant.ePath + eObj.actualFilename, FileMode.Create, FileAccess.ReadWrite);

            switch (eObj.type)
            {
            case Constant.textFile:
                obj.textbox.SaveFile(fs, RichTextBoxStreamType.RichText);
                break;

            case Constant.imageFile:
                if (obj.imageBox.BackgroundImage != null && obj.imageBox.BackgroundImage != global::eFlash.Properties.Resources.defaultImage)
                {
                    obj.imageBox.BackgroundImage.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
                }
                break;

            case Constant.soundFile:
                fs.Write(data, 0, data.Length);
                obj.playerControl.setFile(Constant.ePath + eObj.actualFilename);
                break;

            default:
                throw new Exception("Invalid object type");
            }
            fs.Flush();
            fs.Close();
            fs.Dispose();

            return(eObj);
        }
Esempio n. 29
0
        public static CreatorObject newFromEObject(LayoutEditor newCreator, eObject newObj, int tabStop)
        {
            CreatorObject curNewObj = new CreatorObject(newCreator, newObj);

            curNewObj.Name = "creatorObject";
            curNewObj.TabIndex = tabStop;
            curNewObj.TabStop = true;

            curNewObj.initialize();

            curNewObj.setCoords(newObj.x1, newObj.y1, newObj.x2, newObj.y2);

            return curNewObj;
        }