Ejemplo n.º 1
0
        public void TestBrokenRelatedLinks()
        {
            PivotCollection collection = new PivotCollection();

            collection.FacetCategories.Add(new PivotFacetCategory("alpha", PivotFacetType.String));

            PivotItem item = new PivotItem("0", collection);

            item.AddFacetValues("alpha", "alpha");
            item.AddRelatedLink(new PivotLink(null, "http://pauthor.codeplex.com"));
            collection.Items.Add(item);

            item = new PivotItem("1", collection);
            item.AddFacetValues("alpha", "bravo");
            item.AddRelatedLink(new PivotLink("charlie", null));
            collection.Items.Add(item);

            PivotCollectionBuffer buffer     = new PivotCollectionBuffer(collection);
            String targetPath                = Path.Combine(WorkingDirectory, "sample.cxml");
            LocalCxmlCollectionTarget target = new LocalCxmlCollectionTarget(targetPath);

            target.Write(buffer);

            AssertCxmlSchemaValid(targetPath);

            CxmlCollectionSource targetAsSource = new CxmlCollectionSource(targetPath);

            buffer.Write(targetAsSource);

            AssertEqual("Related Link", buffer.Collection.Items[0].RelatedLinks.First().Title);
            AssertEqual("http://pauthor.codeplex.com", buffer.Collection.Items[0].RelatedLinks.First().Url);
            AssertEqual(0, buffer.Collection.Items[1].RelatedLinks.Count());
        }
Ejemplo n.º 2
0
        public void TestChainedConversions()
        {
            String sourcePath = Path.Combine(this.ResourceDirectory, @"CSV\sample.csv");
            String step1Path  = Path.Combine(WorkingDirectory, @"step1\sample.cxml");
            String step2Path  = Path.Combine(WorkingDirectory, @"step2\sample.xlsx");
            String step3Path  = Path.Combine(WorkingDirectory, @"step3\sample.cxml");
            String step4Path  = Path.Combine(WorkingDirectory, @"step4\sample.csv");

            PauthorProgram.Main(new String[] { "/source", "csv", sourcePath, "/target", "cxml", step1Path });
            IPivotCollectionSource source         = new CsvCollectionSource(sourcePath);
            IPivotCollectionSource targetAsSource = new CxmlCollectionSource(step1Path);

            AssertCxmlSchemaValid(step1Path);
            AssertCollectionsEqual(source, targetAsSource);

            PauthorProgram.Main(new String[] { "/source", "cxml", step1Path, "/target", "excel", step2Path });
            source         = new CxmlCollectionSource(step1Path);
            targetAsSource = new ExcelCollectionSource(step2Path);
            AssertCollectionsEqual(source, targetAsSource);

            PauthorProgram.Main(new String[] { "/source", "excel", step2Path, "/target", "deepzoom", step3Path });
            source         = new ExcelCollectionSource(step2Path);
            targetAsSource = new CxmlCollectionSource(step3Path);
            AssertCxmlSchemaValid(step3Path);
            AssertCollectionsEqual(source, targetAsSource);

            PauthorProgram.Main(new String[] { "/source", "deepzoom", step3Path, "/target", "csv", step4Path });
            source         = new CxmlCollectionSource(step3Path);
            targetAsSource = new CsvCollectionSource(step4Path);
            AssertCollectionsEqual(source, targetAsSource);

            source         = new CsvCollectionSource(sourcePath);
            targetAsSource = new CsvCollectionSource(step4Path);
            AssertCollectionsEqual(source, targetAsSource);
        }
