Skip to content

Commit f98cd8b

Browse files
committed
Fix build
1 parent d9f8e87 commit f98cd8b

File tree

3 files changed

+304
-0
lines changed

3 files changed

+304
-0
lines changed

Flow.Launcher.Infrastructure/Logger/Log.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public enum LOGLEVEL
5555
{
5656
NONE,
5757
ERROR,
58+
WARN,
5859
INFO,
5960
DEBUG
6061
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<UserControl
2+
x:Class="Flow.Launcher.Resources.Controls.InfoBar"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:cc="clr-namespace:Flow.Launcher.Resources.Controls"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:ui="http://schemas.modernwpf.com/2019"
9+
d:DesignHeight="45"
10+
d:DesignWidth="400"
11+
mc:Ignorable="d">
12+
<UserControl.Resources />
13+
<Grid>
14+
<Border
15+
x:Name="PART_Border"
16+
MinHeight="48"
17+
Padding="18 18 18 18"
18+
Background="{DynamicResource InfoBarInfoBG}"
19+
BorderBrush="{DynamicResource Color03B}"
20+
BorderThickness="1"
21+
CornerRadius="5">
22+
<Grid>
23+
<Grid.ColumnDefinitions>
24+
<ColumnDefinition Width="Auto" />
25+
<ColumnDefinition Width="*" />
26+
<ColumnDefinition Width="Auto" MinWidth="24" />
27+
</Grid.ColumnDefinitions>
28+
<StackPanel Grid.Column="0" Orientation="Horizontal">
29+
<Border
30+
x:Name="PART_IconBorder"
31+
Width="16"
32+
Height="16"
33+
Margin="0 0 12 0"
34+
VerticalAlignment="Top"
35+
CornerRadius="10">
36+
<ui:FontIcon
37+
x:Name="PART_Icon"
38+
Margin="1 0 0 1"
39+
VerticalAlignment="Center"
40+
FontFamily="Segoe MDL2 Assets"
41+
FontSize="13"
42+
Foreground="{DynamicResource Color01B}"
43+
Visibility="Visible" />
44+
</Border>
45+
46+
</StackPanel>
47+
<StackPanel
48+
x:Name="PART_StackPanel"
49+
Grid.Column="1"
50+
VerticalAlignment="Center"
51+
Orientation="Horizontal">
52+
<TextBlock
53+
x:Name="PART_Title"
54+
Margin="0 0 12 0"
55+
FontWeight="SemiBold"
56+
Foreground="{DynamicResource Color05B}"
57+
Text="{Binding RelativeSource={RelativeSource AncestorType=cc:InfoBar}, Path=Title}" />
58+
<TextBlock
59+
x:Name="PART_Message"
60+
Foreground="{DynamicResource Color05B}"
61+
Text="{Binding RelativeSource={RelativeSource AncestorType=cc:InfoBar}, Path=Message}"
62+
TextWrapping="Wrap" />
63+
</StackPanel>
64+
65+
<Button
66+
x:Name="PART_CloseButton"
67+
Grid.Column="2"
68+
Width="32"
69+
Height="32"
70+
VerticalAlignment="Center"
71+
AutomationProperties.Name="Close InfoBar"
72+
Click="PART_CloseButton_Click"
73+
Content="&#xE10A;"
74+
FontFamily="Segoe MDL2 Assets"
75+
FontSize="12"
76+
ToolTip="Close"
77+
Visibility="Visible" />
78+
</Grid>
79+
</Border>
80+
</Grid>
81+
</UserControl>
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
using System.Windows;
2+
using System.Windows.Controls;
3+
using System.Windows.Media;
4+
5+
namespace Flow.Launcher.Resources.Controls
6+
{
7+
public partial class InfoBar : UserControl
8+
{
9+
public InfoBar()
10+
{
11+
InitializeComponent();
12+
Loaded += InfoBar_Loaded;
13+
}
14+
15+
private void InfoBar_Loaded(object sender, RoutedEventArgs e)
16+
{
17+
UpdateStyle();
18+
UpdateTitleVisibility();
19+
UpdateMessageVisibility();
20+
UpdateOrientation();
21+
UpdateIconAlignmentAndMargin();
22+
UpdateIconVisibility();
23+
UpdateCloseButtonVisibility();
24+
}
25+
26+
public static readonly DependencyProperty TypeProperty =
27+
DependencyProperty.Register(nameof(Type), typeof(InfoBarType), typeof(InfoBar), new PropertyMetadata(InfoBarType.Info, OnTypeChanged));
28+
29+
public InfoBarType Type
30+
{
31+
get => (InfoBarType)GetValue(TypeProperty);
32+
set => SetValue(TypeProperty, value);
33+
}
34+
35+
private static void OnTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
36+
{
37+
if (d is InfoBar infoBar)
38+
{
39+
infoBar.UpdateStyle();
40+
}
41+
}
42+
43+
public static readonly DependencyProperty MessageProperty =
44+
DependencyProperty.Register(nameof(Message), typeof(string), typeof(InfoBar), new PropertyMetadata(string.Empty, OnMessageChanged));
45+
46+
public string Message
47+
{
48+
get => (string)GetValue(MessageProperty);
49+
set
50+
{
51+
SetValue(MessageProperty, value);
52+
}
53+
}
54+
55+
private static void OnMessageChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
56+
{
57+
if (d is InfoBar infoBar)
58+
{
59+
infoBar.UpdateMessageVisibility();
60+
}
61+
}
62+
63+
private void UpdateMessageVisibility()
64+
{
65+
PART_Message.Visibility = string.IsNullOrEmpty(Message) ? Visibility.Collapsed : Visibility.Visible;
66+
}
67+
68+
public static readonly DependencyProperty TitleProperty =
69+
DependencyProperty.Register(nameof(Title), typeof(string), typeof(InfoBar), new PropertyMetadata(string.Empty, OnTitleChanged));
70+
71+
public string Title
72+
{
73+
get => (string)GetValue(TitleProperty);
74+
set
75+
{
76+
SetValue(TitleProperty, value);
77+
UpdateTitleVisibility(); // Visibility update when change Title
78+
}
79+
}
80+
81+
private static void OnTitleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
82+
{
83+
if (d is InfoBar infoBar)
84+
{
85+
infoBar.UpdateTitleVisibility();
86+
}
87+
}
88+
89+
private void UpdateTitleVisibility()
90+
{
91+
PART_Title.Visibility = string.IsNullOrEmpty(Title) ? Visibility.Collapsed : Visibility.Visible;
92+
}
93+
94+
public static readonly DependencyProperty IsIconVisibleProperty =
95+
DependencyProperty.Register(nameof(IsIconVisible), typeof(bool), typeof(InfoBar), new PropertyMetadata(true, OnIsIconVisibleChanged));
96+
97+
public bool IsIconVisible
98+
{
99+
get => (bool)GetValue(IsIconVisibleProperty);
100+
set => SetValue(IsIconVisibleProperty, value);
101+
}
102+
103+
public static readonly DependencyProperty LengthProperty =
104+
DependencyProperty.Register(nameof(Length), typeof(InfoBarLength), typeof(InfoBar), new PropertyMetadata(InfoBarLength.Short, OnLengthChanged));
105+
106+
public InfoBarLength Length
107+
{
108+
get { return (InfoBarLength)GetValue(LengthProperty); }
109+
set { SetValue(LengthProperty, value); }
110+
}
111+
112+
private static void OnLengthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
113+
{
114+
if (d is InfoBar infoBar)
115+
{
116+
infoBar.UpdateOrientation();
117+
infoBar.UpdateIconAlignmentAndMargin();
118+
}
119+
}
120+
121+
private void UpdateOrientation()
122+
{
123+
PART_StackPanel.Orientation = Length == InfoBarLength.Long ? Orientation.Vertical : Orientation.Horizontal;
124+
}
125+
126+
private void UpdateIconAlignmentAndMargin()
127+
{
128+
if (Length == InfoBarLength.Short)
129+
{
130+
PART_IconBorder.VerticalAlignment = VerticalAlignment.Center;
131+
PART_IconBorder.Margin = new Thickness(0, 0, 12, 0);
132+
}
133+
else
134+
{
135+
PART_IconBorder.VerticalAlignment = VerticalAlignment.Top;
136+
PART_IconBorder.Margin = new Thickness(0, 2, 12, 0);
137+
}
138+
}
139+
140+
public static readonly DependencyProperty ClosableProperty =
141+
DependencyProperty.Register(nameof(Closable), typeof(bool), typeof(InfoBar), new PropertyMetadata(true, OnClosableChanged));
142+
143+
public bool Closable
144+
{
145+
get => (bool)GetValue(ClosableProperty);
146+
set => SetValue(ClosableProperty, value);
147+
}
148+
149+
private void PART_CloseButton_Click(object sender, RoutedEventArgs e)
150+
{
151+
Visibility = Visibility.Collapsed;
152+
}
153+
154+
private void UpdateStyle()
155+
{
156+
switch (Type)
157+
{
158+
case InfoBarType.Info:
159+
PART_Border.Background = (Brush)FindResource("InfoBarInfoBG");
160+
PART_IconBorder.Background = (Brush)FindResource("InfoBarInfoIcon");
161+
PART_Icon.Glyph = "\xF13F";
162+
break;
163+
case InfoBarType.Success:
164+
PART_Border.Background = (Brush)FindResource("InfoBarSuccessBG");
165+
PART_IconBorder.Background = (Brush)FindResource("InfoBarSuccessIcon");
166+
PART_Icon.Glyph = "\xF13E";
167+
break;
168+
case InfoBarType.Warning:
169+
PART_Border.Background = (Brush)FindResource("InfoBarWarningBG");
170+
PART_IconBorder.Background = (Brush)FindResource("InfoBarWarningIcon");
171+
PART_Icon.Glyph = "\xF13C";
172+
break;
173+
case InfoBarType.Error:
174+
PART_Border.Background = (Brush)FindResource("InfoBarErrorBG");
175+
PART_IconBorder.Background = (Brush)FindResource("InfoBarErrorIcon");
176+
PART_Icon.Glyph = "\xF13D";
177+
break;
178+
default:
179+
PART_Border.Background = (Brush)FindResource("InfoBarInfoBG");
180+
PART_IconBorder.Background = (Brush)FindResource("InfoBarInfoIcon");
181+
PART_Icon.Glyph = "\xF13F";
182+
break;
183+
}
184+
}
185+
186+
private static void OnIsIconVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
187+
{
188+
var infoBar = (InfoBar)d;
189+
infoBar.UpdateIconVisibility();
190+
}
191+
192+
private static void OnClosableChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
193+
{
194+
var infoBar = (InfoBar)d;
195+
infoBar.UpdateCloseButtonVisibility();
196+
}
197+
198+
private void UpdateIconVisibility()
199+
{
200+
PART_IconBorder.Visibility = IsIconVisible ? Visibility.Visible : Visibility.Collapsed;
201+
}
202+
203+
private void UpdateCloseButtonVisibility()
204+
{
205+
PART_CloseButton.Visibility = Closable ? Visibility.Visible : Visibility.Collapsed;
206+
}
207+
}
208+
209+
public enum InfoBarType
210+
{
211+
Info,
212+
Success,
213+
Warning,
214+
Error
215+
}
216+
217+
public enum InfoBarLength
218+
{
219+
Short,
220+
Long
221+
}
222+
}

0 commit comments

Comments
 (0)