private void File_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                FileSelection w = new FileSelection(clientLogic, folderRoot, "", false, ((Restore)App.Current.MainWindow).mw);
                if (App.Current.MainWindow is Restore)
                    App.Current.MainWindow.Content = w;
            }
            catch
            {
                if (App.Current.MainWindow is Restore)
                    App.Current.MainWindow.Close();
                App.Current.MainWindow = mw;
                if (mw.clientLogic.clientsocket.Connected)
                {
                    mw.clientLogic.clientsocket.GetStream().Close();
                    mw.clientLogic.clientsocket.Close();
                }
                MainControl main = new MainControl(1);
                App.Current.MainWindow.Content = main;

            }

        }
 private void Home_Click(object sender, RoutedEventArgs e)
 {
     FileSelection main = new FileSelection(clientlogic, folder, "", false, mw);
     if (App.Current.MainWindow is Restore)
         App.Current.MainWindow.Content = main;
 }
        private void item_MouseDoubleClickBack(object sender, MouseButtonEventArgs e)
        {
            if (ListBox.SelectedIndex == -1)
                return;

            ListBoxItem selectedItem = this.ListBox.ItemContainerGenerator.ContainerFromIndex(ListBox.SelectedIndex) as ListBoxItem;

            if (selectedItem == null)
                return;

            if (ListBox.SelectedItem != null)
            {
                FileSelection main;
                Label nameBox = clientlogic.FindDescendant<Label>(selectedItem);

                if (namefile.Contains(@"\"))
                {
                    namefile = namefile.Substring(0, namefile.LastIndexOf(@"\") + 1);
                    main = new FileSelection(clientlogic, folder, namefile, false, mw);
                }
                else
                    main = new FileSelection(clientlogic, folder, "", false, mw);

                if (App.Current.MainWindow is Restore)
                    App.Current.MainWindow.Content = main;

            }
        }
 private void Home_Click(object sender, RoutedEventArgs e)
 {
     likeNome = "";
     FileSelection main = new FileSelection(clientlogic, selFolderPath, likeNome, false, ((Restore)App.Current.MainWindow).mw);
     if (App.Current.MainWindow is Restore)
         App.Current.MainWindow.Content = main;
 }
        private void Search_Click(object sender, RoutedEventArgs e)
        {
            if (SearchBar.Text.Length == 0)
            {
                likeNome = "";
                FileSelection main = new FileSelection(clientlogic, selFolderPath, likeNome, false, ((Restore)App.Current.MainWindow).mw);
                if (App.Current.MainWindow is Restore)
                    App.Current.MainWindow.Content = main;
            }
            else
            {
                likeNome = SearchBar.Text;
                FileSelection main = new FileSelection(clientlogic, selFolderPath, likeNome, true, ((Restore)App.Current.MainWindow).mw);
                if (App.Current.MainWindow is Restore)
                    App.Current.MainWindow.Content = main;
            }

        }
        private void item_MouseDoubleClickFolder(object sender, MouseButtonEventArgs e)
        {
            if (ListBox.SelectedIndex == -1)
                return;

            ListBoxItem selectedItem = this.ListBox.ItemContainerGenerator.ContainerFromIndex(ListBox.SelectedIndex) as ListBoxItem;

            if (selectedItem == null)
                return;

            if (ListBox.SelectedItem != null)
            {
                Label nameBox = clientlogic.FindDescendant<Label>(selectedItem);
                likeNome += nameBox.Content.ToString() + "\\";
                FileSelection main = new FileSelection(clientlogic, selFolderPath, likeNome, false, ((Restore)App.Current.MainWindow).mw);
                if (App.Current.MainWindow is Restore)
                    App.Current.MainWindow.Content = main;

            }
        }
        private void item_MouseDoubleClickBack(object sender, MouseButtonEventArgs e)
        {
            if (ListBox.SelectedIndex == -1)
                return;

            ListBoxItem selectedItem = this.ListBox.ItemContainerGenerator.ContainerFromIndex(ListBox.SelectedIndex) as ListBoxItem;

            if (selectedItem == null)
                return;

            if (ListBox.SelectedItem != null)
            {
                Label nameBox = clientlogic.FindDescendant<Label>(selectedItem);
                likeNome = likeNome.Substring(0, likeNome.Length - 1);
                if (!likeNome.Contains("\\"))
                {
                    likeNome = "";
                }
                else
                {
                    likeNome = likeNome.Substring(0, likeNome.LastIndexOf(@"\") + 1);
                }
                if (App.Current.MainWindow is Restore)
                {
                    FileSelection main = new FileSelection(clientlogic, selFolderPath, likeNome, false, ((Restore)App.Current.MainWindow).mw);
                    if (App.Current.MainWindow is Restore)
                        App.Current.MainWindow.Content = main;
                }
            }
        }