Beispiel #1
0
        public SparkExtension()
        {
            _templateRegistry = new TemplateRegistry();
            _finder           = new TemplateFinder();
            _composer         = new TemplateComposer(_templateRegistry);

            defaults();
        }
        public void Configure(TemplateFinder finder)
        {
            finder.IncludeFile("*spark");
            // TODO: This is not automatically synched with what the attacher looks for.
            finder.IncludeFile("bindings.xml");

            finder.ExcludeHostDirectory(FubuMvcPackageFacility.FubuPackagesFolder);
            finder.ExcludeHostDirectory(FubuMvcPackageFacility.FubuPackagesFolder, FubuMvcPackageFacility.FubuContentFolder);
            finder.ExcludeHostDirectory(FubuMvcPackageFacility.FubuContentFolder);
        }
Beispiel #3
0
        public void TestScaleFactorRelativeToOriginal()
        {
            const float scale        = 2.5f;
            IImage      scaledImage  = SetupImage(scale);
            IImage      defaultImage = SetupImage();

            TemplateFinder templateFinder = TemplateFinder();

            templateFinder.FindTemplateIn(scaledImage);
            templateFinder.FindTemplateIn(defaultImage);

            VerifyResize(scale);
            VerifyResize(1);
        }
Beispiel #4
0
        protected override async Task <int> OnExecuteAsync(CommandLineApplication app)
        {
            Identifier = Identifier.ToLower();

            if (Name.IsNullOrWhiteSpace())
            {
                var defaultName = string.Empty;
                var promptText  = string.Empty;
                switch (Identifier)
                {
                case "console":
                    defaultName = Consts.DefaultConsoleName;
                    promptText  = Consts.Descriptions.New.NameConsolePrompt;
                    break;

                case "module":
                    defaultName = Consts.DefaultModuleName;
                    promptText  = Consts.Descriptions.New.NameModulePrompt;
                    break;

                default:
                    break;
                }

                Name = Prompt.GetString(promptText, defaultValue: defaultName);
            }

            var tplFinder = new TemplateFinder(TemplateName);

            var tplFilePath = await tplFinder.Fetch();

            var projectFolder = Path.Combine(Directory.GetCurrentDirectory(),
                                             $".{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}{Name}");

            if (!Directory.Exists(projectFolder))
            {
                Directory.CreateDirectory(projectFolder);
            }

            ExtractHelper.ExtractZipFile(tplFilePath, projectFolder, Identifier);

            if (Identifier == "module")
            {
                Placeholder = $"{Placeholder}.{DefaultModuleNamePlaceholder}";
            }

            RenameHelper.RenameFolders(projectFolder, Placeholder, Name, false, null);

            return(0);
        }
Beispiel #5
0
        public ExtendedTester()
        {
            var testRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates");

            var pathApp = Path.Combine(testRoot, "App");
            var pathPackage1 = Path.Combine(pathApp, "fubu-packages", "Package1", "WebContent");
            var pathPackage2 = Path.Combine(testRoot, "Package2");

            var packages = new List<IPackageInfo>();
            var pack1 = new PackageInfo(new PackageManifest() { Name = Package1 });
            var pack2 = new PackageInfo(new PackageManifest() { Name = Package2 });
            pack1.RegisterFolder(BottleFiles.WebContentFolder, pathPackage1);
            pack2.RegisterFolder(BottleFiles.WebContentFolder, pathPackage2);
            packages.Add(pack1);
            packages.Add(pack2);

            var scanner = new TemplateFinder<Template>(new FileScanner(), packages){
                HostPath = pathApp
            };
            new DefaultRazorTemplateFinderConventions().Configure(scanner);

            var allTemplates = new TemplateRegistry<IRazorTemplate>();
            allTemplates.AddRange(scanner.FindInPackages());
            allTemplates.AddRange(scanner.FindInHost());

            var viewPathPolicy = new ViewPathPolicy<IRazorTemplate>();
            allTemplates.Each(viewPathPolicy.Apply);

            var config = new TemplateServiceConfiguration{
                BaseTemplateType = typeof (FubuRazorView)
            };
            _templateService = new FubuTemplateService(allTemplates, new TemplateService(config), new FileSystem());

            _pak1TemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.ByOrigin(Package1));
            _pak2TemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.ByOrigin(Package2));
            _appTemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.FromHost());

            _serviceLocator = MockRepository.GenerateMock<IServiceLocator>();

            var sharingGraph = new SharingGraph();
            sharingGraph.Dependency("Package1", "Host");
            sharingGraph.Dependency("Package2", "Host");
            var templateDirectory = new TemplateDirectoryProvider<IRazorTemplate>(new SharedPathBuilder(), allTemplates,
                                                                                  sharingGraph);
            _sharedTemplateLocator = new SharedTemplateLocator<IRazorTemplate>(templateDirectory, allTemplates,
                                                                               new RazorTemplateSelector());
        }
