@@ -21,6 +21,7 @@ public partial class Supporting : Form
2121 private static Tool tool ;
2222 private static Supporters supporters ;
2323 private static ToolSettings settings ;
24+ private static SupportableTool supportabletool ;
2425 private static Random random = new Random ( ) ;
2526
2627 private readonly AppInsights appinsights ;
@@ -31,19 +32,73 @@ public partial class Supporting : Form
3132
3233 public static void ShowIf ( PluginControlBase plugin , bool manual , bool reload , AppInsights appinsights )
3334 {
35+ var toolname = plugin ? . ToolName ;
3436 try
3537 {
36- var display = manual ;
37- if ( reload || settings == null || tools == null || tool == null )
38+ if ( reload || settings == null || supportabletool == null || tools == null || tool == null )
3839 {
3940 settings = ToolSettings . Get ( ) ;
40- // settings.Save();
41- display = ShowSupporting ( plugin . ToolName ) || manual ;
41+ supportabletool = settings [ toolname ] ;
42+ tools = RappenXTB . Load ( settings ) ;
43+ tool = tools [ toolname ] ;
44+ var version = Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version ;
45+ if ( tool . version != version )
46+ {
47+ tool . version = version ;
48+ tool . VersionRunDate = DateTime . Now ;
49+ tools . Save ( ) ;
50+ }
51+ settings . Save ( ) ; // this is only to get a correct format of the tool settings file
4252 }
43- if ( ! display )
53+ if ( settings ? [ toolname ] ? . Enabled != true )
4454 {
4555 return ;
4656 }
57+ if ( reload || supporters == null )
58+ {
59+ supporters = Supporters . DownloadMy ( tools . InstallationId , toolname , settings . ContributionCounts ) ;
60+ }
61+ if ( ! manual )
62+ {
63+ if ( supporters . Count > 0 )
64+ { // I have supportings!
65+ return ;
66+ }
67+ else if ( supportabletool . ShowOnlyManual )
68+ { // Centerally stopping showing automatically
69+ return ;
70+ }
71+ else if ( tool . Support . Type == SupportType . Never )
72+ { // You will never want to support this tool
73+ return ;
74+ }
75+ else if ( tool . FirstRunDate . AddMinutes ( settings . ShowMinutesAfterInstall ) > DateTime . Now )
76+ { // Installed it too soon
77+ return ;
78+ }
79+ else if ( tool . VersionRunDate > tool . FirstRunDate &&
80+ tool . VersionRunDate . AddMinutes ( settings . ShowMinutesAfterNewVersion ) > DateTime . Now )
81+ { // Installed this version too soon
82+ return ;
83+ }
84+ else if ( tool . Support . DisplayDate . AddMinutes ( settings . ShowMinutesAfterShown ) > DateTime . Now )
85+ { // Seen this form to soon
86+ return ;
87+ }
88+ else if ( tool . Support . DisplayCount >= settings . ShowAutoRepeatTimes )
89+ { // Seen this too many times
90+ return ;
91+ }
92+ else if ( tool . Support . SubmittedDate . AddMinutes ( settings . ShowMinutesAfterSubmittingButNotCompleted ) > DateTime . Now )
93+ { // Submitted too soon for JR to handle it
94+ return ;
95+ }
96+ else if ( settings . ShowAutoPercentChance < 1 ||
97+ settings . ShowAutoPercentChance <= random . Next ( 1 , 100 ) )
98+ {
99+ return ;
100+ }
101+ }
47102 if ( manual && tool ? . Support ? . Type == SupportType . Never )
48103 {
49104 tool . Support . Type = SupportType . None ;
@@ -99,69 +154,6 @@ private Supporting(AppInsights appinsights, bool manual)
99154
100155 #endregion Constructors
101156
102- #region Private Methods
103-
104- private static bool ShowSupporting ( string toolname )
105- {
106- var version = Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version ;
107- tools = RappenXTB . Load ( settings ) ;
108- tool = tools [ toolname ] ;
109- if ( tool . Support == null )
110- {
111- tool . Support = new Support ( ) ;
112- }
113- if ( tool . version != version )
114- {
115- tool . version = version ;
116- tool . VersionRunDate = DateTime . Now ;
117- tools . Save ( ) ;
118- }
119- supporters = Supporters . DownloadMy ( tools . InstallationId , toolname , settings . ContributionCounts ) ;
120- if ( supporters . Count > 0 )
121- { // I have supportings!
122- return false ;
123- }
124- else if ( settings . ShowOnlyManual )
125- { // Centerally stopping showing automatically
126- return false ;
127- }
128- else if ( tool . Support . Type == SupportType . Never )
129- { // You will never want to support this tool
130- return false ;
131- }
132- else if ( tool . FirstRunDate . AddMinutes ( settings . ShowMinutesAfterInstall ) > DateTime . Now )
133- { // Installed it too soon
134- return false ;
135- }
136- else if ( tool . VersionRunDate > tool . FirstRunDate && tool . VersionRunDate . AddMinutes ( settings . ShowMinutesAfterNewVersion ) > DateTime . Now )
137- { // Installed this version too soon
138- return false ;
139- }
140- else if ( tool . Support . DisplayDate . AddMinutes ( settings . ShowMinutesAfterShown ) > DateTime . Now )
141- { // Seen this form to soon
142- return false ;
143- }
144- else if ( tool . Support . DisplayCount >= settings . ShowAutoRepeatTimes )
145- { // Seen this too many times
146- return false ;
147- }
148- else if ( tool . Support . SubmittedDate . AddMinutes ( settings . ShowMinutesAfterSubmittingButNotCompleted ) > DateTime . Now )
149- { // Submitted too soon for JR to handle it
150- return false ;
151- }
152- else if ( settings . ShowAutoPercentChance < 1 )
153- {
154- return false ;
155- }
156- else
157- {
158- var rand = random . Next ( 1 , 100 ) ;
159- return rand <= settings . ShowAutoPercentChance ;
160- }
161- }
162-
163- #endregion Private Methods
164-
165157 #region Private Event Methods
166158
167159 private void Supporting_Shown ( object sender , EventArgs e )
@@ -406,7 +398,7 @@ public class ToolSettings
406398 private const string ToolSettingsURL = "https://jonasr.app/xtb/toolsettings.xml" ;
407399
408400 public int SettingsVersion = 1 ;
409- public bool ShowOnlyManual = true ; // false
401+ public List < SupportableTool > SupportableTools = new List < SupportableTool > ( ) ;
410402 public bool ContributionCounts = true ; // false
411403 public int ShowMinutesAfterInstall = int . MaxValue ; // 60
412404 public int ShowMinutesAfterNewVersion = int . MaxValue ; // 120
@@ -477,9 +469,9 @@ public class ToolSettings
477469 public Color clrBgNormal => Color . FromArgb ( int . Parse ( ColorBgNormal , System . Globalization . NumberStyles . HexNumber ) ) ;
478470 public Color clrBgInvalid => Color . FromArgb ( int . Parse ( ColorBgInvalid , System . Globalization . NumberStyles . HexNumber ) ) ;
479471
480- public string HelpWhyTitle = "Community Tool is Conscienceware." ;
472+ public string HelpWhyTitle = "Community Tools are Conscienceware." ;
481473
482- public string HelpWhyText = @"Some in the Power Platform Community are creating tools.
474+ public string HelpWhyText = @"Some of us in the Power Platform Community are creating tools.
483475Some contribute to the community with new ideas, find problems, write documentation, and even solve our bugs.
484476Thousands and thousands in this community are mostly 'consumers'—only using open-source tools.
485477To me, it's very similar to watching TV. Do you pay for channels, Netflix, Amazon Prime, Spotify, etc.?
@@ -523,6 +515,18 @@ private ToolSettings()
523515
524516 public static ToolSettings Get ( ) => new Uri ( ToolSettingsURL ) . DownloadXml ( new ToolSettings ( ) ) ;
525517
518+ public SupportableTool this [ string name ]
519+ {
520+ get
521+ {
522+ if ( ! SupportableTools . Any ( st => st . Name == name ) )
523+ {
524+ SupportableTools . Add ( new SupportableTool { Name = name } ) ;
525+ }
526+ return SupportableTools . FirstOrDefault ( st => st . Name == name ) ;
527+ }
528+ }
529+
526530 public void Save ( )
527531 {
528532 if ( ! Directory . Exists ( Paths . SettingsPath ) )
@@ -534,6 +538,13 @@ public void Save()
534538 }
535539 }
536540
541+ public class SupportableTool
542+ {
543+ public string Name ;
544+ public bool Enabled = false ;
545+ public bool ShowOnlyManual = true ;
546+ }
547+
537548 public class Supporters : List < Supporter >
538549 {
539550 private const string SupportersURL = "https://jonasr.app/xtb/supporters.xml" ;
0 commit comments