public void TestCloseWindow() { WindowHandler handler = new WindowHandler(); handler.Handle = (IntPtr)0x120c8; handler.CloseWindow(); }
private void ColliderOnMouseOver(object sender, EventArgs e) { var MousePosition = WindowHandler.GetMousePositionRelativeToWindow(); var TextPosition = new Vector2f(MousePosition.X + 20, MousePosition.Y); _text.Position = TextPosition; }
/// <summary> /// Initializes the bot by creating a new WindowHandler and adding it as a tab to the ClientWindow /// </summary> /// <param name="cw">A reference to the ClientWindow</param> public void initializeBot(ClientWindow cw) { bot = new WindowHandler(cw); bot.bringToFront(); bot.setTopLevel(false); bot.setVisible(true); bot.setFormBorderStyle(FormBorderStyle.None); bot.setDockStyle(DockStyle.Fill); cw.tabControl1.TabPages[0].Controls.Add(bot); cw.tabControl1.TabPages[0].Text = "Bot"; /* * backgroundScripts = new List<Scriptable>(); * Script.Scripts.InterfaceCloser icloser = new Script.Scripts.InterfaceCloser(); * icloser.initializeInputs(bot); * backgroundScripts.Add(icloser); */ this.cw = cw; //DEBUGGING STUFF //com = new Communicator("\\\\.\\pipe\\TestChannel"); menuHandler = new MenuHandler(bot.MOUSE, bot.PMOUSE, bot.COMMUNICATOR, bot.KEYBOARD); over = new OverviewHandler(bot.MENU, bot.MOUSE, bot.PMOUSE, bot.COMMUNICATOR); }
//Copied from https://github.com/SFML/SFML/wiki/Source%3A-Letterbox-effect-using-a-view private void ForceAspectRatio() { var ViewSize = _camera.GetSize(); var Window = WindowHandler.GetWindow().Size; var WindowRatio = Window.X / (float)Window.Y; var ViewRatio = ViewSize.X / (float)ViewSize.Y; float SizeX = 1; float SizeY = 1; float PosX = 0; float PosY = 0; var HorizontalSpacing = !(WindowRatio < ViewRatio); if (HorizontalSpacing) { SizeX = ViewRatio / WindowRatio; PosX = (1 - SizeX) / 2f; } else { SizeY = WindowRatio / ViewRatio; PosY = (1 - SizeY) / 2f; } _camera.CameraView.Viewport = new FloatRect(PosX, PosY, SizeX, SizeY); }
private void RemoveFile(TreeNode node, bool bDelete = false) { if (node == null) { return; } TreeNode parent = node.Parent; if (parent == null || (node.Nodes.Count > 0)) { return; } string path = ProjectUtils.GetFilePathForTreeNodeItem(node.Parent.Text, node.Text); if (ProjectUtils.RemoveFile(node.Text, node.Parent.Text)) { WindowHandler.DeregisterWindow(node.Text, node.Parent.Text); parent.Nodes.Remove(node); if (bDelete && File.Exists(path)) { try { File.Delete(path); } catch { LoggingUtils.LogEvent(string.Format("Unable to delete file {0}!", path)); } } } }
//Login Panel algin to center of the screen private void FormSetup() { lblTime.Text = WindowHandler.PresentTime(); lblTime.Top = Screen.PrimaryScreen.WorkingArea.Height - 5; lblBeta.Top = lblTime.Top; lblBeta.Left = Screen.PrimaryScreen.WorkingArea.Width - 80; pnlLogin.Left = Screen.PrimaryScreen.WorkingArea.Width / 2 - (pnlLogin.Width / 2); pnlLogin.Top = Screen.PrimaryScreen.WorkingArea.Height / 2 - (pnlLogin.Top / 2); pnlSetup.Left = pnlLogin.Left; pnlSetup.Top = pnlLogin.Top + pnlLogin.Height + 30; lblClose.Left = Screen.PrimaryScreen.WorkingArea.Width - 25; connection = SystemRegistryHandler.ReadRegistry(ProjectConstants.ProjectName, "Connection", EncryptionOptions.NoEncryption); if (connection == null) { txtServerAndSQL.Text = Environment.MachineName + "\\SQLEXPRESS"; pnlSetup.Visible = true; HeadingVisibility(false); } else { HeadingVisibility(true); } }
internal void CheckMine() { string imgPath = $"{_imgDirPath}{_imgNameMine}"; Console.WriteLine("-> Starting to check the mine..."); if (!File.Exists(imgPath)) { ConsoleWriter.WriteLineWarning($"Cannot find file {imgPath}. Phase skipped."); Thread.Sleep(500); return; } WindowHandler.RepositionRaidWindow(raidProcessId); MouseHandler.SetCursorPosition(0, 0); Bitmap bitmapTemoin = new Bitmap(imgPath); Bitmap bitmapTest = ImgHandler.GetBitmap(_recMine); if (!ImgHandler.AreBitmapsDifferent(bitmapTemoin, bitmapTest, RaidOptions.SavePicturesAllowed)) { ConsoleWriter.WriteLineInformation("New gems found. Let's get them."); MouseHandler.MouseClick(823, 404); } else { Console.WriteLine("No gems found."); Thread.Sleep(100); } }
private static void GameLoop() { var Window = WindowHandler.Initialize(); var GUI = GUIHandler.Initialize(); var Clock = new Clock(); new BasicScene(); while (Window.IsOpen) { Window.DispatchEvents(); Window.Clear(); WorldCollision.CheckCollision(); World.UpdateEntities(); GlobalConsole.DrawConsole(); DrawableHandler.Draw(); InputHandler.UpdateInputs(); GUI.Draw(); Window.Display(); var DeltaClock = Clock.Restart(); deltaTime = DeltaClock.AsSeconds(); } }
internal void CheckMarket() { string imgPath = $"{_imgDirPath}{_imgMarket}"; string word = string.Empty; Console.WriteLine("-> Starting to check the market..."); if (!File.Exists(imgPath)) { ConsoleWriter.WriteLineWarning($"Cannot find file {imgPath}. Phase skipped."); Thread.Sleep(500); return; } WindowHandler.RepositionRaidWindow(raidProcessId); MouseHandler.SetCursorPosition(0, 0); Bitmap bitmapTemoin = new Bitmap(imgPath); Bitmap bitmapTest = ImgHandler.GetBitmap(_recMarket); if (!ImgHandler.AreBitmapsDifferent(bitmapTemoin, bitmapTest, RaidOptions.SavePicturesAllowed)) { ConsoleWriter.WriteLineInformation("Update detected. Let's go and search for shards !"); Console.WriteLine("Maybe later..."); //MouseHandler.MouseClick(1161, 515); Thread.Sleep(800); } else { Console.WriteLine("No update detected."); Thread.Sleep(100); } }
internal bool ShowBastion() { string battlePath = $"{_imgDirPath}{_imgNameBattle}"; if (!File.Exists(battlePath)) { ConsoleWriter.WriteLineError($"Cannot find file {battlePath}"); return(false); } MouseHandler.SetCursorPosition(0, 0); Bitmap bitmapTemoin = new Bitmap(battlePath); int c = 0; debut: WindowHandler.RepositionRaidWindow(raidProcessId); if (c > 20) { throw new Exception("Cannot find the bastion. Number of attempts failed."); } Bitmap bitmapTest = ImgHandler.GetBitmap(_recBattle); if (ImgHandler.AreBitmapsDifferent(bitmapTemoin, bitmapTest, RaidOptions.SavePicturesAllowed)) { KeyBoardHandler.SendKey(KEY_ESCAPE); Thread.Sleep(2000); c++; goto debut; } return(true); }
public override void Update() { var Window = WindowHandler.GetWindow(); var MousePosition = SFML.Window.Mouse.GetPosition(Window); var ViewSize = Window.Size; Window.MouseWheelScrolled += RTSCamera_MouseWheelScrolled; if (MousePosition.X >= 0 && MousePosition.X < _scrollWidth) { Entity.Transform.Position.X -= _scrollSpeed * GameTime.deltaTime; } else if (MousePosition.X <= ViewSize.X && MousePosition.X > ViewSize.X - _scrollWidth) { Entity.Transform.Position.X += _scrollSpeed * GameTime.deltaTime; } if (MousePosition.Y >= 0 && MousePosition.Y < _scrollWidth) { Entity.Transform.Position.Y -= _scrollSpeed * GameTime.deltaTime; } else if (MousePosition.Y <= ViewSize.Y && MousePosition.Y > ViewSize.Y - _scrollWidth) { Entity.Transform.Position.Y += _scrollSpeed * GameTime.deltaTime; } }
public static void RefreshVideoSources() { AvailableVideoSources.Clear(); switch (SelectedVideoSourceKind) { case VideoSourceKind.Window: AvailableVideoSources.Add(WindowVSLI.Desktop); AvailableVideoSources.Add(WindowVSLI.TaskBar); foreach (var win in WindowHandler.EnumerateVisible()) { AvailableVideoSources.Add(new WindowVSLI(win.Handle)); } break; case VideoSourceKind.Screen: foreach (var Screen in ScreenVSLI.Enumerate()) { AvailableVideoSources.Add(Screen); } break; } if (Instance != null && SelectedVideoSourceKind != VideoSourceKind.NoVideo) { Instance.VideoSourceBox.SelectedIndex = 0; } }
public void SwaptoParent() { var MainWindow = ""; object MethodName = WindowHandler.SwapToParentWindow(_driver, MainWindow); dict.TryCatch("SwapToParentWindowTest", "Test moves to Main Window", "Windows", ref MethodName, "The Current Window is accurate", "Test is beginning. Time is :" + DateTime.Now.ToString("h:mm:ss tt")); }
public void getChatterFeed(string id, WindowHandler handler) { if (sf.token != null) { StartCoroutine(getChatter(id, handler)); } }
/// <summary> /// Initializes a new instance of the <see cref="LeagueAPI"/> class. /// </summary> /// <param name="port">The league client API's port.</param> /// <param name="token">The authentication token.</param> /// <param name="eventHandler">The event handler.</param> private PykeAPI(int port, string token, Websocket.ILeagueEventHandler eventHandler, LeagueProcessHandler _pHandler, LockFileHandler _lfHandler, Logger logger) { this.logger = logger; _processHandler = _pHandler; _lockFileHandler = _lfHandler; EventHandler = eventHandler; RequestHandler = new LeagueRequestHandler(port, token, this); RiotClientEndpoint = new RiotClientEndpoint(RequestHandler); ProcessControlEndpoint = new ProcessControlEndpoint(RequestHandler); _processHandler.Exited += OnDisconnected; cProc = Process.GetProcessById(ProcessId); _processHandler = new LeagueProcessHandler(); _lockFileHandler = new LockFileHandler(); ChampSelect = new ChampSelect.ChampSelect(this); Events = new LeagueEvents(this); Gameflow = new ClientGameflow(this); MatchMaker = new MatchMaker(this); ClientInfo = new ClientInformation(this); Login = new Login.Login(this); Summoners = new Summoners.Summoners(this); WindowHandler = new Window.WindowHandler(this); Lobby = new ClientLobby(this); Champions = JsonConvert.DeserializeObject <ChampionInfo>(new WebClient().DownloadString("https://ddragon.leagueoflegends.com/cdn/10.16.1/data/en_US/champion.json"), Converter.Settings).Data.Values.ToList(); logger.Information("Pyke Ready"); PykeReady?.Invoke(this, this); }
private void chkDisagree_Click(object sender, EventArgs e) { if (chkDisagree.Checked) { WindowHandler.LoadNewForm(new frmLogin(), this); } }
public void WindowHandler_Setup() { var windowFactory = new Window.Factory(); var camera = SceneView.GetAllSceneCameras().FirstOrDefault(); var mockHandler = new WindowHandler(windowFactory, camera); Assert.IsNotNull(mockHandler); }
protected override void OnBeginDrag() { WindowHandler.OnBeginDrag(); IsShiftKeyDown = CheckShiftKeyDown(); _floatingPreviewStartBounds = _source.GetFloatingWindowPreview(WindowHandler.PreviewStartMousePosition); _floatingWindowStartBounds = WindowHandler.GetFloatingWindowBounds(_floatingPreviewStartBounds); TestDrop(); }
/// <summary> /// Removes the handler. /// </summary> /// <param name="handler">The handler.</param> public void RemoveHandler(WindowHandler handler) { if (handler == null) { throw new ArgumentNullException("handler"); } handlers.Remove(handler); }
public Station(WindowHandler wh) { this.m = wh.MOUSE; this.pm = wh.PMOUSE; this.mh = wh.MENU; this.com = wh.COMMUNICATOR; ran = new Random(); }
public DrawableScreen(ClientWindow cw, WindowHandler wh) : base() { this.wh = wh; this.cw = cw; pm = wh.PMOUSE; m = wh.MOUSE; //DoubleBuffered = true; }
private void GameWindow_RenderFrame(FrameEventArgs obj) { GL.Viewport(0, 0, Width, Height); WindowHandler?.Render((float)obj.Time); gameWindow.SwapBuffers(); }
public MainWindow() { InitializeComponent(); var wpfApp = (App)Application.Current; handler = new WindowHandler(this, wpfApp.Settings); }
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { _timer = new Timer(TimerCallback, null, TimeSpan.FromMilliseconds(400), TimeSpan.FromMilliseconds(400)); string windowName = "Path Of Exile"; _windowHandler = new WindowHandler(windowName); _gameWindowCapturer = new GameWindowCapturer(_windowHandler); }
private void GameWindow_Load() { gameWindow.MakeCurrent(); Size = new Vector2i(gameWindow.ClientSize.X, gameWindow.ClientSize.Y); WindowHandler?.Load(); }
public AddressBook(WindowHandler wh) { this.com = wh.COMMUNICATOR; this.kb = wh.KEYBOARD; m = wh.MOUSE; pm = wh.PMOUSE; this.wh = wh; }
void EventAggHub <OpenReasonInfo, ReasonDto> .ISubscribed.OnEvent(ReasonDto value) { var data = new Dictionary <string, object> { { "Reason", value } }; WindowHandler.OpenWindow(WindowType.ReasonInfo, data); }
public OverviewHandler(WindowHandler wh) { this.m = wh.MOUSE; this.pm = wh.PMOUSE; this.comm = wh.COMMUNICATOR; this.mh = wh.MENU; entries = new List <OverViewEntry>(); ran = new Random(); }
public WaitingWindow(WindowHandler windowHandler) { _windowHandler = windowHandler; _kinectHandler = _windowHandler.Game.KinectHandler; _spriteBatch = new SpriteBatch(_windowHandler.Game.GraphicsDevice); _spriteFont = Game1.contentManager.Load<SpriteFont>(@"MyFont"); startTimer = 0; _waitString = "Waiting for player"; }
public Ship(WindowHandler wh) { overviewhandler = wh.OVERVIEW; com = wh.COMMUNICATOR; menu = wh.MENU; pm = wh.PMOUSE; m = wh.MOUSE; kb = wh.KEYBOARD; }
public PriceAndCostRepository(GridRepository gridRepository) { wallHandler = new WallHandler(gridRepository); windowHandler = new WindowHandler(gridRepository); wallBeamHandler = new WallBeamHandler(gridRepository); doorHandler = new DoorHandler(gridRepository); decorativeColumnHandler = new DecorativeColumnHandler(gridRepository); this._context = new DatabaseContext(); }
public static WindowHandler Instance() { if (!_windowHandler) { _windowHandler = FindObjectOfType(typeof(WindowHandler)) as WindowHandler; if (!_windowHandler) Debug.LogError("There needs to be one active WindowHandler script on a GameObject in your scene."); } return _windowHandler; }
public LevelSelectWindow(WindowHandler windowHandler) { _windowHandler = windowHandler; GraphicsDevice graphicsDevice = _windowHandler.Game.GraphicsDevice; _spriteBatch = new SpriteBatch(graphicsDevice); _camera = new Camera2D(graphicsDevice); _spriteList = new List<Sprite>(); _background = new Sprite(Game1.contentManager.Load<Texture2D>(@"Images\LevelSelectMan")); float windowScaleRatio = graphicsDevice.Viewport.Height / _background.OriginalSize.Y; _background.Scale = new Vector2(windowScaleRatio / START_ZOOM); _background.CenterOrigin(); _background.Position = Utils.GetScreenCenter(graphicsDevice); _dot = new Sprite(Game1.contentManager.Load<Texture2D>(@"Images\Dot")); _dot.CenterOrigin(); _dot.Color = Color.DarkRed; _spriteList.Add(_background); Vector2 imageScaledSize = _background.ScaledSize / 2; HEART_POSITION = Utils.GetScreenCenter(graphicsDevice); KNEE_POSITION = Utils.GetScreenCenter(graphicsDevice); NECK_POSITION = Utils.GetScreenCenter(graphicsDevice); BRAIN_POSITION = Utils.GetScreenCenter(graphicsDevice); HEART_POSITION.X += imageScaledSize.X * -0.005f; HEART_POSITION.Y += imageScaledSize.Y * -0.41f; KNEE_POSITION.X += imageScaledSize.X * 0.06f; KNEE_POSITION.Y += imageScaledSize.Y * 0.43f; NECK_POSITION.X += imageScaledSize.X * -0.01f; NECK_POSITION.Y += imageScaledSize.Y * -0.65f; BRAIN_POSITION.X += imageScaledSize.X * -0.01f; BRAIN_POSITION.Y += imageScaledSize.Y * -0.85f; BodyPartPositions[BodyPartType.BRAIN] = BRAIN_POSITION; BodyPartPositions[BodyPartType.HEART] = HEART_POSITION; BodyPartPositions[BodyPartType.NECK] = NECK_POSITION; BodyPartPositions[BodyPartType.KNEE] = KNEE_POSITION; }
public ScoreWindow(WindowHandler windowHandler) { _inputHelper = new KeyboardInputHelper(); _windowHandler = windowHandler; _spriteBatch = new SpriteBatch(_windowHandler.Game.GraphicsDevice); _titleFont = Game1.contentManager.Load<SpriteFont>(@"ScoreHeading"); _entryFont = Game1.contentManager.Load<SpriteFont>(@"ScoreEntries"); _titleString = "Snabbaste tiderna"; _background = new Sprite(Game1.contentManager.Load<Texture2D>(@"images\highscorebackground")); Vector2 scale; scale.X = _windowHandler.Game.GraphicsDevice.Viewport.Width / _background.OriginalSize.X; scale.Y = _windowHandler.Game.GraphicsDevice.Viewport.Height / _background.OriginalSize.Y; _background.Scale = scale; Vector2 stringDimensions = _titleFont.MeasureString(_titleString); _titlePosition = new Vector2((_windowHandler.Game.GraphicsDevice.Viewport.Width - stringDimensions.X) / 2, _windowHandler.Game.GraphicsDevice.Viewport.Height / 7); _entryPositions = new Vector2(_windowHandler.Game.GraphicsDevice.Viewport.Width / 4, (_windowHandler.Game.GraphicsDevice.Viewport.Height * 2) / 7); }
IEnumerator getChatter(string id, WindowHandler handler) { // Waiting two seconds to let the typing stop before calling out (causes hiccup in VR) yield return new WaitForSeconds(2f); sf.getChatterFeed (id); // wait for query results while(sf.response == null){ yield return new WaitForSeconds(0.1f); } Debug.Log ("Chatter Response from Salesforce: " + sf.response); JSONObject json = JSONObject.Parse(sf.response); JSONArray records = json.GetArray ("elements"); Debug.Log ("records = " + records); handler.setChatterArray(records); }
public void doApprovalProcess(string objectId, string processId, string action, WindowHandler handler) { string comment = (action == "Approve") ? "Approved via VRpportunity!" : "Rejected via VRpportunity!"; JSONObject request = new JSONObject(); request.Add ("actionType", action); request.Add ("contextId", processId); request.Add ("comments", comment); JSONArray requestArray = new JSONArray(); requestArray.Add (new JSONValue(request)); JSONObject jsonBody = new JSONObject(); jsonBody.Add ("requests", new JSONValue(requestArray)); string jsonProcess = jsonBody.ToString(); JSONObject chatter = new JSONObject(); chatter.Add ("feedElementType", "FeedItem"); chatter.Add ("subjectId", objectId); JSONObject chatterBody = new JSONObject(); chatterBody.Add ("type", "Text"); chatterBody.Add ("text", "Approval Process " + comment); JSONArray segments = new JSONArray(); segments.Add (new JSONValue(chatterBody)); JSONObject chatterSegments = new JSONObject(); chatterSegments.Add ("messageSegments", new JSONValue(segments)); chatter.Add ("body", new JSONValue(chatterSegments)); string jsonChatter = chatter.ToString (); StartCoroutine(handleApprovalProcess(jsonProcess, jsonChatter, handler)); }
public void initMain(JSONObject rec, WindowHandler inHandler) { JSONObject actor = rec.GetObject("actor"); string name = actor.GetString ("displayName"); nameText.text = name; JSONObject feedBody = rec.GetObject ("body"); string body = feedBody.GetString ("text"); if (body == null) { JSONObject header = rec.GetObject ("header"); body = header.GetString ("text"); } bodyText.text = body; JSONObject photo = actor.GetObject ("photo"); photoUrl = photo.GetString ("largePhotoUrl"); JSONObject capabilities = rec.GetObject ("capabilities"); JSONValue approval = capabilities.GetValue ("approval"); if (approval != null) { string id = approval.Obj.GetString ("id"); if (id != null) { enableApproval(approval.Obj.GetString ("id")); } } if (!isApproval) { approveButton.enabled = false; approveButton.GetComponent<CanvasRenderer>().SetAlpha(0); rejectButton.enabled = false; rejectButton.GetComponent<CanvasRenderer>().SetAlpha(0); } handler = inHandler; photoRetrieved = false; }
/* ============================================================================ Init functions ============================================================================ */ public void Init() { this.ClearData(); this.partyHandler = new PartyHandler(); if(Application.isPlaying) { if(this.levelHandler == null) { GameObject tmp = new GameObject("LevelHandler"); if(GUISystemType.ORK.Equals(DataHolder.GameSettings().guiSystemType)) { this.levelHandler = (LevelHandler)tmp.AddComponent("LevelHandler"); } else { this.levelHandler = (LevelHandlerGUI)tmp.AddComponent("LevelHandlerGUI"); } } if(this.musicHandler == null) { GameObject tmp = new GameObject("MusicHandler"); this.musicHandler = (MusicHandler)tmp.AddComponent("MusicHandler"); } if(this.dropHandler == null) { GameObject tmp = new GameObject("DropHandler"); this.dropHandler = (DropHandler)tmp.AddComponent("DropHandler"); this.dropHandler.ClearData(); } if(this.dragHandler == null) { GameObject tmp = new GameObject("DragHandler"); this.dragHandler = (DragHandler)tmp.AddComponent("DragHandler"); } if(this.windowHandler == null) { this.windowHandler = new WindowHandler(); } if(this.guiHandler == null) { GameObject tmp = new GameObject("GUIHandler"); this.guiHandler = (GUIHandler)tmp.AddComponent("GUIHandler"); } } }
void Start() { _windowHandler = GameObject.FindGameObjectWithTag(Constants.Tags.WindowManager).GetComponent<WindowHandler>(); //PlayerPrefsBool.SetBool("Pack", false); //PlayerPrefsBool.SetBool("Pack (1)", false); //PlayerPrefsBool.SetBool("Pack (2)", false); //PlayerPrefsBool.SetBool("Pack (3)", false); //PlayerPrefsBool.SetBool("Pack (4)", false); //PlayerPrefsBool.SetBool("Pack (5)", false); //PlayerPrefsBool.SetBool("Pack123", false); //PlayerPrefsBool.SetBool("Pack456", false); //PlayerPrefsBool.SetBool("PackAll", false); }
IEnumerator handleApprovalProcess(string processBody, string chatterBody, WindowHandler handler) { sf.handleApprovalProcess (processBody); // wait for query results while(sf.response == null){ yield return new WaitForSeconds(0.1f); } Debug.Log ("Process Response from Salesforce: " + sf.response); sf.postToChatter (chatterBody); // wait for query results while(sf.response == null){ yield return new WaitForSeconds(0.1f); } Debug.Log ("Chatter Post Response from Salesforce: " + sf.response); handler.reloadChatter(); }
public ProgressionSelectWindow(WindowHandler windowHandler) : base(windowHandler) { _bodyParts.OrderBy(o => o.LevelNumber); }
public WindowVSLI(IntPtr hWnd) { this.Handle = hWnd; Name = new WindowHandler(Handle).Title; }
private void Awake() { // DontDestroyOnLoad(this.gameObject); _windowHandler = GameObject.FindGameObjectWithTag(Constants.Tags.WindowManager).GetComponent<WindowHandler>(); try { LoadData(); } catch (Exception) { _windowHandler.CreateStaticDialog("Phrases/Error", "Phrases/CouldNotLoadDatabaseReinstall"); } }
private void iniciarContador() { int segundosPermitidos = minutosPermitidos*60; bool preavisoMostrado = false; while (segundosTranscurridos < segundosPermitidos) { string cadenaTiempo = File.ReadAllText(rutaControlTiempo); segundosTranscurridos = int.Parse(cadenaTiempo.Substring(cadenaTiempo.IndexOf("-")+1)) + 1; cadenaTiempo = DateTime.Now.Date.ToShortDateString() + "-" + segundosTranscurridos; File.WriteAllText(rutaControlTiempo, cadenaTiempo); this.mostrarTiempoTranscurrido( formatearSegundos( segundosTranscurridos)); this.mostrarTiempoRestante(formatearSegundos((minutosPermitidos * 60) - segundosTranscurridos)); //si faltan 2 minutos para terminar tiempo if (segundosPermitidos - segundosTranscurridos < segundosParaPreaviso && preavisoMostrado == false) { WindowHandler manejador = new WindowHandler(); System.Diagnostics.Process[] procesos = System.Diagnostics.Process.GetProcesses(); IntPtr handle; foreach (System.Diagnostics.Process proceso in procesos) { handle = proceso.MainWindowHandle; if (handle != IntPtr.Zero) manejador.Minimize((int)handle); } int hand = manejador.getIdManejadorVentana("system"); manejador.Maximize(hand); preavisoMostrado = true; } Thread.Sleep(1000); } denegarAcceso(); CierraAplicaciones.cerrarNavegadoresAbiertos(); formularioPrincipal.Close(); }