Exemplo n.º 1
0
        /// <summary>
        /// Helper class that is run on a different thread that converts the ink coordinates into pixel coordinates
        /// </summary>
        /// <param name="extracted">The strokes to convert and add to the model</param>
        private void HandleInkAddedHelper(Ink extracted)
        {
            // Adjust for differences in DPI
            if (ViewerStateModel.NonStandardDpi)
            {
                extracted.Strokes.Transform(ViewerStateModel.DpiNormalizationSendMatrix, true);
            }

            // Get the model object to add it to
            lock (WebService.Instance.GlobalModel) {
                SimpleWebDeck  deck  = (SimpleWebDeck)WebService.Instance.GlobalModel.Decks[WebService.Instance.GlobalModel.CurrentDeck];
                SimpleWebSlide slide = (SimpleWebSlide)deck.Slides[WebService.Instance.GlobalModel.CurrentSlide - 1];
                slide.Inks = new ArrayList();
                // Extract each stroke
                foreach (Stroke s in extracted.Strokes)
                {
                    // Get the points
                    System.Drawing.Point[] pts = s.GetPoints();
                    // Convert and remove duplicates
                    bool                 bFirst  = true;
                    ArrayList            pts_new = new ArrayList();
                    System.Drawing.Point last    = System.Drawing.Point.Empty;
                    foreach (System.Drawing.Point p in pts)
                    {
                        System.Drawing.Point pNew = new System.Drawing.Point((int)Math.Round(p.X / 26.37f), (int)Math.Round(p.Y / 26.37f));
                        if (!bFirst && last == pNew)
                        {
                            continue;
                        }
                        bFirst = false;
                        last   = pNew;
                        pts_new.Add(pNew);
                    }

                    // Add the points to the model
                    SimpleWebInk stroke = new SimpleWebInk();
                    stroke.Pts     = (System.Drawing.Point[])pts_new.ToArray(typeof(System.Drawing.Point));
                    stroke.R       = s.DrawingAttributes.Color.R;
                    stroke.G       = s.DrawingAttributes.Color.G;
                    stroke.B       = s.DrawingAttributes.Color.B;
                    stroke.Opacity = (s.DrawingAttributes.RasterOperation == RasterOperation.MaskPen) ? (byte)127 : (byte)255;
                    stroke.Width   = s.DrawingAttributes.Width / 26.37f;
                    slide.Inks.Add(stroke);
                }
            }
            WebService.Instance.UpdateModel();
        }
Exemplo n.º 2
0
        protected void UpdateAllSlidesAndContent()
        {
            int deckIndex = GetDeckIndex();

            using (Synchronizer.Lock(this.m_Deck.SyncRoot))
            {
                using (Synchronizer.Lock(this.m_Deck.TableOfContents.SyncRoot)) {
                    foreach (TableOfContentsModel.Entry e in this.m_Deck.TableOfContents.Entries)
                    {
                        // Get the index of this entry
                        int index = this.m_Deck.TableOfContents.Entries.IndexOf(e);
                        using (Synchronizer.Lock(e.SyncRoot))
                        {
                            using (Synchronizer.Lock(e.Slide.SyncRoot)) {
                                if (!this.m_SlideWebServices.ContainsKey(e.Slide.Id))
                                {
                                    SlideWebService service = new SlideWebService(this.m_Sender, this.m_Presentation, this.m_Deck, e.Slide);
                                    this.m_SlideWebServices.Add(e.Slide.Id, service);
                                }

                                // Check if the slide exists yet
                                lock (WebService.Instance.GlobalModel) {
                                    SimpleWebSlide s = GetExistingWebSlide((SimpleWebDeck)WebService.Instance.GlobalModel.Decks[deckIndex], e.Slide.Id);
                                    if (s == null)
                                    {
                                        // Add the new slide
                                        s       = new SimpleWebSlide();
                                        s.Id    = e.Slide.Id;
                                        s.Index = index;
                                        s.Name  = e.Slide.Title;
                                        ((SimpleWebDeck)WebService.Instance.GlobalModel.Decks[deckIndex]).Slides.Add(s);
                                    }
                                    else
                                    {
                                        // Update the slide values
                                        s.Index = index;
                                        s.Name  = e.Slide.Title;
                                    }
                                }
                                WebService.Instance.UpdateModel();
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        protected static string BuildSlideString(string prefix, string deckName, int index, SimpleWebSlide slide)
        {
            string newPrefix = prefix + "_" + index;
            string result    = "";

            result += "\t\t\t\t<div id=\"" + newPrefix + "\">\n";
            result += "\t\t\t\t\t<div id=\"" + newPrefix + "_Index\">" + index + "</div>\n";
            result += "\t\t\t\t\t<div id=\"" + newPrefix + "_Name\">" + slide.Name + "</div>\n";
            result += "\t\t\t\t\t<div id=\"" + newPrefix + "_Image\">" + "./images/" + deckName + "/" + deckName + "/" + deckName + "_" + String.Format("{0:000}", index + 1) + ".png" + "</div>\n";
            result += "\t\t\t\t</div>\n";
            return(result);
        }