Exemplo n.º 1
0
        public void AnimateExit()
        {
            var exitSb = new StoryBoard();

            foreach (var element in this.elements.Where(e => e.ExitAnimation != null))
            {
                element.ExitAnimation.Duration = this.EntranceDuration;
                exitSb.AddAnimation(element.ExitAnimation);
            }
            if (this.ShadowedAnimationMode != ShadowedAnimationOptions.None)
            {
                exitSb.AddAnimation(new FunctionBasedAnimation(FunctionBasedAnimation.Functions.Linear)
                {
                    Duration    = this.EntranceDuration,
                    From        = this.ShadowedAnimationMode == ShadowedAnimationOptions.FromRight ? this.offBmp.Width : -this.offBmp.Width * 3,
                    To          = this.ShadowedAnimationMode == ShadowedAnimationOptions.FromRight ? -this.offBmp.Width : -this.offBmp.Width * 1,
                    OnAnimation = v => this.shadowImageX = v
                });
            }
            exitSb.AddAnimation(new CommitStoryboardAnimation {
                Duration = this.EntranceDuration, CommitAction = () => this.ForcedInvalidate()
            });
            exitSb.AnimateSync();

            if (this.OnExitAnimationCompleted != null)
            {
                this.OnExitAnimationCompleted();
            }
        }
Exemplo n.º 2
0
        public void CreateStoryBoard()
        {
            _storyBoard = new StoryBoard(_scene);

            var storyList = new List <BaseStory>();

            for (var i = 0; i < 10; i++)
            {
                var rect = _scene[$"Rect{i}"] as RectangleNode;

                var move = new Vec2Transformation <RectangleNode>(rect, "Position",
                                                                  TimeSpan.FromMilliseconds(40 + i * 10), DefaultEasers.EaseInOutCubic, true, new Vector2(rect.Position.X, 200));

                storyList.Add(move);
            }

            for (var i = 9; i >= 0; i--)
            {
                var rect = _scene[$"Rect{i}"] as RectangleNode;

                var move = new Vec2Transformation <RectangleNode>(rect, "Position",
                                                                  TimeSpan.FromMilliseconds(40 + (10 - i) * 10), DefaultEasers.EaseInOutCubic, true, new Vector2(rect.Position.X, rect.Position.Y));

                storyList.Add(move);
            }

            _storyBoard["MoveAll"] = StoryBuilder.Sequential(storyList.ToArray());
        }
