Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13586


Ignore:
Timestamp:
02/04/16 13:28:04 (8 years ago)
Author:
jkarder
Message:

#2567: worked on saving Location/Size/WindowState settings

  • added settings for StarterForm
  • removed ShowMaximized setting used by MainForm
  • implemented checks to fall back to default values if necessary
Location:
trunk/sources
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimizer/3.3/OptimizerDockingMainForm.cs

    r12012 r13586  
    8080        startPage.Show();
    8181      }
    82 
    83       WindowState = Properties.Settings.Default.ShowMaximized ? FormWindowState.Maximized : FormWindowState.Normal;
    8482    }
    8583
     
    9391    protected override void OnClosed(EventArgs e) {
    9492      base.OnClosed(e);
    95       Properties.Settings.Default.ShowMaximized = WindowState == FormWindowState.Maximized;
    9693      Properties.Settings.Default.CollapseClipboard = clipboard.Collapsed;
    9794      OperatorsSidebar operatorsSidebar = MainFormManager.MainForm.Views.OfType<OperatorsSidebar>().FirstOrDefault();
  • trunk/sources/HeuristicLab.Optimizer/3.3/OptimizerMultipleDocumentMainForm.cs

    r12012 r13586  
    8080        startPage.Show();
    8181      }
    82 
    83       WindowState = Properties.Settings.Default.ShowMaximized ? FormWindowState.Maximized : FormWindowState.Normal;
    8482    }
    8583
     
    9391    protected override void OnClosed(EventArgs e) {
    9492      base.OnClosed(e);
    95       Properties.Settings.Default.ShowMaximized = WindowState == FormWindowState.Maximized;
    9693      Properties.Settings.Default.CollapseClipboard = clipboard.Collapsed;
    9794      OperatorsSidebar operatorsSidebar = MainFormManager.MainForm.Views.OfType<OperatorsSidebar>().FirstOrDefault();
  • trunk/sources/HeuristicLab.Optimizer/3.3/OptimizerSingleDocumentMainForm.cs

    r12012 r13586  
    8080        startPage.Show();
    8181      }
    82 
    83       WindowState = Properties.Settings.Default.ShowMaximized ? FormWindowState.Maximized : FormWindowState.Normal;
    8482    }
    8583
     
    9391    protected override void OnClosed(EventArgs e) {
    9492      base.OnClosed(e);
    95       Properties.Settings.Default.ShowMaximized = WindowState == FormWindowState.Maximized;
    9693      Properties.Settings.Default.CollapseClipboard = clipboard.Collapsed;
    9794      OperatorsSidebar operatorsSidebar = MainFormManager.MainForm.Views.OfType<OperatorsSidebar>().FirstOrDefault();
  • trunk/sources/HeuristicLab.Optimizer/3.3/Plugin.cs.frame

    r13567 r13586  
    2020#endregion
    2121
     22using System.Drawing;
    2223using System.Linq;
    2324using System.Windows.Forms;
     
    6061      }
    6162
    62       if (mainForm != null) {     
    63         mainForm.Location = Settings.Default.MainFormLocation;
    64         mainForm.Size = Settings.Default.MainFormSize;
    65         mainForm.Load += (sender, eventArgs) => {
     63      if (mainForm != null) {
     64        if (CheckSavedMainFormSettings()) {
     65          mainForm.Location = Settings.Default.MainFormLocation;
     66          mainForm.Size = Settings.Default.MainFormSize;
    6667          mainForm.WindowState = Settings.Default.MainFormWindowState;
    67         };
     68        }
    6869
    6970        mainForm.FormClosing += (sender, eventArgs) => {
    70           Settings.Default.MainFormWindowState = mainForm.WindowState;
     71          if (mainForm.WindowState != FormWindowState.Minimized)
     72            Settings.Default.MainFormWindowState = mainForm.WindowState;
    7173          if (mainForm.WindowState != FormWindowState.Normal) {
    7274            Settings.Default.MainFormLocation = mainForm.RestoreBounds.Location;
     
    9092      }
    9193    }
     94
     95    private bool CheckSavedMainFormSettings() {
     96      var formArea = new Rectangle(Settings.Default.MainFormLocation, Settings.Default.MainFormSize);
     97      var screenArea = Screen.FromRectangle(formArea).WorkingArea;
     98      var overlappingArea = Rectangle.Intersect(formArea, screenArea);
     99      bool offLimits = overlappingArea.IsEmpty || overlappingArea.Width * overlappingArea.Height < formArea.Width * formArea.Height * 0.25;
     100      return !formArea.IsEmpty && !offLimits;
     101    }
    92102  }
    93103}
  • trunk/sources/HeuristicLab.Optimizer/3.3/Properties/Settings.Designer.cs

    r13567 r13586  
    22// <auto-generated>
    33//     This code was generated by a tool.
    4 //     Runtime Version:4.0.30319.34209
     4//     Runtime Version:4.0.30319.42000
    55//
    66//     Changes to this file may cause incorrect behavior and will be lost if
     
    1313   
    1414    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    15     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
     15    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
    1616    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
    1717       
     
    5757            set {
    5858                this["ShowClipboard"] = value;
    59             }
    60         }
    61        
    62         [global::System.Configuration.UserScopedSettingAttribute()]
    63         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    64         [global::System.Configuration.DefaultSettingValueAttribute("True")]
    65         public bool ShowMaximized {
    66             get {
    67                 return ((bool)(this["ShowMaximized"]));
    68             }
    69             set {
    70                 this["ShowMaximized"] = value;
    7159            }
    7260        }
  • trunk/sources/HeuristicLab.Optimizer/3.3/Properties/Settings.settings

    r13567 r13586  
    1010    </Setting>
    1111    <Setting Name="ShowClipboard" Type="System.Boolean" Scope="User">
    12       <Value Profile="(Default)">True</Value>
    13     </Setting>
    14     <Setting Name="ShowMaximized" Type="System.Boolean" Scope="User">
    1512      <Value Profile="(Default)">True</Value>
    1613    </Setting>
  • trunk/sources/HeuristicLab.Optimizer/3.3/app.config

    r13567 r13586  
    1515            </setting>
    1616            <setting name="ShowClipboard" serializeAs="String">
    17                 <value>True</value>
    18             </setting>
    19             <setting name="ShowMaximized" serializeAs="String">
    2017                <value>True</value>
    2118            </setting>
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Properties/Settings.Designer.cs

    r11623 r13586  
    22// <auto-generated>
    33//     This code was generated by a tool.
    4 //     Runtime Version:4.0.30319.34014
     4//     Runtime Version:4.0.30319.42000
    55//
    66//     Changes to this file may cause incorrect behavior and will be lost if
     
    1313   
    1414    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    15     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
     15    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
    1616    public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
    1717       
     
    8383            }
    8484        }
     85       
     86        [global::System.Configuration.UserScopedSettingAttribute()]
     87        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     88        [global::System.Configuration.DefaultSettingValueAttribute("0, 0")]
     89        public global::System.Drawing.Point StarterFormLocation {
     90            get {
     91                return ((global::System.Drawing.Point)(this["StarterFormLocation"]));
     92            }
     93            set {
     94                this["StarterFormLocation"] = value;
     95            }
     96        }
     97       
     98        [global::System.Configuration.UserScopedSettingAttribute()]
     99        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     100        [global::System.Configuration.DefaultSettingValueAttribute("0, 0")]
     101        public global::System.Drawing.Size StarterFormSize {
     102            get {
     103                return ((global::System.Drawing.Size)(this["StarterFormSize"]));
     104            }
     105            set {
     106                this["StarterFormSize"] = value;
     107            }
     108        }
     109       
     110        [global::System.Configuration.UserScopedSettingAttribute()]
     111        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     112        [global::System.Configuration.DefaultSettingValueAttribute("Normal")]
     113        public global::System.Windows.Forms.FormWindowState StarterFormWindowState {
     114            get {
     115                return ((global::System.Windows.Forms.FormWindowState)(this["StarterFormWindowState"]));
     116            }
     117            set {
     118                this["StarterFormWindowState"] = value;
     119            }
     120        }
    85121    }
    86122}
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Properties/Settings.settings

    r4495 r13586  
    1818      <Value Profile="(Default)">http://services.heuristiclab.com/Deployment-3.3/AdminService.svc</Value>
    1919    </Setting>
     20    <Setting Name="StarterFormLocation" Type="System.Drawing.Point" Scope="User">
     21      <Value Profile="(Default)">0, 0</Value>
     22    </Setting>
     23    <Setting Name="StarterFormSize" Type="System.Drawing.Size" Scope="User">
     24      <Value Profile="(Default)">0, 0</Value>
     25    </Setting>
     26    <Setting Name="StarterFormWindowState" Type="System.Windows.Forms.FormWindowState" Scope="User">
     27      <Value Profile="(Default)">Normal</Value>
     28    </Setting>
    2029  </Settings>
    2130</SettingsFile>
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Starter/StarterForm.cs

    r12012 r13586  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Drawing;
    2425using System.IO;
    2526using System.Linq;
     
    2930using HeuristicLab.PluginInfrastructure.Advanced;
    3031using HeuristicLab.PluginInfrastructure.Manager;
     32using HeuristicLab.PluginInfrastructure.Properties;
    3133
    3234namespace HeuristicLab.PluginInfrastructure.Starter {
     
    6769      splashScreen.Show(this, "Loading HeuristicLab...");
    6870
     71      if (CheckSavedStarterFormSettings()) {
     72        Location = Settings.Default.StarterFormLocation;
     73        Size = Settings.Default.StarterFormSize;
     74        WindowState = Settings.Default.StarterFormWindowState;
     75      }
     76
    6977      pluginManager.DiscoverAndCheckPlugins();
    7078      UpdateApplicationsList();
     
    96104      splashScreen.Close();
    97105      abortRequested = true;
     106
     107      if (WindowState != FormWindowState.Minimized)
     108        Settings.Default.StarterFormWindowState = WindowState;
     109      if (WindowState != FormWindowState.Normal) {
     110        Settings.Default.StarterFormLocation = RestoreBounds.Location;
     111        Settings.Default.StarterFormSize = RestoreBounds.Size;
     112      } else if (WindowState == FormWindowState.Normal) {
     113        Settings.Default.StarterFormLocation = Location;
     114        Settings.Default.StarterFormSize = Size;
     115      }
     116
     117      Settings.Default.Save();
    98118    }
    99119
     
    177197
    178198    #region Helpers
     199    private bool CheckSavedStarterFormSettings() {
     200      var formArea = new Rectangle(Settings.Default.StarterFormLocation, Settings.Default.StarterFormSize);
     201      var screenArea = Screen.FromRectangle(formArea).WorkingArea;
     202      var overlappingArea = Rectangle.Intersect(formArea, screenArea);
     203      bool offLimits = overlappingArea.IsEmpty || overlappingArea.Width * overlappingArea.Height < formArea.Width * formArea.Height * 0.25;
     204      return !formArea.IsEmpty && !offLimits;
     205    }
     206
    179207    private void UpdateApplicationsList() {
    180208      if (InvokeRequired) Invoke((Action)UpdateApplicationsList);
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/app.config

    r11623 r13586  
    2323      <setting name="UpdateLocationAdministrationAddress" serializeAs="String">
    2424        <value>http://services.heuristiclab.com/Deployment-3.3/AdminService.svc</value>
     25      </setting>
     26      <setting name="StarterFormLocation" serializeAs="String">
     27        <value>0, 0</value>
     28      </setting>
     29      <setting name="StarterFormSize" serializeAs="String">
     30        <value>0, 0</value>
     31      </setting>
     32      <setting name="StarterFormWindowState" serializeAs="String">
     33        <value>Normal</value>
    2534      </setting>
    2635    </HeuristicLab.PluginInfrastructure.Properties.Settings>
Note: See TracChangeset for help on using the changeset viewer.