File tree Expand file tree Collapse file tree 5 files changed +46
-12
lines changed
ServicesImplementation/Settings
ViewModels/SettingsViewModels Expand file tree Collapse file tree 5 files changed +46
-12
lines changed Original file line number Diff line number Diff line change
1
+ using CommunityToolkit . WinUI . Helpers ;
1
2
using System ;
2
3
using Windows . UI ;
3
4
@@ -36,5 +37,20 @@ public static uint ToUint(this Color c)
36
37
{
37
38
return ( uint ) ( ( ( c . A << 24 ) | ( c . R << 16 ) | ( c . G << 8 ) | c . B ) & 0xffffffffL ) ;
38
39
}
40
+
41
+ /// <summary>
42
+ /// Generates a random color and returns its Hex
43
+ /// </summary>
44
+ /// <returns></returns>
45
+ public static string RandomColor ( )
46
+ {
47
+ var color = Color . FromArgb (
48
+ 255 ,
49
+ ( byte ) Random . Shared . Next ( 0 , 256 ) ,
50
+ ( byte ) Random . Shared . Next ( 0 , 256 ) ,
51
+ ( byte ) Random . Shared . Next ( 0 , 256 ) ) ;
52
+
53
+ return color . ToHex ( ) ;
54
+ }
39
55
}
40
56
}
Original file line number Diff line number Diff line change 1
1
using Files . App . Extensions ;
2
+ using Files . App . Helpers ;
2
3
using Files . App . Serialization ;
3
4
using Files . App . Serialization . Implementation ;
4
5
using Files . Backend . Services . Settings ;
@@ -78,7 +79,7 @@ public void CreateNewTag()
78
79
{
79
80
var newTag = new TagViewModel (
80
81
"NewTag" ,
81
- "#9EA3A1" ,
82
+ ColorHelpers . RandomColor ( ) ,
82
83
Guid . NewGuid ( ) . ToString ( ) ) ;
83
84
84
85
var oldTags = FileTagList . ToList ( ) ;
Original file line number Diff line number Diff line change @@ -43,10 +43,10 @@ public class AdvancedViewModel : ObservableObject
43
43
44
44
public ICommand AddTagCommand { get ; }
45
45
46
- public ICommand EditTagCommand { get ; }
47
-
48
46
public ICommand DeleteTagCommand { get ; }
49
47
48
+ public ICommand EditTagCommand { get ; set ; }
49
+
50
50
public ObservableCollection < TagViewModel > Tags { get ; set ; }
51
51
52
52
private int selectedTagIndex = - 1 ;
Original file line number Diff line number Diff line change 160
160
Command=" {x:Bind ViewModel.AddTagCommand, Mode=OneWay}"
161
161
Icon=" Add"
162
162
Label=" {helpers:ResourceString Name=Add}" />
163
+ <AppBarButton
164
+ Command=" {x:Bind ViewModel.EditTagCommand}"
165
+ Icon=" Edit"
166
+ IsEnabled=" {x:Bind ViewModel.AreTagsCommandEnabled, Mode=OneWay}"
167
+ Label=" {helpers:ResourceString Name=Edit}" />
163
168
<AppBarButton
164
169
Command=" {x:Bind ViewModel.DeleteTagCommand}"
165
170
Icon=" Delete"
204
209
<SolidColorBrush x : Key =" TextControlBackgroundFocused" Color =" {ThemeResource SolidBackgroundFillColorSecondary}" />
205
210
</TextBox .Resources>
206
211
</TextBox >
207
- <Ellipse
212
+ <Button
208
213
Grid.Column=" 2"
209
- Width=" 24"
210
- Height=" 24"
211
- Margin=" 0,8"
212
- Fill=" {x:Bind Color}" >
213
- <Ellipse .ContextFlyout>
214
+ Padding=" 0"
215
+ AutomationProperties.Name=" {helpers:ResourceString Name=TagColor}" >
216
+ <StackPanel Orientation =" Horizontal" >
217
+ <Border
218
+ Width=" 24"
219
+ Height=" 24"
220
+ Margin=" 4"
221
+ Background=" {x:Bind Color}"
222
+ CornerRadius=" 4" />
223
+ <FontIcon
224
+ Margin=" 8,4,10,4"
225
+ FontSize=" 12"
226
+ Glyph="  " />
227
+ </StackPanel >
228
+ <Button .Flyout>
214
229
<Flyout >
215
230
<controls : ColorPicker
216
- Grid.Column=" 2"
217
231
ColorChanged=" ColorPicker_ColorChanged"
218
232
IsAlphaEnabled=" True"
219
233
IsColorSpectrumVisible=" False" />
220
234
</Flyout >
221
- </Ellipse .ContextFlyout >
222
- </Ellipse >
235
+ </Button .Flyout >
236
+ </Button >
223
237
</Grid >
224
238
</DataTemplate >
225
239
</ListView .ItemTemplate>
Original file line number Diff line number Diff line change
1
+ using CommunityToolkit . Mvvm . Input ;
1
2
using CommunityToolkit . WinUI . UI ;
2
3
using Files . Backend . ViewModels . FileTags ;
3
4
using Microsoft . UI . Xaml ;
@@ -26,6 +27,8 @@ public Advanced()
26
27
{
27
28
InitializeComponent ( ) ;
28
29
30
+ ViewModel . EditTagCommand = new RelayCommand ( StartRenameTag ) ;
31
+
29
32
tapDebounceTimer = DispatcherQueue . CreateTimer ( ) ;
30
33
}
31
34
You can’t perform that action at this time.
0 commit comments