Exemplo n.º 3
0
        /// <inheritdoc/>
        public override async Task Run()
        {
            SerializeableCloudStorageCredentials credentials = StoryBoard.LoadFromSession <SerializeableCloudStorageCredentials>(SynchronizationStorySessionKey.CloudStorageCredentials.ToInt());
            ICloudStorageClient cloudStorageClient           = _cloudStorageClientFactory.GetOrCreate(credentials.CloudStorageId);

            try
            {
                bool stopBecauseNewOAuthLoginIsRequired = false;
                if ((cloudStorageClient is OAuth2CloudStorageClient oauthStorageClient) &&
                    credentials.Token.NeedsRefresh())
                {
                    try
                    {
                        // Get a new access token by using the refresh token
                        credentials.Token = await oauthStorageClient.RefreshTokenAsync(credentials.Token);

                        SaveCredentialsToSettings(credentials);
                    }
                    catch (RefreshTokenExpiredException)
                    {
                        // Refresh-token cannot be used to get new access-tokens anymore, a new
                        // authorization by the user is required.
                        stopBecauseNewOAuthLoginIsRequired = true;
                        switch (StoryBoard.Mode)
                        {
                        case StoryBoardMode.GuiAndToasts:
                            await StoryBoard.ContinueWith(SynchronizationStoryStepId.ShowCloudStorageAccount.ToInt());

                            break;

                        case StoryBoardMode.ToastsOnly:
                            _feedbackService.ShowToast(_languageService["sync_error_generic"]);
                            break;
                        }
                    }
                }

                if (!stopBecauseNewOAuthLoginIsRequired)
                {
                    bool repositoryExists = await cloudStorageClient.ExistsFileAsync(Config.RepositoryFileName, credentials);

                    // If no error occured the credentials are ok and we can safe them
                    SaveCredentialsToSettings(credentials);

                    if (repositoryExists)
                    {
                        await StoryBoard.ContinueWith(SynchronizationStoryStepId.DownloadCloudRepository.ToInt());
                    }
                    else
                    {
                        await StoryBoard.ContinueWith(SynchronizationStoryStepId.StoreLocalRepositoryToCloudAndQuit.ToInt());
                    }
                }
            }
            catch (Exception ex)
            {
                // Keep the current page open and show the error message
                ShowExceptionMessage(ex, _feedbackService, _languageService);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Method that launch the OpenFile method of the Filebrowser.
        /// </summary>
        private void OpenFile()
        {
            browser.OpenFile();
            if (browser.filePath != null)
            {
                String     json = File.ReadAllText(browser.filePath);
                StoryBoard st   = JsonConvert.DeserializeObject <StoryBoard>(json);

                StoryBoard.INSTANCE.purge();
                VisualAddingViewModel.INSTANCE.listVideo.Clear();
                VisualAddingViewModel.INSTANCE.listPhoto.Clear();

                foreach (StoryBoardElement ste in st.fileList)
                {
                    if (ste.fileType == "Video")
                    {
                        Video v = new Video(ste.filePath, ste.fileName, ste.fileSize);
                        StoryBoard.INSTANCE.addFile(v, ste.startTime, ste.endTime, ste.fileType);
                        VisualAddingViewModel.INSTANCE.listVideo.Add(v);
                    }

                    if (ste.fileType == "Image")
                    {
                        Photo p = new Photo(ste.filePath, ste.fileName, ste.fileSize);
                        StoryBoard.INSTANCE.addFile(p, ste.startTime, ste.endTime, ste.fileType);
                        VisualAddingViewModel.INSTANCE.listPhoto.Add(p);
                    }
                }
            }
            MainViewModel.INSTANCE.actualViewIndex = 1;
            browser.reset();
        }
        /// <inheritdoc/>
        public override Task Run()
        {
            if (StoryBoard.Mode.ShouldUseGui())
            {
                SerializeableCloudStorageCredentials credentials = StoryBoard.LoadFromSession <SerializeableCloudStorageCredentials>(SynchronizationStorySessionKey.CloudStorageCredentials.ToInt());
                ICloudStorageClient cloudStorageClient           = _cloudStorageClientFactory.GetOrCreate(credentials.CloudStorageId);
                if (cloudStorageClient is IOAuth2CloudStorageClient oauthStorageClient)
                {
                    // Show waiting page
                    _navigationService.Navigate(ControllerNames.CloudStorageOauthWaiting);

                    // Open OAuth2 login page in external browser
                    string oauthState        = CryptoUtils.GenerateRandomBase62String(16, _randomSource);
                    string oauthCodeVerifier = CryptoUtils.GenerateRandomBase62String(64, _randomSource);
                    StoryBoard.StoreToSession(SynchronizationStorySessionKey.OauthState.ToInt(), oauthState);
                    StoryBoard.StoreToSession(SynchronizationStorySessionKey.OauthCodeVerifier.ToInt(), oauthCodeVerifier);

                    string url = oauthStorageClient.BuildAuthorizationRequestUrl(oauthState, oauthCodeVerifier);
                    _nativeBrowserService.OpenWebsiteInApp(url);
                }
                else
                {
                    _navigationService.Navigate(ControllerNames.CloudStorageAccount);
                }
            }
            return(Task.CompletedTask);
        }
Exemplo n.º 6
0
        /*
         *      public async static Task OpenAsync(this MediaElement media, Uri uri, CancellationToken cancel = default(CancellationToken))
         *      {
         *          // TODO: This code still needs auditing for the case "media Is Nothing"
         *
         *          if (cancel.IsCancellationRequested)
         *              return;
         *
         *          if (media.CurrentState == MediaElementState.Buffering || media.CurrentState == MediaElementState.Opening || media.CurrentState == MediaElementState.Playing)
         *              // Throw New Exception("MediaElement not ready to open")
         *              return;
         *          else if ((media.CurrentState == MediaElementState.Paused || media.CurrentState == MediaElementState.Stopped) && uri == null)
         *              return;
         *
         *          TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
         *
         *          Action lambdaOpened = () => tcs.TrySetResult(null);
         *
         * Input:
         *      Dim lambdaChanged As RoutedEventHandler = Sub() If media.CurrentState = MediaElementState.Closed Then tcs.TrySetResult(Nothing)
         *
         *
         * Action lambdaFailed = (s, e) => tcs.TrySetException(new Exception(e.ErrorMessage));
         *  CancellationTokenRegistration? cancelReg = default(CancellationTokenRegistration?);
         *
         *  try
         *  {
         *      media.MediaOpened += lambdaOpened;
         *      media.MediaFailed += lambdaFailed;
         *      media.CurrentStateChanged += lambdaChanged;
         *
         *      if (uri != null)
         *          media.Source = uri;
         *      else
         *          // It's possible that it changed state either before we added the handlers (or after...)
         *          // NB. No way to distinguish "closed" due to xaml-not-yet-loaded-the-source vs closed due to xaml-loaded-a-failed-source
         *          if (media.CurrentState == MediaElementState.Paused || media.CurrentState == MediaElementState.Stopped)
         *          return;
         *
         *      if (!tcs.Task.IsCompleted)
         *      {
         *          cancelReg = cancel.Register(() =>
         *          {
         *              var dummy = media.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => media.ClearValue(MediaElement.SourceProperty));
         *          });
         *      }
         *
         *      await tcs.Task;
         *  }
         *  finally
         *  {
         *      media.MediaOpened -= lambdaOpened;
         *      media.MediaFailed -= lambdaFailed;
         *      media.CurrentStateChanged -= lambdaChanged;
         *      if (cancelReg.HasValue)
         *          cancelReg.Value.Dispose();
         *  }
         * }
         *
         * public async static Task PlayAsync(this MediaElement media, CancellationToken cancel = default(CancellationToken))
         * {
         *  if (cancel.IsCancellationRequested)
         *      return;
         *
         *  // TODO: This code still needs auditing for this call to OpenAsync.
         *  // Q. Under what circumstances will a call to media.Play *enqueue* that request?
         *  // Q. What is the best behavior for when the element is already playing something else?
         *  await OpenAsync(media, null/* TODO Change to default(_) if this is not a reference type , cancel);
         *
         *  if (media.CurrentState != MediaElementState.Paused && media.CurrentState != MediaElementState.Stopped)
         *      return;
         *
         *  TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
         *
         *  RoutedEventHandler lambdaEnded = () => tcs.TrySetResult(null);
         *
         *
         * Input:
         * Dim lambdaChanged As RoutedEventHandler = Sub() If media.CurrentState = MediaElementState.Stopped Then tcs.TrySetResult(Nothing)
         *
         *
         *  CancellationTokenRegistration? cancelReg = default(CancellationTokenRegistration?);
         *
         *  try
         *  {
         *      media.MediaEnded += lambdaEnded;
         *      media.CurrentStateChanged += lambdaChanged;
         *
         *      media.Play();
         *
         *      if (!tcs.Task.IsCompleted)
         *      {
         *          cancelReg = cancel.Register(() =>
         *          {
         *              var dummy = media.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => media.Stop());
         *          });
         *      }
         *
         *      await tcs.Task;
         *  }
         *  finally
         *  {
         *      media.MediaEnded -= lambdaEnded;
         *      media.CurrentStateChanged -= lambdaChanged;
         *      if (cancelReg.HasValue)
         *          cancelReg.Value.Dispose();
         *  }
         * }
         */
        public static Task PlayAsync(this StoryBoard sb, CancellationToken cancel = default(CancellationToken))
        {
            if (cancel.IsCancellationRequested)
            {
                return(Task.CompletedTask);
            }
            return(sb.Begin());

            /*
             * TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
             * EventHandler<object> lambda = () => tcs.TrySetResult(null);
             *
             * sb.Completed += lambda;
             * try
             * {
             *  sb.Begin();
             *  using (var cancelReg = cancel.Register(() =>
             *  {
             *      var dummyTask = sb.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => sb.Stop());
             *      tcs.TrySetResult(null);
             *  }))
             *  {
             *      await tcs.Task;
             *  }
             * }
             * finally
             * {
             *  sb.Completed -= lambda;
             * }
             */
        }
Exemplo n.º 7
0
        /// <summary>
        /// 將媒體櫃放入分鏡腳本
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void MediaScriptList_Drop(object sender, DragEventArgs e)
        {
            var guid = await e.Data.GetView().GetTextAsync("MediaDataGuid");

            Media      media      = this.ViewModel.GridViewMediaCabinetList.FirstOrDefault(i => i.Guid.ToString() == guid);
            StoryBoard storyBoard = new StoryBoard(media);

            if (!this.ViewModel.GridViewStoryBoardScriptDataList.Any())
            {
                this.ViewModel.InsertStoryBoardIntoScript(0, storyBoard.MediaSource);
                return;
            }

            var gridView = ((GridView)sender);

            //Find the position where item will be dropped in the gridview
            Point pos = e.GetPosition(gridView.ItemsPanelRoot);

            //Get the size of one of the list items
            GridViewItem gvi        = (GridViewItem)gridView.ContainerFromIndex(0);
            double       itemHeight = gvi.ActualWidth + gvi.Margin.Left + gvi.Margin.Right;

            //Determine the index of the item from the item position (assumed all items are the same size)
            int index = Math.Min(gridView.Items.Count - 1, (int)(pos.X / itemHeight));

            this.ViewModel.InsertStoryBoardIntoScript(index, storyBoard.MediaSource);
        }
Exemplo n.º 8
0
 private void ClipButton_Click(object sender, RoutedEventArgs e)
 {
     if (this._selectedStoryBoard != null)
     {
         this.Frame.Navigate(typeof(ClipEditPage), _selectedStoryBoard);
         this._selectedStoryBoard = null;
     }
 }
        /// <inheritdoc/>
        public override async Task Run()
        {
            SettingsModel settings = _settingsService.LoadSettingsOrDefault();
            SerializeableCloudStorageCredentials credentials = settings.Credentials;

            if (!settings.HasCloudStorageClient || !settings.HasTransferCode)
            {
                _feedbackService.ShowToast(_languageService["pushpull_error_need_sync_first"]);
                return;
            }

            ICloudStorageClient cloudStorageClient = _cloudStorageClientFactory.GetOrCreate(credentials.CloudStorageId);

            try
            {
                bool stopBecauseNewOAuthLoginIsRequired = false;
                if ((cloudStorageClient is OAuth2CloudStorageClient oauthStorageClient) &&
                    credentials.Token.NeedsRefresh())
                {
                    try
                    {
                        // Get a new access token by using the refresh token
                        credentials.Token = await oauthStorageClient.RefreshTokenAsync(credentials.Token);

                        SaveCredentialsToSettings(credentials);
                    }
                    catch (RefreshTokenExpiredException)
                    {
                        // Refresh-token cannot be used to get new access-tokens anymore, a new
                        // authorization by the user is required.
                        stopBecauseNewOAuthLoginIsRequired = true;
                    }
                }

                if (stopBecauseNewOAuthLoginIsRequired)
                {
                    _feedbackService.ShowToast(_languageService["sync_error_oauth_refresh"]);
                }
                else
                {
                    bool repositoryExists = await cloudStorageClient.ExistsFileAsync(Config.RepositoryFileName, credentials);

                    if (repositoryExists)
                    {
                        await StoryBoard.ContinueWith(PullPushStoryStepId.DownloadCloudRepository);
                    }
                    else
                    {
                        _feedbackService.ShowToast(_languageService["pushpull_error_need_sync_first"]);
                    }
                }
            }
            catch (Exception ex)
            {
                // Keep the current page open and show the error message
                ShowExceptionMessage(ex, _feedbackService, _languageService);
            }
        }
Exemplo n.º 10
0
 private void AnimateCurrentReposition()
 {
     StoryBoard.BeginPlay(new FunctionBasedAnimation(FunctionBasedAnimation.Functions.SoftedFluid)
     {
         Duration    = 200,
         From        = this.offsetForPanning,
         To          = 0,
         OnAnimation = v => { this.offsetForPanning = v; this.Update(); }
     });
 }
Exemplo n.º 11
0
    public BattleContext(BattleController controller, Party playerParty, Party enemyParty)
    {
        storyBoard       = new StoryBoard();
        battleController = controller;
        turnCount        = 0;
        this.playerParty = playerParty;
        this.enemyParty  = enemyParty;

        playerParty.SetBattleContext(this);
        enemyParty.SetBattleContext(this);
    }
Exemplo n.º 12
0
 /// <inheritdoc/>
 public override Task Run()
 {
     StoryBoard.ClearSession();
     _storyBoardService.ActiveStory = null;
     _feedbackService.ShowBusyIndicator(false);
     if (StoryBoard.Mode.ShouldUseGui())
     {
         _navigationService.Navigate(ControllerNames.NoteRepository);
     }
     return(Task.CompletedTask);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Assets are loaded in from the CreateResources method
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void OnCreateResources(CanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.CanvasCreateResourcesEventArgs args)
        {
            _screenSize = new Vector2((float)Cvs.Size.Width, (float)Cvs.Size.Height);

            //set parent canvas for image manager
            ImageManager.ParentCanvas = sender;

            //Animated Hero Images
            await ImageManager.AddImage("Hero_Up_1", @"Assets/Hero_Up_1.gif");

            await ImageManager.AddImage("Hero_Right_1", @"Assets/Hero_Right_1.gif");

            await ImageManager.AddImage("Hero_Left_1", @"Assets/Hero_Left_1.gif");

            await ImageManager.AddImage("Hero", @"Assets/Hero.gif");

            //Minion Images
            await ImageManager.AddImage("MinionLeft", @"Assets/MinionLeft.png");

            await ImageManager.AddImage("MinionRight", @"Assets/MinionRight.png");

            //
            await ImageManager.AddImage("Arrow", @"Assets/Arrow.png");

            await ImageManager.AddImage("Boss", @"Assets/BossEdit.png");

            await ImageManager.AddImage("BossHurt", @"Assets/Boss_Hurt.png");

            await ImageManager.AddImage("Title", @"Assets/Evilution.png");

            await ImageManager.AddImage("GameOver", @"Assets/GameOver.png");

            await AudioManager.AddAudio("Generic Title Scene", "TitleTheme.mp3");

            await AudioManager.AddAudio("Main Game Scene", "BattleTheme.mp3");

            await AudioManager.AddAudio("Game Over Scene", "GameOver.mp3");


            // set up the scene
            var ts = new TitleScene((int)this._screenSize.X, (int)this._screenSize.Y);

            StoryBoard.AddScene(ts);
            StoryBoard.CurrentScene = ts;

            //create scenes
            var game_scene      = new GameScene((int)this._screenSize.X, (int)this._screenSize.Y);
            var game_over_scene = new GameOverScene((int)this._screenSize.X, (int)this._screenSize.Y);

            //add scenes to storyboard
            StoryBoard.AddScene(game_scene);
            StoryBoard.AddScene(game_over_scene);
        }
Exemplo n.º 14
0
        public void AddStoryBoardIntoScriptDataTest()
        {
            //Arrange
            Model sut = new Model();
            StoryBoard storyBoard = new StoryBoard(new Media());
            //Act
            sut.AddStoryBoardIntoScriptData(storyBoard);

            //Assert
            Assert.AreEqual(1, sut.getAllStoryBoardScriptData().Count);

        }
Exemplo n.º 15
0
        private async void StoryBoardScriptList_ItemClick(object sender, ItemClickEventArgs e)
        {
            this._selectedStoryBoard = e.ClickedItem as StoryBoard;
            StorageFile file = await this.loadFileFromAbsolutePath(_selectedStoryBoard.MediaSource.SourcePath);

            if (file != null)
            {
                var stream = await file.OpenAsync(FileAccessMode.Read);

                this.MediaPreView.Source = MediaSource.CreateFromStream(stream, file.ContentType);
            }
        }
Exemplo n.º 16
0
        private void ExportProject()
        {
            StoryBoard st = StoryBoard.INSTANCE;

            String json     = JsonConvert.SerializeObject(st);
            String savePath = null;

            savePath = _browser.SaveFile("Fichier JSON (.json)|*.json");
            if (savePath != "")
            {
                File.WriteAllText(savePath, json);
            }
        }
Exemplo n.º 17
0
        public void RemoveStoryBoardFromScriptDataTest()
        {
            //Arrange
            Model model = new Model();
            StoryBoard storyBoard = new StoryBoard(new Media());

            //Act
            model.AddStoryBoardIntoScriptData(storyBoard);
            model.RemoveStoryBoardFromScriptData(storyBoard);

            //Assert
            Assert.AreEqual(0, model.getAllStoryBoardScriptData().Count);
        }
   private void RtClickButton_ClickImpl(object sender, EventArgs e, ref StoryBoard SB)
   {
       string TBT = TxtBox.Text;
       switch(Counter)
       {
         case 0:
             TextBoxes[Counter] = TBT;
             break;
        }
        SB.Counter++; // Adds 1 to the counter.
        LtClickButton.Enabled = true;
        TxtBox.Clear(); // Clears the text box.
 }
        /// <inheritdoc/>
        public override async Task Run()
        {
            SettingsModel settings = _settingsService.LoadSettingsOrDefault();

            // Execute step
            if (!string.IsNullOrWhiteSpace(settings.TransferCode))
            {
                await StoryBoard.ContinueWith(SynchronizationStoryStepId.DecryptCloudRepository.ToInt());
            }
            else
            {
                await StoryBoard.ContinueWith(SynchronizationStoryStepId.ShowTransferCode.ToInt());
            }
        }
Exemplo n.º 20
0
        /// <inheritdoc/>
        public override async Task Run()
        {
            SettingsModel settings = _settingsService.LoadSettingsOrDefault();

            // Execute step
            if (settings.HasTransferCode)
            {
                await StoryBoard.ContinueWith(SynchronizationStoryStepId.DecryptCloudRepository);
            }
            else
            {
                await StoryBoard.ContinueWith(SynchronizationStoryStepId.ShowTransferCode);
            }
        }
Exemplo n.º 21
0
        /// <inheritdoc/>
        public override async Task Run()
        {
            _repositoryStorageService.LoadRepositoryOrDefault(out NoteRepositoryModel localRepository);
            NoteRepositoryModel cloudRepository = StoryBoard.LoadFromSession <NoteRepositoryModel>(SynchronizationStorySessionKey.CloudRepository);

            if (localRepository.Id == cloudRepository.Id)
            {
                await StoryBoard.ContinueWith(SynchronizationStoryStepId.StoreMergedRepositoryAndQuit);
            }
            else
            {
                await StoryBoard.ContinueWith(SynchronizationStoryStepId.ShowMergeChoice);
            }
        }
Exemplo n.º 22
0
        /// <inheritdoc/>
        public override async Task Run()
        {
            SettingsModel settings = _settingsService.LoadSettingsOrDefault();

            if (settings.HasCloudStorageClient)
            {
                StoryBoard.StoreToSession(SynchronizationStorySessionKey.CloudStorageCredentials, settings.Credentials);
                await StoryBoard.ContinueWith(SynchronizationStoryStepId.ExistsCloudRepository);
            }
            else
            {
                await StoryBoard.ContinueWith(SynchronizationStoryStepId.ShowFirstTimeDialog);
            }
        }
        public override async Task Run()
        {
            try
            {
                if (!StoryBoard.TryLoadFromSession(SynchronizationStorySessionKey.CloudStorageCredentials, out SerializeableCloudStorageCredentials credentials))
                {
                    throw new ArgumentNullException(nameof(credentials));
                }
                if (!StoryBoard.TryLoadFromSession(SynchronizationStorySessionKey.OauthState, out string oauthState))
                {
                    throw new ArgumentNullException(nameof(oauthState));
                }
                if (!StoryBoard.TryLoadFromSession(SynchronizationStorySessionKey.OauthCodeVerifier, out string oauthCodeVerifier))
                {
                    throw new ArgumentNullException(nameof(oauthState));
                }
                if (!StoryBoard.TryLoadFromSession(SynchronizationStorySessionKey.OauthRedirectUrl, out string redirectUrl))
                {
                    throw new ArgumentNullException(nameof(redirectUrl));
                }

                StoryBoard.RemoveFromSession(SynchronizationStorySessionKey.OauthState);
                StoryBoard.RemoveFromSession(SynchronizationStorySessionKey.OauthCodeVerifier);
                StoryBoard.RemoveFromSession(SynchronizationStorySessionKey.OauthRedirectUrl);

                ICloudStorageClient cloudStorageClient = _cloudStorageClientFactory.GetOrCreate(credentials.CloudStorageId);
                if (cloudStorageClient is IOAuth2CloudStorageClient oauthStorageClient)
                {
                    CloudStorageToken token = await oauthStorageClient.FetchTokenAsync(redirectUrl, oauthState, oauthCodeVerifier);

                    if (token != null)
                    {
                        // User has granted access.
                        credentials.Token = token;
                        await StoryBoard.ContinueWith(SynchronizationStoryStepId.ExistsCloudRepository);
                    }
                    else
                    {
                        // User has rejected access.
                        _feedbackService.ShowToast(_languageService.LoadText("sync_reject"));
                        await StoryBoard.ContinueWith(SynchronizationStoryStepId.StopAndShowRepository);
                    }
                }
            }
            catch (Exception ex)
            {
                // Keep the current page open and show the error message
                ShowExceptionMessage(ex, _feedbackService, _languageService);
            }
        }
        /// <inheritdoc/>
        public override async Task Run()
        {
            _repositoryStorageService.LoadRepositoryOrDefault(out NoteRepositoryModel localRepository);
            NoteRepositoryModel cloudRepository = StoryBoard.LoadFromSession <NoteRepositoryModel>(PullPushStorySessionKey.CloudRepository);

            if (localRepository.Id == cloudRepository.Id)
            {
                await StoryBoard.ContinueWith(PullPushStoryStepId.StoreMergedRepositoryAndQuit);
            }
            else
            {
                _feedbackService.ShowToast(_languageService["pushpull_error_need_sync_first"]);
            }
        }
Exemplo n.º 25
0
        public void InsertStoryBoardIntoScriptData()
        {
            //Arrange
            Model sut = new Model();
            Media media = new Media();
            media.Describe = "storyBoard1";
            StoryBoard storyBoard = new StoryBoard(media);

            //Act
            sut.InsertStoryBoardIntoScriptData(0, storyBoard);

            //Assert
            Assert.AreEqual("storyBoard1", storyBoard.MediaSource.Describe);

        }
Exemplo n.º 26
0
        // GET: StoryBoards/Create
        public IActionResult Create([FromRoute] int id)
        {
            var storyBoard = new StoryBoard()
            {
                PostDateTime = DateTime.Now,
                ClientPageId = id
            };

            var viewModel = new StoryBoardCreateEditViewModel()
            {
                StoryBoard = storyBoard
            };

            return(View(viewModel));
        }
Exemplo n.º 27
0
        /// <inheritdoc/>
        public override async Task Run()
        {
            try
            {
                SettingsModel settings = _settingsService.LoadSettingsOrDefault();
                byte[]        binaryCloudRepository = StoryBoard.LoadFromSession <byte[]>(SynchronizationStorySessionKey.BinaryCloudRepository);

                // Try to decode with all possible transfer codes
                bool successfullyDecryptedRepository = TryDecryptWithAllTransferCodes(
                    settings, binaryCloudRepository, out byte[] decryptedRepository);

                if (successfullyDecryptedRepository)
                {
                    // Deserialize and update repository
                    XDocument cloudRepositoryXml = XmlUtils.LoadFromXmlBytes(decryptedRepository);
                    if (_noteRepositoryUpdater.IsTooNewForThisApp(cloudRepositoryXml))
                    {
                        throw new SynchronizationStoryBoard.UnsuportedRepositoryRevisionException();
                    }

                    _noteRepositoryUpdater.Update(cloudRepositoryXml);
                    NoteRepositoryModel cloudRepository = XmlUtils.DeserializeFromXmlDocument <NoteRepositoryModel>(cloudRepositoryXml);

                    // Continue with next step
                    StoryBoard.StoreToSession(SynchronizationStorySessionKey.CloudRepository, cloudRepository);
                    await StoryBoard.ContinueWith(SynchronizationStoryStepId.IsSameRepository);
                }
                else
                {
                    bool existsUserEnteredTransferCode = StoryBoard.TryLoadFromSession <string>(SynchronizationStorySessionKey.UserEnteredTransferCode, out _);
                    if (existsUserEnteredTransferCode)
                    {
                        // Keep transfercode page open and show message
                        _feedbackService.ShowToast(_languageService["sync_error_transfercode"]);
                    }
                    else
                    {
                        // Open transfercode page
                        await StoryBoard.ContinueWith(SynchronizationStoryStepId.ShowTransferCode);
                    }
                }
            }
            catch (Exception ex)
            {
                // Keep the current page open and show the error message
                ShowExceptionMessage(ex, _feedbackService, _languageService);
            }
        }
        /// <inheritdoc/>
        public override async Task Run()
        {
            try
            {
                NoteRepositoryModel cloudRepository = StoryBoard.LoadFromSession <NoteRepositoryModel>(SynchronizationStorySessionKey.CloudRepository);
                _repositoryStorageService.TrySaveRepository(cloudRepository);
                await StoryBoard.ContinueWith(SynchronizationStoryStepId.StopAndShowRepository);

                _feedbackService.ShowToast(_languageService["sync_success"]);
            }
            catch (Exception ex)
            {
                // Keep the current page open and show the error message
                ShowExceptionMessage(ex, _feedbackService, _languageService);
            }
        }
Exemplo n.º 29
0
        /// <inheritdoc/>
        public override async Task Run()
        {
            SettingsModel settings = _settingsService.LoadSettingsOrDefault();

            bool clientIsSet = (settings.Credentials?.CloudStorageId != null);

            if (clientIsSet)
            {
                StoryBoard.StoreToSession(SynchronizationStorySessionKey.CloudStorageCredentials.ToInt(), settings.Credentials);
                await StoryBoard.ContinueWith(SynchronizationStoryStepId.ExistsCloudRepository.ToInt());
            }
            else
            {
                await StoryBoard.ContinueWith(SynchronizationStoryStepId.ShowFirstTimeDialog.ToInt());
            }
        }
        /// <inheritdoc/>
        public override async Task Run()
        {
            try
            {
                SerializeableCloudStorageCredentials credentials = StoryBoard.LoadFromSession <SerializeableCloudStorageCredentials>(SynchronizationStorySessionKey.CloudStorageCredentials);
                _repositoryStorageService.LoadRepositoryOrDefault(out NoteRepositoryModel localRepository);
                SettingsModel settings     = _settingsService.LoadSettingsOrDefault();
                string        transferCode = settings.TransferCode;

                bool needsNewTransferCode = !TransferCode.IsCodeSet(transferCode);
                if (needsNewTransferCode)
                {
                    transferCode = TransferCode.GenerateCode(_cryptoRandomService);
                }

                byte[] encryptedRepository = EncryptRepository(
                    localRepository, transferCode, _cryptoRandomService, settings.SelectedEncryptionAlgorithm);

                ICloudStorageClient cloudStorageClient = _cloudStorageClientFactory.GetOrCreate(credentials.CloudStorageId);
                await cloudStorageClient.UploadFileAsync(Config.RepositoryFileName, encryptedRepository, credentials);

                // All went well, time to save the transfer code, if a new one was created
                if (needsNewTransferCode)
                {
                    settings.TransferCode = transferCode;
                    _settingsService.TrySaveSettingsToLocalDevice(settings);

                    string formattedTransferCode = TransferCode.FormatTransferCodeForDisplay(transferCode).Replace(' ', '-');
                    string messageNewCreated     = _languageService.LoadTextFmt("transfer_code_created", formattedTransferCode);
                    string messageWriteDown      = _languageService.LoadText("transfer_code_writedown");
                    if (StoryBoard.Mode.ShouldUseGui())
                    {
                        await _feedbackService.ShowMessageAsync(messageNewCreated + Environment.NewLine + messageWriteDown, null, MessageBoxButtons.Ok, false);
                    }
                }

                await StoryBoard.ContinueWith(SynchronizationStoryStepId.StopAndShowRepository);

                _feedbackService.ShowToast(_languageService["sync_success"]);
            }
            catch (Exception ex)
            {
                // Keep the current page open and show the error message
                ShowExceptionMessage(ex, _feedbackService, _languageService);
            }
        }
Exemplo n.º 31
0
 public MainWindow()
 {
     InitializeComponent();
     navigationViewController = new NavigationViewController(this, this.NavigationBar);
     storyBoard = new StoryBoard(this,navigationViewController);
 }
Exemplo n.º 32
0
 public ViewControllerContext(StoryBoard storyBoard, NavigationViewController navigationViewController)
 {
     this._storyBoard = storyBoard;
     this._navigationViewController = navigationViewController;
 }
Exemplo n.º 33
0
        public void AnimateExit()
        {
            var exitSb = new StoryBoard();
            foreach (var element in this.elements.Where(e => e.ExitAnimation != null))
            {
                element.ExitAnimation.Duration = this.EntranceDuration;
                exitSb.AddAnimation(element.ExitAnimation);
            }
            if (this.ShadowedAnimationMode != ShadowedAnimationOptions.None)
            {
                exitSb.AddAnimation(new FunctionBasedAnimation(FunctionBasedAnimation.Functions.Linear)
                {
                    Duration = this.EntranceDuration,
                    From = this.ShadowedAnimationMode == ShadowedAnimationOptions.FromRight ? this.offBmp.Width : -this.offBmp.Width * 3,
                    To = this.ShadowedAnimationMode == ShadowedAnimationOptions.FromRight ? -this.offBmp.Width : -this.offBmp.Width * 1,
                    OnAnimation = v => this.shadowImageX = v
                });
            }
            exitSb.AddAnimation(new CommitStoryboardAnimation { Duration = this.EntranceDuration, CommitAction = () => this.ForcedInvalidate() });
            exitSb.AnimateSync();

            if (this.OnExitAnimationCompleted != null)
            {
                this.OnExitAnimationCompleted();
            }
        }