public DownloadFile(ClientLogic clientLogic, string root, string nameFile, Boolean searchPass, MainWindow mainw, String idFile) { try { InitializeComponent(); mw = mainw; clientlogic = clientLogic; search = searchPass; folder = root; namefile = nameFile; completePath = folder + @"\" + namefile; App.Current.MainWindow.Width = 600; App.Current.MainWindow.Height = 430; clientLogic.WriteStringOnStream(ClientLogic.GETVFILE + clientLogic.username + "+" + folder + "+" + completePath + "+" + idFile); String retFiles; Boolean exit = false; while (!exit) { retFiles = clientLogic.ReadStringFromStream(); String[] parametri = retFiles.Split('+'); String comando = parametri[1]; if (comando.Equals("FLP")) { addElementToListbox(parametri[3]); clientlogic.WriteStringOnStream(ClientLogic.OK); } else if (comando.Equals("ENDLIST") || comando.Equals("INFO")) { exit = true; } else { exit = true; } } if (!search) addElementToListbox("..."); } catch { if (App.Current.MainWindow is Restore) App.Current.MainWindow.Close(); if (clientLogic.clientsocket.Client.Connected) { clientLogic.clientsocket.GetStream().Close(); clientLogic.clientsocket.Close(); } App.Current.MainWindow = mainw; MainControl main = new MainControl(1); App.Current.MainWindow.Content = main; return; } }
public RestoreUC(ClientLogic clientLogic, MainWindow mainw) { try { InitializeComponent(); clientlogic = clientLogic; mw = mainw; App.Current.MainWindow.Width = 400; App.Current.MainWindow.Height = 400; clientLogic.WriteStringOnStream(ClientLogic.GETFOLDERUSER + clientLogic.username); String retFolders = clientLogic.ReadStringFromStream(); String[] parametri = retFolders.Split('+'); String comando = parametri[1]; if (comando.Equals("OK")) { String[] folders = parametri[2].Split(';'); int numParametri = folders.Length; if (numParametri > 1) { noFolder.Visibility = Visibility.Hidden; for (int i = 0; i < numParametri; i++) { if (folders[i] != string.Empty) { addElementToListbox(folders[i]); } } } else { noFolder.Visibility = Visibility.Visible; } } else { if (App.Current.MainWindow is Restore) App.Current.MainWindow.Close(); if (clientLogic.clientsocket.Client.Connected) { clientLogic.clientsocket.GetStream().Close(); clientLogic.clientsocket.Close(); } App.Current.MainWindow = mainw; MainControl main = new MainControl(1); App.Current.MainWindow.Content = main; return; } } catch { if (App.Current.MainWindow is Restore) App.Current.MainWindow.Close(); if (clientLogic.clientsocket.Client.Connected) { clientLogic.clientsocket.GetStream().Close(); clientLogic.clientsocket.Close(); } App.Current.MainWindow = mainw; MainControl main = new MainControl(1); App.Current.MainWindow.Content = main; return; } }
public FileSelection(ClientLogic clientLogic, string folder, string likeNomePass, Boolean searchBar, MainWindow mainw) { try { InitializeComponent(); mw = mainw; listElement = new List<string>(); search = searchBar; selFolderPath = folder; likeNome = likeNomePass; clientlogic = clientLogic; App.Current.MainWindow.Width = 600; App.Current.MainWindow.Height = 430; clientLogic.WriteStringOnStream(ClientLogic.LISTFILES + clientLogic.username + "+" + folder + "+" + likeNome); String retFiles; Boolean exit = false; Boolean fine = false; while (!exit) { retFiles = clientLogic.ReadStringFromStream(); String[] parametri = retFiles.Split('+'); String comando = parametri[1]; if (comando.Equals("FLP")) { noFile.Visibility = Visibility.Hidden; addElementToListbox(parametri[3]); clientlogic.WriteStringOnStream(ClientLogic.OK); } else if (comando.Equals("ENDLIST") || comando.Equals("INFO")) { exit = true; } else { exit = true; fine = true; } } if (fine) { App.Current.MainWindow.Close(); } if (!likeNome.Equals(String.Empty) && !search) { addElementToListbox("..."); } } catch (Exception) { if (App.Current.MainWindow is Restore) App.Current.MainWindow.Close(); if (clientLogic.clientsocket.Client.Connected) { clientLogic.clientsocket.GetStream().Close(); clientLogic.clientsocket.Close(); } App.Current.MainWindow = mainw; MainControl main = new MainControl(1); App.Current.MainWindow.Content = main; return; } }