domingo, 15 de setembro de 2013

c# - timer - Monitorar dois monitores

c# - timer - Monitorar dois monitores





using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO; 
 // esse using é obrigatorio para usar funcoes arquivo
 
namespace monitor
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            mostra_tela();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
 
        }
 
        public void mostra_tela()
        {
            // Verifica se arquivo existe
            if (File.Exists("c:\\matwin\\encerra.txt")) 
            {
                string arquivo = "c:\\matwin\\encerra.txt";
                StreamReader sr = new StreamReader(arquivo, Encoding.UTF8);
                listBox_mostra.Items.Clear(); // limpa conteudo do listbox
                string linha = sr.ReadLine();
                //Enquanto a variavel linha for diferente de null (nulo) ...
                while (linha != null) 
                {
                    listBox_mostra.Items.Add(linha);
                    linha = sr.ReadLine(); // Lê a prox linhha...
                }
                sr.Close();
            }
            else
            {
                listBox_mostra.Items.Clear();
                listBox_mostra.Items.Add("Esperando Encerramento");
                // Caso nao existir o arquivo 
            }
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            mostra_tela(); // funcao timer chama mostra_Tela
        }
 
        private void listBox_mostra_SelectedIndexChanged(object sender, EventArgs e)
        {
 
        }
 
    }
}

Nenhum comentário:

Postar um comentário