private void represent(IEnumerable<MeTLLib.DataTypes.QuizAnswer> answers, MeTLLib.DataTypes.QuizQuestion question)
 {
     if (answers == null || question == null) return;
     App.auditor.trace("AssessAQuiz {0}", question.Id);
     Dispatcher.adoptAsync(delegate
     {
         var response = (answers.Count() > 1 || answers.Count() == 0) ? "({0} responses)" : "({0} response)"; 
         responseCount.Content = string.Format(response, answers.Count());
         resultDisplay.ItemsSource = question.Options.Select(o =>
         {
             if (answers != null)
             {
                 var relevant = answers.Where(a => a.answer == o.name);
                 return new DisplayableResultSet
                 {
                     color = o.color,
                     count = relevant.Count(),
                     proportion = answers.Count() == 0 ? 0 :
                         (double)relevant.Count() / answers.Count(),
                     tooltip = o.optionText,
                     name = o.name
                 };
             }
             return new DisplayableResultSet();
         });
     });
 }
 public AssessAQuiz(ObservableCollection<MeTLLib.DataTypes.QuizAnswer> answers, MeTLLib.DataTypes.QuizQuestion question)
     : this()
 {
     DataContext = question;
     represent(answers, question);
     answers.CollectionChanged += (sender, args) => represent(answers, question);
 }
Ejemplo n.º 3
0
 private void PreParserAvailable(MeTLLib.Providers.Connection.PreParser parser)
 {
     BeginInit();
     stack.handwriting.ReceiveStrokes(parser.ink);
     stack.images.ReceiveImages(parser.images.Values);
     foreach (var text in parser.text.Values)
         stack.text.doText(text);
     EndInit();
 }
 private void UpdateConversationDetails(MeTLLib.DataTypes.ConversationDetails details)
 {
     if (ConversationDetails.Empty.Equals(details)) return;
     Dispatcher.adoptAsync(delegate
     {
         var editingMode = isAuthor(details) || canStudentPublish(details);
         handwriting.SetCanEdit(editingMode);
         text.SetCanEdit(editingMode);
         images.SetCanEdit(editingMode);
     });
 }
        private void receiveSubmission(MeTLLib.DataTypes.TargettedSubmission submission)
        {
            if (string.IsNullOrEmpty(submission.target) || submission.target != "bannedcontent")
                return;

            if (!IHaveThisSubmission(submission))
            {
                submissionList.Add(submission);
                Commands.RequerySuggested(Commands.ViewBannedContent);
            }
        }
