Exemple #1
0
        public void Handwheel() //Full integrated with all optimizations
        {
            var resKeyInfo = new ResKeyInfo {
                Prefix = "Prefix"
            };
            var xaml = ConverterLogic.SvgFileToXaml("TestFiles\\Handwheel.svg", ResultMode.DrawingGroup, resKeyInfo, false, null);

            CheckXamlOutput(xaml);
        }
        public void SvgDirToXaml_with_defaultSettingsTest()
        {
            var resKeyInfo = new ResKeyInfo {
                XamlName = "Test", Prefix = "NamePrefix"
            };
            var xaml = ConverterLogic.SvgDirToXaml("TestFiles\\", resKeyInfo, null, false);

            CheckXamlOutput(xaml);
        }
Exemple #3
0
        public void SvgDirToXaml_with_defaultSettingsTest()
        {
            var resKeyInfo = new ResKeyInfo {
                XamlName = "Test", Prefix = "NamePrefix"
            };
            var xaml = ConverterLogic.SvgDirToXaml("TestFiles\\", resKeyInfo, null);

            Console.WriteLine(xaml);
        }
Exemple #4
0
        public void BuildDrawingImageName_returns_simpleName()
        {
            var resKeyInfo = new ResKeyInfo
            {
                UseComponentResKeys = false,
                Prefix = null
            };

            ConverterLogic.BuildDrawingImageName("ElementName", resKeyInfo).Should().Be("ElementNameDrawingImage");
        }
Exemple #5
0
        public void BuildDrawingGroupName_returns_prefixedName()
        {
            var resKeyInfo = new ResKeyInfo
            {
                UseComponentResKeys = false,
                Prefix = "NamePrefix"
            };

            ConverterLogic.BuildDrawingGroupName("ElementName", resKeyInfo).Should().Be("NamePrefix_ElementNameDrawingGroup");
        }
Exemple #6
0
        public void Handwheel() //Full integrated with all optimizations
        {
            var resKeyInfo = new ResKeyInfo {
                Prefix = "Prefix"
            };
            var xaml = ConverterLogic.SvgFileToXaml("TestFiles\\Handwheel.svg", ResultMode.DrawingGroup, resKeyInfo, null);

            Console.WriteLine(xaml);
            Clipboard.SetText(xaml);
        }
        public void Handwheel3() //integrated conversion, integrated writing
        {
            var drawing = ConverterLogic.SvgFileToWpfObject("TestFiles\\Handwheel.svg", null);
            var xaml    = ConverterLogic.SvgObjectToXaml(drawing, true, new XamlWriteOptions()
            {
                Name = "Test"
            });

            Console.WriteLine(xaml);
            Clipboard.SetText(xaml);
        }
Exemple #8
0
        public void SvgDirToXamlTest()
        {
            var settings = new WpfDrawingSettings
            {
                IncludeRuntime = false,
                TextAsGeometry = false,
                OptimizePath   = true,
            };
            var xaml = ConverterLogic.SvgDirToXaml("..\\..\\TestFiles\\", "Test", settings);

            Console.WriteLine(xaml);
        }
Exemple #9
0
        public void ConvertFileToDrawingGroupWithRuntime(string filename)
        {
            var settings = new WpfDrawingSettings
            {
                IncludeRuntime = true,
                TextAsGeometry = false,
                OptimizePath   = true,
            };
            var xaml = ConverterLogic.SvgFileToXaml(filename, ResultMode.DrawingGroup, settings);

            Console.WriteLine(xaml);
        }
Exemple #10
0
        private void ReadImagesFromDir(string folder)
        {
            Images.Clear();
            var svgFiles  = ConverterLogic.SvgFilesFromFolder(folder);
            var svgImages = svgFiles.Select(f => new SvgImageViewModel(f));

            var graphicFiles  = GetFilesMulti(folder, GraphicImageViewModel.SupportedFormats);
            var graphicImages = graphicFiles.Select(f => new GraphicImageViewModel(f));

            var allImages = svgImages.Concat <ImageBaseViewModel>(graphicImages).OrderBy(e => e.Filepath);

            Images.AddRange(allImages);
        }
Exemple #11
0
        public void SvgDirToXamlTest_withUseCompResKey()
        {
            var settings = new WpfDrawingSettings
            {
                IncludeRuntime = false,
                TextAsGeometry = false,
                OptimizePath   = true,
            };

            var xaml = ConverterLogic.SvgDirToXaml("TestFiles\\", ResKeyInfoUseCompResKey, settings, false);

            CheckXamlOutput(xaml);
        }
