private void PropertiesBoxForm_Load(object sender, EventArgs e) { switch (recognizeSelectedItem(Tag)) { case 1: //DRIVE r.DrivesInformationResponse.DriveInfo div = (r.DrivesInformationResponse.DriveInfo)Tag; Close(); break; case 2: //DIRECTORY r.DirectoryInformationResponse.DirectoryInfo dir = (r.DirectoryInformationResponse.DirectoryInfo)Tag; Text = $"{dir.Name} Properties"; nameLabel.Text = dir.Name; typeLabel.Text = "Folder"; locLabel.Text = dir.FullName.Substring(0, dir.FullName.Length - dir.Name.Length); sizeLabel.Text = "<unknown>"; DateTime dt = FileSystem.StringToDate(dir.CreationTime); createdLabel.Text = $"{dt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dt.Month)} {dt.Day.ToString("00")}, {dt.Year}, {dt.Hour.ToString("00")}:{dt.Minute.ToString("00")}:{dt.Second.ToString("00")}"; dt = FileSystem.StringToDate(dir.LastWriteTime); modifiedLabel.Text = $"{dt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dt.Month)} {dt.Day.ToString("00")}, {dt.Year}, {dt.Hour.ToString("00")}:{dt.Minute.ToString("00")}:{dt.Second.ToString("00")}"; dt = FileSystem.StringToDate(dir.LastAccessTime); accessedLabel.Text = $"{dt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dt.Month)} {dt.Day.ToString("00")}, {dt.Year}, {dt.Hour.ToString("00")}:{dt.Minute.ToString("00")}:{dt.Second.ToString("00")}"; break; case 3: //FILE r.FileInformationResponse.FileInfo fil = (r.FileInformationResponse.FileInfo)Tag; Text = $"{fil.Name.Replace(fil.Extention,"")} Properties"; nameLabel.Text = fil.Name; typeLabel.Text = $"File ({fil.Extention})"; locLabel.Text = fil.FullName.Substring(0, fil.FullName.Length - fil.Name.Length); sizeLabel.Text = $"{fil.Length} bytes"; DateTime dtt = FileSystem.StringToDate(fil.CreationTime); createdLabel.Text = $"{dtt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dtt.Month)} {dtt.Day.ToString("00")}, {dtt.Year}, {dtt.Hour.ToString("00")}:{dtt.Minute.ToString("00")}:{dtt.Second.ToString("00")}"; dtt = FileSystem.StringToDate(fil.LastWriteTime); modifiedLabel.Text = $"{dtt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dtt.Month)} {dtt.Day.ToString("00")}, {dtt.Year}, {dtt.Hour.ToString("00")}:{dtt.Minute.ToString("00")}:{dtt.Second.ToString("00")}"; dtt = FileSystem.StringToDate(fil.LastAccessTime); accessedLabel.Text = $"{dtt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dtt.Month)} {dtt.Day.ToString("00")}, {dtt.Year}, {dtt.Hour.ToString("00")}:{dtt.Minute.ToString("00")}:{dtt.Second.ToString("00")}"; break; } if (objectIcon != null) { pictureBox1.Image = objectIcon; } }
private void openWithNewConnectionToolStripMenuItem_Click(object sender, EventArgs e) { string imm = ""; ListViewItem sItem = contentView.SelectedItems[0]; //GET THE SELECTED OBJECT switch (recognizeSelectedItem(sItem)) { case 1: //DRIVE r.DrivesInformationResponse.DriveInfo div = (r.DrivesInformationResponse.DriveInfo)sItem.Tag; imm = div.RootDirectoryPath; break; case 2: //DIRECTORY r.DirectoryInformationResponse.DirectoryInfo dir = (r.DirectoryInformationResponse.DirectoryInfo)sItem.Tag; imm = dir.FullName; break; case 3: //FILE break; case 0: MessageBox.Show("UnKnown Item found", "Error"); return; } NetworkServer.requestNewConnectionToOpenPort(server.serverPort.ServerIP, new NetworkServer.NewConnectionEstablished( (NetworkServer newServer, CommunicationNetworkStream stream) => { exploreForm f = new exploreForm(); f.server = newServer; f.ImmidiatePath = imm; f.StartPosition = FormStartPosition.CenterScreen; Invoke(new UpdateData(() => { f.Show(); })); } ), new NetworkServer.ErrorEncounted( (RServer newServer, CommunicationNetworkStream stream, string data) => { MessageBox.Show("Server is flooded with connection. Try again later.", "Error"); } ) ); }
private async void openSelectedItem() { ListViewItem sItem = contentView.SelectedItems[0]; //GET THE SELECTED OBJECT switch (recognizeSelectedItem(sItem)) { case 1: //DRIVE r.DrivesInformationResponse.DriveInfo div = (r.DrivesInformationResponse.DriveInfo)sItem.Tag; addressBox.Text = div.RootDirectoryPath; break; case 2: //DIRECTORY r.DirectoryInformationResponse.DirectoryInfo dir = (r.DirectoryInformationResponse.DirectoryInfo)sItem.Tag; addressBox.Text = dir.FullName; break; case 3: //FILE r.FileInformationResponse.FileInfo fil = (r.FileInformationResponse.FileInfo)sItem.Tag; if (fil.Length > 4194304d) { if (MessageBox.Show("Selected file is too long.\nWant to continue...", "Confirm", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } string fPath = await MyGlobal.DB.LocalStorage.GetLocalFile(server.serverPort.ServerIP, fil); if (MyGlobal.DB.LocalStorage.isUpdated) { await MyGlobal.DB.saveDatabase(); } Process.Start(fPath); return; break; case 0: MessageBox.Show("UnKnown Item found", "Error"); break; } refreshContent(); //REQUEST FOR NEW CONTENTS }