Ejemplo n.º 1
0
        public void CurrentSlideChangesCorrectly_AddThenRemove()
        {
            var presentation = new Presentation();

            var counter = 0;

            presentation.PropertyChanged += (sender, arg) =>
            {
                counter++;
            };

            // adding should only change CurrentSlide 1 time
            for (int i = 0; i < 4; i++)
            {
                presentation.Add(new Slide());
            }

            // removing currentSlide should update each time
            presentation.Remove(presentation.CurrentSlide);
            presentation.Remove(presentation.CurrentSlide);
            presentation.Remove(presentation.CurrentSlide);
            presentation.Remove(presentation.CurrentSlide);


            Assert.AreEqual(5, counter);
        }
Ejemplo n.º 2
0
        //Export all the pages in a Wiki category into a index presentation, each page
        //will contain up to expPagining summaries. A summary will be composed up to
        //descSize characters taken from the first Header of the Page
        public void ExportIndex(string expCat, string outFileName, int expPaging, int descSize, WikiMedia.ExportNotify expNotify)
        {
            Microsoft.Office.Interop.PowerPoint.Slide     slide     = null;
            Microsoft.Office.Interop.PowerPoint.TextRange textRange = null;
            Presentation pres = new Presentation(fTemplatePath);
            PageList     pl   = wiki.GetPages(expCat);
            int          cnt  = 0;

            foreach (Page page in pl)
            {
                string title = GetTitle(page);
                if (title == null)
                {
                    continue;
                }
                cnt++;
                if ((cnt % expPaging) == 1)
                {
                    slide     = pres.Add(Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText, GetTitleName(expCat));
                    textRange = slide.Shapes[2].TextFrame.TextRange;
                }
                if (expNotify != null)
                {
                    expNotify(page.title);
                }
                page.LoadHTML();
                Document doc = HTML2Model.Convert(page.text);
                AddFirstHeader(textRange, doc, page, title, descSize);
            }
            pres.Save(fBasePath + outFileName);
            pres.Close();
        }
Ejemplo n.º 3
0
            public void PreviousCausesCurrentSlidePropertyChanges()
            {
                var presentation = new Presentation();

                var counter = 0;

                presentation.PropertyChanged += (sender, arg) =>
                {
                    counter++;
                };

                // adding should only change CurrentSlide 1 time
                for (int i = 0; i < 4; i++)
                {
                    presentation.Add(new Slide());
                }

                // 3 next
                presentation.Next();
                presentation.Next();
                presentation.Next();

                // 3 previous
                presentation.Previous();
                presentation.Previous();
                presentation.Previous();

                // no more!
                presentation.Previous();
                presentation.Previous();
                presentation.Previous();

                Assert.AreEqual(7, counter);
            }
Ejemplo n.º 4
0
        public void CanListenToCollectionChanged()
        {
            var presentation = new Presentation();

            var counter = 0;

            presentation.CollectionChanged += (sender, arg) =>
            {
                counter++;
            };

            // add 4 times
            for (int i = 0; i < 4; i++)
            {
                presentation.Add(new Slide());
            }

            // remove 4 times
            presentation.Remove(presentation.CurrentSlide);
            presentation.Remove(presentation.CurrentSlide);
            presentation.Remove(presentation.CurrentSlide);
            presentation.Remove(presentation.CurrentSlide);

            Assert.AreEqual(8, counter);
        }
Ejemplo n.º 5
0
        public void AddSlideExists()
        {
            var presentation = new Presentation();
            var slide        = new Slide();

            presentation.Add(slide);
        }
Ejemplo n.º 6
0
        public void CurrentSlideChangesCorrectly_NextAtEndNoNotify()
        {
            var presentation = new Presentation();

            var counter = 0;

            presentation.PropertyChanged += (sender, arg) =>
            {
                counter++;
            };

            // adding should only change CurrentSlide 1 time
            for (int i = 0; i < 4; i++)
            {
                presentation.Add(new Slide());
            }
            // current is index 0
            presentation.Next(); // current - index 1 (notify!)
            presentation.Next(); // current - index 2 (notify!)
            presentation.Next(); // current - index 3 (notify!)

            // all these extra should not send a new notification
            presentation.Next();
            presentation.Next();
            presentation.Next();
            presentation.Next();
            presentation.Next();
            presentation.Next();

            Assert.AreEqual(4, counter);
        }
Ejemplo n.º 7
0
 // Converts a wiki page into a set of slide (one for each header)
 // Exclude header that have only a sentence presente in SKIPS
 public void Page2Slide(Presentation pres, Document doc, string title, bool skipEmpty)
 {
     Microsoft.Office.Interop.PowerPoint.Slide     slide;
     Microsoft.Office.Interop.PowerPoint.TextRange tr;
     slide = pres.Add(Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutTitle, title);
     foreach (Header header in doc.headers)
     {
         if (skipEmpty)
         {
             if (IsEmptyHeader(header))
             {
                 continue;
             }
         }
         slide = pres.Add(Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText, header.name);
         tr    = slide.Shapes[2].TextFrame.TextRange;
         AddHeader(tr, header, true, 0);
     }
 }
