Skip to content

Conversation

YohskDista
Copy link
Contributor

Goal

The goal of this PR is to be able to select and show a background image for a custom theme and have a more fancy terminal. This refers to the issue #539.

What was done

Theme settings

Add / Edit the theme

Firstly we add a browse button when we create or edit a theme so that the user can select an image in a specific folder of his computer. Once the image is selected we will put it in the LocalCache/BackgroundImageTmp folder so that we can show a preview to the user.

We need to do this because our application cannot access or show an image that is outside its application folder unless we gave the application the specific capabilities.
To do a preview of the background image we must have a background color below the toolbar and the color configuration otherwise we didn't see anything because of the image.

When we save the theme we will remove all the image in the temporary folder and save the selected one in the Roaming folder.

We create an interface to manage the selection of these image functionnality called IImageFileSystemService. That allow us to separate the file system managment from the image theme managment.

Remove the background image

We put a button to be able to remove the background image any time we want. If we click on the cancel button after we deleted the image don't worry, we don't loose your precious image :)

Import / Export

We add the possibility to import and export the theme with the background image (if it exists). When we export it we encode the image in a base64 string and decode it when we import the theme.

To export/import the theme we need to create an ExportedTerminalTheme object that contains a TerminalTheme and the encoded image string. We did this because it was a pitty to change the TerminalTheme object for this encoded image that we need only for the import/export theme.

Show the background image

Now we can show the background image of the selected theme directly in the TerminalView. Be carefull to select a good image so that you can still see the text of the console ;)

The goal was to create a command that permit to browse user pictures.
The user can now select is picture by browsing file or to simply copy the
link of the image in the textbox.
We call the method `ImportImageFile` so that we can show a picker dialog
and directly import the image in the roaming folder.
We make some check to avoid the application crash, still need to test
Now that we have a background image we need to set the background according
to the theme color or the selected image.
To do this we need to use the `ThemeViewModel` and the new converter to
select the right brush to use (`ImageBrush` or ` AcrylicBrush`)
@felixse
Copy link
Owner

felixse commented Oct 16, 2019

Looks good so far, nice work 👍

Some things I have noticed:

  • After selecting an image and saving: If you select another theme and then go back to the just edited one, the background disappears
  • The background colors for the the theme page look a bit odd. I don't think we need them. If you cannot read your text there anymore it's a good indicator that your image might not be a suitable background.
  • The image is not keeping it's aspect ratio. Adding Stretch.UniformToFill to the Brush might help.

@YohskDista
Copy link
Contributor Author

Thanks ! I've made the suggestion that you were talking. I let you check if it's ok for you now 👍

@felixse felixse merged commit 37b4fd2 into felixse:master Oct 20, 2019
@Leonetienne
Copy link

This is such a cool feature! Thanks a lot! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants