Skip to content

Commit 3c647e0

Browse files
committed
Add Images / Adjust Layouts
1 parent 9e5cfd2 commit 3c647e0

File tree

9 files changed

+212
-62
lines changed

9 files changed

+212
-62
lines changed

Flow.Launcher/CustomShortcutSetting.xaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
Title="{DynamicResource customeQueryShortcutTitle}"
77
Width="530"
88
Background="{DynamicResource PopuBGColor}"
9+
DataContext="{Binding RelativeSource={RelativeSource Self}}"
910
Foreground="{DynamicResource PopupTextColor}"
1011
Icon="Images\app.png"
1112
ResizeMode="NoResize"
1213
SizeToContent="Height"
13-
WindowStartupLocation="CenterScreen"
14-
DataContext="{Binding RelativeSource={RelativeSource Self}}">
14+
WindowStartupLocation="CenterScreen">
1515
<WindowChrome.WindowChrome>
1616
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
1717
</WindowChrome.WindowChrome>
@@ -100,8 +100,7 @@
100100
Grid.Row="0"
101101
Grid.Column="1"
102102
Margin="10"
103-
Text="{Binding Key}"
104-
/>
103+
Text="{Binding Key}" />
105104
<TextBlock
106105
Grid.Row="1"
107106
Grid.Column="0"
@@ -126,8 +125,8 @@
126125
x:Name="tbExpand"
127126
Margin="10"
128127
HorizontalAlignment="Stretch"
129-
Text="{Binding Value}"
130-
VerticalAlignment="Center" />
128+
VerticalAlignment="Center"
129+
Text="{Binding Value}" />
131130
</DockPanel>
132131
</Grid>
133132
</StackPanel>

Flow.Launcher/Images/Error.png

49.3 KB
Loading

Flow.Launcher/Images/Exclamation.png

32.7 KB
Loading

Flow.Launcher/Images/Information.png

50.3 KB
Loading

Flow.Launcher/Images/Question.png

51.4 KB
Loading

Flow.Launcher/MessageBoxEx.xaml

Lines changed: 67 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:Flow.Launcher"
77
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8-
Title="MessageBoxEx"
9-
Width="800"
10-
Height="450"
8+
x:Name="MessageBoxWindow"
9+
Width="420"
10+
Height="Auto"
1111
ResizeMode="NoResize"
12+
SizeToContent="Height"
1213
WindowStartupLocation="CenterScreen"
1314
mc:Ignorable="d">
1415
<WindowChrome.WindowChrome>
@@ -22,8 +23,9 @@
2223
</Window.CommandBindings>
2324
<Grid>
2425
<Grid.RowDefinitions>
26+
<RowDefinition Height="Auto" />
2527
<RowDefinition />
26-
<RowDefinition Height="80" />
28+
<RowDefinition MinHeight="68" />
2729
</Grid.RowDefinitions>
2830
<StackPanel Grid.Row="0">
2931
<StackPanel>
@@ -37,7 +39,7 @@
3739
</Grid.ColumnDefinitions>
3840
<Button
3941
Grid.Column="4"
40-
Click="BtnCancel_OnClick"
42+
Click="Button_Cancel"
4143
Style="{StaticResource TitleBarCloseButtonStyle}">
4244
<Path
4345
Width="46"
@@ -58,48 +60,77 @@
5860
</Button>
5961
</Grid>
6062
</StackPanel>
61-
<StackPanel Margin="26,0,26,0">
62-
<StackPanel Grid.Row="0" Margin="0,0,0,12">
63-
<TextBlock
64-
x:Name="TitleTextBlock"
65-
Grid.Column="0"
66-
Margin="0,0,0,0"
67-
FontFamily="Segoe UI"
68-
FontSize="20"
69-
FontWeight="SemiBold"
70-
TextAlignment="Left" />
71-
</StackPanel>
72-
<StackPanel>
73-
<TextBlock
74-
x:Name="DescTextBlock"
75-
FontSize="14"
76-
TextAlignment="Left"
77-
TextWrapping="WrapWithOverflow" />
78-
</StackPanel>
79-
</StackPanel>
63+
</StackPanel>
64+
<StackPanel Grid.Row="1" Margin="0,0,0,24">
65+
<Grid Grid.Column="0" Margin="0,0,0,12">
66+
<Grid.ColumnDefinitions>
67+
<ColumnDefinition Width="Auto" />
68+
<ColumnDefinition Width="*" />
69+
</Grid.ColumnDefinitions>
70+
<Image
71+
Name="Img"
72+
Grid.Column="0"
73+
Width="18"
74+
Height="18"
75+
Margin="30,0,10,0"
76+
HorizontalAlignment="Left"
77+
Visibility="Collapsed" />
78+
<TextBlock
79+
x:Name="TitleTextBlock"
80+
Grid.Column="1"
81+
MaxWidth="400"
82+
Margin="26,0,26,0"
83+
FontFamily="Segoe UI"
84+
FontSize="20"
85+
FontWeight="SemiBold"
86+
TextAlignment="Left"
87+
TextWrapping="Wrap" />
88+
</Grid>
89+
<TextBlock
90+
x:Name="DescTextBlock"
91+
Grid.Column="1"
92+
MaxWidth="400"
93+
Margin="26,0,26,0"
94+
HorizontalAlignment="Stretch"
95+
FontSize="14"
96+
TextAlignment="Left"
97+
TextWrapping="Wrap" />
8098
</StackPanel>
8199
<Border
82-
Grid.Row="1"
83-
Margin="0,14,0,0"
100+
Grid.Row="2"
101+
Margin="0,0,0,0"
84102
Background="{DynamicResource PopupButtonAreaBGColor}"
85103
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
86104
BorderThickness="0,1,0,0">
87-
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
105+
<WrapPanel
106+
HorizontalAlignment="Center"
107+
VerticalAlignment="Center"
108+
Orientation="Horizontal">
88109
<Button
89110
x:Name="btnCancel"
90111
MinWidth="140"
91-
Margin="10,0,5,0"
92-
Click="BtnCancel_OnClick"
112+
Margin="5,0,5,0"
113+
Click="Button_Click"
93114
Content="{DynamicResource cancel}" />
94115
<Button
95-
x:Name="btnAdd"
116+
x:Name="btnNo"
96117
MinWidth="140"
97-
Margin="5,0,10,0"
98-
Click="BtnAdd_OnClick"
99-
Style="{StaticResource AccentButtonStyle}">
100-
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
101-
</Button>
102-
</StackPanel>
118+
Margin="5,0,5,0"
119+
Click="Button_Click"
120+
Content="{DynamicResource cancel}" />
121+
<Button
122+
x:Name="btnOk"
123+
MinWidth="140"
124+
Margin="5,0,5,0"
125+
Click="Button_Click"
126+
Content="{DynamicResource done}" />
127+
<Button
128+
x:Name="btnYes"
129+
MinWidth="140"
130+
Margin="5,0,5,0"
131+
Click="Button_Click"
132+
Content="{DynamicResource done}" />
133+
</WrapPanel>
103134
</Border>
104135
</Grid>
105136
</Window>

