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

Color picker wpf #37149

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Color picker wpf #37149

wants to merge 11 commits into from

Conversation

mantaionut
Copy link
Contributor

Summary of the Pull Request

Use .net WPF instead of WPFUI.

PR Checklist

  • Closes: #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Comparison Windows 11. Left side new one, right side old one.
Light

light light_menu

Dark

dark dark

Aquatic

aquatic aquatic

Desert

desert desert

Dusk

dusk dusk

Night Sky

night_sky night_sky

Validation Steps Performed

Test on W11 and W10, dark and light and all HC themes.

<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
AutomationProperties.LiveSetting="Assertive"
AutomationProperties.Name="{x:Static p:Resources.Copied_to_clipboard}"
Orientation="Horizontal">
<ui:SymbolIcon
<TextBlock
FontFamily="Segoe Fluent Icons, Segoe MDL2 Assets"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tip: never hardcode values like this. This is super sensitive to typos and other reasons for failure. Use a FontIcon instead :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no FontIcon in .net WPF.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this a resource and link to it? I can imagine we have these at various places?

e.g.

FontFamily="{StaticResource IconFontFamily}"

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've made the change.

x:Name="OKButton"
Grid.Row="9"
Grid.ColumnSpan="4"
Margin="0,32,0,0"
HorizontalAlignment="Stretch"
Appearance="Primary"
Background="{DynamicResource {x:Static SystemColors.AccentColorBrushKey}}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to use {StaticResource} with a value from WinUI Gallery?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't use WinUI but .net WPF.

@Jay-o-Way
Copy link
Collaborator

First image on the left shows a button with black text on a green background. This is not good accessibility. Let's see how to fix that. (my general advice: stick with the basics)

@shuaiyuanxx
Copy link
Contributor

The code looks good, but I do have one small concern: the original UI didn’t seem to have any problems, so why switch to .NET WPF?

@mantaionut
Copy link
Contributor Author

I've updated the select button to use the accent style. Below are the screenshots for W11.
Dark
dark
Light
light
Aquatic
aquatic
Desert
desert
Dusk
dusk
Night Sky
night_sky

@@ -274,7 +292,8 @@
TextWrapping="Wrap" />
</StackPanel>

<Border
<Border
Background="{DynamicResource {x:Static SystemColors.AccentColorBrushKey}}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Background="{DynamicResource {x:Static SystemColors.AccentColorBrushKey}}"
BorderBrush="{DynamicResource SurfaceStrokeColorFlyoutBrush}"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean to replace BorderBrush to SurfaceStrokeColorFlyoutBrush and to remove the Background? Or just replace the BorderBrush?

@crutkas crutkas added the Needs-Review This Pull Request awaits the review of a maintainer. label Feb 19, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 4 out of 12 changed files in this pull request and generated 1 comment.

Files not reviewed (8)
  • src/modules/colorPicker/ColorPickerUI/App.xaml: Language not supported
  • src/modules/colorPicker/ColorPickerUI/ColorEditorWindow.xaml: Language not supported
  • src/modules/colorPicker/ColorPickerUI/ColorPickerUI.csproj: Language not supported
  • src/modules/colorPicker/ColorPickerUI/Controls/ColorFormatControl.xaml: Language not supported
  • src/modules/colorPicker/ColorPickerUI/Controls/ColorPickerControl.xaml: Language not supported
  • src/modules/colorPicker/ColorPickerUI/Resources/Styles.xaml: Language not supported
  • src/modules/colorPicker/ColorPickerUI/Views/ColorEditorView.xaml: Language not supported
  • src/modules/colorPicker/ColorPickerUI/Views/ZoomView.xaml: Language not supported
Comments suppressed due to low confidence (1)

src/modules/colorPicker/ColorPickerUI/Controls/ColorPickerControl.xaml.cs:385

  • [nitpick] The method name GetValueFromNumberBox is outdated as it now uses TextBox instead of NumberBox. Consider renaming it to GetValueFromTextBox.
private static byte GetValueFromNumberBox(TextBox numberBox, byte previousValue)

@@ -357,15 +356,19 @@ private void HexCode_GotKeyboardFocus(object sender, KeyboardFocusChangedEventAr
(sender as System.Windows.Controls.TextBox).SelectAll();
}

private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !System.Text.RegularExpressions.Regex.IsMatch(e.Text, "^[0-9]+$");
Copy link
Preview

Copilot AI Feb 19, 2025

Choose a reason for hiding this comment

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

The regex should allow hexadecimal characters (0-9, a-f, A-F) for color codes. Update the regex to: "^[0-9a-fA-F]+$".

Suggested change
e.Handled = !System.Text.RegularExpressions.Regex.IsMatch(e.Text, "^[0-9]+$");
e.Handled = !System.Text.RegularExpressions.Regex.IsMatch(e.Text, "^[0-9a-fA-F]+$");

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Contributor

@shuaiyuanxx shuaiyuanxx left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In for .89 Needs-Review This Pull Request awaits the review of a maintainer.
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

5 participants