Ejemplo n.º 3
0
        public void TestCsvToCxmlWithTemplate()
        {
            String sourcePath   = Path.Combine(this.ResourceDirectory, @"CSV\sample_missing_images.csv");
            String templatePath = Path.Combine(this.ResourceDirectory, @"CSV\template-1.htm");
            String targetPath   = Path.Combine(WorkingDirectory, "sample.cxml");

            PauthorProgram.Main(new String[] {
                "/source", "csv", sourcePath, "/html-template", templatePath, "/target", "cxml", targetPath
            });

            AssertCxmlSchemaValid(targetPath);
            AssertFileExists(@"sample.cxml");
            AssertFileExists(@"sample_images\0.png");

            IPivotCollectionSource source         = new CsvCollectionSource(sourcePath);
            IPivotCollectionSource targetAsSource = new CxmlCollectionSource(targetPath);
            PivotCollectionBuffer  buffer         = new PivotCollectionBuffer();

            buffer.Write(source);
            PivotCollection expected = buffer.Collection;

            buffer.Write(targetAsSource);
            PivotCollection actual = buffer.Collection;

            AssertEqual(expected.Name, actual.Name);
            AssertEqual(expected.Icon, actual.Icon);
            AssertEqual(expected.FacetCategories[0].Name, actual.FacetCategories[0].Name);
            AssertEqual(expected.FacetCategories.Count, actual.FacetCategories.Count);
            AssertEqual(expected.Items[0].Name, actual.Items[0].Name);
            AssertNotEqual(expected.Items[0].Image, actual.Items[0].Image);
        }
Ejemplo n.º 4
0
 protected void MainPage_Loaded(object sender, RoutedEventArgs e)
 {
     if (App.Current.Host.InitParams.ContainsKey("collection"))
     {
         string collection = App.Current.Host.InitParams["collection"].ToString();
         Pivot.Visibility = System.Windows.Visibility.Visible;
         try
         {
             _source = new CxmlCollectionSource(new Uri(collection));
             _source.StateChanged += _source_StateChanged;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             Console.WriteLine(ex.ToString());
         }
     }
     else if (App.Current.Host.InitParams.ContainsKey("photo"))
     {
         string photo = App.Current.Host.InitParams["photo"].ToString();
         Image.Visibility = System.Windows.Visibility.Visible;
         try
         {
             Image.Source = new DeepZoomImageTileSource(new Uri(photo));
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             Console.WriteLine(ex.ToString());
         }
     }
 }
Ejemplo n.º 5
0
 protected void MainPage_Loaded(object sender, RoutedEventArgs e)
 {
     if (App.Current.Host.InitParams.ContainsKey("collection"))
     {
         string collection = App.Current.Host.InitParams["collection"].ToString();
         Pivot.Visibility = System.Windows.Visibility.Visible;
         try
         {
             _source = new CxmlCollectionSource(new Uri(collection));
             _source.StateChanged += _source_StateChanged;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             Console.WriteLine(ex.ToString());
         }
     }
     else if (App.Current.Host.InitParams.ContainsKey("photo"))
     {
         string photo = App.Current.Host.InitParams["photo"].ToString();
         Image.Visibility = System.Windows.Visibility.Visible;
         try
         {
             Image.Source = new DeepZoomImageTileSource(new Uri(photo));
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             Console.WriteLine(ex.ToString());
         }
     }
 }
Ejemplo n.º 6
0
        private static void RemoveCurrentUniqueItems(
            ICollection <PivotViewerItem> currentItems, CxmlCollectionSource newItems)
        {
            IEnumerable <PivotViewerItem> onlyInCurrentCollection =
                currentItems.Where(pivotViewerItem => newItems.Items.All(i => i.Id != pivotViewerItem.Id));
            // Need to produce a list, otherwise it will crash (concurrent looping and editing the IEnumerable, or something related)
            var onlyInCurrentCollectionList = onlyInCurrentCollection.ToList();

            foreach (var pivotViewerItem in onlyInCurrentCollectionList)
            {
                currentItems.Remove(pivotViewerItem);
            }
        }
Ejemplo n.º 7
0
        public void TestRoundTrip()
        {
            String sourcePath = Path.Combine(this.ResourceDirectory, @"DeepZoom\sample.cxml");
            String targetPath = Path.Combine(WorkingDirectory, "sample.cxml");

            CxmlCollectionSource      source         = new CxmlCollectionSource(sourcePath);
            LocalCxmlCollectionTarget target         = new LocalCxmlCollectionTarget(targetPath);
            CxmlCollectionSource      targetAsSource = new CxmlCollectionSource(targetPath);

            target.Write(source);

            AssertCxmlSchemaValid(targetPath);
            AssertCollectionsEqual(source, targetAsSource);
        }
