Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format from/to custom number base #430

Merged
merged 51 commits into from
Mar 26, 2022
Merged

Conversation

youkai95
Copy link
Contributor

@youkai95 youkai95 commented Feb 27, 2022

Ok, now I think it has all the required functionalities. Here I left some features available like allowing formatting even for those base numbers using custom dictionaries. That idea could be improved as it would be nice to allow user to change the default character and group size... Yes, it is hardcoded at the moment.

I am not sure at all if I faced this problem in a correct way. If you have any comment regarding my code, please share it with me to improve it.

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • UI change (please include screenshot!)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Internationalization and localization
  • Other (please describe):

What is the current behavior?

Issue Number: resolve #384

What is the new behavior?

  • Convert numbers from/to different bases
  • Provide and advanced view to allow complex functionalities.
  • Allows formatting for custom dictionaries (need work)

Other information

Quality check

Before creating this PR, have you:

  • Followed the code style guideline as described in CONTRIBUTING.md
  • Verified that the change work in Release build configuration
  • Checked all unit tests pass

@youkai95 youkai95 changed the title Custom number base Format from/to custom number base Feb 27, 2022
@youkai95 youkai95 marked this pull request as ready for review March 6, 2022 01:03
Comment on lines 50 to 65
if (!string.IsNullOrWhiteSpace(parameters.ClipBoardContent))
{
string clipBoardContent = NumberBaseFormatter.RemoveFormatting(parameters.ClipBoardContent).ToString();
// TODO: This feature would be nice to find a way to keep it
//if (!string.IsNullOrWhiteSpace(parameters.ClipBoardContent))
//{
// string clipBoardContent = NumberBaseFormatter.RemoveFormatting(parameters.ClipBoardContent).ToString();

if (NumberBaseHelper.IsValidBinary(clipBoardContent!))
{
ViewModel.InputBaseNumber = NumberBaseFormat.Binary;
}
else if (NumberBaseHelper.IsValidHexadecimal(clipBoardContent!))
{
ViewModel.InputBaseNumber = NumberBaseFormat.Hexadecimal;
}
// if (NumberBaseHelper.IsValidBinary(clipBoardContent!))
// {
// ViewModel.InputBaseNumber = NumberBaseFormat.Binary;
// }
// else if (NumberBaseHelper.IsValidHexadecimal(clipBoardContent!))
// {
// ViewModel.InputBaseNumber = NumberBaseFormat.Hexadecimal;
// }

ViewModel.InputValue = parameters.ClipBoardContent;
}
// ViewModel.InputValue = parameters.ClipBoardContent;
//}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to revert this changes and keep this feature. This could require big changes but if you give me any idea I will try to fix it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the challenge you're encounter here? Is the problem to determine whether it's an advanced mode or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the tool opens through NumberBaseConverter main view but the functionalities are inside Basic/Advanced view models, who are not declared inside the main view. However, I just realized that I could get this done using messages, isn't it? Still remains the problem of selecting between basic or advanced view...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. You should be able to do this by:

  1. Set x:Name="AdvancedNumberBaseConverterControl" on the advanced control in the main view
  2. And then, something like:
ViewModel.AdvancedMode = true;
AdvancedNumberBaseConverterControl.ViewModel.Property = something;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will keep this feature as it is at the moment. To include advanced conversions into this feature could be really confusing, so I will keep it working with basic conversions. I could later open an issue if we want to take this further.

* Added the possibility to Favorite/Unfavorite a tool.

* Updated localization

* addressed feedback
@youkai95
Copy link
Contributor Author

youkai95 commented Mar 8, 2022

@veler @btiteux this PR is ready to review 😁 There are few details that would be nice to improve, but overall, it is ready to check.

@veler
Copy link
Collaborator

veler commented Mar 12, 2022

@veler @btiteux this PR is ready to review 😁 There are few details that would be nice to improve, but overall, it is ready to check.

Hello :)
Sorry for the very late answer. I'm still very busy lately. I will take a look now. :)

@veler
Copy link
Collaborator

veler commented Mar 12, 2022

Custom base doesn't seem to work, or I don't understand how it should work.

image

I'm also facing some error banner when enabling/disabling Format number.
Also sometimes I'd type something in the Basic mode input and would get an error about the fact that the Custom Base dictionary is wrong. You should really separate the view model of the Basic and Advanced mode so they don't conflict.

Copy link
Collaborator

@veler veler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite a big PR, good job :)
I encountered some bugs though, or didn't understand how to use it (in particular the custom base).

I'm also hitting some bugs that seems to come from the Advanced mode when I'm editing something in Basic mode (for example, the Format number option).

Thank you :)

@youkai95
Copy link
Contributor Author

Custom base doesn't seem to work, or I don't understand how it should work.

image

If you use a custom dictionary for input, then you should write an input value using that dictionary. Using you example, a correct input should be a value with characters:

 1234abcd
(01234567)

The line below correspond to the values that every character has when converting to decimal base.

I'm also facing some error banner when enabling/disabling Format number. Also sometimes I'd type something in the Basic mode input and would get an error about the fact that the Custom Base dictionary is wrong. You should really separate the view model of the Basic and Advanced mode so they don't conflict.

I am not sure about how to replicate this error. I would be grateful if you could provide me an example to simulate it. I have decided to keep the info box into the parent component to avoid having duplicated code as it is the same behavior for both views.