Exemple #12
0
        public void BuildDrawingGroupName_returns_prefixedName_using_CompResKey()
        {
            var resKeyInfo = new ResKeyInfo
            {
                UseComponentResKeys = true,
                XamlName            = "XamlName",
                NameSpaceName       = "NameSpaceName",
                //Prefix = "NamePrefix"
            };
            var key = ConverterLogic.BuildDrawingGroupName("ElementName", resKeyInfo);

            Console.WriteLine(key);
            key.Should().Be("{x:Static NameSpaceName:XamlName.ElementNameDrawingGroupKey}");
        }
Exemple #13
0
        private void ExportDirExecute()
        {
            string outFileName = Path.Combine(CurrentDir, Path.GetFileNameWithoutExtension(CurrentDir) + ".xaml");
            var    saveDlg     = new SaveFileDialog {
                AddExtension = true, DefaultExt = ".xaml", Filter = "Xaml-File|*.xaml", FileName = outFileName
            };

            if (saveDlg.ShowDialog() == DialogResult.OK)
            {
                outFileName = saveDlg.FileName;
                File.WriteAllText(outFileName, ConverterLogic.SvgDirToXaml(CurrentDir, Path.GetFileNameWithoutExtension(outFileName)));
                MessageBox.Show(outFileName + "\nhas been written");
            }
        }
Exemple #14
0
        public void ConvertFileToDrawingGroup2()
        {
            var settings = new WpfDrawingSettings
            {
                IncludeRuntime = false,
                TextAsGeometry = false,
                OptimizePath   = true,
            };
            var xaml = ConverterLogic.SvgFileToXaml("..\\..\\TestFiles\\3d-view-icon.svg", ResultMode.DrawingGroup, settings);

            Console.WriteLine(xaml);
            string expected = File.ReadAllText("..\\..\\TestFiles\\3d-view-icon_expected.txt");

            xaml.Should().Be(expected);
        }
Exemple #15
0
        public void ConvertFileToDrawingImage(string filename)
        {
            var settings = new WpfDrawingSettings
            {
                IncludeRuntime = false,
                TextAsGeometry = false,
                OptimizePath   = true,
            };
            var resKeyInfo = new ResKeyInfo {
                Prefix = "Prefix"
            };
            var xaml = ConverterLogic.SvgFileToXaml(filename, ResultMode.DrawingImage, resKeyInfo, settings);

            Console.WriteLine(xaml);
        }
Exemple #16
0
        public void ConvertFileToDrawingImage(string filename)
        {
            var settings = new WpfDrawingSettings
            {
                IncludeRuntime = false,
                TextAsGeometry = false,
                OptimizePath   = true,
            };
            var resKeyInfo = new ResKeyInfo {
                Prefix = "Prefix"
            };
            var xaml = ConverterLogic.SvgFileToXaml(filename, ResultMode.DrawingImage, resKeyInfo, true, settings);

            CheckXamlOutput(xaml, Path.GetFileName(filename));
        }
Exemple #17
0
        public void SvgDirToXamlTest_withNamePrefix()
        {
            var settings = new WpfDrawingSettings
            {
                IncludeRuntime = false,
                TextAsGeometry = false,
                OptimizePath   = true,
            };
            var resKeyInfo = new ResKeyInfo {
                XamlName = "Test", Prefix = "NamePrefix"
            };
            var xaml = ConverterLogic.SvgDirToXaml("TestFiles\\", resKeyInfo, settings, true);

            CheckXamlOutput(xaml);
        }
Exemple #18
0
        public void ConvertFileToDrawingGroup2()
        {
            var settings = new WpfDrawingSettings
            {
                IncludeRuntime = false,
                TextAsGeometry = false,
                OptimizePath   = true,
            };
            var resKeyInfo = new ResKeyInfo {
                Prefix = "Prefix"
            };
            var xaml = ConverterLogic.SvgFileToXaml("TestFiles\\3d-view-icon.svg", ResultMode.DrawingGroup, resKeyInfo, false, settings);

            CheckXamlOutput(xaml);
        }