Ejemplo n.º 6
0
 public PrintParser(
     Credentials credentials,
     int room,
     MeTLLib.Providers.Structure.IConversationDetailsProvider conversationDetailsProvider,
     HttpHistoryProvider historyProvider,
     CachedHistoryProvider cachedHistoryProvider,
     MetlConfiguration metlServerAddress,
     ResourceCache cache,
     IReceiveEvents receiveEvents,
     IWebClientFactory webClientFactory,
     HttpResourceProvider httpResourceProvider,
     IAuditor _auditor)
     : base(credentials, room, conversationDetailsProvider, historyProvider, cachedHistoryProvider, metlServerAddress, cache, receiveEvents, webClientFactory, httpResourceProvider,_auditor)
 {
 }
        private void PreParserAvailable(MeTLLib.Providers.Connection.PreParser parser)
        {
            Dispatcher.adopt(delegate
            {
                try
                {
                    BeginInit();
                    notepadStack.ReceiveStrokes(parser.ink);
                    notepadStack.ReceiveImages(parser.images.Values);
                    foreach (var text in parser.text.Values)
                        notepadStack.DoText(text);
                    foreach (var moveDelta in parser.moveDeltas)
                        notepadStack.ReceiveMoveDelta(moveDelta, processHistory: true);

                }
                finally
                {
                    EndInit();
                }
            });
        }
 private void receiveFile(MeTLLib.DataTypes.TargettedFile fileInfo)
 {
     //if (!Globals.conversationDetails.IsJidEqual(fileInfo.conversationJid.ToString())) return;  // it appears that the files aren't holding their jids properly, which is not surprising, given that only C# thinks it's necessary for the element to know it, and I'm not sure what it's using it for, other than this check.
         var fileInfoFileType = FileHelper.DetermineFileTypeFromExtension(fileInfo.name);
         if (files.Select(f => f.identity).Contains(fileInfo.identity)) return;
         var uploadTime = DateTime.Now;
         try
         {
             uploadTime = new DateTime(long.Parse(fileInfo.uploadTime));
         }
         catch (Exception ex)
         {
             try
             {
                 uploadTime = DateTime.Parse(fileInfo.uploadTime);
             }
             catch (Exception exc)
             {
             }
         }
     Dispatcher.adoptAsync(() =>
     {
         files.Add(new FileInfo
         {
             fileType = fileInfoFileType,
             filename = fileInfo.name,
             author = fileInfo.author,
             identity = fileInfo.identity,
             fileImage = FileHelper.GetFileTypeImageResource(fileInfo.name),
             uploadTime = fileInfo.uploadTime,
             size = fileInfo.size,
             tooltip = string.Format("Type: {0}\nAuthor: {1}\nUpload Time: {2}\nSize: {3}",
             fileInfoFileType,
             fileInfo.author,
             uploadTime,
             string.Format(new FileSizeFormatProvider(), "{0:fs}", fileInfo.size))
         });
     });
 }
 private bool isAuthor(MeTLLib.DataTypes.ConversationDetails details)
 {
     return details.Author == Globals.me ? true : false;
 }
Ejemplo n.º 10
0
 private static bool videoCompare(MeTLLib.DataTypes.Video video, MeTLLib.DataTypes.Video currentVideo)
 {
     if (System.Windows.Controls.Canvas.GetTop(currentVideo) == System.Windows.Controls.Canvas.GetTop(video))
         return false;
     if (System.Windows.Controls.Canvas.GetLeft(currentVideo) == System.Windows.Controls.Canvas.GetLeft(video))
         return false;
     if (video.VideoSource.ToString() != currentVideo.VideoSource.ToString())
         return false;
     if (video.tag().id != currentVideo.tag().id)
         return false;
     return true;
 }
 private void loggedIn(MeTLLib.DataTypes.Credentials identity)
 {
     handwriting.Enable();
 }
Ejemplo n.º 12
0
 private void ReceiveImage(MeTLLib.DataTypes.TargettedImage image)
 {
 }
Ejemplo n.º 13
0
 /*Utility methods*/
 private bool videoExistsOnCanvas(MeTLLib.DataTypes.Video testVideo)
 {
     foreach (UIElement video in Children)
         if (video is MeTLLib.DataTypes.Video)
             if (videoCompare((MeTLLib.DataTypes.Video)video, testVideo))
                 return true;
     return false;
 }
Ejemplo n.º 14
0
 public void UploadAndSendVideo(MeTLLib.DataTypes.MeTLStanzas.LocalVideoInformation lvi)
 {
     Action work = delegate
     {
         var newPath = new Uri(resourceUploader.uploadResource(lvi.slide.ToString(), lvi.file, false), UriKind.Absolute);
         MeTLLib.DataTypes.Video newVideo = lvi.video;
         newVideo.VideoSource = newPath;
         newVideo.MediaElement = new MediaElement();
         newVideo.MediaElement.Source = newPath;
         wire.SendVideo(new TargettedVideo(lvi.slide, lvi.author, lvi.target, lvi.privacy, newVideo));
     };
     tryIfConnected(work);
 }
Ejemplo n.º 15
0
 public void UploadAndSendImage(MeTLLib.DataTypes.MeTLStanzas.LocalImageInformation lii)
 {
     Action work = delegate
     {
         Trace.TraceInformation("Beginning ImageUpload: " + lii.file);
         var newPath = resourceUploader.uploadResource(lii.slide.ToString(), lii.file, false);
         Trace.TraceInformation("ImageUpload remoteUrl set to: " + newPath);
         Image newImage = lii.image;
         newImage.Source = (ImageSource)new ImageSourceConverter().ConvertFromString(newPath);
         wire.SendImage(new TargettedImage(lii.slide, lii.author, lii.target, lii.privacy, newImage));
     };
     tryIfConnected(work);
 }
