@@ -19,6 +19,9 @@ public partial class PluginViewModel : BaseModel
19
19
20
20
private static readonly Settings Settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
21
21
22
+ private static readonly Thickness SettingPanelMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelMargin" ) ;
23
+ private static readonly Thickness SettingPanelItemTopBottomMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelItemTopBottomMargin" ) ;
24
+
22
25
private readonly PluginPair _pluginPair ;
23
26
public PluginPair PluginPair
24
27
{
@@ -139,8 +142,6 @@ public Control SettingControl
139
142
: null ;
140
143
private ImageSource _image = ImageLoader . MissingImage ;
141
144
142
- private static readonly Thickness SettingPanelMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelMargin" ) ;
143
- private static readonly Thickness SettingPanelItemTopBottomMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelItemTopBottomMargin" ) ;
144
145
private static Control TryCreateSettingPanel ( PluginPair pair )
145
146
{
146
147
try
@@ -156,25 +157,7 @@ private static Control TryCreateSettingPanel(PluginPair pair)
156
157
// Show error message in UI
157
158
var errorMsg = string . Format ( App . API . GetTranslation ( "errorCreatingSettingPanel" ) ,
158
159
pair . Metadata . Name , Environment . NewLine , e . Message ) ;
159
- var grid = new Grid ( )
160
- {
161
- Margin = SettingPanelMargin
162
- } ;
163
- var textBox = new TextBox
164
- {
165
- Text = errorMsg ,
166
- IsReadOnly = true ,
167
- HorizontalAlignment = HorizontalAlignment . Stretch ,
168
- VerticalAlignment = VerticalAlignment . Top ,
169
- TextWrapping = TextWrapping . Wrap ,
170
- Margin = SettingPanelItemTopBottomMargin
171
- } ;
172
- textBox . SetResourceReference ( TextBlock . ForegroundProperty , "Color04B" ) ;
173
- grid . Children . Add ( textBox ) ;
174
- return new UserControl
175
- {
176
- Content = grid
177
- } ;
160
+ return CreateErrorSettingPanel ( errorMsg ) ;
178
161
}
179
162
}
180
163
@@ -228,5 +211,28 @@ private void SetActionKeywords()
228
211
var changeKeywordsWindow = new ActionKeywords ( this ) ;
229
212
changeKeywordsWindow . ShowDialog ( ) ;
230
213
}
214
+
215
+ private static UserControl CreateErrorSettingPanel ( string text )
216
+ {
217
+ var grid = new Grid ( )
218
+ {
219
+ Margin = SettingPanelMargin
220
+ } ;
221
+ var textBox = new TextBox
222
+ {
223
+ Text = text ,
224
+ IsReadOnly = true ,
225
+ HorizontalAlignment = HorizontalAlignment . Stretch ,
226
+ VerticalAlignment = VerticalAlignment . Top ,
227
+ TextWrapping = TextWrapping . Wrap ,
228
+ Margin = SettingPanelItemTopBottomMargin
229
+ } ;
230
+ textBox . SetResourceReference ( TextBlock . ForegroundProperty , "Color04B" ) ;
231
+ grid . Children . Add ( textBox ) ;
232
+ return new UserControl
233
+ {
234
+ Content = grid
235
+ } ;
236
+ }
231
237
}
232
238
}
0 commit comments