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

Annotation of /trunk/RomCheater/RomCheaterConfigDialog.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 64 - (hide annotations) (download)
Wed May 9 16:35:07 2012 UTC (9 years ago) by william
File size: 3436 byte(s)
modify user settings dialog

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     private void RomCheaterConfigDialog_Load(object sender, EventArgs e)
20     {
21 william 64 logger.Info.WriteLine("Loading user settings...");
22     load_loggerflags();
23     logger.Info.WriteLine("Loaded user settings.");
24     }
25     private void load_loggerflags()
26     {
27     logger.Debug.WriteLine("Loading logger flags...");
28     loggerflags logflags = (loggerflags)Logging.Properties.Settings.Default.LoggingFlags;
29     foreach (loggerflags flags in Enum.GetValues(typeof(loggerflags)))
30 william 63 {
31     if (flags == loggerflags.ALL ||
32     flags == loggerflags.NONE ||
33     flags == loggerflags.DEFAULT)
34     continue;
35    
36     string name = flags.ToString();
37     int value = (int)flags;
38    
39     CheckBox chkloggerflags = new CheckBox();
40     chkloggerflags.Name = name;
41     chkloggerflags.Text = name;
42     chkloggerflags.Tag = value;
43     grpLoggingFlags_flow.Controls.Add(chkloggerflags);
44 william 64 logger.Debug.WriteLine("\tAdding logger flag: {0} value: 0x{1:x4}", name, value);
45 william 63
46     if (logflags.HasFlag((loggerflags)value))
47     {
48     chkloggerflags.Checked = true;
49 william 64 logger.Debug.WriteLine("\tTurning on logger flag: {0} value: 0x{1:x4}", name, value);
50 william 63 }
51     }
52     grpLoggingFlags.AutoSize = true;
53     grpLoggingFlags.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
54 william 64 logger.Debug.WriteLine("Loaded logger flags.");
55 william 63 }
56     private void btnSave_Click(object sender, EventArgs e)
57     {
58 william 64 logger.Info.WriteLine("Saving user settings...");
59 william 63 SaveSettings();
60     this.Close();
61     }
62     private void btnCancel_Click(object sender, EventArgs e)
63     {
64     this.Close();
65     }
66     private void SaveSettings()
67     {
68     SaveLoggingFlags();
69     RomCheater.Properties.Settings.Default.Save();
70     Logging.Properties.Settings.Default.Save();
71 william 64 logger.Info.WriteLine("Saved user settings.");
72 william 63 }
73     private void SaveLoggingFlags()
74     {
75 william 64 logger.Debug.WriteLine("Saving Logger flags...");
76 william 63 loggerflags logflags = loggerflags.NONE;
77     foreach (CheckBox cb in grpLoggingFlags_flow.Controls)
78     {
79     if (!cb.Checked) continue;
80 william 64 int value = Convert.ToInt32(cb.Tag);
81 william 63 logflags = logflags | (loggerflags)value;
82 william 64 logger.Debug.WriteLine("\tAdding flag: {0} value: 0x{1:x4} LoggingFlags=0x{2:x4}", cb.Text, value, (int)logflags);
83 william 63 }
84     Logging.Properties.Settings.Default.LoggingFlags = (int)logflags;
85 william 64 logger.Debug.WriteLine("Saved Logger flags.");
86 william 63 }
87     }
88     }

  ViewVC Help
Powered by ViewVC 1.1.22