Flow.Launcher/MessageBoxEx.xaml.cs

Lines changed: 138 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,46 +17,166 @@
1717

1818
namespace Flow.Launcher
1919
{
20-
/// <summary>
21-
/// MessageBoxEx.xaml에 대한 상호 작용 논리
22-
/// </summary>
2320
public partial class MessageBoxEx : Window
2421
{
25-
static MessageBoxEx msgBox;
26-
static string Button_id;
2722
public MessageBoxEx()
2823
{
2924
InitializeComponent();
3025
}
3126

27+
public enum MessageBoxType
28+
{
29+
ConfirmationWithYesNo = 0,
30+
ConfirmationWithYesNoCancel,
31+
Information,
32+
Error,
33+
Warning
34+
}
3235

33-
public static string Show(string txtMessage, string txtTitle)
36+
public enum MessageBoxImage
3437
{
35-
msgBox = new MessageBoxEx();
36-
msgBox.TitleTextBlock.Text = txtTitle;
37-
msgBox.DescTextBlock.Text = txtMessage;
38-
//msgBox.label1.Text = txtMessage;
39-
//msgBox.Text = txtTitle;
40-
msgBox.ShowDialog();
41-
return Button_id;
38+
Warning = 0,
39+
Question,
40+
Information,
41+
Error,
42+
None
4243
}
4344

44-
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
45+
static MessageBoxEx msgBox;
46+
static MessageBoxResult _result = MessageBoxResult.No;
47+
48+
49+
/// 1 parameter
50+
public static MessageBoxResult Show(string msg)
4551
{
46-
DialogResult = false;
47-
Close();
52+
return Show(string.Empty, msg, MessageBoxButton.OK, MessageBoxImage.None);
4853
}
4954

50-
private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
55+
// 2 parameter
56+
public static MessageBoxResult Show(string caption, string text)
5157
{
58+
return Show(caption, text, MessageBoxButton.OK, MessageBoxImage.None);
59+
}
5260

53-
Close();
61+
/// 3 parameter
62+
public static MessageBoxResult Show(string caption, string msg, MessageBoxType type)
63+
{
64+
switch (type)
65+
{
66+
case MessageBoxType.ConfirmationWithYesNo:
67+
return Show(caption, msg, MessageBoxButton.YesNo,
68+
MessageBoxImage.Question);
69+
case MessageBoxType.ConfirmationWithYesNoCancel:
70+
return Show(caption, msg, MessageBoxButton.YesNoCancel,
71+
MessageBoxImage.Question);
72+
case MessageBoxType.Information:
73+
return Show(caption, msg, MessageBoxButton.OK,
74+
MessageBoxImage.Information);
75+
case MessageBoxType.Error:
76+
return Show(caption, msg, MessageBoxButton.OK,
77+
MessageBoxImage.Error);
78+
case MessageBoxType.Warning:
79+
return Show(caption, msg, MessageBoxButton.OK,
80+
MessageBoxImage.Warning);
81+
default:
82+
return MessageBoxResult.No;
83+
}
84+
}
85+
86+
// 4 parameter, Final Display Message.
87+
public static MessageBoxResult Show(string caption, string text, MessageBoxButton button, MessageBoxImage image)
88+
{
89+
msgBox = new MessageBoxEx();
90+
msgBox.TitleTextBlock.Text = text;
91+
msgBox.DescTextBlock.Text = caption;
92+
msgBox.Title = text;
93+
SetVisibilityOfButtons(button);
94+
SetImageOfMessageBox(image);
95+
msgBox.ShowDialog();
96+
return _result;
97+
}
98+
private void Button_Click(object sender, RoutedEventArgs e)
99+
{
100+
if (sender == btnOk)
101+
_result = MessageBoxResult.OK;
102+
else if (sender == btnYes)
103+
_result = MessageBoxResult.Yes;
104+
else if (sender == btnNo)
105+
_result = MessageBoxResult.No;
106+
else if (sender == btnCancel)
107+
_result = MessageBoxResult.Cancel;
108+
else
109+
_result = MessageBoxResult.None;
110+
msgBox.Close();
111+
msgBox = null;
54112
}
55113

114+
private static void SetVisibilityOfButtons(MessageBoxButton button)
115+
{
116+
switch (button)
117+
{
118+
case MessageBoxButton.OK:
119+
msgBox.btnCancel.Visibility = Visibility.Collapsed;
120+
msgBox.btnNo.Visibility = Visibility.Collapsed;
121+
msgBox.btnYes.Visibility = Visibility.Collapsed;
122+
msgBox.btnOk.Focus();
123+
break;
124+
case MessageBoxButton.OKCancel:
125+
msgBox.btnNo.Visibility = Visibility.Collapsed;
126+
msgBox.btnYes.Visibility = Visibility.Collapsed;
127+
msgBox.btnCancel.Focus();
128+
break;
129+
case MessageBoxButton.YesNo:
130+
msgBox.btnOk.Visibility = Visibility.Collapsed;
131+
msgBox.btnCancel.Visibility = Visibility.Collapsed;
132+
msgBox.btnNo.Focus();
133+
break;
134+
case MessageBoxButton.YesNoCancel:
135+
msgBox.btnOk.Visibility = Visibility.Collapsed;
136+
msgBox.btnCancel.Focus();
137+
break;
138+
default:
139+
break;
140+
}
141+
}
142+
private static void SetImageOfMessageBox(MessageBoxImage image)
143+
{
144+
switch (image)
145+
{
146+
case MessageBoxImage.Warning:
147+
msgBox.SetImage("Warning.png");
148+
break;
149+
case MessageBoxImage.Question:
150+
msgBox.SetImage("Question.png");
151+
break;
152+
case MessageBoxImage.Information:
153+
msgBox.SetImage("Information.png");
154+
break;
155+
case MessageBoxImage.Error:
156+
msgBox.SetImage("Error.png");
157+
break;
158+
default:
159+
msgBox.Img.Visibility = Visibility.Collapsed;
160+
break;
161+
}
162+
}
163+
private void SetImage(string imageName)
164+
{
165+
string uri = string.Format("/Images/{0}", imageName);
166+
var uriSource = new Uri(uri, UriKind.RelativeOrAbsolute);
167+
Img.Source = new BitmapImage(uriSource);
168+
}
56169
private void cmdEsc_OnPress(object sender, ExecutedRoutedEventArgs e)
57170
{
58171
DialogResult = false;
59172
Close();
60173
}
174+
175+
private void Button_Cancel(object sender, RoutedEventArgs e)
176+
{
177+
msgBox.Close();
178+
msgBox = null;
179+
}
180+
61181
}
62182
}

Flow.Launcher/SettingWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2905,7 +2905,7 @@
29052905
Margin="0,0,12,0"
29062906
Click="ClearLogFolder"
29072907
Content="{Binding CheckLogFolder, UpdateSourceTrigger=PropertyChanged}" />
2908-
<Button
2908+
<Button Name="TestBtn"
29092909
Margin="0,0,12,0"
29102910
Click="OpenTestBtn"
29112911
Content="Open Test" />

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ private void OpenWelcomeWindow(object sender, RoutedEventArgs e)
280280
}
281281
private void OpenTestBtn(object sender, RoutedEventArgs e)
282282
{
283-
var messageBoxResult = MessageBoxEx.Show("Message Box Title", "Are you sure?");
283+
var messageBoxResult = MessageBoxEx.Show("The TitleBarBackground property can be used to set the background for the Title bar. ... The following screen shots illustrate the title bar background changes.", "This is Title Part This is Title Part This is Title Part This is Title Part");
284284
}
285285
private void OpenLogFolder(object sender, RoutedEventArgs e)
286286
{

0 commit comments

Comments
 (0)