コード例 #1
0
        /// <inheritdoc/>
        public override void ShowInView(IHtmlView htmlView, KeyValueList <string, string> variables, Navigation redirectedFrom)
        {
            base.ShowInView(htmlView, variables, redirectedFrom);
            _viewModel = new OpenSafeViewModel(
                Ioc.GetOrCreate <INavigationService>(),
                Ioc.GetOrCreate <ILanguageService>(),
                Ioc.GetOrCreate <ISvgIconService>(),
                Ioc.GetOrCreate <IThemeService>(),
                Ioc.GetOrCreate <IBaseUrlService>(),
                Ioc.GetOrCreate <IFeedbackService>(),
                Ioc.GetOrCreate <ICryptoRandomService>(),
                Ioc.GetOrCreate <ISettingsService>(),
                Ioc.GetOrCreate <IRepositoryStorageService>(),
                RedirectedFrom);

            Bindings.BindCommand("GoBack", _viewModel.GoBackCommand);
            Bindings.BindCommand("OkCommand", _viewModel.OkCommand);
            Bindings.BindCommand("CancelCommand", _viewModel.CancelCommand);
            Bindings.BindCommand("ResetSafeCommand", _viewModel.ResetSafeCommand);
            Bindings.BindText("Password", null, (v) => _viewModel.Password = SecureStringExtensions.StringToSecureString(v), null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindText("PasswordConfirmation", null, (v) => _viewModel.PasswordConfirmation = SecureStringExtensions.StringToSecureString(v), null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindInvalid("Password", () => _viewModel.InvalidPasswordError, _viewModel, nameof(_viewModel.InvalidPasswordError), HtmlViewBindingMode.OneWayToView);
            Bindings.BindInvalid("PasswordConfirmation", () => _viewModel.InvalidPasswordConfirmationError, _viewModel, nameof(_viewModel.InvalidPasswordConfirmationError), HtmlViewBindingMode.OneWayToView);

            string html = _viewService.GenerateHtml(_viewModel);

            View.LoadHtml(html);
        }
コード例 #2
0
        /// <inheritdoc/>
        public override void ShowInView(IHtmlView htmlView, KeyValueList <string, string> variables, Navigation redirectedFrom)
        {
            base.ShowInView(htmlView, variables, redirectedFrom);
            _viewModel = new SettingsViewModel(
                Ioc.GetOrCreate <INavigationService>(),
                Ioc.GetOrCreate <ILanguageService>(),
                Ioc.GetOrCreate <ISvgIconService>(),
                Ioc.GetOrCreate <IThemeService>(),
                Ioc.GetOrCreate <IBaseUrlService>(),
                Ioc.GetOrCreate <ISettingsService>(),
                Ioc.GetOrCreate <IStoryBoardService>());

            Bindings.BindCommand("GoBack", _viewModel.GoBackCommand);
            Bindings.BindCommand("ChangeCloudSettingsCommand", _viewModel.ChangeCloudSettingsCommand);
            Bindings.BindCommand("ClearCloudSettingsCommand", _viewModel.ClearCloudSettingsCommand);
            Bindings.BindDropdown("SelectedEncryptionAlgorithm", null, SetEncryptionAlgorithmToViewmodel, null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindDropdown("SelectedAutoSyncMode", null, (string value) => _viewModel.SelectedAutoSyncMode = value, null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindText("CloudStorageSettings", () => _viewModel.AccountSummary, null, _viewModel, nameof(_viewModel.AccountSummary), HtmlViewBindingMode.OneWayToView);
            Bindings.BindBackgroundImage("SelectedTheme", () => _viewModel.SelectedTheme.Image, _viewModel, nameof(_viewModel.SelectedTheme), HtmlViewBindingMode.OneWayToView);
            Bindings.BindCheckbox("UseSolidColorTheme", null, (bool value) => _viewModel.UseSolidColorTheme                       = value, null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindText("ColorForSolidThemeHex", null, (string value) => _viewModel.ColorForSolidThemeHex                   = value, null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindDropdown("SelectedThemeMode", null, (string value) => _viewModel.SelectedThemeMode                       = value, null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindDropdown("SelectedNoteInsertionMode", null, (string value) => _viewModel.SelectedNoteInsertionMode       = value, null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindCheckbox("UseColorForAllNotesInDarkMode", null, (bool value) => _viewModel.UseColorForAllNotesInDarkMode = value, null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindText("ColorForAllNotesInDarkModeHex", null, (string value) => _viewModel.ColorForAllNotesInDarkModeHex   = value, null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.UnhandledViewBindingEvent += UnhandledViewBindingEventHandler;

            string html = _viewService.GenerateHtml(_viewModel);

            View.LoadHtml(html);
        }
コード例 #3
0
        /// <inheritdoc/>
        public override void ShowInView(IHtmlView htmlView, KeyValueList <string, string> variables)
        {
            base.ShowInView(htmlView, variables);
            _viewModel = new SettingsViewModel(
                Ioc.GetOrCreate <INavigationService>(),
                Ioc.GetOrCreate <ILanguageService>(),
                Ioc.GetOrCreate <ISvgIconService>(),
                Ioc.GetOrCreate <IBaseUrlService>(),
                Ioc.GetOrCreate <ISettingsService>(),
                Ioc.GetOrCreate <IThemeService>(),
                Ioc.GetOrCreate <IStoryBoardService>());

            Bindings.BindCommand("GoBack", _viewModel.GoBackCommand);
            Bindings.BindCommand("ChangeCloudSettingsCommand", _viewModel.ChangeCloudSettingsCommand);
            Bindings.BindCommand("ClearCloudSettingsCommand", _viewModel.ClearCloudSettingsCommand);
            Bindings.BindDropdown("SelectedEncryptionAlgorithm", null, SetEncryptionAlgorithmToViewmodel, null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindCheckbox("AdoptCloudEncryptionAlgorithm", null, (value) => _viewModel.AdoptCloudEncryptionAlgorithm = value, null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindDropdown("SelectedAutoSyncMode", null, (string value) => _viewModel.SelectedAutoSyncMode            = value, null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindText("CloudStorageSettings", () => _viewModel.AccountSummary, null, _viewModel, nameof(_viewModel.AccountSummary), HtmlViewBindingMode.OneWayToView);
            Bindings.BindCheckbox("ShowCursorArrowKeys", null, (value) => _viewModel.ShowCursorArrowKeys = value, null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindBackgroundImage("SelectedTheme", () => _viewModel.SelectedTheme.Image, _viewModel, nameof(_viewModel.SelectedTheme), HtmlViewBindingMode.OneWayToView);
            Bindings.UnhandledViewBindingEvent += UnhandledViewBindingEventHandler;

            string html = _viewService.GenerateHtml(_viewModel);

            View.LoadHtml(html);
        }
コード例 #4
0
        /// <inheritdoc/>
        public override void ShowInView(IHtmlView htmlView, KeyValueList <string, string> variables)
        {
            base.ShowInView(htmlView, variables);
            IStoryBoardService storyBoardService             = Ioc.GetOrCreate <IStoryBoardService>();
            SerializeableCloudStorageCredentials credentials = storyBoardService.ActiveStory.LoadFromSession <SerializeableCloudStorageCredentials>(SynchronizationStorySessionKey.CloudStorageCredentials.ToInt());

            _viewModel = new CloudStorageAccountViewModel(
                Ioc.GetOrCreate <INavigationService>(),
                Ioc.GetOrCreate <ILanguageService>(),
                Ioc.GetOrCreate <ISvgIconService>(),
                Ioc.GetOrCreate <IBaseUrlService>(),
                storyBoardService,
                Ioc.GetOrCreate <IFeedbackService>(),
                Ioc.GetOrCreate <ICloudStorageClientFactory>(),
                credentials);

            Bindings.BindCommand("GoBack", _viewModel.GoBackCommand);
            Bindings.BindCommand("OkCommand", _viewModel.OkCommand);
            Bindings.BindCommand("CancelCommand", _viewModel.CancelCommand);
            Bindings.BindText("Url", null, (v) => _viewModel.Url           = v, null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindText("Username", null, (v) => _viewModel.Username = v, null, null, HtmlViewBindingMode.OneWayToViewmodel);
            Bindings.BindText("Password", () => SecureStringExtensions.SecureStringToString(_viewModel.Password), (v) => _viewModel.Password = SecureStringExtensions.StringToSecureString(v), _viewModel, nameof(_viewModel.Password), HtmlViewBindingMode.TwoWayPlusOneTimeToView);
            Bindings.BindCheckbox("Secure", null, (v) => _viewModel.Secure = v, null, null, HtmlViewBindingMode.OneWayToViewmodel);

            string html = _viewService.GenerateHtml(_viewModel);

            View.LoadHtml(html);
        }
コード例 #5
0
ファイル: NoteController.cs プロジェクト: qmonk/SilentNotes
        /// <inheritdoc/>
        public override void ShowInView(IHtmlView htmlView, KeyValueList <string, string> variables, Navigation redirectedFrom)
        {
            base.ShowInView(htmlView, variables, redirectedFrom);
            ISettingsService settingsService = Ioc.GetOrCreate <ISettingsService>();

            View.NavigationCompleted += NavigationCompletedEventHandler;
            _repositoryService.LoadRepositoryOrDefault(out NoteRepositoryModel noteRepository);

            NoteModel note;

            _startedWithSendToSilentnotes = variables.ContainsKey(ControllerParameters.SendToSilentnotesText);
            if (_startedWithSendToSilentnotes)
            {
                // Create new note and update repository
                note = new NoteModel();
                note.BackgroundColorHex = settingsService.LoadSettingsOrDefault().DefaultNoteColorHex;
                noteRepository.Notes.Insert(0, note);
                _sendToSilentnotesText = variables[ControllerParameters.SendToSilentnotesText];
            }
            else
            {
                // Get the note from the repository
                Guid noteId = new Guid(variables[ControllerParameters.NoteId]);
                note = noteRepository.Notes.FindById(noteId);
            }

            ICryptor cryptor = new Cryptor(NoteModel.CryptorPackageName, Ioc.GetOrCreate <ICryptoRandomService>());

            _viewModel = new NoteViewModel(
                Ioc.GetOrCreate <INavigationService>(),
                Ioc.GetOrCreate <ILanguageService>(),
                Ioc.GetOrCreate <ISvgIconService>(),
                Ioc.GetOrCreate <IThemeService>(),
                Ioc.GetOrCreate <IBaseUrlService>(),
                null,
                _repositoryService,
                Ioc.GetOrCreate <IFeedbackService>(),
                settingsService,
                cryptor,
                noteRepository.Safes,
                note);
            SetHtmlViewBackgroundColor(htmlView);

            Bindings.BindCommand("PullNoteFromOnlineStorage", _viewModel.PullNoteFromOnlineStorageCommand);
            Bindings.BindCommand("PushNoteToOnlineStorage", _viewModel.PushNoteToOnlineStorageCommand);
            Bindings.BindCommand("GoBack", _viewModel.GoBackCommand);
            Bindings.BindText("PrettyTimeAgo", () => _viewModel.PrettyTimeAgo, null, _viewModel, nameof(_viewModel.PrettyTimeAgo), HtmlViewBindingMode.OneWayToView);
            Bindings.UnhandledViewBindingEvent += UnhandledViewBindingEventHandler;

            string html = _viewService.GenerateHtml(_viewModel);

            View.LoadHtml(html);
        }
コード例 #6
0
        /// <inheritdoc/>
        public override void ShowInView(IHtmlView htmlView, KeyValueList <string, string> variables)
        {
            base.ShowInView(htmlView, variables);
            _viewModel = new TransferCodeViewModel(
                Ioc.GetOrCreate <INavigationService>(),
                Ioc.GetOrCreate <ILanguageService>(),
                Ioc.GetOrCreate <ISvgIconService>(),
                Ioc.GetOrCreate <IBaseUrlService>(),
                Ioc.GetOrCreate <IStoryBoardService>(),
                Ioc.GetOrCreate <IFeedbackService>());

            Bindings.BindCommand("OkCommand", _viewModel.OkCommand);
            Bindings.BindCommand("GoBack", _viewModel.GoBackCommand);
            Bindings.BindCommand("CancelCommand", _viewModel.CancelCommand);
            Bindings.BindText("Code", () => _viewModel.Code, (v) => _viewModel.Code = v, null, null, HtmlViewBindingMode.OneWayToViewmodel);

            string html = _viewService.GenerateHtml(_viewModel);

            View.LoadHtml(html);
        }
コード例 #7
0
        /// <inheritdoc/>
        public override void ShowInView(IHtmlView htmlView, KeyValueList <string, string> variables, Navigation redirectedFrom)
        {
            base.ShowInView(htmlView, variables, redirectedFrom);
            View.NavigationCompleted += NavigationCompletedEventHandler;
            IRepositoryStorageService repositoryService = Ioc.GetOrCreate <IRepositoryStorageService>();

            _scrollToNote = variables?.GetValueOrDefault(ControllerParameters.NoteId);

            RepositoryStorageLoadResult loadResult = repositoryService.LoadRepositoryOrDefault(out _);

            if (loadResult != RepositoryStorageLoadResult.InvalidRepository)
            {
                _viewModel = new NoteRepositoryViewModel(
                    Ioc.GetOrCreate <INavigationService>(),
                    Ioc.GetOrCreate <ILanguageService>(),
                    Ioc.GetOrCreate <ISvgIconService>(),
                    Ioc.GetOrCreate <IThemeService>(),
                    Ioc.GetOrCreate <IBaseUrlService>(),
                    Ioc.GetOrCreate <IStoryBoardService>(),
                    Ioc.GetOrCreate <IFeedbackService>(),
                    Ioc.GetOrCreate <ISettingsService>(),
                    Ioc.GetOrCreate <IEnvironmentService>(),
                    Ioc.GetOrCreate <ICryptoRandomService>(),
                    repositoryService);

                Bindings.BindCommand("NewNote", _viewModel.NewNoteCommand);
                Bindings.BindCommand("NewChecklist", _viewModel.NewChecklistCommand);
                Bindings.BindCommand("Synchronize", _viewModel.SynchronizeCommand);
                Bindings.BindCommand("ShowTransferCode", _viewModel.ShowTransferCodeCommand);
                Bindings.BindCommand("ShowRecycleBin", _viewModel.ShowRecycleBinCommand);
                Bindings.BindCommand("ShowSettings", _viewModel.ShowSettingsCommand);
                Bindings.BindCommand("ShowInfo", _viewModel.ShowInfoCommand);
                Bindings.BindCommand("OpenSafe", _viewModel.OpenSafeCommand);
                Bindings.BindCommand("CloseSafe", _viewModel.CloseSafeCommand);
                Bindings.BindCommand("ChangeSafePassword", _viewModel.ChangeSafePasswordCommand);
                Bindings.BindCommand("FilterButtonCancel", _viewModel.ClearFilterCommand);
                Bindings.BindText("TxtFilter", () => _viewModel.Filter, (value) => _viewModel.Filter = value, _viewModel, nameof(_viewModel.Filter), HtmlViewBindingMode.TwoWay);
                Bindings.BindVisibility("FilterButtonMagnifier", () => string.IsNullOrEmpty(_viewModel.Filter), _viewModel, nameof(_viewModel.FilterButtonMagnifierVisible), HtmlViewBindingMode.OneWayToView);
                Bindings.BindVisibility("FilterButtonCancel", () => !string.IsNullOrEmpty(_viewModel.Filter), _viewModel, nameof(_viewModel.FilterButtonCancelVisible), HtmlViewBindingMode.OneWayToView);
                Bindings.BindGeneric <object>(
                    NotesChangedEventHandler,
                    null,
                    null,
                    null,
                    new HtmlViewBindingViewmodelNotifier(_viewModel, "Notes"),
                    HtmlViewBindingMode.OneWayToView);
                Bindings.UnhandledViewBindingEvent += UnhandledViewBindingEventHandler;

                // Load html page and content (notes)
                string html      = _viewService.GenerateHtml(_viewModel);
                string htmlNotes = _viewContentService.GenerateHtml(_viewModel);
                html = html.Replace("<ul id=\"note-repository\"></ul>", htmlNotes); // Replace node "note-repository" with content
                View.LoadHtml(html);
            }
            else
            {
                // Show error message and stop loading the application
                _stopViewModel = new StopViewModel(
                    Ioc.GetOrCreate <INavigationService>(),
                    Ioc.GetOrCreate <ILanguageService>(),
                    Ioc.GetOrCreate <ISvgIconService>(),
                    Ioc.GetOrCreate <IThemeService>(),
                    Ioc.GetOrCreate <IBaseUrlService>());
                string html = _viewStop.GenerateHtml(_stopViewModel);
                View.LoadHtml(html);
            }
        }