/[RomCheater]/trunk/RomCheater/RomCheaterConfigDialog.cs
ViewVC logotype

Annotation of /trunk/RomCheater/RomCheaterConfigDialog.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 63 - (hide annotations) (download)
Wed May 9 16:14:39 2012 UTC (9 years ago) by william
File size: 2483 byte(s)
+ add support to save logging flags at user level

1 william 63 using System;
2     using System.Collections.Generic;
3     using System.ComponentModel;
4     using System.Data;
5     using System.Drawing;
6     using System.Linq;
7     using System.Text;
8     using System.Windows.Forms;
9     using RomCheater.Logging;
10    
11     namespace RomCheater
12     {
13     public partial class RomCheaterConfigDialog : Form
14     {
15     public RomCheaterConfigDialog()
16     {
17     InitializeComponent();
18     }
19    
20     private void RomCheaterConfigDialog_Load(object sender, EventArgs e)
21     {
22     foreach(loggerflags flags in Enum.GetValues(typeof(loggerflags)))
23     {
24     if (flags == loggerflags.ALL ||
25     flags == loggerflags.NONE ||
26     flags == loggerflags.DEFAULT)
27     continue;
28    
29     string name = flags.ToString();
30     int value = (int)flags;
31    
32     CheckBox chkloggerflags = new CheckBox();
33     chkloggerflags.Name = name;
34     chkloggerflags.Text = name;
35     chkloggerflags.Tag = value;
36     grpLoggingFlags_flow.Controls.Add(chkloggerflags);
37     loggerflags logflags = (loggerflags)Logging.Properties.Settings.Default.LoggingFlags;
38    
39     if (logflags.HasFlag((loggerflags)value))
40     {
41     chkloggerflags.Checked = true;
42     }
43     }
44     grpLoggingFlags.AutoSize = true;
45     grpLoggingFlags.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
46     }
47    
48     private void btnSave_Click(object sender, EventArgs e)
49     {
50     SaveSettings();
51     this.Close();
52     }
53     private void btnCancel_Click(object sender, EventArgs e)
54     {
55     this.Close();
56     }
57    
58     private void SaveSettings()
59     {
60     SaveLoggingFlags();
61     RomCheater.Properties.Settings.Default.Save();
62     Logging.Properties.Settings.Default.Save();
63     }
64     private void SaveLoggingFlags()
65     {
66     loggerflags logflags = loggerflags.NONE;
67     foreach (CheckBox cb in grpLoggingFlags_flow.Controls)
68     {
69     if (!cb.Checked) continue;
70     int value = Convert.ToInt32(cb.Tag);
71     logflags = logflags | (loggerflags)value;
72     }
73     Logging.Properties.Settings.Default.LoggingFlags = (int)logflags;
74     }
75     }
76     }

  ViewVC Help
Powered by ViewVC 1.1.22