@@ -19,6 +19,9 @@ public partial class PluginViewModel : BaseModel
1919
2020 private static readonly Settings Settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
2121
22+ private static readonly Thickness SettingPanelMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelMargin" ) ;
23+ private static readonly Thickness SettingPanelItemTopBottomMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelItemTopBottomMargin" ) ;
24+
2225 private readonly PluginPair _pluginPair ;
2326 public PluginPair PluginPair
2427 {
@@ -139,8 +142,6 @@ public Control SettingControl
139142 : null ;
140143 private ImageSource _image = ImageLoader . MissingImage ;
141144
142- private static readonly Thickness SettingPanelMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelMargin" ) ;
143- private static readonly Thickness SettingPanelItemTopBottomMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelItemTopBottomMargin" ) ;
144145 private static Control TryCreateSettingPanel ( PluginPair pair )
145146 {
146147 try
@@ -156,25 +157,7 @@ private static Control TryCreateSettingPanel(PluginPair pair)
156157 // Show error message in UI
157158 var errorMsg = string . Format ( App . API . GetTranslation ( "errorCreatingSettingPanel" ) ,
158159 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 ) ;
178161 }
179162 }
180163
@@ -228,5 +211,28 @@ private void SetActionKeywords()
228211 var changeKeywordsWindow = new ActionKeywords ( this ) ;
229212 changeKeywordsWindow . ShowDialog ( ) ;
230213 }
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+ }
231237 }
232238}
0 commit comments