Ejemplo n.º 1
0
        public MainForm()
        {
            InitializeComponent();

            this.settings = new PersistentSettings();
            this.settings.Load(Path.ChangeExtension(Application.ExecutablePath, ".config"));

            // make sure the buffers used for double buffering are not disposed
            // after each draw call
            BufferedGraphicsManager.Current.MaximumBuffer = Screen.PrimaryScreen.Bounds.Size;

            // set the DockStyle here, to avoid conflicts with the MainMenu
            this.splitContainer.Dock = DockStyle.Fill;

            this.Font = SystemFonts.MessageBoxFont;
            treeView.Font = SystemFonts.MessageBoxFont;

            nodeTextBoxText.DrawText += nodeTextBoxText_DrawText;
            nodeTextBoxACValue.DrawText += nodeTextBoxText_DrawText;
            nodeTextBoxDCValue.DrawText += nodeTextBoxText_DrawText;
            nodeTextBoxUnit.DrawText += nodeTextBoxText_DrawText;
            nodeTextBoxText.EditorShowing += nodeTextBoxText_EditorShowing;

            foreach (TreeColumn column in treeView.Columns)
            {
                column.Width = Math.Max(20, Math.Min(400,
                    settings.GetValue("treeView.Columns." + column.Header + ".Width",
                    column.Width)));
            }

            treeView.RowHeight = Math.Max(treeView.Font.Height + 1, 18);

            treeModel = new TreeModel();

            showHiddenSettings = new UserOption("hiddenMenuItem", false,
                hiddenMenuItem, settings);
            showHiddenSettings.Changed += delegate(object sender, EventArgs e)
            {
                treeModel.ForceVisible = showHiddenSettings.Value;
            };

            applyChanges = new UserOption("applyMenuItem", false,
                applyMenuItem, settings);

            forcePowerManager = new UserOption("forceMenuItem", false,
                forceMenuItem, settings);

            root = new ComputerNode(System.Environment.MachineName, settings);
            treeModel.Root = root;
            treeView.Model = treeModel;

            nodeTextBoxACValue.IsVisibleValueNeeded += nodeTextBoxAC_IsVisibleValueNeeded;
            nodeComboBoxACValue.IsVisibleValueNeeded += nodeComboBoxAC_IsVisibleValueNeeded;

            nodeComboBoxACValue.DrawText += nodeTextBoxText_DrawText;
            nodeTextBoxACValue.DataPropertyName = "AcValue";
            nodeComboBoxACValue.DataPropertyName = "AcValue";

            nodeTextBoxDCValue.IsVisibleValueNeeded += nodeTextBoxAC_IsVisibleValueNeeded;
            nodeComboBoxDCValue.IsVisibleValueNeeded += nodeComboBoxAC_IsVisibleValueNeeded;

            nodeComboBoxDCValue.DrawText += nodeTextBoxText_DrawText;
            nodeTextBoxDCValue.DataPropertyName = "DcValue";
            nodeComboBoxDCValue.DataPropertyName = "DcValue";

            Show();

            // Create a handle, otherwise calling Close() does not fire FormClosed
            IntPtr handle = Handle;

            // Make sure the settings are saved when the user logs off
            Microsoft.Win32.SystemEvents.SessionEnded += delegate
            {
                SaveConfiguration();
            };
        }
Ejemplo n.º 2
0
        public MainForm()
        {
            InitializeComponent();

            this.settings = new PersistentSettings();
            this.settings.Load(Path.ChangeExtension(Application.ExecutablePath, ".config"));

            // make sure the buffers used for double buffering are not disposed
            // after each draw call
            BufferedGraphicsManager.Current.MaximumBuffer = Screen.PrimaryScreen.Bounds.Size;

            // set the DockStyle here, to avoid conflicts with the MainMenu
            this.splitContainer.Dock = DockStyle.Fill;

            this.Font     = SystemFonts.MessageBoxFont;
            treeView.Font = SystemFonts.MessageBoxFont;

            nodeTextBoxText.DrawText      += nodeTextBoxText_DrawText;
            nodeTextBoxACValue.DrawText   += nodeTextBoxText_DrawText;
            nodeTextBoxDCValue.DrawText   += nodeTextBoxText_DrawText;
            nodeTextBoxUnit.DrawText      += nodeTextBoxText_DrawText;
            nodeTextBoxText.EditorShowing += nodeTextBoxText_EditorShowing;

            foreach (TreeColumn column in treeView.Columns)
            {
                column.Width = Math.Max(20, Math.Min(400,
                                                     settings.GetValue("treeView.Columns." + column.Header + ".Width",
                                                                       column.Width)));
            }

            treeView.RowHeight = Math.Max(treeView.Font.Height + 1, 18);

            treeModel = new TreeModel();

            showHiddenSettings = new UserOption("hiddenMenuItem", false,
                                                hiddenMenuItem, settings);
            showHiddenSettings.Changed += delegate(object sender, EventArgs e)
            {
                treeModel.ForceVisible = showHiddenSettings.Value;
            };

            applyChanges = new UserOption("applyMenuItem", false,
                                          applyMenuItem, settings);

            forcePowerManager = new UserOption("forceMenuItem", false,
                                               forceMenuItem, settings);


            root           = new ComputerNode(System.Environment.MachineName, settings);
            treeModel.Root = root;
            treeView.Model = treeModel;

            nodeTextBoxACValue.IsVisibleValueNeeded  += nodeTextBoxAC_IsVisibleValueNeeded;
            nodeComboBoxACValue.IsVisibleValueNeeded += nodeComboBoxAC_IsVisibleValueNeeded;

            nodeComboBoxACValue.DrawText        += nodeTextBoxText_DrawText;
            nodeTextBoxACValue.DataPropertyName  = "AcValue";
            nodeComboBoxACValue.DataPropertyName = "AcValue";

            nodeTextBoxDCValue.IsVisibleValueNeeded  += nodeTextBoxAC_IsVisibleValueNeeded;
            nodeComboBoxDCValue.IsVisibleValueNeeded += nodeComboBoxAC_IsVisibleValueNeeded;

            nodeComboBoxDCValue.DrawText        += nodeTextBoxText_DrawText;
            nodeTextBoxDCValue.DataPropertyName  = "DcValue";
            nodeComboBoxDCValue.DataPropertyName = "DcValue";

            Show();

            // Create a handle, otherwise calling Close() does not fire FormClosed
            IntPtr handle = Handle;

            // Make sure the settings are saved when the user logs off
            Microsoft.Win32.SystemEvents.SessionEnded += delegate
            {
                SaveConfiguration();
            };
        }