using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; using System.Windows.Forms; using System.Drawing; using System.Diagnostics; namespace PowerSwitcher { class Program { private static NotifyIcon trayi = new NotifyIcon(); private static InIReader ini; static void Main(string[] args) { init(); toogle(); remove(); } private static void remove() { trayi.Visible = false; } private static void toogle() { List all = ini.getSections(); all.Remove("[Application]"); all.Remove("[" + ini.getValue("Application", "lastused") + "]"); String profile = all.ElementAt(0).Substring(1); profile = profile.Substring(0, profile.Length - 1); showTooltip("Profil:", profile, ToolTipIcon.Info); runProgram(ini.getValue("Application", "graphicexe"), ini.getValue(profile, "graphic")); showTooltip("Neue Einstelllung", "Grafikkartengeschwindigkeit", ToolTipIcon.Info); runProgram(ini.getValue("Application", "pwcfgexe"), ini.getValue(profile, "pwcfg")); showTooltip("Neue Einstelllung", "CPU Geschwindigkeit", ToolTipIcon.Info); ini.SetValue("Application", "lastused", profile); System.Threading.Thread.Sleep(5000); } private static void runProgram(string prog, string args) { Process p = new Process(); p.StartInfo.Arguments = args; p.StartInfo.FileName = prog; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.UseShellExecute = false; p.Start(); string output = p.StandardOutput.ReadToEnd(); p.WaitForExit(); } private static void showTooltip(string title, string text, ToolTipIcon toolTipIcon) { trayi.BalloonTipIcon = toolTipIcon; trayi.BalloonTipText = text; trayi.BalloonTipTitle = title; trayi.ShowBalloonTip(100); } private static void init() { setIcon(); loadConfig(); } private static void loadConfig() { ini = new InIReader("config.ini"); } private static void setIcon() { trayi.Visible = true; trayi.Icon = new Icon(SystemIcons.WinLogo, 40, 40); trayi.Text = "PowerSwitcher"; } } }