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

Contents of /trunk/RomCheater/RomCheaterConfigDialog.cs

Parent Directory Parent Directory | Revision Log Revision Log


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

1 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 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 {
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 logger.Debug.WriteLine("\tAdding logger flag: {0} value: 0x{1:x4}", name, value);
45
46 if (logflags.HasFlag((loggerflags)value))
47 {
48 chkloggerflags.Checked = true;
49 logger.Debug.WriteLine("\tTurning on logger flag: {0} value: 0x{1:x4}", name, value);
50 }
51 }
52 grpLoggingFlags.AutoSize = true;
53 grpLoggingFlags.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
54 logger.Debug.WriteLine("Loaded logger flags.");
55 }
56 private void btnSave_Click(object sender, EventArgs e)
57 {
58 logger.Info.WriteLine("Saving user settings...");
59 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 logger.Info.WriteLine("Saved user settings.");
72 }
73 private void SaveLoggingFlags()
74 {
75 logger.Debug.WriteLine("Saving Logger flags...");
76 loggerflags logflags = loggerflags.NONE;
77 foreach (CheckBox cb in grpLoggingFlags_flow.Controls)
78 {
79 if (!cb.Checked) continue;
80 int value = Convert.ToInt32(cb.Tag);
81 logflags = logflags | (loggerflags)value;
82 logger.Debug.WriteLine("\tAdding flag: {0} value: 0x{1:x4} LoggingFlags=0x{2:x4}", cb.Text, value, (int)logflags);
83 }
84 Logging.Properties.Settings.Default.LoggingFlags = (int)logflags;
85 logger.Debug.WriteLine("Saved Logger flags.");
86 }
87 }
88 }

  ViewVC Help
Powered by ViewVC 1.1.22