public Form1() { InitializeComponent(); hook.KeyPressed += new EventHandler <KeyPressedEventArgs>(hook_KeyPressed); if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/SoundEvents/Sounds.txt")) { Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/SoundEvents/"); File.Create(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/SoundEvents/Sounds.txt").Close(); } else { string[] lines = File.ReadAllLines(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/SoundEvents/Sounds.txt"); int lineNumber = -1; foreach (string line in lines) { ++lineNumber; string[] columns = line.Split('|'); if (columns.Length != 6) { continue; } ModifierKeys mod = (ModifierKeys)Enum.Parse(typeof(ModifierKeys), columns[0]); Keys key = (Keys)Enum.Parse(typeof(Keys), columns[1]); Button btn = new Button(); Event.PlayModes playmode = (Event.PlayModes)Enum.Parse(typeof(Event.PlayModes), columns[5]); Event ev = new Event(mod, key, columns[2], columns[3], lineNumber, btn, Convert.ToSingle(columns[4]), playmode); if (!(ev.modifier == Sound_events.ModifierKeys.None && ev.key == Keys.None)) { hook.RegisterHotKey(ev.modifier, ev.key); } btn.Parent = panel; int index = panel.Controls.GetChildIndex(btn, false); panel.Controls.SetChildIndex(btn, index - 1); btn.Size = new Size(100, 100); try { btn.BackgroundImage = Image.FromFile(ev.ImageName); btn.BackgroundImageLayout = ImageLayout.Stretch; btn.BackColor = Color.Transparent; } catch { } btn.FlatStyle = FlatStyle.Popup; btn.MouseUp += new MouseEventHandler(delegate(Object o, MouseEventArgs args) { if (args.Button == MouseButtons.Left) { hook_KeyPressed(btn, new KeyPressedEventArgs(ev.modifier, ev.key)); } else if (args.Button == MouseButtons.Right) { EditEvent(ev); } }); events.Add(ev); } } if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/SoundEvents/Settings.txt")) { File.Create(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/SoundEvents/Settings.txt").Close(); List <string> lines = new List <string>(File.ReadAllLines(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/SoundEvents/Settings.txt")); lines.Add("0|0"); lines.Add("0.3"); lines.Add("0,0|434,384"); File.WriteAllLines(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/SoundEvents/Settings.txt", lines); ShowOptions(); } else { string[] lines = File.ReadAllLines(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/SoundEvents/Settings.txt"); string[] indicies = lines[0].Split('|'); if (indicies.Length < 2) { ShowOptions(); } else { try { Helper.Mic = (Guid) new GuidConverter().ConvertFromString(indicies[0]); Helper.Out = (Guid) new GuidConverter().ConvertFromString(indicies[1]); } catch { ShowOptions(); } } string[] posloc = lines[2].Split('|'); string[] pos = posloc[0].Split(','); string[] loc = posloc[1].Split(','); Size = new Size(Convert.ToInt32(pos[0]), Convert.ToInt32(pos[1])); Location = new Point(Convert.ToInt32(loc[0]), Convert.ToInt32(loc[1])); } ModifierKeys nmod = Sound_events.ModifierKeys.Alt | Sound_events.ModifierKeys.Control; Keys nkey = Keys.R; Button nbtn = new Button(); float vol = 0.3f; string[] volumelines = File.ReadAllLines(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/SoundEvents/Settings.txt"); if (volumelines.Length > 1) { vol = Convert.ToSingle(volumelines[1]); } Event nev = new Event(nmod, nkey, "reee.mp3", "reeeeeee.jpg", -1, nbtn, vol, Event.PlayModes.multi); if (!(nev.modifier == Sound_events.ModifierKeys.None && nev.key == Keys.None)) { hook.RegisterHotKey(nev.modifier, nev.key); } nbtn.Parent = panel; panel.Controls.SetChildIndex(nbtn, 0); nbtn.Size = new Size(100, 100); try { nbtn.BackgroundImage = Image.FromFile(nev.ImageName); nbtn.BackgroundImageLayout = ImageLayout.Stretch; nbtn.BackColor = Color.Transparent; } catch { } nbtn.FlatStyle = FlatStyle.Popup; nbtn.MouseUp += new MouseEventHandler(delegate(Object o, MouseEventArgs args) { if (args.Button == MouseButtons.Left) { hook_KeyPressed(nbtn, new KeyPressedEventArgs(nev.modifier, nev.key)); } else if (args.Button == MouseButtons.Right) { EditEvent(nev); } }); events.Add(nev); }
private void rb_playmode_once_CheckedChanged(object sender, EventArgs e) { Playmode = Event.PlayModes.once; }
private void rb_playmode_start_stop_CheckedChanged(object sender, EventArgs e) { Playmode = Event.PlayModes.start_stop; }
private void rb_playmode_multi_CheckedChanged(object sender, EventArgs e) { Playmode = Event.PlayModes.multi; }