Free cookie consent management tool by TermsFeed Policy Generator

Changeset 775 for trunk/sources


Ignore:
Timestamp:
11/19/08 02:56:12 (16 years ago)
Author:
swagner
Message:

Experimented with the .NET application settings framework (#7)

Location:
trunk/sources/HeuristicLab.Settings
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Settings/MainForm.Designer.cs

    r757 r775  
    2727      this.button1 = new System.Windows.Forms.Button();
    2828      this.textBox2 = new System.Windows.Forms.TextBox();
     29      this.button2 = new System.Windows.Forms.Button();
     30      this.label1 = new System.Windows.Forms.Label();
     31      this.label2 = new System.Windows.Forms.Label();
    2932      this.SuspendLayout();
    3033      //
    3134      // textBox1
    3235      //
    33       this.textBox1.Location = new System.Drawing.Point(12, 12);
     36      this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     37                  | System.Windows.Forms.AnchorStyles.Right)));
     38      this.textBox1.Location = new System.Drawing.Point(80, 12);
    3439      this.textBox1.Name = "textBox1";
    35       this.textBox1.Size = new System.Drawing.Size(260, 20);
     40      this.textBox1.Size = new System.Drawing.Size(192, 20);
    3641      this.textBox1.TabIndex = 0;
    3742      this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
     
    3944      // button1
    4045      //
    41       this.button1.Location = new System.Drawing.Point(12, 38);
     46      this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     47      this.button1.Location = new System.Drawing.Point(116, 78);
    4248      this.button1.Name = "button1";
    4349      this.button1.Size = new System.Drawing.Size(75, 23);
    4450      this.button1.TabIndex = 1;
    45       this.button1.Text = "button1";
     51      this.button1.Text = "Save";
    4652      this.button1.UseVisualStyleBackColor = true;
    4753      this.button1.Click += new System.EventHandler(this.button1_Click);
     
    4955      // textBox2
    5056      //
    51       this.textBox2.Location = new System.Drawing.Point(12, 106);
     57      this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     58                  | System.Windows.Forms.AnchorStyles.Right)));
     59      this.textBox2.Location = new System.Drawing.Point(80, 38);
    5260      this.textBox2.Name = "textBox2";
    53       this.textBox2.ReadOnly = true;
    54       this.textBox2.Size = new System.Drawing.Size(260, 20);
     61      this.textBox2.Size = new System.Drawing.Size(192, 20);
    5562      this.textBox2.TabIndex = 0;
    56       this.textBox2.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
     63      this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
     64      //
     65      // button2
     66      //
     67      this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     68      this.button2.Location = new System.Drawing.Point(197, 78);
     69      this.button2.Name = "button2";
     70      this.button2.Size = new System.Drawing.Size(75, 23);
     71      this.button2.TabIndex = 2;
     72      this.button2.Text = "Reload";
     73      this.button2.UseVisualStyleBackColor = true;
     74      this.button2.Click += new System.EventHandler(this.button2_Click);
     75      //
     76      // label1
     77      //
     78      this.label1.AutoSize = true;
     79      this.label1.Location = new System.Drawing.Point(12, 15);
     80      this.label1.Name = "label1";
     81      this.label1.Size = new System.Drawing.Size(62, 13);
     82      this.label1.TabIndex = 3;
     83      this.label1.Text = "Application:";
     84      //
     85      // label2
     86      //
     87      this.label2.AutoSize = true;
     88      this.label2.Location = new System.Drawing.Point(12, 41);
     89      this.label2.Name = "label2";
     90      this.label2.Size = new System.Drawing.Size(32, 13);
     91      this.label2.TabIndex = 3;
     92      this.label2.Text = "User:";
    5793      //
    5894      // MainForm
     
    6096      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    6197      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    62       this.ClientSize = new System.Drawing.Size(284, 264);
     98      this.ClientSize = new System.Drawing.Size(284, 113);
     99      this.Controls.Add(this.label2);
     100      this.Controls.Add(this.label1);
     101      this.Controls.Add(this.button2);
    63102      this.Controls.Add(this.button1);
    64103      this.Controls.Add(this.textBox2);
     
    77116    private System.Windows.Forms.Button button1;
    78117    private System.Windows.Forms.TextBox textBox2;
     118    private System.Windows.Forms.Button button2;
     119    private System.Windows.Forms.Label label1;
     120    private System.Windows.Forms.Label label2;
    79121  }
    80122}
  • trunk/sources/HeuristicLab.Settings/MainForm.cs

    r758 r775  
    1717    private void MainForm_Load(object sender, EventArgs e) {
    1818      settings = Properties.Settings.Default;
    19       settings.Reload();
    20       textBox1.Text = settings.AnotherSetting;
    21       textBox2.Text = settings.MySetting;
     19      textBox1.Text = settings.MyApplicationSetting;
     20      textBox2.Text = settings.MyUserSetting;
    2221    }
    2322
     
    2726
    2827    private void textBox1_TextChanged(object sender, EventArgs e) {
    29       settings.AnotherSetting = textBox1.Text;
     28      settings.MyApplicationSetting = textBox1.Text;
     29    }
     30
     31    private void textBox2_TextChanged(object sender, EventArgs e) {
     32      settings.MyUserSetting = textBox2.Text;
     33    }
     34
     35    private void button2_Click(object sender, EventArgs e) {
     36      settings.Reload();
     37      textBox1.Text = settings.MyApplicationSetting;
     38      textBox2.Text = settings.MyUserSetting;
    3039    }
    3140  }
  • trunk/sources/HeuristicLab.Settings/Properties/Settings.Designer.cs

    r757 r775  
    2626        [global::System.Configuration.ApplicationScopedSettingAttribute()]
    2727        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    28         [global::System.Configuration.DefaultSettingValueAttribute("Nice Value")]
    29         public string MySetting {
     28        [global::System.Configuration.DefaultSettingValueAttribute("Application Setting Value")]
     29        public string MyApplicationSetting {
    3030            get {
    31                 return ((string)(this["MySetting"]));
     31                return ((string)(this["MyApplicationSetting"]));
     32            }
     33            set {
     34                this["MyApplicationSetting"] = value;
    3235            }
    3336        }
     
    3538        [global::System.Configuration.UserScopedSettingAttribute()]
    3639        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    37         [global::System.Configuration.DefaultSettingValueAttribute("COOL!!")]
    38         public string AnotherSetting {
     40        [global::System.Configuration.DefaultSettingValueAttribute("User Setting Value")]
     41        public string MyUserSetting {
    3942            get {
    40                 return ((string)(this["AnotherSetting"]));
     43                return ((string)(this["MyUserSetting"]));
    4144            }
    4245            set {
    43                 this["AnotherSetting"] = value;
     46                this["MyUserSetting"] = value;
    4447            }
    4548        }
  • trunk/sources/HeuristicLab.Settings/Properties/Settings.settings

    r757 r775  
    33  <Profiles />
    44  <Settings>
    5     <Setting Name="MySetting" Type="System.String" Scope="Application">
    6       <Value Profile="(Default)">Nice Value</Value>
     5    <Setting Name="MyApplicationSetting" Type="System.String" Scope="Application">
     6      <Value Profile="(Default)">Application Setting Value</Value>
    77    </Setting>
    8     <Setting Name="AnotherSetting" Type="System.String" Scope="User">
    9       <Value Profile="(Default)">COOL!!</Value>
     8    <Setting Name="MyUserSetting" Type="System.String" Scope="User">
     9      <Value Profile="(Default)">User Setting Value</Value>
    1010    </Setting>
    1111  </Settings>
  • trunk/sources/HeuristicLab.Settings/app.config

    r757 r775  
    1111    <applicationSettings>
    1212        <HeuristicLab.Settings.Properties.Settings>
    13             <setting name="MySetting" serializeAs="String">
    14                 <value>Nice Value</value>
     13            <setting name="MyApplicationSetting" serializeAs="String">
     14                <value>Application Setting Value</value>
    1515            </setting>
    1616        </HeuristicLab.Settings.Properties.Settings>
     
    1818    <userSettings>
    1919        <HeuristicLab.Settings.Properties.Settings>
    20             <setting name="AnotherSetting" serializeAs="String">
    21                 <value>COOL!!</value>
     20            <setting name="MyUserSetting" serializeAs="String">
     21                <value>User Setting Value</value>
    2222            </setting>
    2323        </HeuristicLab.Settings.Properties.Settings>
Note: See TracChangeset for help on using the changeset viewer.