Пример #1
0
 public static void Maintain(this Form @this, System.Configuration.ApplicationSettingsBase settings, string recPropertyId, bool checkWorkingArea = true)
 {
     @this.Load += (sender, args) =>
     {
         Rectangle rec = (Rectangle)settings[recPropertyId];
         if (checkWorkingArea)
         {
             if (partVisible(rec) < 0.01)
             {
                 return;
             }
         }
         if (!rec.IsEmpty)
         {
             @this.Location = rec.Location;
             @this.Size     = rec.Size;
         }
     };
     @this.Closing += (sender, args) =>
     {
         Point loc = @this.Location;
         var   s   = @this.WindowState == FormWindowState.Normal ? @this.Size : @this.RestoreBounds.Size;
         settings[recPropertyId] = new Rectangle(loc, s);
         settings.Save();
     };
 }
Пример #2
0
 public static void SetValue <T>(this System.Configuration.ApplicationSettingsBase settings, string key, T value)
 {
     settings[key] = value;
     settings.Save();
 }