Ejemplo n.º 1
0
        static void LoadSignInDialog(FigmaViewRendererService rendererService, FigmaViewRendererServiceOptions options)
        {
            mainWindow.Size = new Size(440, 456);
            //var customConverters = new FigmaViewConverter[] {
            //	new SearchFilterConverter(),
            //};
            //rendererService.CustomConverters.AddRange(customConverters);

            //new SearchFilterConverter ()
            var dialog = rendererService.RenderByName <IView>(SignInDialog, options);

            dialog.CornerRadius    = 5;
            dialog.BackgroundColor = Color.White;

            SetContentDialog(dialog);

            //foreach (var viewConverter in customConverters)
            //	rendererService.CustomConverters.Remove(viewConverter);

            var closeButton = dialog.Children
                              .OfType <IImageButton>()
                              .FirstOrDefault();

            closeButton.Clicked += (s, e) =>
            {
                if (closeButton is IViewTransitable figmaTransition)
                {
                    ProcessTransitionNodeID(figmaTransition.TransitionNodeID, rendererService, options);
                }
            };
        }
Ejemplo n.º 2
0
        static async void LoadLoadingDialog(FigmaViewRendererService rendererService, FigmaViewRendererServiceOptions options)
        {
            mainWindow.Size = new Size(720, 467);

            var loadingSpinnerConverter = new LoadingSpinnerConverter();

            rendererService.CustomConverters.Add(loadingSpinnerConverter);

            var loadingDialogFigmaNode = rendererService.FindNodeByName(LoadingDialog);
            var loadingDialog          = rendererService.RenderByName <IView>(LoadingDialog, options);

            loadingDialog.BackgroundColor = new Color(0.27f, 0.15f, 0.41f);
            loadingDialog.CornerRadius    = 5;
            SetContentDialog(loadingDialog);

            rendererService.CustomConverters.Remove(loadingSpinnerConverter);

            //finds view and process animation
            var spinnerView = rendererService.FindViewByName <ISpinner>(LoadingSpinnerConverter.LoadingSpinnerName);

            spinnerView.Start();

            //we wait for 5 seconds and we show next screen
            await Task.Run(() =>
            {
                if (loadingDialogFigmaNode is FigmaFrameEntity figmaFrameEntity)
                {
                    Thread.Sleep((int)figmaFrameEntity.transitionDuration);
                    FigmaSharp.AppContext.Current.BeginInvoke(() => ProcessTransitionNodeID(figmaFrameEntity.transitionNodeID, rendererService, options));
                }
            });
        }
Ejemplo n.º 3
0
        static void LoadLoginDialog(FigmaViewRendererService rendererService, FigmaViewRendererServiceOptions options)
        {
            mainWindow.Size = new Size(720, 467);
            var customConverters = new FigmaViewConverter[] {
                new DoThisLaterButtonConverter(),
                new SignInMicrosoftButtonConverter(),
                //new CreateAccountLinkConverter (),
                //new WhySignInLinkConverter (),
            };

            rendererService.CustomConverters.AddRange(customConverters);

            var signInDialog = rendererService.RenderByName <IView>(LoginDialog, options);

            signInDialog.CornerRadius    = 5;
            signInDialog.BackgroundColor = new Color(0.27f, 0.15f, 0.41f);
            SetContentDialog(signInDialog);

            foreach (var viewConverter in customConverters)
            {
                rendererService.CustomConverters.Remove(viewConverter);
            }

            //logic
            var signInButton = rendererService.FindViewByName <IButton>(SignInMicrosoftButtonConverter.SignInMicrosoftButtonName);

            signInButton.Focus();
            signInButton.Clicked += (s, e) =>
            {
                if (signInButton is IViewTransitable figmaTransition)
                {
                    ProcessTransitionNodeID(figmaTransition.TransitionNodeID, rendererService, options);
                }
            };

            var doThisLaterButton = rendererService.FindViewByName <IButton>(DoThisLaterButtonConverter.DoThisLaterButtonName);

            doThisLaterButton.Clicked += (s, e) =>
            {
                if (doThisLaterButton is IViewTransitable figmaTransition)
                {
                    ProcessTransitionNodeID(figmaTransition.TransitionNodeID, rendererService, options);
                }
            };
        }
Ejemplo n.º 4
0
        public GameWindow(Rectangle rect) : base(rect)
        {
            Resizable = false;

            //we get the default basic view converters from the current loaded toolkit
            var converters = FigmaSharp.AppContext.Current.GetFigmaConverters();

            //in this case we want use a remote file provider (figma url from our document)
            var fileProvider = new FigmaRemoteFileProvider();

            fileProvider.Load("Jv8kwhoRsrmtJDsSHcTgWGYu");

            //we initialize our renderer service, this uses all the converters passed
            //and generate a collection of NodesProcessed which is basically contains <FigmaModel, IView, FigmaParentModel>
            var rendererService = new FigmaViewRendererService(fileProvider, converters);

            //play background music
            backgroundMusic = new MusicPlayer("Background", "mp3");
            backgroundMusic.Play(-1);

            coinSound     = new MusicPlayer("Coin", "mp3");
            gameOverSound = new MusicPlayer("GameOver", "mp3");

            //we want load the entire level 1
            IView view = rendererService.RenderByName <IView>("Level1");

            Content = view;

            playerTile = rendererService.FindViewStartsWith <IImageView>("Player");

            startingPoint = playerTile.Allocation.Origin;

            pointsLabel = rendererService.FindViewByName <ILabel>("Points");
            gemsTiles   = rendererService.FindViewsStartsWith <IImageView>("Gem")
                          .ToList();
            wallTiles = rendererService.FindViewsStartsWith <IImageView>("Tile")
                        .ToArray();
            spikesTiles = rendererService.FindViewsStartsWith <IImageView>("Spikes")
                          .ToArray();
            heartTiles = rendererService.FindViewsStartsWith <IImageView>("Heart")
                         .OrderBy(s => s.Allocation.X)
                         .ToList();
            WorldUpdate();
        }
Ejemplo n.º 5
0
        static void LoadRecentItemsDialog(FigmaViewRendererService rendererService, FigmaViewRendererServiceOptions options)
        {
            mainWindow.Size = new Size(720, 467);

            var customConverters = new FigmaViewConverter[] {
                new SearchFilterConverter(),
            };

            rendererService.CustomConverters.AddRange(customConverters);

            //new SearchFilterConverter ()
            var dialog = rendererService.RenderByName <IView>("RecentItemsDialog", options);

            dialog.CornerRadius    = 5;
            dialog.BackgroundColor = Color.White;

            SetContentDialog(dialog);

            foreach (var viewConverter in customConverters)
            {
                rendererService.CustomConverters.Remove(viewConverter);
            }

            var searchBox = dialog.Children
                            .OfType <ISearchBox>()
                            .FirstOrDefault();

            searchBox.Focus();

            var closeButton = dialog.Children
                              .OfType <IImageButton>()
                              .FirstOrDefault();

            closeButton.Clicked += (s, e) =>
            {
                NSRunningApplication.CurrentApplication.Terminate();
            };
        }