Beispiel #1
0
        private void trayIcon_MouseDown(object sender, MouseEventArgs e)
        {
            bool[] state = ApiCalls.GetGlobalExecutionState();
            UpdateText(preventMonitorOff, state[0]);
            UpdateText(preventStandby, state[1]);
            while (contextMenu.Items.Count > 8)
            {
                contextMenu.Items.RemoveAt(contextMenu.Items.Count - 3);
            }
            var  schemeItems  = new List <ToolStripMenuItem>();
            Guid activeScheme = ApiCalls.ActivePowerScheme;
            var  schemes      = ApiCalls.GetPowerSchemes();

            foreach (var guid in schemes.Keys)
            {
                ToolStripMenuItem item = new ToolStripMenuItem(schemes[guid], null, powerScheme_Click);
                item.Tag = guid;
                if (guid == activeScheme)
                {
                    item.Checked = true;
                }
                schemeItems.Add(item);
            }
            schemeItems.Sort((x, y) => x.Text.CompareTo(y.Text));
            foreach (var item in schemeItems)
            {
                contextMenu.Items.Insert(contextMenu.Items.Count - 2, item);
            }
            contextMenu.Show(Cursor.Position.X, Cursor.Position.Y);
        }
Beispiel #2
0
        private void monitorOff_Click(object sender, EventArgs e)
        {
            ApiCalls.PowerOffDisplay();
            Timer t = new Timer();

            t.Interval = 200;
            t.Tick    += delegate(object ss, EventArgs ee)
            {
                ApiCalls.PowerOffDisplay();
                t.Stop();
            };
            t.Start();
        }
Beispiel #3
0
 private void preventItem_Click(object sender, EventArgs e)
 {
     ApiCalls.SetLocalExecutionState(preventMonitorOff.Checked, preventStandby.Checked);
 }
Beispiel #4
0
 private void screensaver_Click(object sender, EventArgs e)
 {
     ApiCalls.StartScreensaver();
 }