Exemple #19
0
        public void SvgDirToXamlTest_withUseCompResKey()
        {
            var settings = new WpfDrawingSettings
            {
                IncludeRuntime = false,
                TextAsGeometry = false,
                OptimizePath   = true,
            };

            var xaml = ConverterLogic.SvgDirToXaml("TestFiles\\", ResKeyInfoUseCompResKey, settings);

            Console.WriteLine(xaml);
            File.WriteAllText("TestFiles\\ExpectedXaml_SvgDirToXamlTest_withUseCompResKey.xaml", xaml);
            var expectedXaml = File.ReadAllText("TestFiles\\ExpectedXaml_SvgDirToXamlTest_withUseCompResKey.xaml");

            xaml.Should().Be(expectedXaml);
        }
Exemple #20
0
        public async Task <IActionResult> GetAllProducts([FromQuery] string requestedCurrency, string requestedProduct)
        {
            var            parser = new DataParser();
            ConverterLogic logic  = new ConverterLogic();

            string currencyData = await parser.GetFile(RateUrl, client);

            string productData = await parser.GetFile(ProductUrl, client);

            List <CurrencyRate> RateList    = logic.CurrencyRateToList(currencyData, ',', 1);
            List <Product>      ProductList = logic.ProductsToList(productData, ',', 1);

            Result price = logic.ConvertCurrency(RateList, ProductList, requestedCurrency, requestedProduct);

            var output = JsonConvert.SerializeObject(price);

            return(Ok(output));
        }
Exemple #21
0
        private void ExportDirExecute()
        {
            string outFileName = Path.GetFileNameWithoutExtension(CurrentDir) + ".xaml";
            var    saveDlg     = new SaveFileDialog {
                AddExtension = true, DefaultExt = ".xaml", Filter = "Xaml-File|*.xaml", InitialDirectory = CurrentDir, FileName = outFileName
            };

            if (saveDlg.ShowDialog() == DialogResult.OK)
            {
                string namePrefix = null;

                bool   useComponentResKeys = false;
                string nameSpaceName       = null;
                var    nameSpace           = Microsoft.VisualBasic.Interaction.InputBox("Enter a NameSpace for using static ComponentResKeys (or leave empty to not use it)", "NameSpace");
                if (!string.IsNullOrWhiteSpace(nameSpace))
                {
                    useComponentResKeys = true;
                    nameSpaceName       =
                        Microsoft.VisualBasic.Interaction.InputBox(
                            "Enter a Name of NameSpace for using static ComponentResKeys", "NamespaceName");
                }
                else
                {
                    namePrefix = Microsoft.VisualBasic.Interaction.InputBox("Enter a namePrefix (or leave empty to not use it)", "Name Prefix");
                    if (string.IsNullOrWhiteSpace(namePrefix))
                    {
                        namePrefix = null;
                    }
                }

                outFileName = Path.GetFullPath(saveDlg.FileName);
                var resKeyInfo = new ResKeyInfo
                {
                    XamlName            = Path.GetFileNameWithoutExtension(outFileName),
                    Prefix              = namePrefix,
                    UseComponentResKeys = useComponentResKeys,
                    NameSpace           = nameSpace,
                    NameSpaceName       = nameSpaceName,
                };
                File.WriteAllText(outFileName, ConverterLogic.SvgDirToXaml(CurrentDir, resKeyInfo));

                BuildBatchFile(outFileName, resKeyInfo);
            }
        }
        public async Task <IActionResult> GetAllItemsSortedAsync([FromQuery] string targetCurrency, string product)
        {
            var            parser = new DataParser();
            ConverterLogic logic  = new ConverterLogic();

            targetCurrency = targetCurrency.ToUpper();
            string exchangeData = await parser.GetFileAsync(exchangeUrl, HttpClient);

            string productData = await parser.GetFileAsync(productUrl, HttpClient);

            List <ExchangeRate> exchangeRates = parser.ExchangeRateToList(exchangeData, ',', 1);
            List <Product>      products      = parser.ProductsToList(productData, ',', 1);

            Price price = logic.ConvertCurrency(exchangeRates, products, targetCurrency, product);

            var output = JsonConvert.SerializeObject(price);

            return(Ok(output));
        }
Exemple #23
0
        public void SvgDirToXamlTest_withNamePrefix()
        {
            var settings = new WpfDrawingSettings
            {
                IncludeRuntime = false,
                TextAsGeometry = false,
                OptimizePath   = true,
            };
            var resKeyInfo = new ResKeyInfo {
                XamlName = "Test", Prefix = "NamePrefix"
            };
            var xaml = ConverterLogic.SvgDirToXaml("TestFiles\\", resKeyInfo, settings);

            Console.WriteLine(xaml);
            //File.WriteAllText("TestFiles\\ExpectedXaml_SvgDirToXamlTest_withNamePrefix.xaml", xaml);
            var expectedXaml = File.ReadAllText("TestFiles\\ExpectedXaml_SvgDirToXamlTest_withNamePrefix.xaml");

            xaml.Should().Be(expectedXaml);
        }
