Example #1
0
        private async void ExecuteDeleteProjectCommand(ProjectViewModel arg)
        {
            ConfirmationServiceArgs args = new ConfirmationServiceArgs(Strings.Confirm, string.Format(Strings.DoYouReallyWantToDeleteProjectXXX, arg.Model.Name), Strings.Yes, Strings.No);

            if (!await ViewServices.Execute <IConfirmationService, bool>(args))
            {
                return;
            }

            arg.CurrentChanged -= Proj_CurrentChanged;

            Projects.Remove(arg);
            ProjectRepo.Delete(arg.Model);

            if (!Projects.Contains(CurrentProject))
            {
                CurrentProject = Projects.FirstOrDefault();
                if (CurrentProject != null)
                {
                    CurrentProject.IsCurrent = true;
                }
            }

            MessengerInstance.Send(new NotificationMessage(Strings.ProjectDeleted));
        }
Example #2
0
        private async void ExecuteBrowseFolderCommand()
        {
            var path = await ViewServices.Execute <IBrowseFileService, string>(System.IO.Path.GetDirectoryName(Path));

            if (!string.IsNullOrWhiteSpace(path))
            {
                Path = path;
            }
        }
Example #3
0
        private async void ExecuteDeleteEntryCommand()
        {
            ConfirmationServiceArgs args = new ConfirmationServiceArgs(Strings.Confirm, Strings.DoYouReallyWantToDeleteThisEntry, Strings.Yes, Strings.No);

            if (!await ViewServices.Execute <IConfirmationService, bool>(args))
            {
                return;
            }

            DeleteRequested?.Invoke(this, EventArgs.Empty);
        }
Example #4
0
        private async void ExecuteDeleteTagCommand(TagViewModel arg)
        {
            ConfirmationServiceArgs args = new ConfirmationServiceArgs(Strings.Confirm,
                                                                       string.Format(Strings.DoYouReallyWantToDeleteTagXXX, arg.Model.Name),
                                                                       Strings.Yes, Strings.No);

            if (!await ViewServices.Execute <IConfirmationService, bool>(args))
            {
                return;
            }

            TagRepo.Delete(arg.Model);
            Tags.Remove(arg);

            MessengerInstance.Send(new TagRemovedMessage(arg.Model));
            MessengerInstance.Send(new NotificationMessage(Strings.TagDeleted));
            ReadTagNames();
        }
Example #5
0
        private async void ExecuteMoveDatabaseCommand()
        {
            var result = await ViewServices.Execute <IMoveDatabaseService, MoveDatabaseResult>();

            if (string.IsNullOrWhiteSpace(result.Path))
            {
                return;
            }

            if (result.OverwriteExisting || !File.Exists(result.Path))
            {
                await ViewServices.Execute <IProgressService>(new ProgressServiceArgs( report =>
                {
                    SQLiteBackupCallback callback =
                        (source, sourceName, destination, destinationName, pages, remainingPages, totalPages, retry) =>
                    {
                        report.SetProgress(totalPages - remainingPages, totalPages);
                        return(true);
                    };

                    SQLiteConnectionStringBuilder sb = new SQLiteConnectionStringBuilder
                    {
                        DataSource = result.Path
                    };

                    using (SQLiteConnection destConnection = new SQLiteConnection(sb.ToString()))
                    {
                        destConnection.Open();

                        var connection = App.Session.Connection as SQLiteConnection;
                        Debug.Assert(connection != null, "connection != null");
                        connection.BackupDatabase(destConnection, "main", "main", -1, callback, 100);
                    }
                } ));
            }

            Settings.Set(SettingKeys.DatabasePath, result.Path);
            Application.Current.Shutdown();
            Process.Start(Assembly.GetExecutingAssembly().Location);
        }
Example #6
0
 private async void ExecuteInfoCommand()
 {
     await ViewServices.Execute <IInfoService>();
 }