-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
dde1cf8
to
5a03d4d
Compare
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; | ||
//} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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:
- Set
x:Name="AdvancedNumberBaseConverterControl"
on the advanced control in the main view - And then, something like:
ViewModel.AdvancedMode = true;
AdvancedNumberBaseConverterControl.ViewModel.Property = something;
There was a problem hiding this comment.
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
Custom base doesn't seem to work, or I don't understand how it should work. I'm also facing some error banner when enabling/disabling |
There was a problem hiding this 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 :)
...dev/impl/DevToys/Views/Tools/Converters/NumberBaseConverter/NumberBaseConverterToolPage.xaml
Outdated
Show resolved
Hide resolved
...dev/impl/DevToys/Views/Tools/Converters/NumberBaseConverter/NumberBaseConverterToolPage.xaml
Outdated
Show resolved
Hide resolved
...dev/impl/DevToys/Views/Tools/Converters/NumberBaseConverter/NumberBaseConverterToolPage.xaml
Outdated
Show resolved
Hide resolved
...impl/DevToys/Views/Tools/Converters/NumberBaseConverter/BasicNumberBaseConverterControl.xaml
Outdated
Show resolved
Hide resolved
...l/DevToys/Views/Tools/Converters/NumberBaseConverter/AdvancedNumberBaseConverterControl.xaml
Outdated
Show resolved
Hide resolved
src/dev/impl/DevToys/ViewModels/Tools/Converters/NumberBaseConverter/NumberBaseFormatFactory.cs
Outdated
Show resolved
Hide resolved
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:
The line below correspond to the values that every character has when converting to decimal base.
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. |
* 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]>
@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. |
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?
Thank you for this too. I gave it a try and it seems better :D After all this, I think it will be good to merge. Thanks again! |
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.
Ok, I could address them in few time and do the merge. I also noticed that I miss some old changes... |
There was a problem hiding this 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! :)
src/dev/impl/DevToys/ViewModels/Tools/Converters/NumberBaseConverter/NumberBaseFormatBuilder.cs
Show resolved
Hide resolved
src/dev/impl/DevToys/ViewModels/Tools/Converters/NumberBaseConverter/NumberBaseFormatBuilder.cs
Show resolved
Hide resolved
src/dev/impl/DevToys/ViewModels/Tools/Converters/NumberBaseConverter/NumberBaseFormatter.cs
Outdated
Show resolved
Hide resolved
...evToys/Views/Tools/Converters/NumberBaseConverter/AdvancedNumberBaseConverterControl.xaml.cs
Show resolved
Hide resolved
* 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]>
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:
What is the current behavior?
Issue Number: resolve #384
What is the new behavior?
Other information
Quality check
Before creating this PR, have you: