Ejemplo n.º 1
0
        /// <summary>
        /// CSVエクスポートクリックイベント
        /// </summary>
        private void _csvExportButton_Click(object sender, System.EventArgs e)
        {
            StreamWriter sw       = null;
            bool         delPWFlg = false;

            if (_saveCSVFileDialog.ShowDialog() == DialogResult.OK)
            {
                // パスワード出力/削除確認
                if (ConnectProfilePlugin.AskUserYesNoInvoke(ConnectProfilePlugin.Strings.GetString("Message.ConnectProfile.CSVExportDetetePasssword"), MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    delPWFlg = true;
                }

                // CSVファイル出力
                try {
                    sw = new System.IO.StreamWriter(_saveCSVFileDialog.FileName, false, System.Text.Encoding.UTF8);
                    sw.WriteLine(_cmd.CSVHeader);
                    foreach (ConnectProfileStruct prof in ConnectProfilePlugin.Profiles)
                    {
                        sw.WriteLine(_cmd.ConvertCSV(prof, delPWFlg));
                    }
                    ConnectProfilePlugin.MessageBoxInvoke(ConnectProfilePlugin.Strings.GetString("Message.ConnectProfile.CSVExportComplete"), MessageBoxIcon.Information);
                } catch (Exception ex) {
                    ConnectProfilePlugin.MessageBoxInvoke(ex.Message, MessageBoxIcon.Error);
                } finally {
                    if (sw != null)
                    {
                        sw.Close();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// プロファイル削除
        /// </summary>
        private void DeleteProfile()
        {
            ConnectProfileStruct prof = GetSelectedProfile();

            if (prof != null)
            {
                if (ConnectProfilePlugin.AskUserYesNoInvoke(ConnectProfilePlugin.Strings.GetString("Message.ConnectProfile.ConfirmProfileDelete"), MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    _cmd.DeleteProfileCommand(ConnectProfilePlugin.Profiles, prof);
                    RefreshAllProfiles();
                    RefreshSelectCount();
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// CSVインポートクリックイベント
        /// </summary>
        private void _csvImportButton_Click(object sender, System.EventArgs e)
        {
            ConnectProfileList   profList = new ConnectProfileList();
            ConnectProfileStruct prof     = new ConnectProfileStruct();
            StreamReader         sr       = null;
            bool appendFlg = false;
            int  lineCnt   = 1;

            if (_openCSVFileDialog.ShowDialog() == DialogResult.OK)
            {
                // インポート実行確認
                if (ConnectProfilePlugin.AskUserYesNoInvoke(ConnectProfilePlugin.Strings.GetString("Message.ConnectProfile.CSVImportConfirm"), MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    // 追加/削除確認
                    if (ConnectProfilePlugin.AskUserYesNoInvoke(ConnectProfilePlugin.Strings.GetString("Message.ConnectProfile.CSVImportAppendProfileList"), MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        appendFlg = true;
                    }

                    // インポート実行
                    try {
                        sr = new System.IO.StreamReader(_openCSVFileDialog.FileName, System.Text.Encoding.UTF8);
                        while (!sr.EndOfStream)
                        {
                            string line = sr.ReadLine();

                            // 各種チェック
                            if (lineCnt == 1)
                            {
                                // ヘッダーチェック(1行目固定)
                                if (_cmd.CheckCSVHeader(line) != true)
                                {
                                    ConnectProfilePlugin.MessageBoxInvoke(string.Format(ConnectProfilePlugin.Strings.GetString("Message.ConnectProfile.CSVImportInvalidHeader"), lineCnt.ToString()), MessageBoxIcon.Error);
                                    return;
                                }
                            }
                            else if ((line == "") || (line.IndexOf("#") == 0))
                            {
                                // 空白行/行頭シャープの行はスキップ
                                lineCnt++;
                                continue;
                            }
                            else
                            {
                                // フィールド数チェック
                                if (_cmd.CheckCSVFieldCount(line) != true)
                                {
                                    ConnectProfilePlugin.MessageBoxInvoke(string.Format(ConnectProfilePlugin.Strings.GetString("Message.ConnectProfile.CSVImportInvalidFieldCount"), lineCnt.ToString()), MessageBoxIcon.Error);
                                    return;
                                }

                                // 各項目チェック
                                prof = _cmd.CheckCSVData(line);
                                if (prof == null)
                                {
                                    ConnectProfilePlugin.MessageBoxInvoke(string.Format(ConnectProfilePlugin.Strings.GetString("Message.ConnectProfile.CSVImportFailed"), lineCnt.ToString()), MessageBoxIcon.Error);
                                    return;
                                }

                                // プロファイル追加
                                if (appendFlg == true)
                                {
                                    _cmd.AddProfileCommand(ConnectProfilePlugin.Profiles, prof);
                                }
                                else
                                {
                                    _cmd.AddProfileCommand(profList, prof);
                                }
                            }
                            lineCnt++;
                        }
                        // プロファイルリスト全置換
                        if (appendFlg == false)
                        {
                            _cmd.ReplaceAllProfileCommand(ConnectProfilePlugin.Profiles, profList);
                        }

                        RefreshAllProfiles();
                        RefreshSelectCount();
                        ConnectProfilePlugin.MessageBoxInvoke(ConnectProfilePlugin.Strings.GetString("Message.ConnectProfile.CSVImportComplete"), MessageBoxIcon.Information);
                    } catch (Exception ex) {
                        ConnectProfilePlugin.MessageBoxInvoke(ex.Message, MessageBoxIcon.Error);
                    } finally {
                        if (sr != null)
                        {
                            sr.Close();
                        }
                    }
                }
                else
                {
                    // キャンセル
                    ConnectProfilePlugin.MessageBoxInvoke(ConnectProfilePlugin.Strings.GetString("Message.ConnectProfile.CSVImportCancel"), MessageBoxIcon.Warning);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// OKボタンイベント
        /// </summary>
        private void _okButton_Click(object sender, EventArgs e)
        {
            ArrayList hostlist = new ArrayList();

            this.DialogResult = DialogResult.None;
            _connectCancelFlg = false;
            EnableControl(false);

            if ((_selectCnt == 0) && (_profileListView.Items.Count == 1))
            {
                // 選択数0 & リスト1行のみ
                _profileListView.Items[0].Selected = true;
                Connect(GetSelectedProfile());
                this.DialogResult = DialogResult.OK;
            }
            else if ((_selectCnt == 0) && (_profileListView.SelectedItems.Count == 1))
            {
                // 選択数0 & リスト1行選択
                Connect(GetSelectedProfile());
                this.DialogResult = DialogResult.OK;
            }
            else if (_selectCnt > 0)
            {
                // 選択数1以上(複数接続)
                foreach (ConnectProfileStruct prof in ConnectProfilePlugin.Profiles)
                {
                    if (prof.Check == true)
                    {
                        hostlist.Add(prof.HostName);
                    }
                }

                // 接続確認
                if (ConnectProfilePlugin.AskUserYesNoInvoke(String.Format(ConnectProfilePlugin.Strings.GetString("Message.ConnectProfile.ConnectConfirm"), _selectCnt, String.Join(", ", (string[])hostlist.ToArray(typeof(string)))), MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    // 接続
                    foreach (ConnectProfileStruct prof in ConnectProfilePlugin.Profiles)
                    {
                        if (_connectCancelFlg != true)
                        {
                            if (prof.Check == true)
                            {
                                Connect(prof);
                            }
                        }
                        else
                        {
                            // キャンセルボタン押下
                            ConnectProfilePlugin.MessageBoxInvoke(ConnectProfilePlugin.Strings.GetString("Message.ConnectProfile.ConnectCancel"), MessageBoxIcon.Warning);
                            this.DialogResult = DialogResult.None;
                            EnableControl(true);
                            _okButton.Focus();
                            return;
                        }
                    }
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    // キャンセル
                    EnableControl(true);
                    _okButton.Focus();
                }
            }
            else
            {
                // リスト未選択
                ConnectProfilePlugin.AskUserYesNoInvoke(ConnectProfilePlugin.Strings.GetString("Message.ConnectProfile.ProfileNotSelected"), MessageBoxIcon.Warning);
                EnableControl(true);
                _okButton.Focus();
            }
        }