Ejemplo n.º 8
0
        public void TestCxmlToExcel()
        {
            String sourcePath = Path.Combine(this.ResourceDirectory, @"CXML\sample.cxml");
            String targetPath = Path.Combine(WorkingDirectory, "sample.xlsx");

            PauthorProgram.Main(new String[] { "/source", "cxml", sourcePath, "/target", "excel", targetPath });

            IPivotCollectionSource source         = new CxmlCollectionSource(sourcePath);
            IPivotCollectionSource targetAsSource = new ExcelCollectionSource(targetPath);

            AssertCollectionsEqual(source, targetAsSource);

            AssertFileExists(@"sample.xlsx");
            AssertFileExists(@"sample_icon.ico");
            AssertFileExists(@"sample_images\0.png");
        }
Ejemplo n.º 9
0
        public void TestDeepZoomToCsv()
        {
            String sourcePath = Path.Combine(this.ResourceDirectory, @"DeepZoom\sample.cxml");
            String targetPath = Path.Combine(WorkingDirectory, "sample.csv");

            PauthorProgram.Main(new String[] { "/source", "deepzoom", sourcePath, "/target", "csv", targetPath });

            IPivotCollectionSource source         = new CxmlCollectionSource(sourcePath);
            IPivotCollectionSource targetAsSource = new CsvCollectionSource(targetPath);

            AssertCollectionsEqual(source, targetAsSource);

            AssertFileExists(@"sample.csv");
            AssertFileExists(@"sample_collection.csv");
            AssertFileExists(@"sample_facetcategories.csv");
            AssertFileExists(@"sample_icon.ico");
            AssertFileExists(@"sample_images\0.png");
        }
Ejemplo n.º 10
0
        public void TestExcelToDeepZoom()
        {
            String sourcePath = Path.Combine(this.ResourceDirectory, @"Excel\sample.xlsx");
            String targetPath = Path.Combine(WorkingDirectory, "sample.cxml");

            PauthorProgram.Main(new String[] { "/source", "excel", sourcePath, "/target", "deepzoom", targetPath });

            IPivotCollectionSource source         = new ExcelCollectionSource(sourcePath);
            IPivotCollectionSource targetAsSource = new CxmlCollectionSource(targetPath);

            AssertCxmlSchemaValid(targetPath);
            AssertCollectionsEqual(source, targetAsSource);

            AssertFileExists(@"sample.cxml");
            AssertFileExists(@"sample_icon.ico");
            AssertFileExists(@"sample_deepzoom\sample.dzc");
            AssertFileExists(@"sample_deepzoom\sample_files\0\0_0.png");
            AssertFileExists(@"sample_deepzoom\0.dzi");
            AssertFileExists(@"sample_deepzoom\0_files\0\0_0.png");
        }
Ejemplo n.º 11
0
        private static void AddNewUniqueItems(ICollection <PivotViewerItem> currentItems, CxmlCollectionSource newItems)
        {
            IEnumerable <PivotViewerItem> onlyInNewCollection =
                newItems.Items.Where(pivotViewerItem => currentItems.All(i => i.Id != pivotViewerItem.Id));

            foreach (var pivotViewerItem in onlyInNewCollection)
            {
                currentItems.Add(pivotViewerItem);
            }
        }
Ejemplo n.º 12
0
 public static void KeepIntersection(
     this ICollection <PivotViewerItem> currentItems, CxmlCollectionSource newItems)
 {
     RemoveCurrentUniqueItems(currentItems, newItems);
     AddNewUniqueItems(currentItems, newItems);
 }
Ejemplo n.º 13
0
 private void pViewer_Loaded(object sender, RoutedEventArgs e)
 {
     _cxml = new CxmlCollectionSource(new Uri(
         "http://pivot.blob.core.windows.net/msdn-magazine/msdnmagazine.cxml", UriKind.Absolute));
     _cxml.StateChanged += _cxml_StateChanged;
 }