public void AttachTo(WindowScrape.Types.HwndObject hwndobject, BindingBoy Boy) { this.bind_boy = Boy; this.hwndobject = hwndobject; this.Top = hwndobject.Location.Y; this.Left = hwndobject.Location.X; }
private void LoadPTTFromFile() { try { BindingBoys = new ObservableCollection <BindingBoy>(); string[] lines = File.ReadAllLines(PTTSavedSettingsFileName); int bindingcountmax = int.Parse(lines[0]) * 2; int i = -1 + 1; while (i < bindingcountmax) { BindingBoy boi = new BindingBoy() { WindowName = lines[++i], Binding = lines[++i] }; boi.BindingName = BindingBoy.GetBindingName(boi.Binding); BindingBoys.Add(boi); } BeginKeybindTextBox.Text = lines[++i]; EndKeybindTextBox.Text = lines[++i]; BindingDataGrid.ItemsSource = BindingBoys; } catch (Exception e) { Console.WriteLine(e.Message + "\r\n" + e.StackTrace); } }
private void PopUpAttachBoy(IntPtr hwnd, BindingBoy b) { attachboy.AttachTo(WindowScrape.Types.HwndObject.GetWindowByTitle(b.WindowName), b); attachboy.FixLocation(); attachboy.StebinTextBox.Text = ""; attachboy.Show(); sm_kp = _sm_kp.TTSMODE; }
private void SavePTTToFile() { List <string> lines = new List <string>(); lines.Add("" + BindingBoys.Count); foreach (var x in BindingBoys) { lines.Add(x.WindowName); x.Binding = "" + BindingBoy.ReverseAgain(x.BindingName); lines.Add(x.Binding.ToUpper()); } lines.Add(BeginKeybindTextBox.Text); lines.Add(EndKeybindTextBox.Text); File.WriteAllLines(PTTSavedSettingsFileName, lines.ToArray()); }
public void ButtonClickBoy(object sender, object uselessboy) { Button b = (Button)sender; switch (b.Name) { case "KeyGrabber": mainwindowreference.sm_kp = MainWindow._sm_kp.GET_BINDING; break; case "WindowRefreshButton": populatewindowlist(); break; case "AddBindingButton": BindingBoy newboy = new BindingBoy() { WindowName = (string)(WindowNameComboBox.SelectedValue), Binding = KeyBindingTextBox.Text }; newboy.BindingName = BindingBoy.GetBindingName(newboy.Binding); BindingBoys.Add(newboy); BindingDataGrid.ItemsSource = BindingBoys; break; case "SaveButton": SavePTTToFile(); mainwindowreference.BindingBoys = BindingBoys.ToList(); break; case "CancelButton": LoadPTTFromFile(); if (mainwindowreference.sm_kp == MainWindow._sm_kp.GET_BINDING || mainwindowreference.sm_kp == MainWindow._sm_kp.GET_BINDING_BEGIN || mainwindowreference.sm_kp == MainWindow._sm_kp.GET_BINDING_END) { mainwindowreference.sm_kp = MainWindow._sm_kp.NORMAL; } this.Hide(); break; case "CloseButton": if (mainwindowreference.sm_kp == MainWindow._sm_kp.GET_BINDING || mainwindowreference.sm_kp == MainWindow._sm_kp.GET_BINDING_BEGIN || mainwindowreference.sm_kp == MainWindow._sm_kp.GET_BINDING_END) { mainwindowreference.sm_kp = MainWindow._sm_kp.NORMAL; } this.Hide(); break; case "BeginKeybindButton": mainwindowreference.sm_kp = MainWindow._sm_kp.GET_BINDING_BEGIN; break; case "EndKeybindButton": mainwindowreference.sm_kp = MainWindow._sm_kp.GET_BINDING_END; break; } }