Ejemplo n.º 16
0
 public void ReceiveTextBox(MeTLLib.DataTypes.TargettedTextBox targettedBox)
 {
     if (targettedBox.target != target) return;
     if (targettedBox.author == Globals.me && alreadyHaveThisTextBox(targettedBox.box.toMeTLTextBox()) && me != "projector")
     {
         var box = textBoxFromId(targettedBox.identity);
         if (box != null)
             ApplyPrivacyStylingToElement(box, box.tag().privacy);
         return;
     }//I never want my live text to collide with me.
     if (targettedBox.slide == currentSlide && (targettedBox.privacy == "private" || me == "projector"))
         removeDoomedTextBoxes(targettedBox);
     if (targettedBox.slide == currentSlide && (targettedBox.privacy == "public" || (targettedBox.author == Globals.me && me != "projector")))
             doText(targettedBox);
 }
 public LocalVideoInformation(int Slide, string Author, string Target, string Privacy, MeTLLib.DataTypes.Video Video, string File, bool Overwrite)
 {
     slide = Slide;
     author = Author;
     target = Target;
     privacy = Privacy;
     video = Video;
     file = File;
     overwrite = Overwrite;
 }
Ejemplo n.º 18
0
 private void DugPublicSpace(MeTLLib.DataTypes.LiveWindowSetup setup)
 {
     if (target != "notepad") return;
     Dispatcher.adopt((Action)delegate
     {
         var view = new Rect(setup.origin, new Size(setup.frame.Width, setup.frame.Height));
         var liveWindow = new Rectangle
         {
             Width = setup.frame.Width,
             Height = setup.frame.Height,
             Fill = new VisualBrush
             {
                 Visual = setup.visualSource,
                 TileMode = TileMode.None,
                 Stretch = Stretch.None,
                 AlignmentX = AlignmentX.Left,
                 AlignmentY = AlignmentY.Top,
                 ViewboxUnits = BrushMappingMode.Absolute,
                 Viewbox = view
             },
             Tag = setup.snapshotAtTimeOfCreation
         };
         var RLW = new MeTLLib.DataTypes.RenderedLiveWindow()
         {
             Rectangle = liveWindow,
             Height = liveWindow.Height,
             Width = liveWindow.Width
         };
         Children.Add(RLW);
         InkCanvas.SetLeft(RLW, setup.target.X);
         InkCanvas.SetTop(RLW, setup.target.Y);
     });
 }
Ejemplo n.º 19
0
 public void AddVideoClone(MeTLLib.DataTypes.Video element)
 {
     if (!videoExistsOnCanvas(element) && element.tag().privacy == "public")
     {
         var videoClone = new MeTLLib.DataTypes.VideoMirror();
         videoClone.id = element.tag().id;
         if (videoClone.Rectangle == null)
             videoClone.RequestNewRectangle();
         Children.Add(videoClone);
         InkCanvas.SetLeft(videoClone, element.X);
         InkCanvas.SetTop(videoClone, element.Y);
         videoClone.Height = element.Height;
         videoClone.Width = element.Width;
     }
 }
Ejemplo n.º 20
0
 public void AddVideo(MeTLLib.DataTypes.Video element)
 {
     if (!videoExistsOnCanvas(element))
     {
         var height = element.Height;
         var width = element.Width;
         Children.Add(element);
         element.MediaElement.LoadedBehavior = MediaState.Manual;
         InkCanvas.SetLeft(element, element.X);
         InkCanvas.SetTop(element, element.Y);
         element.Height = height;
         element.Width = width;
     }
 }