Beispiel #6
0
        public ExtendedTester()
        {
            var testRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates");

            var pathApp      = Path.Combine(testRoot, "App");
            var pathPackage1 = Path.Combine(pathApp, "fubu-packages", "Package1", "WebContent");
            var pathPackage2 = Path.Combine(testRoot, "Package2");

            var packages = new List <IPackageInfo>();
            var pack1    = new PackageInfo(Package1);
            var pack2    = new PackageInfo(Package2);

            pack1.RegisterFolder(BottleFiles.WebContentFolder, pathPackage1);
            pack2.RegisterFolder(BottleFiles.WebContentFolder, pathPackage2);
            packages.Add(pack1);
            packages.Add(pack2);

            var scanner = new TemplateFinder(new FileScanner(), packages)
            {
                HostPath = pathApp
            };

            // This is now conventionally applied in SparkEngine
            new DefaultTemplateFinderConventions().Configure(scanner);

            var allTemplates = new TemplateRegistry();

            allTemplates.AddRange(scanner.FindInPackages());
            allTemplates.AddRange(scanner.FindInHost());

            var viewPathPolicy = new ViewPathPolicy();

            allTemplates.Each(viewPathPolicy.Apply);
            _viewFolder = new TemplateViewFolder(allTemplates);
            _engine     = new SparkViewEngine
            {
                ViewFolder      = _viewFolder,
                BindingProvider = new FubuBindingProvider(new TemplateRegistry(allTemplates))
            };

            _pak1TemplateRegistry = new TemplateRegistry(allTemplates.ByOrigin(Package1));
            _pak2TemplateRegistry = new TemplateRegistry(allTemplates.ByOrigin(Package2));
            _appTemplateRegistry  = new TemplateRegistry(allTemplates.FromHost());
        }
