yschmitzz Posted June 10, 2012 at 06:05 AM Report Share #461729 Posted June 10, 2012 at 06:05 AM (edited) é 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 June 10, 2012 at 06:11 AM by yschmitzz Link to comment Share on other sites More sharing options...
petvetbr Posted June 10, 2012 at 11:29 AM Report Share #461744 Posted June 10, 2012 at 11:29 AM Você poderia colocar o código? Você não deveria precisar instanciar um novo objeto, pois isto já é feito para você quando abre uma janela. Acho que talvez esteja um pouco confuso sobre como trabalhar com o WPF e a manipulação de telas que é realmente um pouco diferente de Winforms. Fernando Lage Bastos - MCP/MCTS/MCPD Link to comment Share on other sites More sharing options...
yschmitzz Posted June 12, 2012 at 03:49 AM Author Report Share #462095 Posted June 12, 2012 at 03:49 AM 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 More sharing options...
petvetbr Posted June 12, 2012 at 09:15 AM Report Share #462111 Posted June 12, 2012 at 09:15 AM No método BaixarArquivo por exemplo, ao invés de criar uma nova mainwindow o certo seria passar a mainwindow como parâmetro. Ficaria algo como BaixarArquivo(MainWindow mwindow,.... 1 Report Fernando Lage Bastos - MCP/MCTS/MCPD Link to comment Share on other sites More sharing options...
yschmitzz Posted June 18, 2012 at 04:58 AM Author Report Share #463570 Posted June 18, 2012 at 04:58 AM ae quando chamar o metodo baixarArquivo chamo da seguinte maneira, baixarArquivo(new MainWindow) ?? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now