示例#1
0
 public void AddVariant(DeviceRequirement requirement, string path, ImageAlignment alignment, ImageResizing resizing)
 {
     this.AddVariant((AssetCatalogItemWithVariants.VariantData) new AssetImageSet.ImageSetVariant(requirement, path)
     {
         alignment = alignment,
         resizing  = resizing
     });
 }
 public void AddVariant(DeviceRequirement requirement, string path, ImageAlignment alignment, ImageResizing resizing)
 {
     ImageSetVariant newItem = new ImageSetVariant(requirement, path) {
         alignment = alignment,
         resizing = resizing
     };
     base.AddVariant(newItem);
 }
示例#3
0
        public void AddVariant(DeviceRequirement requirement, string path, ImageAlignment alignment, ImageResizing resizing)
        {
            var imageset = new ImageSetVariant(requirement, path);

            imageset.alignment = alignment;
            imageset.resizing  = resizing;
            AddVariant(imageset);
        }
示例#4
0
        private void WriteAlignmentToJson(JsonElementDict item, ImageAlignment alignment)
        {
            JsonElementDict dict = item.CreateDict("alignment-insets");

            dict.SetInteger("top", alignment.top);
            dict.SetInteger("bottom", alignment.bottom);
            dict.SetInteger("left", alignment.left);
            dict.SetInteger("right", alignment.right);
        }
示例#5
0
        public void ImageSetCreationWorks()
        {
            var testFiles = new TestFileCache(Path.Combine(GetTestOutputPath(), "Imageset1Files"));

            string catalogPath = Path.Combine(GetTestOutputPath(), "Imageset1.xcassets");
            var    catalog     = new AssetCatalog(catalogPath, "test.test");
            var    imageset    = catalog.OpenImageSet("img1");

            imageset.AddVariant(new DeviceRequirement().AddWidthClass(SizeClassRequirement.Regular),
                                testFiles.CreateFile("data1.png", "img1"));

            imageset.AddVariant(new DeviceRequirement().AddHeightClass(SizeClassRequirement.Compact),
                                testFiles.CreateFile("data2.png", "img2"));

            imageset.AddVariant(new DeviceRequirement().AddScale(ScaleRequirement.X1),
                                testFiles.CreateFile("data3.png", "img3"));

            var alignment = new ImageAlignment();

            alignment.top    = 1;
            alignment.bottom = 2;
            alignment.left   = 3;
            alignment.right  = 4;

            var resizing = new ImageResizing();

            resizing.type             = ImageResizing.SlicingType.HorizontalAndVertical;
            resizing.top              = 1;
            resizing.bottom           = 2;
            resizing.left             = 3;
            resizing.right            = 4;
            resizing.centerResizeMode = ImageResizing.ResizeMode.Stretch;
            resizing.centerWidth      = 2;
            resizing.centerHeight     = 4;

            imageset.AddVariant(new DeviceRequirement().AddScale(ScaleRequirement.X3),
                                testFiles.CreateFile("data4.png", "img4"), alignment, resizing);
            catalog.Write();

            string imagesetPath = Path.Combine(catalogPath, "img1.imageset");

            Assert.IsTrue(Directory.Exists(catalogPath));
            Assert.IsTrue(Directory.Exists(imagesetPath));
            AssertFileExistsAndHasContents(Path.Combine(imagesetPath, "Contents.json"),
                                           File.ReadAllText(Path.Combine(GetTestSourcePath(), "Imageset1.Contents.json")));
            AssertFileExistsAndHasContents(Path.Combine(imagesetPath, "data1.png"), "img1");
            AssertFileExistsAndHasContents(Path.Combine(imagesetPath, "data2.png"), "img2");
            AssertFileExistsAndHasContents(Path.Combine(imagesetPath, "data3.png"), "img3");
            AssertFileExistsAndHasContents(Path.Combine(imagesetPath, "data4.png"), "img4");

            if (!DebugEnabled())
            {
                testFiles.CleanUp();
                Directory.Delete(catalogPath, true);
            }
        }
        public void AddVariant(DeviceRequirement requirement, string path, ImageAlignment alignment, ImageResizing resizing)
        {
            ImageSetVariant newItem = new ImageSetVariant(requirement, path)
            {
                alignment = alignment,
                resizing  = resizing
            };

            base.AddVariant(newItem);
        }
 private void WriteAlignmentToJson(JsonElementDict item, ImageAlignment alignment)
 {
     JsonElementDict dict = item.CreateDict("alignment-insets");
     dict.SetInteger("top", alignment.top);
     dict.SetInteger("bottom", alignment.bottom);
     dict.SetInteger("left", alignment.left);
     dict.SetInteger("right", alignment.right);
 }
 public ImageSetVariant(DeviceRequirement requirement, string path) : base(requirement, path)
 {
     this.alignment = null;
     this.resizing = null;
 }
 public ImageSetVariant(DeviceRequirement requirement, string path) : base(requirement, path)
 {
     this.alignment = null;
     this.resizing  = null;
 }