Beispiel #7
0
        protected override async Task <int> OnExecuteAsync(CommandLineApplication app)
        {
            if (!Mpa)
            {
                //switch to personball/module-zero-core-template to reduce size of project template zip file
                if (TemplateName == Consts.DefaultProjectTemplateName)
                {
                    TemplateName = Consts.DefaultProjectTemplateForSPA;
                }

                if (string.IsNullOrWhiteSpace(SpaType))
                {
                    SpaType = Prompt.GetString(Consts.Descriptions.Init.SpaTypeDescription, defaultValue: "vue");
                    SpaType = SpaType.ToLower();
                    if ("vue,ng,react".IndexOf(SpaType) == -1)
                    {
                        SpaType = "vue";
                    }
                }
            }

            Console.WriteLine($"TemplateName\t:{TemplateName}");
            Console.WriteLine($"Placeholder\t:{Placeholder}");
            Console.WriteLine($"ProjectName\t:{ProjectName}");
            Console.WriteLine($"MPA\t\t:{Mpa}");
            Console.WriteLine($"SpaType\t\t:{SpaType}");
            Console.WriteLine($"RenameBackup\t:{RenameBackup}");

            //Create Target folder
            var projectFolder = Path.Combine(Directory.GetCurrentDirectory(), ProjectName);

            if (!Directory.Exists(projectFolder))
            {
                Directory.CreateDirectory(projectFolder);
            }

            var tplFinder = new TemplateFinder(TemplateName);

            var tplFilePath = await tplFinder.Fetch();

            ExtractHelper.ExtractZipFile(tplFilePath, projectFolder);

            var excludeFolders = new List <string>();

            InitExcludedFolders.ForEach(s =>
            {
                excludeFolders.Add(s);
            });

            if (!Mpa)
            {
                excludeFolders.Add($"./aspnet-core/src/{Placeholder}.Web.Mvc");
                //TODO@personball remove web.mvc entry in vs solution file(sln).
                switch (SpaType.ToLower())
                {
                case "ng":
                    excludeFolders.Remove("./angular");
                    break;

                case "react":
                    excludeFolders.Remove("./reactjs");
                    break;

                case "vue":
                default:
                    excludeFolders.Remove("./vue");
                    break;
                }
            }

            // Placeholder as AbpCompanyName.AbpProjectName
            // ProjectName as CompanyName.ProjectName or just ProjectName
            RenameHelper.RenameFolders(projectFolder, Placeholder, ProjectName, RenameBackup, excludeFolders);

            Console.WriteLine("Init Completed!");
            return(0);
        }
 public void Configure(TemplateFinder finder)
 {
     _configure(finder);
 }
        /// <summary>
        /// find hands based on the informations provided by the skeleton
        /// </summary>
        /// <param name="skeleton">the skeleton provided by Kinect</param>
        /// <param name="depthFrame">the depthFrame</param>
        /// <returns>a handgesture as a string</returns>
        public string FindHandGesture(HandType handtype)
        {
            //reset the values for hand detection
            this.currentContour = null;
            this.depthImage     = new Image <Gray, byte>(this.depthFrameWidth, this.depthFrameHeight);

            this.handJoint = KinectHelper.Instance.GetHandJoint(handtype, skeleton);
            float     zhand     = handJoint.Position.Z;
            JointType jointtype = (handtype == HandType.LEFT) ? JointType.HandLeft : JointType.HandRight;

            if (min < zhand && zhand < max && CheckOrientation(handtype))
            {
                //set the ROI around the hand
                Joint  hand   = skeleton.Joints[jointtype].ScaleTo((int)(this.depthFrameWidth * 1), (int)(this.depthFrameHeight * 1));
                PointF center = new PointF(hand.Position.X, hand.Position.Y);
                this.depthImage  = new Image <Gray, byte>(this.depthFrameWidth, this.depthFrameHeight);
                depthImage.Bytes = GetEverythingBetween(min, max, depthFrame);
                recSize          = new Size(75 - (int)(50 * (zhand - MinDepthDistance)), 90 - (int)(35.7 * (zhand - MinDepthDistance)));


                if (CheckRectangleIsInside(depthImageBoth.Width, depthImageBoth.Height, recSize, center))
                {
                    depthImage.ROI = new Rectangle((int)center.X - recSize.Width / 2, (int)center.Y - recSize.Height / 2, recSize.Width, recSize.Height);

                    if (!CheckForMovement(handtype))
                    {
                        //get the contour
                        ExtractContourAndHull(depthImage.Copy(), handtype);

                        //find the name of the gesture if there is one
                        if (this.currentContour != null)
                        {
                            FoundTemplateDesc result = TemplateFinder.GetNearestClass(this.currentContour, depthImage.ROI, this.templates, handtype);
                            if (result != null)
                            {
                                return(result.name.ToString());
                            }
                        }
                    }


                    if ((isLeftHandTracked == false && handtype == HandType.LEFT) || (isRightHandTracked == false && handtype == HandType.RIGHT))
                    {
                        if (handtype == HandType.RIGHT)
                        {
                            isRightHandTracked = true;
                        }
                        else
                        {
                            isLeftHandTracked = true;
                        }
                    }
                }
            }
            else
            {
                if (handtype == HandType.LEFT)
                {
                    isLeftHandTracked = false;
                }
                else
                {
                    isRightHandTracked = false;
                }
            }
            return(null);
        }