private void LoadData() { if (!File.Exists(_dataFilename)) { UpdateStatusStripLabel("Please setup general settings."); return; } using (StreamReader r = new StreamReader(_dataFilename)) { string json = r.ReadToEnd(); CustomDataObject data = JsonConvert.DeserializeObject <CustomDataObject>(json); txtClientName.Text = data.ClientName; chkFullScreen.Checked = data.FullScreenWhenAuto; chkFullScreen.CheckState = data.FullScreenWhenAuto ? CheckState.Checked : CheckState.Unchecked; txtScreenResolutionX.Text = data.ScreenResolution.X.ToString(); txtScreenResolutionY.Text = data.ScreenResolution.Y.ToString(); Master.Instance.ScreenResolution = data.ScreenResolution; foreach (Profile profile in data.Profiles) { TabPage tp = new TabPage(profile.Name); UControlContext context = new UControlContext(IntPtr.Zero, chkFullScreen.Checked); context.LoadData(profile.Data); tp.Controls.Add(context); tabUControl.TabPages.Add(tp); } } }
private void BtnPairProcess_Click(object sender, EventArgs e) { if (lbxProcess.SelectedIndex == -1 || lbxUControl.SelectedIndex == -1) { MessageBox.Show("Please select a process and control tab first!", "Error"); return; } TabPage tbp = tabUControl.TabPages[lbxUControl.SelectedIndex]; UControlContext context = (UControlContext)tbp.Controls[0]; IntPtr intPtr; if (lbxProcess.SelectedItem.ToString().Contains(" - paired")) { intPtr = new IntPtr(Convert.ToInt32(lbxProcess.SelectedItem.ToString().Replace(" - paired", string.Empty))); } else { intPtr = (IntPtr)lbxProcess.SelectedItem; } if (chkFullScreen.Checked) { User32.ShowWindow(intPtr, AutoClickHandlers.SW_MAXIMIZED); } context.InitIntPtr(intPtr); TabUControl_ControlChanged(null, null); }
private List <Profile> GetTabsData() { List <Profile> allData = new List <Profile>(); foreach (TabPage tbp in tabUControl.TabPages) { Profile data = new Profile { Name = tbp.Text }; UControlContext context = (UControlContext)tbp.Controls[0]; data.Data = context.GetSettingsData(); allData.Add(data); } return(allData); }
private void TabUControl_ControlChanged(object sender, ControlEventArgs e) { lbxProcess.Items.Clear(); List <IntPtr> hWnds = User32.GetListWinHandleByWindowTitle(txtClientName.Text); hWnds.ForEach(hWnd => lbxProcess.Items.Add(hWnd)); lbxUControl.Items.Clear(); foreach (TabPage tbp in tabUControl.TabPages) { UControlContext context = (UControlContext)tbp.Controls[0]; lbxUControl.Items.Add($"{tbp.Text} ({context.HWnd})"); if (!hWnds.Contains(context.HWnd)) { context.Final(); } else { lbxProcess.Items.Remove(context.HWnd); lbxProcess.Items.Add($"{context.HWnd} - paired"); } } }
public abstract void SwitchState(UControlContext context);
public override void SwitchState(UControlContext context) { context.State = new ContextRunningState(_pottingStrategy, _buffStrategy, _attackingStrategy, _refillPotStrategy, _pickItemStrategy); context.State.Attach(_observers); context.State.Notify(); }