Jump to content

Crio um objeto da classe principal, aparece outro form


yschmitzz

Recommended Posts

é o seguinte, criei um aplicativo usando o wtf xaml, so que ainda estou com dificuldades, por nao ter acesso ao codigo em c# a edição dele fica muito dificil, crio um objeto da classe principal xaml para poder manipular os componentes dela (texbox botao...) so que quando crio o objeto, cria outra janela, alguem sabe como resolver isso, as classes estao tudo em uma só, uma verdadeira bagunça

Edited by yschmitzz
Link to comment
Share on other sites

namespace DartagnanLauncher {
   class BaixarArquivo {
    public void baixarArquivo(String inexistenteFile, String salvarClient) {
	    WebClient Client = new WebClient();
	    MainWindow main = new MainWindow();

	    try {
		    main.textBox1.Text = main.textBox1.Text + "Baixnado de: http://localhost:8090/UPDATES" + inexistenteFile + @salvarClient +"\n";
		    Client.DownloadFile("http://localhost:8090/UPDATES" + inexistenteFile, @salvarClient);
	    } catch (WebException) {
		    main.textBox1.Text = main.textBox1.Text + "Erro ao fazer o download/n";
	    }
    }
   }
}

acontece que quando crio o objeto para poder acessar os componentes da classe, ele cria outra janela, pensei em criar uma classe so com variaveis, mas nao tenho acesso ao codigo em C# do wpf, xaml (nao sei ao certo se é possivel isso)

realmente, estou com muitas duvidas quando a wpf, xaml, tanto que nem sei a diferença do wpf para xaml rsrs)

quanto a classe principal é isso aqui, nao tem nada de mais

public partial class MainWindow{
    public static WebClient Client;
    public static String client;
    public static String servidor;
    public static String arquivo;

    public MainWindow() {
	    InitializeComponent();

    }
    private void Button_Click(object sender, RoutedEventArgs e) {
	    try {
		    WebClient Client = new WebClient();
		    Stream update = Client.OpenRead("http://localhost:8090/UPDATES/update.txt");
		    StreamReader sr3 = new StreamReader(update);
		    StreamReader srline3 = new StreamReader(update);
		    String arquivo = sr3.ReadLine();
		    String nLinhas = srline3.ReadLine();
		    String client;
		    String servidor;
		    int p1Limite = 0;
		    int p1Valor = 0;
		    while (nLinhas != null) {
			    p1Limite++;
			    srline3.ReadLine();
		    }
		    progressBar1.Maximum = p1Limite;
		    while (arquivo != null) {
			    p1Valor++;
			    client = "c:/l2" + arquivo;
			    servidor = "c:/xampp/htdocs/UPDATES" + arquivo;
			    compararRapido(client, servidor, arquivo);
			    arquivo = sr3.ReadLine();
			    progressBar1.Value = p1Valor;
		    }
	    } catch (Exception) {
	    }
    }
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.