Ejemplo n.º 1
0
        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();
                    }
                }
            });
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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;
            });
        }
Ejemplo n.º 4
0
        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;
            });
        }
Ejemplo n.º 5
0
        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");
        }
Ejemplo n.º 6
0
        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;
            });
        }