using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using ChatworkBulkSender.UserControls;
namespace ChatworkBulkSender.Forms
{
public partial class T_SendHistory : Form
{
private HistorySearchBoxControl _historySearchBox = null;
private SendHistoryDgvControl _sendHistoryDgv = null;
private BtnReturnControl _btnControl = null;
public T_SendHistory()
{
InitializeComponent();
// 初期のウィンドウサイズ
this.ClientSize = new Size(1600, 900);
this.MinimumSize = new Size(1000, 600);
// 初期の表示位置
this.StartPosition = FormStartPosition.CenterScreen;
_historySearchBox = new HistorySearchBoxControl();
_sendHistoryDgv = new SendHistoryDgvControl();
_btnControl = new BtnReturnControl();
_historySearchBox.Dock = DockStyle.Fill;
_sendHistoryDgv.Dock = DockStyle.Fill;
panelSearch.Controls.Add(_historySearchBox);
panelDgv.Controls.Add(_sendHistoryDgv);
panelBtn.Controls.Add(_btnControl);
}
private void T_SendHistory_Load(object sender, EventArgs e)
{
this.ActiveControl = panelSearch;
_btnControl.BtnReturnClicked += BtnReturn_Click;
// 検索イベントの登録
_historySearchBox.SearchRequested += HistorySearchBox_SearchRequested;
}
private void DisposeViewControls()
{
panelSearch.Controls.Clear();
panelDgv.Controls.Clear();
panelBtn.Controls.Clear();
_historySearchBox.Dispose();
_sendHistoryDgv.Dispose();
_btnControl.Dispose();
}
/// <summary>
/// 戻るボタンクリックで画面を閉じる
/// </summary>
private void BtnReturn_Click(object sender, EventArgs e)
{
this.Close();
}
/// <summary>
/// 検索イベントハンドラ
/// </summary>
private void HistorySearchBox_SearchRequested(object sender, Dictionary<string, object> criteria)
{
_sendHistoryDgv.Search(criteria);
}
private void T_SendHistory_FormClosing(object sender, FormClosingEventArgs e)
{
// 確認メッセージは表示しない(戻るボタンからの終了時)
// イベント登録の解除
_btnControl.BtnReturnClicked -= BtnReturn_Click;
_historySearchBox.SearchRequested -= HistorySearchBox_SearchRequested;
// 明示的に解放する
this.DisposeViewControls();
// 設定メニューを表示する
this.Owner.Show();
// 再描写を行う
this.Owner.Refresh();
}
}
}