Exemple #1
0
 public void addNote(PostItNote note)
 {
     if (getNoteWithID(note.Id) == null)
     {
         postItNotes.Add(note);
         if (noteAddedEventHandler != null)
         {
             noteAddedEventHandler(note);
         }
     }
     else
     {
         PostItNote existingNote = getNoteWithID(note.Id);
         if (!(existingNote.IsAvailable))
         {
             existingNote.IsAvailable = true;
             existingNote.CenterX     = 0;
             existingNote.CenterY     = 0;
             existingNote.Content     = note.Content;
             existingNote.DataType    = note.DataType;
             if (noteAddedEventHandler != null)
             {
                 noteAddedEventHandler(existingNote);
             }
         }
         else
         {
             existingNote.Content = note.Content;
             if (noteUpdatedEventHandler != null)
             {
                 noteUpdatedEventHandler(existingNote);
             }
         }
     }
 }
        public void update(GenericIdeationObjects.IdeationUnit idea)
        {
            Bitmap bmpContent = PostItNote.DeepClone(idea.Content) as Bitmap;

            updateDisplayedContent(bmpContent);
            this.Tag = idea;
        }
Exemple #3
0
 public void AddDiscardedIdea(GenericIdeationObjects.IdeationUnit idea)
 {
     try
     {
         IPostItUI addedIdeaUI = null;
         if (idea is PostItNote)
         {
             PostItNote castNote = (PostItNote)idea;
             if (castNote.Content is Bitmap)
             {
                 ImageBasedPostItUI noteUI = new ImageBasedPostItUI();
                 noteUI.Tag = idea;
                 noteUI.setNoteID(castNote.Id);
                 noteUI.updateDisplayedContent(((Bitmap)castNote.Content).Clone());
                 noteUI.Width = noteUI.Height = this.Height * 2 / 3;
                 noteUI.DisableZoomButtons();
                 addedIdeaUI = noteUI;
             }
         }
         if (addedIdeaUI != null)
         {
             addedIdeaUI.noteUIDeletedEventHandler += new NoteUIDeletedEvent(ideaUI_noteUIDeletedEventHandler);
             this.discardedItemsContainer.Children.Add((UserControl)addedIdeaUI);
         }
     }
     catch (Exception ex)
     {
         Utilities.UtilitiesLib.LogError(ex);
     }
 }
Exemple #4
0
        private void AddSinglePostItNote(IdeationUnit idea, int initAngle, bool init)
        {
            try
            {
                IPostItUI       addedIdeaUI = null;
                ScatterViewItem container   = new ScatterViewItem();
                PostItNote      castNote    = (PostItNote)idea;
                if (castNote.Content is Bitmap)
                {
                    ImageBasedPostItUI noteUI = new ImageBasedPostItUI();

                    noteUI.Tag = idea;
                    noteUI.setNoteID(castNote.Id);
                    noteUI.update(idea);
                    noteUI.Width  = noteUI.InitWidth;
                    noteUI.Height = noteUI.InitHeight;
                    if (castNote.MetaData.UiBackgroundColor.Length > 0)
                    {
                        noteUI.setBackgroundPostItColor(castNote.MetaData.UiBackgroundColor);
                        noteUI.approvedNewBackgroundColor(castNote.MetaData.UiBackgroundColor);
                    }

                    container.Content = noteUI;
                    container.Width   = noteUI.Width;
                    container.Height  = noteUI.Height;

                    if (idea.CenterX == 0 && idea.CenterY == 0)
                    {
                        int centerX = (int)(container.Width / 2);
                        int centerY = (int)(sv_MainCanvas.Height - container.Height / 2);
                        idea.CenterX = centerX;
                        idea.CenterY = centerY;
                    }
                    sv_MainCanvas.Items.Add(container);
                    container.Center      = new System.Windows.Point(idea.CenterX, idea.CenterY);
                    container.Orientation = initAngle;
                    container.ZIndex      = 1;
                    container.CanScale    = false;
                    addedIdeaUI           = noteUI;
                    addedIdeaUI.InitContainer(container);
                }
                if (addedIdeaUI != null)
                {
                    if (init)
                    {
                        addedIdeaUI.startJustAddedAnimation(container.Orientation);
                    }
                    addedIdeaUI.noteUITranslatedEventHandler     += new NoteUITranslatedEvent(noteUIManipluatedEventHandler);
                    addedIdeaUI.noteUIDeletedEventHandler        += new NoteUIDeletedEvent(noteUIDeletedEventHandler);
                    addedIdeaUI.noteUISizeChangedListener        += new NoteUISizeChangedEvent(addedIdeaUI_noteUISizeChangedListener);
                    addedIdeaUI.colorPaletteLaunchedEventHandler += new ColorPaletteLaunchedEvent(addedIdeaUI_colorPaletteLaunchedEventHandler);
                }
                Utilities.BrainstormingEventLogger.GetInstance(dropboxGeneralNoteDownloader.Storage).UploadLogString(Utilities.BrainstormingEventLogger.getLogStr_NoteAdded(idea));
            }
            catch (Exception ex)
            {
                Utilities.UtilitiesLib.LogError(ex);
            }
        }
        PostItCommand decodeAddCommand(byte[] data)
        {
            string commndStr = Encoding.UTF8.GetString(data);

            if (!commndStr.Contains(Encoding.UTF8.GetString(PostItCommand.ADD_PREFIX)) ||
                !commndStr.Contains(Encoding.UTF8.GetString(PostItCommand.ADD_POSTFIX)))
            {
                return(null);
            }
            if (!commndStr.StartsWith(Encoding.UTF8.GetString(PostItCommand.ADD_PREFIX)))
            {
                return(null);
            }
            //start to extract part of the message;
            //structure of an Add command
            //<ADD> ID X Y Orientation Size DataType Data </ADD>
            PostItCommand command = new PostItCommand();

            command.CommandType = PostItCommandType.Add;
            int        index = PostItCommand.ADD_PREFIX.Length;
            PostItNote note  = new PostItNote();

            //ID
            byte[] buffer = new byte[4];
            Array.Copy(data, index, buffer, 0, 4);
            note.Id = Utilities.UtilitiesLib.Bytes2Int(buffer);
            index  += 4;
            //X
            Array.Copy(data, index, buffer, 0, 4);
            note.CenterX = Utilities.UtilitiesLib.Bytes2Float(buffer);
            index       += 4;
            //Y
            Array.Copy(data, index, buffer, 0, 4);
            note.CenterY = Utilities.UtilitiesLib.Bytes2Float(buffer);
            index       += 4;
            //skip 4 bytes of orientation, can be used in the future
            index += 4;
            //get size of the content
            Array.Copy(data, index, buffer, 0, 4);
            int contentSize = Utilities.UtilitiesLib.Bytes2Int(buffer);

            index += 4;
            //get content data type
            Array.Copy(data, index, buffer, 0, 4);
            note.DataType = PostItCommand.GetPostItContentType(buffer);
            index        += 4;
            //start getting content
            buffer = new byte[contentSize];
            Array.Copy(data, index, buffer, 0, buffer.Length);
            note.ParseContentFromBytes(note.DataType, buffer);
            command.CommandData = note;
            return(command);
        }