Exemple #24
0
        private void ExportDirExecute()
        {
            string outFileName = Path.GetFileNameWithoutExtension(CurrentDir) + ".xaml";
            var    saveDlg     = new SaveFileDialog {
                AddExtension = true, DefaultExt = ".xaml", Filter = "Xaml-File|*.xaml", InitialDirectory = CurrentDir, FileName = outFileName
            };

            if (saveDlg.ShowDialog() == DialogResult.OK)
            {
                outFileName = Path.GetFullPath(saveDlg.FileName);
                var resKeyInfo = new ResKeyInfo
                {
                    XamlName            = Path.GetFileNameWithoutExtension(outFileName),
                    Prefix              = null,
                    UseComponentResKeys = false,
                    NameSpace           = null,
                    NameSpaceName       = null,
                };
                File.WriteAllText(outFileName, ConverterLogic.SvgDirToXaml(CurrentDir, resKeyInfo, false));

                BuildBatchFile(outFileName, resKeyInfo);
            }
        }
 public void CreateConverterObject()
 {
     converter = new ConverterLogic();
 }
Exemple #26
0
 public void GetElemNameFromResKey_CompResKey()
 {
     ConverterLogic.GetElemNameFromResKey("{x:Static NameSpaceName:XamlName.ElementNameKey}", ResKeyInfoUseCompResKey).Should().Be("ElementName");
 }
Exemple #27
0
 public void GetElemNameFromResKey_NamePrefix()
 {
     ConverterLogic.GetElemNameFromResKey("NamePrefix_ElementName", ResKeyInfoUseNamePrefix).Should().Be("ElementName");
 }
Exemple #28
0
 public void BuildDrawingImageName_returns_prefixedName()
 {
     ConverterLogic.BuildDrawingImageName("ElementName", ResKeyInfoUseNamePrefix).Should().Be("NamePrefix_ElementNameDrawingImage");
 }
Exemple #29
0
        public void SvgDirToXaml_with_defaultSettingsTest()
        {
            var xaml = ConverterLogic.SvgDirToXaml("..\\..\\TestFiles\\", "Test", null);

            Console.WriteLine(xaml);
        }
Exemple #30
0
        static void Main(string[] args)
        {
            if (args == null || args.Count() < 2)
            {
                throw new ArgumentException("Please makes sure that you provide a source folder and a target file path");
            }

            var workingDirectory = args[0];
            var filePath         = args[1];
            var fullClassName    = args[2];

            var svgFiles = ConverterLogic.SvgFilesFromFolder(workingDirectory, true);

            var content = new StringBuilder();

            var resourceNames = new List <string>();

            string GetName(string baseName)
            {
                var nameParts           = baseName.Split('_');
                var resourceNameBuilder = new StringBuilder();

                foreach (var namePart in nameParts)
                {
                    var local = namePart.Replace("-", string.Empty);

                    if (int.TryParse(local, out int _))
                    {
                        local = "N" + local;
                    }

                    resourceNameBuilder.Append(ToUpper(local));
                }

                var resourcesName = resourceNameBuilder.ToString();

                Console.WriteLine();
                Console.WriteLine($"Generated resource name: {resourcesName}");

                resourceNames.Add(resourcesName);

                return(resourcesName);
            }

            foreach (var svgFile in svgFiles)
            {
                var resKey = new ResKeyInfo
                {
                    XamlName      = Path.GetFileNameWithoutExtension(svgFile),
                    NameConverter = GetName
                };

                var result = ConverterLogic.SvgFileToXaml(svgFile, ResultMode.DrawingImage, resKey, false);

                content.Append(result);
            }

            var nameInfo = ResourceLookupGenerator.GetFileNameFromNamespace(fullClassName);

            Directory.CreateDirectory(filePath);

            File.WriteAllText(Path.Combine(filePath, nameInfo.className + ".xaml"), content.ToString());
            var resourceLookup = new ResourceLookupGenerator();

            resourceLookup.Generate(resourceNames, filePath, fullClassName);
        }