@@ -144,11 +144,12 @@ public class YukiTheme_VisualPascalABCPlugin : IVisualPascalABCPlugin, IColorUpd
144144
145145 #endregion
146146
147- private Size defaultSize ;
148- private Panel panel_bg ;
149- private CustomList themeList ;
150- public Image tmpImage1 ;
151- public Image tmpImage2 ;
147+ private Size defaultSize ;
148+ private Panel panel_bg ;
149+ private CustomList themeList ;
150+ private Label lbl ;
151+ public Image tmpImage1 ;
152+ public Image tmpImage2 ;
152153
153154 private IconManager manager ;
154155 public static ToolBarCamouflage camouflage ;
@@ -160,8 +161,13 @@ public class YukiTheme_VisualPascalABCPlugin : IVisualPascalABCPlugin, IColorUpd
160161 int imagesEnabled = 0 ; // Is enabled bg image and (or) sticker
161162 bool nameInStatusBar = false ; // Name in status bar
162163 private ToolStripItem openInExplorerItem ;
163- const string yukiThemeUpdate = "Yuki Theme Update" ;
164- private int lastFocused = - 1 ;
164+ const string yukiThemeUpdate = "Yuki Theme Update" ;
165+ private int lastFocused = - 1 ;
166+ private bool needToReturnTheme = false ;
167+ private bool needToFullExportTheme = false ;
168+ private string oldThemeNameForPreExport = "" ;
169+ private DateTime prevPreExportTime ;
170+ private bool hideBG = false ;
165171
166172 public PopupFormsController popupController ;
167173
@@ -670,7 +676,6 @@ private void ToggleQuiet (object sender, EventArgs e)
670676 updateQuietImage ( ) ;
671677 updateWallpaperImage ( ) ;
672678 updateStickerImage ( ) ;
673- // GetWindowProperities ();
674679 }
675680
676681 private void ToggleWallpaper ( object sender , EventArgs e )
@@ -690,10 +695,12 @@ private void SwitchTheme (object sender, EventArgs e)
690695
691696 panel_bg = new CustomPanel ( 0 ) ;
692697 panel_bg . Name = "Custom Panel Switcher" ;
693-
698+ needToReturnTheme = true ;
699+ needToFullExportTheme = false ;
700+ prevPreExportTime = DateTime . Now ;
694701 Font fnt = new Font ( FontFamily . GenericSansSerif , 10 , GraphicsUnit . Point ) ;
695-
696- Label lbl = new Label ( ) ;
702+
703+ lbl = new Label ( ) ;
697704 lbl . BackColor = bg ;
698705 lbl . ForeColor = clr ;
699706 lbl . Font = fnt ;
@@ -737,6 +744,7 @@ private void SwitchTheme (object sender, EventArgs e)
737744 themeList . SelectedIndexChanged += ThemeListOnSelectedIndexChanged ;
738745 themeList . AccessibleName = themeList . SelectedItem . ToString ( ) ;
739746 panel_bg . Click += CloseOnClick ;
747+ oldThemeNameForPreExport = themeList . AccessibleName ;
740748
741749 panel_bg . Controls . Add ( themeList ) ;
742750 panel_bg . Controls . Add ( lbl ) ;
@@ -986,10 +994,38 @@ private void UpdateBottomTextPanel ()
986994 }
987995
988996 public void ReloadLayout ( )
997+ {
998+ ReloadLayoutAll ( false ) ;
999+ }
1000+
1001+ public void ReloadLayoutLight ( )
1002+ {
1003+ ReloadLayoutAll ( true ) ;
1004+ panel_bg . Visible = false ;
1005+
1006+ Timer tim = new Timer ( ) ;
1007+ tim . Interval = 5 ;
1008+ tim . Tick += ( sender , args ) =>
1009+ {
1010+ tim . Stop ( ) ;
1011+ if ( panel_bg != null && ! panel_bg . IsDisposed )
1012+ {
1013+ panel_bg . Visible = true ;
1014+ panel_bg . BringToFront ( ) ;
1015+ themeList . searchBar . Focus ( ) ;
1016+ }
1017+ } ;
1018+ tim . Start ( ) ;
1019+ }
1020+
1021+ public void ReloadLayoutAll ( bool lightReload )
9891022 {
9901023 HighlightingManager . Manager . ReloadSyntaxModes ( ) ;
991- LoadImage ( ) ;
992- LoadSticker ( ) ;
1024+ if ( ! lightReload )
1025+ {
1026+ LoadImage ( ) ;
1027+ LoadSticker ( ) ;
1028+ }
9931029 LoadColors ( ) ;
9941030 UpdateColors ( ) ;
9951031 fm . Refresh ( ) ;
@@ -1254,7 +1290,7 @@ private void PaintBG (object sender, PaintEventArgs e)
12541290 foldmargin . DrawingPosition . Height ) ;
12551291 }
12561292
1257- if ( img != null && bgImage )
1293+ if ( img != null && bgImage && ! hideBG )
12581294 {
12591295 Size vm = textEditor . ClientSize ;
12601296 // bool chnd = false;
@@ -1376,6 +1412,21 @@ private void list_1_DrawItem (object sender, DrawItemEventArgs e)
13761412
13771413 private void CloseOnClick ( object sender , EventArgs e )
13781414 {
1415+ if ( Settings . showPreview )
1416+ {
1417+ if ( needToReturnTheme )
1418+ {
1419+ needToFullExportTheme = true ;
1420+ PreviewTheme ( themeList . AccessibleName , oldThemeNameForPreExport ) ;
1421+ needToReturnTheme = false ;
1422+ needToFullExportTheme = false ;
1423+ } else
1424+ {
1425+ hideBG = ! CLI . currentTheme . HasWallpaper ;
1426+ stickerControl . Visible = Settings . swSticker && CLI . currentTheme . HasSticker ;
1427+ }
1428+ }
1429+
13791430 fm . Controls . Remove ( panel_bg ) ;
13801431 panel_bg ? . Dispose ( ) ;
13811432 themeList ? . searchBar . Dispose ( ) ;
@@ -1420,19 +1471,66 @@ private void ThemeListOnSelectedIndexChanged (object sender, EventArgs e)
14201471 CLI_Actions . ifDoesntHaveSticker2 = null ;
14211472 }
14221473 }
1423-
1474+ needToReturnTheme = false ;
14241475 CloseOnClick ( sender , e ) ;
14251476 }
14261477 }
14271478
14281479 private void ThemeListMouseHover ( object sender , EventArgs e )
14291480 {
1430- Point point = themeList . PointToClient ( Cursor . Position ) ;
1431- int index = themeList . IndexFromPoint ( point ) ;
1481+ InvalidateItem ( ) ;
1482+ if ( Settings . showPreview )
1483+ {
1484+ string nm = themeList . Items [ themeList . selectionindex ] . ToString ( ) ;
1485+ if ( ( DateTime . Now - prevPreExportTime ) . TotalMilliseconds >= 25 && nm != oldThemeNameForPreExport ) // Preview Theme if delay is more than 25 milliseconds
1486+ {
1487+ prevPreExportTime = DateTime . Now ;
1488+ PreviewTheme ( nm , oldThemeNameForPreExport ) ;
1489+ lbl . BackColor = bg ;
1490+ lbl . ForeColor = clr ;
1491+ themeList . BackColor = bgdef ;
1492+ themeList . ForeColor = clr ;
1493+ oldThemeNameForPreExport = themeList . Items [ themeList . selectionindex ] . ToString ( ) ;
1494+ }
1495+ }
1496+ }
1497+
1498+ private void PreviewTheme ( string name , string oldName )
1499+ {
1500+ if ( name != oldName )
1501+ {
1502+ if ( CLI . SelectTheme ( name ) )
1503+ {
1504+ CLI . restore ( ) ;
1505+ hideBG = ! CLI . currentTheme . HasWallpaper ;
1506+ stickerControl . Visible = Settings . swSticker && CLI . currentTheme . HasSticker ;
1507+ if ( needToFullExportTheme )
1508+ {
1509+ CLI . preview ( SyntaxType . NULL , true , ReloadLayoutLight ) ;
1510+ } else
1511+ {
1512+ SyntaxType type = ShadowNames . GetSyntaxByExtension ( Path . GetExtension ( fm . CurrentCodeFileDocument . FileName ) ) ;
1513+ if ( type != SyntaxType . Pascal )
1514+ {
1515+ CLI . preview ( type , true , null ) ; // Not to reload layout
1516+ CLI . preview ( SyntaxType . Pascal , false , ReloadLayoutLight ) ; // Pascal theme is necessary for UI
1517+ } else
1518+ {
1519+ CLI . preview ( type , true , ReloadLayoutLight ) ;
1520+ }
1521+ }
1522+ }
1523+ }
1524+ }
1525+
1526+ private void InvalidateItem ( )
1527+ {
1528+ Point point = themeList . PointToClient ( Cursor . Position ) ;
1529+ int index = themeList . IndexFromPoint ( point ) ;
14321530 //Do any action with the item
14331531 themeList . UpdateHighlighting ( index ) ;
14341532 }
1435-
1533+
14361534 void setBorder ( Control ctl , Control ctl2 , Control ctl3 )
14371535 {
14381536 Panel pan = new Panel ( ) ;
0 commit comments