public void objectMovedHandler(CreatorObject movedObj) { if (movedObj == obj) { trackObj(); } }
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; }
public void attachTo(CreatorObject newObj) { path = ""; obj = newObj; trackObj(); this.show(); this.Focus(); }
private void canvas_DragLeave(object sender, EventArgs e) { if (draggingObj != null) { ((TabPage)sender).Controls.Remove(draggingObj); draggingObj = null; } }
public void detachFrom(CreatorObject detachee) { if (detachee == obj) { obj = null; this.hide(); } }
public void removeObject(CreatorObject obj) { foreach (TabPage curTab in tabSides.TabPages) { if (curTab.Controls.Contains(obj)) { curTab.Controls.Remove(obj); } } }
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); }
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); }
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; } } }
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); } }
/// <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); }
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); } }
/// <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; }
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); }
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; } } }
public void selectObject(CreatorObject newObj) { selectedObject = newObj; }
public bool isAttachedTo(CreatorObject that) { return(that == obj); }
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); } }
private void canvas_DragLeave(object sender, EventArgs e) { if (draggingObj != null) { ((TabPage) sender).Controls.Remove(draggingObj); draggingObj = null; } }
public bool isAttachedTo(CreatorObject that) { return that == obj; }
/// <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); }
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; }