public bool AddNote(StickyNote note) { if (!availableNotes.ContainsKey(note.Id)) { availableNotes.Add(note.Id, note); Console.WriteLine("Note {0} added", note.Id); return true; } return false; }
public static byte[] GenerateAddCommand(StickyNote note, Bitmap additionalContent) { byte[] noteFullData = note.getByteData(additionalContent); byte[] commandBytes = new byte[ADD_Prefix.Length + noteFullData.Length + ADD_Postfix.Length]; int index = 0; Array.Copy(ADD_Prefix, 0, commandBytes, index, ADD_Prefix.Length); index += ADD_Prefix.Length; Array.Copy(noteFullData, 0, commandBytes, index, noteFullData.Length); index += noteFullData.Length; Array.Copy(ADD_Postfix, 0, commandBytes, index, ADD_Postfix.Length); Console.WriteLine("Command length: {0}", commandBytes.Length); return commandBytes; }
void touchManager_noteCrossedByALineEventHandler(int noteID, float notePosX, float notePosY, float noteOrientation) { StickyNote newNote = new StickyNote(); newNote.Id = noteID; newNote.AnchorX = notePosX; newNote.AnchorY = notePosY; newNote.Orientation = noteOrientation; bool addResult = noteManager.AddNote(newNote); if (addResult) { //extract corresponding image of the note Bitmap screenshot = getScreenShotBitmap(true); Bitmap noteImage = StickyNoteExtractor.ProcessToExtract(new Emgu.CV.Image<Emgu.CV.Structure.Gray, byte>(screenshot), newNote.AnchorX, newNote.AnchorY, newNote.Orientation); //construct ADD command //byte[] addNoteCommandData = CommandGenerator.GenerateAddCommand(newNote, noteImage); //send it //WifiCommunicator.Send(addNoteCommandData); string fileName = String.Format("{0}.png", IDGenerator.getHashedID(noteID)); cloudNoteUploader.setFileAndFileNameToUpload(noteImage, fileName); Thread uploadThread = new Thread(new ThreadStart(cloudNoteUploader.UploadNoteBitmap)); uploadThread.Start(); } }