Ejemplo n.º 8
0
        public void AddMultipleSlides_CheckCount()
        {
            var presentation = new Presentation();

            for (int i = 0; i < 4; i++)
            {
                presentation.Add(new Slide());
            }

            Assert.AreEqual(4, presentation.Count);
        }
Ejemplo n.º 9
0
        public void MultipleRemoveCurrentSlide()
        {
            var presentation = new Presentation();

            for (int i = 0; i < 3; i++)
            {
                presentation.Add(new Slide());
            }

            var lastSlide = new Slide();

            presentation.Add(lastSlide);

            presentation.Remove(presentation.CurrentSlide); // removes first
            presentation.Remove(presentation.CurrentSlide); // removes new first
            presentation.Remove(presentation.CurrentSlide); // removes new first
            // now we should only have the last one left

            Assert.AreEqual(lastSlide, presentation.CurrentSlide);
        }
Ejemplo n.º 10
0
        public void CurrentSlideDefaultToFirst()
        {
            var presentation = new Presentation();

            for (int i = 0; i < 4; i++)
            {
                presentation.Add(new Slide());
            }

            Assert.AreEqual(presentation[0], presentation.CurrentSlide);
        }
Ejemplo n.º 11
0
        public void GetCurrentSlide()
        {
            var presentation = new Presentation();
            var slide        = new Slide();

            presentation.Add(slide);

            Slide current = presentation.CurrentSlide;

            Assert.AreEqual(slide, presentation.CurrentSlide);
        }
Ejemplo n.º 12
0
            public void PreviousCannotMovePastStart()
            {
                var presentation = new Presentation();

                var slide = new Slide();

                presentation.Add(slide);

                presentation.Previous();

                Assert.AreEqual(slide, presentation.CurrentSlide);
            }
Ejemplo n.º 13
0
        public void CurrentSlide_AfterNext_IsSecondSlide()
        {
            var presentation = new Presentation();

            for (int i = 0; i < 4; i++)
            {
                presentation.Add(new Slide());
            }

            presentation.Next();

            Assert.AreEqual(presentation[1], presentation.CurrentSlide);
        }
Ejemplo n.º 14
0
        public void CurrentSlide_AfterMultipleNext_CurrentIsCorrect()
        {
            var presentation = new Presentation();

            for (int i = 0; i < 4; i++)
            {
                presentation.Add(new Slide());
            }

            presentation.Next();
            presentation.Next();

            Assert.AreEqual(presentation[2], presentation.CurrentSlide);
        }
Ejemplo n.º 15
0
        public void CurrentSlide_NextCanReachLastSlide()
        {
            var presentation = new Presentation();

            for (int i = 0; i < 4; i++)
            {
                presentation.Add(new Slide());
            }

            presentation.Next();
            presentation.Next();
            presentation.Next();

            Assert.AreEqual(presentation[3], presentation.CurrentSlide);
        }
Ejemplo n.º 16
0
            public void CurrentSlideChangesCorrectly_NextPrevious()
            {
                var presentation = new Presentation();

                // adding should only change CurrentSlide 1 time
                for (int i = 0; i < 4; i++)
                {
                    presentation.Add(new Slide());
                }

                presentation.Next();
                presentation.Previous();

                Assert.AreEqual(presentation[0], presentation.CurrentSlide);
            }
Ejemplo n.º 17
0
        public void CurrentSlide_NextCannotGoBeyondLastSlide_DoesNotThrowException()
        {
            var presentation = new Presentation();

            for (int i = 0; i < 4; i++)
            {
                presentation.Add(new Slide());
            }

            presentation.Next();
            presentation.Next();
            presentation.Next();
            presentation.Next(); // This next should do nothing.
            presentation.Next(); // This next should do nothing.

            Assert.AreEqual(presentation[3], presentation.CurrentSlide);
        }
Ejemplo n.º 18
0
        public void RemoveCurrentSlide()
        {
            var presentation = new Presentation();

            for (int i = 0; i < 4; i++)
            {
                presentation.Add(new Slide());
            }

            presentation.Next();
            presentation.Next();
            presentation.Next();

            presentation.Remove(presentation.CurrentSlide);

            Assert.AreEqual(presentation[2], presentation.CurrentSlide);
        }
