Beispiel #1
0
        public static void CreateThumbnail(string path, IDialogService dialogService = null)
        {
            Image image = Image.Thumbnail(path, 75, 75);

            var  newPath   = "";
            int  index     = path.IndexOf(".", StringComparison.InvariantCulture);
            bool overwrite = false;

            if (index > 0)
            {
                newPath = path.Substring(0, index) + "_thumb.jpg";
            }

            image.WriteToFile("test.jpg");
            if (File.Exists(newPath))
            {
                var dialog = new OkCancelViewModel("File already exists.", "File already exists. Would you like to replace the existing file?");
                if (dialogService?.OpenDialog(dialog) == DialogResult.No)
                {
                    return;
                }

                overwrite = true;
            }

            File.Move("test.jpg", newPath, overwrite);
        }
Beispiel #2
0
        public void ConstructorsAndPropertiesTest()
        {
            var ok = new OkCancelViewModel("message", "heading");

            Assert.AreEqual("message", ok.Message);
            Assert.AreEqual("heading", ok.Heading);
            Assert.IsNotNull(ok.CancelCommand);
        }
Beispiel #3
0
 public void CancelTest()
 {
     try
     {
         var ok = new OkCancelViewModel("message", "heading");
         ok.CancelCommand.Execute(new object());
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
        private async void OnChangeEditedNationalityExecute(Guid?nationalityId)
        {
            if (this.domainService.Repository.HasChanges())
            {
                var dialog = new OkCancelViewModel("Close the view?", "You have made changes. Changing editable nationality will loose all unsaved changes. Are you sure you still want to switch?");
                var result = dialogService.OpenDialog(dialog);

                if (result == DialogResult.No)
                {
                    return;
                }
            }

            domainService.Repository.ResetTracking(SelectedItem.Model);
            HasChanges = domainService.Repository.HasChanges();

            await LoadAsync((Guid)nationalityId);
        }
        private bool ShouldDatabaseBeCreated()
        {
            var dialog = new OkCancelViewModel("Would you like to create a database now?", "Create database?");

            return(_dialogService.OpenDialog(dialog) == DialogResult.Yes);
        }