Exemple #6
0
        public void ProcessPostItNoteCommand(PostItCommandType commandType, object commandArg)
        {
            switch (commandType)
            {
            case PostItCommandType.Add:
                PostItNote addedNote = (PostItNote)commandArg;
                if (getNoteWithID(addedNote.Id) == null)
                {
                    postItNotes.Add(addedNote);
                }
                if (noteAddedEventHandler != null)
                {
                    noteAddedEventHandler(addedNote);
                }
                break;

            case PostItCommandType.Update:
                PostItNote updatedNote  = (PostItNote)commandArg;
                PostItNote matchingNote = getNoteWithID(updatedNote.Id);
                if (!(matchingNote == null))
                {
                    matchingNote.CenterX = updatedNote.CenterX;
                    matchingNote.CenterX = updatedNote.CenterY;
                    if (updatedNote.Content != null)
                    {
                        matchingNote.Content = updatedNote.Content;
                    }
                    if (noteUpdatedEventHandler != null)
                    {
                        noteUpdatedEventHandler(matchingNote);
                    }
                }
                break;

            case PostItCommandType.Delete:
                int        noteID      = (int)commandArg;
                PostItNote tobeRemoved = getNoteWithID(noteID);
                if (tobeRemoved != null)
                {
                    postItNotes.Remove(tobeRemoved);
                    if (noteRemovedEventHandler != null)
                    {
                        noteRemovedEventHandler(tobeRemoved);
                    }
                }
                break;
            }
        }
Exemple #7
0
 public void handleDownloadedStreamsFromCloud(Dictionary <int, Stream> noteStreams)
 {
     foreach (int noteID in noteStreams.Keys)
     {
         Stream stream = noteStreams[noteID];
         if (stream is MemoryStream)
         {
             PostItNote note = new PostItNote();
             note.Id       = noteID;
             note.CenterX  = 0;
             note.CenterY  = 0;
             note.DataType = PostItContentDataType.WritingImage;
             note.ParseContentFromBytes(note.DataType, (stream as MemoryStream).ToArray());
             if (newNoteExtractedEventHandler != null)
             {
                 newNoteExtractedEventHandler(note);
             }
         }
     }
 }
        PostItCommand decodeUpdateCommand(byte[] data)
        {
            string commndStr = Encoding.UTF8.GetString(data);

            if (!commndStr.Contains(Encoding.UTF8.GetString(PostItCommand.UPDATE_PREFIX)) ||
                !commndStr.Contains(Encoding.UTF8.GetString(PostItCommand.UPDATE_POSTFIX)))
            {
                return(null);
            }
            if (!commndStr.StartsWith(Encoding.UTF8.GetString(PostItCommand.UPDATE_PREFIX)))
            {
                return(null);
            }
            //start to extract part of the message;
            //structure of an Add command
            //<UPD> ID X Y Orientation </UPD>
            PostItCommand command = new PostItCommand();

            command.CommandType = PostItCommandType.Update;
            int        index = PostItCommand.UPDATE_PREFIX.Length;
            PostItNote note  = new PostItNote();

            //ID
            byte[] buffer = new byte[4];
            Array.Copy(data, index, buffer, 0, 4);
            note.Id = Utilities.UtilitiesLib.Bytes2Int(buffer);
            index  += 4;
            //X
            Array.Copy(data, index, buffer, 0, 4);
            note.CenterX = Utilities.UtilitiesLib.Bytes2Float(buffer);
            index       += 4;
            //Y
            Array.Copy(data, index, buffer, 0, 4);
            note.CenterY = Utilities.UtilitiesLib.Bytes2Float(buffer);
            //at this moment, do not read the Orientation
            command.CommandData = note;
            return(command);
        }
        public void ChangeIdeaUIColorInBackground(int ideaID, string colorCode)
        {
            PostItNote postItIdea = (PostItNote)getIdeaWithId(ideaID);

            postItIdea.MetaData.UiBackgroundColor = colorCode;
        }