Ejemplo n.º 19
0
        public void RemoveAllCurrentSlide()
        {
            var presentation = new Presentation();

            for (int i = 0; i < 4; i++)
            {
                presentation.Add(new Slide());
            }

            presentation.Remove(presentation.CurrentSlide);
            presentation.Remove(presentation.CurrentSlide);
            presentation.Remove(presentation.CurrentSlide);
            presentation.Remove(presentation.CurrentSlide);

            // There should always be a default slide even when we have tried to remove all other slides
            Assert.IsNotNull(presentation.CurrentSlide);
        }
Ejemplo n.º 20
0
 //Generate a slide with the given header element names
 public void ExportHeaders(Presentation pres, string title, Header[] heads, string[] names, bool firstSpecial)
 {
     Microsoft.Office.Interop.PowerPoint.Slide     slide = pres.Add(Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText, title);
     Microsoft.Office.Interop.PowerPoint.TextRange textRange;
     Microsoft.Office.Interop.PowerPoint.TextRange tr1;
     textRange = slide.Shapes[2].TextFrame.TextRange;
     for (int i = 0; i < heads.Length; i++)
     {
         Header header = heads[i];
         if (!converter.IsEmptyHeader(header))
         {
             tr1 = textRange.InsertAfter(names[i] + "\r");
             converter.AddHeader(textRange, header, firstSpecial, 0);
             tr1.Font.Bold = MsoTriState.msoTrue;
             tr1.ParagraphFormat.Bullet.Visible = MsoTriState.msoFalse;
         }
     }
 }
Ejemplo n.º 21
0
        //Create slides with the index of all the pages in a wiki category
        //Pages will be subdivided into two columns and paged in pageSize elements per page
        public void Index2Slide(Presentation pres, PageList pl, string indexName, int pageSize)
        {
            Microsoft.Office.Interop.PowerPoint.Slide     idexSlide;
            Microsoft.Office.Interop.PowerPoint.TextRange index1 = null;
            Microsoft.Office.Interop.PowerPoint.TextRange index2 = null;
            Microsoft.Office.Interop.PowerPoint.TextRange index  = null;
            int  cnt   = 0;
            bool first = true;

            foreach (Page page in pl)
            {
                string title = GetTitle(page);
                if (title == null)
                {
                    continue;
                }
                if ((cnt % pageSize) == 0)
                {
                    idexSlide = pres.Add(Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutTwoColumnText, indexName);
                    index1    = idexSlide.Shapes[2].TextFrame.TextRange;
                    index2    = idexSlide.Shapes[3].TextFrame.TextRange;
                    first     = true;
                }
                if ((cnt % 2) == 0)
                {
                    index = index1;
                }
                else
                {
                    index = index2;
                }
                if (!first)
                {
                    index.Text += Presentation.SEP;
                }
                index.Text += title;
                if ((cnt % 2) != 0)
                {
                    first = false;
                }
                cnt++;
            }
        }
Ejemplo n.º 22
0
        public void CurrentSlideChangesCorrectly_Add()
        {
            var presentation = new Presentation();

            var counter = 0;

            presentation.PropertyChanged += (sender, arg) =>
            {
                counter++;
            };

            // adding should only change CurrentSlide 1 time
            for (int i = 0; i < 4; i++)
            {
                presentation.Add(new Slide());
            }

            Assert.AreEqual(1, counter);
        }
Ejemplo n.º 23
0
        public Toolbar()
        {
            Masking          = true;
            RelativeSizeAxes = Axes.Y;
            Children         = new Drawable[]
            {
                new Container
                {
                    Width  = TOOLBAR_WIDTH_CONTROLS - TOOLBAR_WIDTH,
                    Margin = new MarginPadding {
                        Left = TOOLBAR_WIDTH
                    },
                    RelativeSizeAxes = Axes.Y,
                    Children         = new Drawable[]
                    {
                        new ThemedSolidBox
                        {
                            ThemeColour      = ThemeColour.NeutralLight,
                            RelativeSizeAxes = Axes.Both,
                        },
                        sections = new Presentation <ToolbarSection>
                        {
                            RelativeSizeAxes = Axes.Both,
                        },
                    }
                },
                navigationBar = new NavigationBar
                {
                    ToggleRequested = () => ToggleVisibility(),
                    Items           = new ToolbarSection[]
                    {
                        new BackgroundSettingSection(),
                        new ApplicationSettingSection(),
                    },
                },
            };

            EdgeEffect = new EdgeEffectParameters
            {
                Type   = EdgeEffectType.Shadow,
                Colour = Colour4.Black.Opacity(0.4f),
                Radius = 20.0f,
                Hollow = true,
            };

            navigationBar.Current.BindValueChanged((e) =>
            {
                if (e.NewValue != null)
                {
                    if (!sections.Items.Contains(e.NewValue))
                    {
                        LoadComponentAsync(e.NewValue, loaded =>
                        {
                            sections.Add(loaded);
                            sections.Select(loaded);
                        });
                        return;
                    }

                    sections.Select(e.NewValue);
                }
            }, true);
        }