/[NexusPowerControl]/trunk/NexusPowerControl/MainUI.cs
ViewVC logotype

Contents of /trunk/NexusPowerControl/MainUI.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 21 - (show annotations) (download)
Tue Oct 25 07:13:09 2011 UTC (8 years ago) by william
File size: 3573 byte(s)
*** Fully implement default theme and AeroLowRes theme buttons

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
10 namespace NexusPowerControl
11 {
12 public partial class MainUI : Form
13 {
14 MouseTrapper mouse_trapper = new MouseTrapper();
15 public MainUI()
16 {
17 InitializeComponent();
18 }
19
20 private void Form1_Load(object sender, EventArgs e)
21 {
22 // load theme
23 ThemeLoader loader = new ThemeLoader();
24 loader.LoadThemeOrDefault(NexusPowerControl.Properties.Settings.Default.ActiveThemeName);
25 ThemeLoader.ThemeDefinition theme = loader.GetLoadedTheme();
26
27 if (theme.ThemeLoaded)
28 {
29 pic_main.Image = Image.FromFile(theme.MainImage);
30 btnShutdown.Image = Image.FromFile(theme.ShutdownImage);
31 btnRestart.Image = Image.FromFile(theme.RestartImage);
32 btnLogoff.Image = Image.FromFile(theme.LogoffImage);
33 btnLockScreen.Image = Image.FromFile(theme.LockScreenImage);
34 btnSleep.Image = Image.FromFile(theme.SleepImage);
35 btnClose.Image = Image.FromFile(theme.CloseImage);
36 }
37 else
38 {
39 pic_main.Image = ThemeConstants.Resources.DefaultThemeImages.MainImage;
40 btnShutdown.Image = ThemeConstants.Resources.DefaultThemeImages.ShutdownImage;
41 btnRestart.Image = ThemeConstants.Resources.DefaultThemeImages.RestartImage;
42 btnLogoff.Image = ThemeConstants.Resources.DefaultThemeImages.LogoffImage;
43 btnLockScreen.Image = ThemeConstants.Resources.DefaultThemeImages.LockScreenImage;
44 btnSleep.Image = ThemeConstants.Resources.DefaultThemeImages.SleepImage;
45 btnClose.Image = ThemeConstants.Resources.DefaultThemeImages.CloseImage;
46 }
47
48
49 btnShutdown.OnClickEvent += new EventHandler(btnShutdown_Click);
50 btnRestart.OnClickEvent += new EventHandler(btnRestart_Click);
51 btnLogoff.OnClickEvent += new EventHandler(btnLogoff_Click);
52 btnLockScreen.OnClickEvent += new EventHandler(btnLockScreen_Click);
53 btnSleep.OnClickEvent += new EventHandler(btnSleep_Click);
54 btnClose.OnClickEvent += new EventHandler(btnClose_Click);
55 }
56 private void MainUI_Shown(object sender, EventArgs e)
57 {
58 mouse_trapper.TrapMouse(this);
59 }
60
61 private void MainUI_FormClosed(object sender, FormClosedEventArgs e)
62 {
63 mouse_trapper.ReleaseMouse(this);
64 }
65 private void btnShutdown_Click(object sender, EventArgs e)
66 {
67 // shutdown the computer
68 }
69
70 private void btnRestart_Click(object sender, EventArgs e)
71 {
72 // restart the computer
73 }
74
75 private void btnLogoff_Click(object sender, EventArgs e)
76 {
77 // logoff the current user
78 }
79
80 private void btnLockScreen_Click(object sender, EventArgs e)
81 {
82 // lock the screen
83 }
84
85 private void btnSleep_Click(object sender, EventArgs e)
86 {
87 // put the computer to sleep
88 }
89
90 private void btnClose_Click(object sender, EventArgs e)
91 {
92 // close this dialog
93 this.Close();
94 }
95 }
96 }

  ViewVC Help
Powered by ViewVC 1.1.22