Пример #1
0
        public Page2(Config config, string userData, string filesData, MainWindow main)
        {
            InitializeComponent();
            //this.Search_DataGrid = new DataGrid();
            Search_DataGrid.AutoGenerateColumns   = false;
            Search_DataGrid.IsReadOnly            = true;
            Search_DataGrid.CanUserAddRows        = false;
            Search_DataGrid.CanUserDeleteRows     = false;
            Search_DataGrid.CanUserReorderColumns = false;
            Search_DataGrid.CanUserResizeColumns  = false;
            Search_DataGrid.CanUserResizeRows     = false;
            Search_DataGrid.CanUserSortColumns    = false;
            this.config    = config;
            this.userData  = userData;
            this.filesData = filesData;
            this.server    = new Mediation.MediationSoapClient();
            this.manager   = new SocketsManager(config.path);
            this.main      = main;
            Task.Factory.StartNew(() => manager.HandleIncomingFile(config.ip, PORT_IN));
            Task.Factory.StartNew(() => manager.HandleIncomingRequest(config.ip, PORT_OUT));
            List <DAL.File> files = JsonConvert.DeserializeObject <List <DAL.File> >(server.getFiles());

            files.RemoveAll(file => file.allUsers == config.name);
            Files_DataGrid.ItemsSource = files;
        }
Пример #2
0
        private void Search_Click(object sender, RoutedEventArgs e)
        {
            string fileName = Search_TextBox.Text.ToString();
            string listData;

            this.index    = -1;
            this.fileSize = 0;
            try
            {
                if (fileName != null || fileName != "")
                {
                    files     = JsonConvert.DeserializeObject <List <DAL.File> >(server.getFiles());
                    listData  = server.fileRequest(userData, fileName);
                    fileUsers = JsonConvert.DeserializeObject <List <DAL.User> >(listData);
                    if (fileUsers.Count == 0)
                    {
                        MessageBox.Show("No such file.");
                    }
                    else
                    {
                        DAL.User temp = new DAL.User();
                        foreach (var u in fileUsers)
                        {
                            if (config.name == u.name)
                            {
                                temp = u;
                            }
                        }
                        fileUsers.Remove(temp);
                        Search_DataGrid.ItemsSource = fileUsers;
                        foreach (var file in this.files)
                        {
                            if (file != null)
                            {
                                if (file.name == fileName)
                                {
                                    fileSize = file.size;
                                }
                            }
                        }
                        this.calculateSize(fileSize);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                MessageBox.Show("File not found.");
            }
        }