Ejemplo n.º 21
0
 public void ReceiveVideo(MeTLLib.DataTypes.TargettedVideo video)
 {
     Dispatcher.adoptAsync(delegate
     {
         video.video.MediaElement.LoadedBehavior = MediaState.Manual;
         video.video.MediaElement.ScrubbingEnabled = true;
         if (me == "projector")
             AddVideoClone(video.video);
         else
             AddVideo(video.video);
     });
 }
 private bool canStudentPublish(MeTLLib.DataTypes.ConversationDetails details)
 {
     return details.Permissions.studentCanPublish;
 }
        private void receiveSubmission(MeTLLib.DataTypes.TargettedSubmission submission)
        {
            if (!String.IsNullOrEmpty(submission.target) && submission.target != "submission")
                return;

            if (!IHaveThisSubmission(submission))
            {
                submissionList.Add(submission);
                Commands.RequerySuggested(Commands.ViewSubmissions);
            }
        }
Ejemplo n.º 24
0
 private void mirrorVideo(MeTLLib.DataTypes.VideoMirror.VideoMirrorInformation info)
 {
     if (me != "projector") return;
     try
     {
         foreach (FrameworkElement fe in Children.ToList())
         {
             if (fe is MeTLLib.DataTypes.VideoMirror)
             {
                 var vm = (MeTLLib.DataTypes.VideoMirror)fe;
                 if (info.rect == null)
                     Children.Remove(vm);
                 else vm.UpdateMirror(info);
             }
         }
     }
     catch (Exception) { }
 }
Ejemplo n.º 25
0
 public void UploadAndSendFile(MeTLLib.DataTypes.MeTLStanzas.LocalFileInformation lfi)
 {
     Action work = delegate
     {
         var newPath = resourceUploader.uploadResource(lfi.slide.ToString(), lfi.file, lfi.overwrite);
         wire.sendFileResource(new TargettedFile(lfi.slide, lfi.author, lfi.target, lfi.privacy, newPath, lfi.uploadTime, lfi.size, lfi.name));
     };
     tryIfConnected(work);
 }
Ejemplo n.º 26
0
        public void doText(MeTLLib.DataTypes.TargettedTextBox targettedBox)
        {
            Dispatcher.adoptAsync(delegate
                                      {
                                          if (targettedBox.target != target) return;
                                          if (targettedBox.slide == currentSlide &&
                                              (targettedBox.privacy == "public" || targettedBox.author == Globals.me))
                                          {

                                              var box = targettedBox.box.toMeTLTextBox();
                                              removeDoomedTextBoxes(targettedBox);
                                              Children.Add(applyDefaultAttributes(box));
                                              if (!(targettedBox.author == Globals.me && focusable))
                                                  box.Focusable = false;
                                              ApplyPrivacyStylingToElement(box, targettedBox.privacy);
                                          }
                                      });
        }
Ejemplo n.º 27
0
 public override void actOnQuizReceived(MeTLLib.DataTypes.QuizQuestion details)
 {
     //Nothing.  Printer doesn't care about quiz
 }
 public DisplayAQuiz(MeTLLib.DataTypes.QuizQuestion thisQuiz)
 {
     DataContext = thisQuiz;
     InitializeComponent();
 }
Ejemplo n.º 29
0
 private void removeDoomedTextBoxes(MeTLLib.DataTypes.TargettedTextBox targettedBox)
 {
     var box = targettedBox.box;
     var doomedChildren = new List<FrameworkElement>();
     foreach (var child in Children)
     {
         if (child is MeTLTextBox)
             if (((MeTLTextBox)child).tag().id.Equals(box.tag().id))
                 doomedChildren.Add((FrameworkElement)child);
     }
     foreach (var child in doomedChildren)
         Children.Remove(child);
 }
Ejemplo n.º 30
0
 private bool shouldDisplay(MeTLLib.DataTypes.TargettedVideo video)
 {
     return !(video.slide != currentSlide ||
         !(video.target.Equals(target)) ||
         (!(video.privacy == "public" || (video.author == Globals.me && me != "projector"))));
 }