/// <summary> /// This is an image that the user added dynamically. /// TODO: We need to compress most images down to fairly small size in order to work.. /// </summary> /// <param name="rtia"></param> private void FilterRTImageAnnotation(RTImageAnnotation rtia) { Guid guid = rtia.Guid; BufferChunk data; lock (subQueue) { //if annotation with this guid is found in low priority queue, replace it, otherwise enqueue it. for (int i = 0; i < subQueue.Count; i++) { if ((((WorkItem)subQueue[i]).OpCode == PacketType.RTImageAnnotation) && (((WorkItem)subQueue[i]).Guid == guid)) { subQueue.RemoveAt(i); break; } } } rtia.Img = CompressImage(rtia.Img); data = new BufferChunk(Helpers.ObjectToByteArray(rtia)); WorkItem wi = new WorkItem(data, PacketType.RTImageAnnotation, guid); wi.DeckGuid = rtia.DeckGuid; wi.SlideIndex = rtia.SlideIndex; enqueueSub(wi); }
/// <summary> /// /// </summary> /// <param name="ism"></param> /// <returns></returns> internal object AddImageAnnotation(UW.ClassroomPresenter.Network.Messages.Presentation.ImageSheetMessage ism) { if (ism.SheetCollectionSelector != UW.ClassroomPresenter.Network.Messages.Presentation.SheetMessage.SheetCollection.AnnotationSheets) { //We only support annotation sheets, not content sheets return(null); } if ((ism.Parent == null) || !(ism.Parent is CP3Msgs.SlideInformationMessage)) { warning += "Failed to locate slide for a image sheet. Ignoring Image Annotation. "; return(null); } Guid slideId = (Guid)ism.Parent.TargetId; TableOfContents.TocEntry tocEntry = toc.LookupBySlideId(slideId); if (tocEntry == null) { warning += "Warning: Failed to find table of contents entry for a image annotation. Ignoring the annotation. "; return(null); } //WebViewer wants things scaled to 500x500 (this was a CP2 convention). Rectangle r = ((CP3Msgs.SheetMessage)ism).Bounds; float fX = (float)r.X * 500F / getCurrentSlideWidth(); float fY = (float)r.Y * 500F / getCurrentSlideHeight(); Point scaledOrigin = new Point((int)Math.Round(fX), (int)Math.Round(fY)); int scaledWidth = r.Width * 500 / (int)getCurrentSlideWidth(); int scaledHeight = r.Height * 500 / (int)getCurrentSlideHeight(); RTImageAnnotation rtia = new RTImageAnnotation(scaledOrigin, (Guid)ism.TargetId, tocEntry.DeckId, tocEntry.SlideIndex, scaledWidth, scaledHeight, ism.Img); return(rtia); }
/// <summary> /// These are images that are added to slides "on-the-fly". /// </summary> /// <param name="rtia"></param> private void ReceiveImageAnnotation(RTImageAnnotation rtia) { //Get the internal slide index: int slideIndex = slideMap.GetMapping(rtia.SlideIndex, rtia.DeckGuid); //Get the slide and overlay Slide s = SlideDeck.GetSlide(slideIndex); SlideOverlay so = SlideDeck.GetOverlay(slideIndex); lock (so.DynamicImages) { //If the annotation is already on the slide, replace, otherwise add. if (so.DynamicImages.ContainsKey(rtia.Guid)) { so.DynamicImages[rtia.Guid] = new DynamicImage(rtia.Guid, rtia.Origin, rtia.Width, rtia.Height, rtia.Img); } else { so.DynamicImages.Add(rtia.Guid, new DynamicImage(rtia.Guid, rtia.Origin, rtia.Width, rtia.Height, rtia.Img)); } } so.RefreshDynamicElements(); }