Beispiel #1
0
        public static SlidePreview CreateFromSlide(Slide slide, string presentationId, string text = null)
        {
            var preview = new SlidePreview();
            preview.slideText = text ?? (slide != null ? ("" + slide.SlideNumber) : "1");
            preview.presentationId = presentationId;

            preview.slideImage = new BitmapImage();

            byte[] buffer;

            if (slide == null || slide.ImageData == null) {
                var bitmap = new Bitmap(1024, 768);
                var g = Graphics.FromImage(bitmap);
                g.Clear(Color.Transparent);

                using (var memory = new MemoryStream()) {
                    bitmap.Save(memory, ImageFormat.Png);
                    memory.Position = 0;
                    using (var br = new BinaryReader(memory)) {
                        buffer = br.ReadBytes((Int32) memory.Length);
                    }
                }

                if (slide != null) slide.ImageData = buffer;
            } else {
                buffer = slide.ImageData;
            }

            preview.slideImage.BeginInit();
            preview.slideImage.StreamSource = new MemoryStream(buffer);
            preview.slideImage.EndInit();

            return preview;
        }
Beispiel #2
0
        public static SlidePreview CreateAddNewSlide(string presentationId, string text = "New Slide")
        {
            var preview = new SlidePreview();
            preview.slideText = text;
            preview.presentationId = presentationId;

            preview.slideImage = new BitmapImage();

            var bitmap = new Bitmap(Resources.newSlide);

            byte[] buffer;

            using (var memory = new MemoryStream()) {
                bitmap.Save(memory, ImageFormat.Png);
                memory.Position = 0;
                using (var br = new BinaryReader(memory)) {
                    buffer = br.ReadBytes((Int32)memory.Length);
                }
            }

            preview.slideImage.BeginInit();
            preview.slideImage.StreamSource = new MemoryStream(buffer);
            preview.slideImage.EndInit();

            return preview;
        }
Beispiel #3
0
 /// <summary>
 /// Start a Presentation and start a Command Receive Thread
 /// </summary>
 public void StartPresentation(SlidePreview presentationPreview)
 {
     new Thread(() => {
         if (ShowPresentation != null) {
             var p = FetchPresentation(presentationPreview);
             if (p == null) {
                 if (CancelStartPresentation != null) CancelStartPresentation(this, null);
                 return;
             }
             ShowPresentation(this, p);
             commandThread = new Thread(RequestNextCommand);
             commandThread.Start();
         } else {
             if (CancelStartPresentation != null) CancelStartPresentation(this, null);
         }
     }).Start();
 }
Beispiel #4
0
        /// <summary>
        /// Get All Slides of a Presentation
        /// </summary>
        private Presentation FetchPresentation(SlidePreview presentationPreview)
        {
            var slides = new List<Slide>();

            var cnt = service.GetPresentationSlidesCount(clientId, presentationPreview.PresentationId);
            if (cnt < 0) return null;
            if (GotPresentationSlidesCount != null) GotPresentationSlidesCount(this, cnt);
            for (var i = 0; i < cnt; ++i) {
                var slide = service.GetPresentationSlide(clientId, presentationPreview.PresentationId, i);
                if (slide == null) return null;
                if (GotPresentationSlide != null) GotPresentationSlide(this, null);
                slides.Add(slide);
            }

            return new Presentation {
                Id = presentationPreview.PresentationId,
                Name = presentationPreview.SlideText,
                Owner = clientId,
                Slides = slides
            };
        }
Beispiel #5
0
 /// <summary>
 /// Edit a Presentation, so fetch and display as a first Step
 /// </summary>
 public void ChangePresentation(SlidePreview presentationPreview)
 {
     new Thread(() => {
         if (EditPresentation != null) {
             var p = FetchPresentation(presentationPreview);
             if (p == null) return;
             currentPresentation = p;
             CommandManager.InvalidateRequerySuggested();
             EditPresentation(this, currentPresentation);
         } else {
             if (CancelStartPresentation != null) CancelStartPresentation(this, null);
         }
     }).Start();
 }