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 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 TaskManeger_Load(object sender, EventArgs e) { Task.Factory.StartNew(() => { try { serverMain.Send("+START_TASKMGR " + serverTaskManeger_Port.ToString()); serverTaskMgr = new TCP.Server(serverTaskManeger_Port); serverTaskMgr.Start(); mainProcessListReload_Button_Click(null, EventArgs.Empty); mainProcessListReload_Button.Enabled = true; mainProcessExit_Button.Enabled = true; mainSaveFile_Button.Enabled = true; } catch (Exception ex) { if (serverTaskMgr != null) { serverTaskMgr.Stop(); } MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.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 mainProcessListReload_Button_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => { try { mainProcessListReload_Button.Enabled = false; mainProcessExit_Button.Enabled = false; mainSaveFile_Button.Enabled = false; serverTaskMgr.Send("+GET_PROCESS"); 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 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 mainCmdSend_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => { try { Text = "RemotePanel - 電源 (送信中...)"; mainCmdSend.Enabled = false; string powerCmd = ""; if (mainPowerCmd_comboBox.SelectedIndex == 0) { powerCmd = "-s -f"; } else if (mainPowerCmd_comboBox.SelectedIndex == 1) { powerCmd = "-r -f"; } else if (mainPowerCmd_comboBox.SelectedIndex == 2) { powerCmd = "-l -f"; } else if (mainPowerCmd_comboBox.SelectedIndex == 3) { powerCmd = "-h -f"; } else if (mainPowerCmd_comboBox.SelectedIndex == 4) { powerCmd = "-a"; } string powerCommands = ""; if (powerCmd == "-a") { powerCommands = "/c shutdown -a"; } else { powerCommands = "/c shutdown " + powerCmd + " -t " + mainPowerTime_numericUpDown.Value.ToString() + " -c \"" + mainPowerComment_Textbox.Text + " \""; } serverMain.Send("+CMD " + powerCommands); serverMain.RecvBytes(); Text = "RemotePanel - 電源 (送信完了)"; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); Text = "RemotePanel - 電源 (送信失敗)"; } mainCmdSend.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 mainFileListView_MouseDoubleClick(object sender, MouseEventArgs e) { Task.Factory.StartNew(() => { try { string selectedDirName = getSelectedDirName; if (selectedDirName != null) { serverExplorer.Send("+GET_DIR_LIST |" + selectedDirName + "|"); loadFilePathInformations(selectedDirName); } } catch (Exception ex) { MessageBox.Show(ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }); }
private void mainSendCMD_Button_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => { Text = "RemotePanel - コマンドプロンプト (送信中...)"; mainSendCMD_Button.Enabled = false; try { serverMain.Send("+CMD /c " + mainCMDOption_Textbox.Text.Replace("\r\n", "")); serverMain.RecvBytes(); Text = "RemotePanel - コマンドプロンプト (送信完了)"; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); Text = "RemotePanel - コマンドプロンプト (送信失敗)"; } mainSendCMD_Button.Enabled = true; }); }
public void reload_image() { Task.Factory.StartNew(() => { try { Main_reload_bt.Enabled = false; serverMain.Send("+SCREENSHOT"); ImageConverter imgconv = new ImageConverter(); Main_save_pic.Image = (Image)imgconv.ConvertFrom(serverMain.RecvBytes()); } catch { MessageBox.Show("アクセス制限されているか、スクリーンショットを取得できません", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } Main_reload_bt.Enabled = true; }); DateTime dt = DateTime.Now; Main_info_tx.Text = "ScreenShot_" + dt.ToString("yyyy-MM-dd_HH-mm-ss"); }
private void mainArgv_Button_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => { Text = "引数を指定して実行 (送信中...)"; mainArgv_Button.Enabled = false; try { serverMain.Send("+CMD /c \"" + SendPath + "\" " + mainArgv_TextBox.Text.Replace("\r\n", "")); serverMain.RecvBytes(); Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); Text = "引数を指定して実行 (送信失敗)"; } mainArgv_Button.Enabled = true; }); }
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(); } }); }