Guzzter and others added 3 commits March 14, 2022 23:02
* Add StartWithLoremIpsum option

* Updated language bundles

* Added refresh buttom for lorem ipsum

* Replaced click handler with Refresh ICommand

* Fixing error

Co-authored-by: Guus Beltman <[email protected]>
@youkai95
Copy link
Contributor Author

youkai95 commented Mar 21, 2022

@veler the reviews you asked for should be solved with this push, sorry for the late. I also found some bugs and misbehavior in the code that should be solved now.

@veler
Copy link
Collaborator

veler commented Mar 21, 2022

Custom base doesn't seem to work, or I don't understand how it should work.
image

If you use a custom dictionary for input, then you should write an input value using that dictionary. Using you example, a correct input should be a value with characters:

 1234abcd
(01234567)

The line below correspond to the values that every character has when converting to decimal base.

I'm also facing some error banner when enabling/disabling Format number. Also sometimes I'd type something in the Basic mode input and would get an error about the fact that the Custom Base dictionary is wrong. You should really separate the view model of the Basic and Advanced mode so they don't conflict.

I am not sure about how to replicate this error. I would be grateful if you could provide me an example to simulate it. I have decided to keep the info box into the parent component to avoid having duplicated code as it is the same behavior for both views.

I see! Thanks for the explanation! It wasn't clear to me by looking at the UI that works this way. Should we consider clarifying it in the UI? What do yout think?

@veler the reviews you asked for should be solved with this push, sorry for the late. I also found some bugs and misbehavior in the code that should be solved now.

Thank you for this too. I gave it a try and it seems better :D
I added a few other comments to the code. Can you please address them when you have some time?
There's also a merge conflict to address.

After all this, I think it will be good to merge.

Thanks again!

@youkai95
Copy link
Contributor Author

Should we consider clarifying it in the UI? What do yout think?

I think that would be a good idea. If you were aware of this tool capabilities and you got confused, what could we expect from others? XD Also, I will try to discover what is happening with the label that doesnt get shown.

I added a few other comments to the code. Can you please address them when you have some time?
There's also a merge conflict to address.

Ok, I could address them in few time and do the merge. I also noticed that I miss some old changes...

Copy link
Collaborator

@veler veler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,
Sorry for the delay.
It looks great now ! :D I will merge it. Thank you for the contribution, much appreciated! :)

@veler veler merged commit cf421ab into DevToys-app:main Mar 26, 2022
veler added a commit that referenced this pull request Mar 31, 2023
* Number conversion using custom bases functionalities and few tests

* Functionalities to format numbers using any base and dictionary

* Add new language text

* Change models to fit new features

* Add new communication messages between number converter view models

* Add views and functionalities to allow custom dictionaries

* Activate model to receive messages

* Include language generated component

* Rebase and cleanup code

* Update InfoBar message to show/hide it correctly

* Remove remaining code generating compile errors

* Code refactoring

* Fix test cases

* Added the possibility to Favorite/Unfavorite a tool. (#437)

* Added the possibility to Favorite/Unfavorite a tool.

* Updated localization

* addressed feedback

* Fix README.md minor typo (#441)

* Update japanese translation. (#444)

* Bumped up version number

* Feature/add refresh button lorem ipsum (#413)

* Add StartWithLoremIpsum option

* Updated language bundles

* Added refresh buttom for lorem ipsum

* Replaced click handler with Refresh ICommand

* Fixing error

Co-authored-by: Guus Beltman <[email protected]>

* Added some assets

* Updated chocolatey

* updated wikiUrl in Chocolatey

* Update Traditional Chinese translation (#442)

* Updates to cs-CZ localization (#447)

* feature: 💬 add new lang (Portuguese-Brazil) (#449)

* Update japanese translation. (lorem ipsum) (#450)

* Update japanese translation. (lorem ipsum)

* Fix typo.

* Update chinese translation (#451)

* Added String Escape / Unescape tool (#446)

* Set nullable

* Set nullable and change to string dictionaries

* Fix errors, inject view models and improve code

* Add translations

* Number conversion using custom bases functionalities and few tests

* Functionalities to format numbers using any base and dictionary

* Add new language text

* Change models to fit new features

* Add new communication messages between number converter view models

* Add views and functionalities to allow custom dictionaries

* Activate model to receive messages

* Include language generated component

* Rebase and cleanup code

* Update InfoBar message to show/hide it correctly

* Remove remaining code generating compile errors

* Code refactoring

* Fix test cases

* Set nullable

* Set nullable and change to string dictionaries

* Fix errors, inject view models and improve code

* Add translations

* Automatic input when navigating to the tool

Co-authored-by: Etienne BAUDOUX <[email protected]>
Co-authored-by: kspc1000 <[email protected]>
Co-authored-by: Sou Niyari <[email protected]>
Co-authored-by: Guus Beltman <[email protected]>
Co-authored-by: Guus Beltman <[email protected]>
Co-authored-by: SiderealArt <[email protected]>
Co-authored-by: Morning4coffe <[email protected]>
Co-authored-by: Rafael Andrade de Oliveira <[email protected]>
Co-authored-by: Boring3 <[email protected]>
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.

Number Base Converter - Custom base
9 participants