public MainF() { InitializeComponent(); Width = Screen.PrimaryScreen.Bounds.Width; Height = Screen.PrimaryScreen.Bounds.Height; Top = 0; Left = 0; if (Program.settings.Count > 0) { Program.set_entry temp = Get_nearlest_back(); Program.current_settings = new Program.set_entry(temp.hour, temp.minute, temp.len, temp.option); } else { Program.current_settings = new Program.set_entry(0, 0, 180, (Program.set_opt_enum) 255); } if (Program.current_settings.option.HasFlag(Program.set_opt_enum.AnswerKeyboard)) { HookKeyboard.HookK.Hook_workmode = 1; HookKeyboard.HookK.Hook_active = true; } if (Program.current_settings.option.HasFlag(Program.set_opt_enum.AnswerMouse) || Program.current_settings.option.HasFlag(Program.set_opt_enum.AnswerKeyboard)) { timer1.Start(); } timer3.Start(); }
Program.set_entry Get_nearlest_back() { DateTime c = DateTime.Now; short diff, min = 3; Program.set_entry min_o = null; for (byte i = 0; i < Program.settings.Count; i++) { diff = (short)((Program.settings[i].hour * 60 + Program.settings[i].minute) - (c.Hour * 60 + c.Minute)); if (diff >= 0 && diff < min) { min = diff; min_o = Program.settings[i]; } } if (min <= 2) { return(min_o); } min = 3; for (byte i = 0; i < Program.settings.Count; i++) { diff = (short)(1439 - (c.Hour * 60 + c.Minute)); if (diff >= 0 && diff < min) { min = diff; } } if (min <= 2) { min = 3; for (byte i = 0; i < Program.settings.Count; i++) { diff = (short)(Program.settings[i].hour * 60 + Program.settings[i].minute); if (diff < min) { min = diff; min_o = Program.settings[i]; } } if (min <= 2) { return(min_o); } } min = 1440; for (byte i = 0; i < Program.settings.Count; i++) { diff = (short)((c.Hour * 60 + c.Minute) - (Program.settings[i].hour * 60 + Program.settings[i].minute)); if (diff >= 0 && diff < min) { min = diff; min_o = Program.settings[i]; } } if (min != 1440) { return(min_o); } for (byte i = 0; i < Program.settings.Count; i++) { diff = (short)(1439 - (Program.settings[i].hour * 60 + Program.settings[i].minute)); if (diff >= 0 && diff < min) { min = diff; min_o = Program.settings[i]; } } return(min_o); }