OSDN Git Service

f644b949611a94762ce7f83494ecae1fc8339d83
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / FormatPatchDlg.cpp
1 // FormatPatch.cpp : implementation file\r
2 //\r
3 \r
4 #include "stdafx.h"\r
5 #include "TortoiseProc.h"\r
6 #include "FormatPatchDlg.h"\r
7 #include "git.h"\r
8 #include "BrowseFolder.h"\r
9 // CFormatPatchDlg dialog\r
10 \r
11 IMPLEMENT_DYNAMIC(CFormatPatchDlg, CResizableStandAloneDialog)\r
12 \r
13 CFormatPatchDlg::CFormatPatchDlg(CWnd* pParent /*=NULL*/)\r
14         : CResizableStandAloneDialog(CFormatPatchDlg::IDD, pParent),\r
15         m_regSendMail(_T("Software\\TortoiseGit\\TortoiseProc\\FormatPatch\\SendMail"),0)\r
16 {\r
17         m_Num=1;\r
18         this->m_bSendMail = m_regSendMail;\r
19         this->m_Radio = IDC_RADIO_SINCE;\r
20 }\r
21 \r
22 CFormatPatchDlg::~CFormatPatchDlg()\r
23 {\r
24 }\r
25 \r
26 void CFormatPatchDlg::DoDataExchange(CDataExchange* pDX)\r
27 {\r
28         CDialog::DoDataExchange(pDX);\r
29         DDX_Control(pDX, IDC_COMBOBOXEX_DIR,    m_cDir);\r
30         DDX_Control(pDX, IDC_COMBOBOXEX_SINCE,  m_cSince);\r
31         DDX_Control(pDX, IDC_COMBOBOXEX_FROM,   m_cFrom);\r
32         DDX_Control(pDX, IDC_COMBOBOXEX_TO,             m_cTo);\r
33         DDX_Control(pDX, IDC_EDIT_NUM,                  m_cNum);\r
34 \r
35         DDX_Text(pDX,IDC_EDIT_NUM,m_Num);\r
36 \r
37         DDX_Text(pDX, IDC_COMBOBOXEX_DIR,       m_Dir);\r
38         DDX_Text(pDX, IDC_COMBOBOXEX_SINCE,     m_Since);\r
39         DDX_Text(pDX, IDC_COMBOBOXEX_FROM,      m_From);\r
40         DDX_Text(pDX, IDC_COMBOBOXEX_TO,        m_To);\r
41         \r
42         DDX_Check(pDX, IDC_CHECK_SENDMAIL, m_bSendMail);\r
43 }\r
44 \r
45 \r
46 BEGIN_MESSAGE_MAP(CFormatPatchDlg, CResizableStandAloneDialog)\r
47         ON_BN_CLICKED(IDC_BUTTON_DIR, &CFormatPatchDlg::OnBnClickedButtonDir)\r
48         ON_BN_CLICKED(IDC_BUTTON_FROM, &CFormatPatchDlg::OnBnClickedButtonFrom)\r
49         ON_BN_CLICKED(IDC_BUTTON_TO, &CFormatPatchDlg::OnBnClickedButtonTo)\r
50         ON_BN_CLICKED(IDOK, &CFormatPatchDlg::OnBnClickedOk)\r
51         ON_BN_CLICKED(IDC_RADIO_SINCE, &CFormatPatchDlg::OnBnClickedRadio)\r
52         ON_BN_CLICKED(IDC_RADIO_NUM, &CFormatPatchDlg::OnBnClickedRadio)\r
53         ON_BN_CLICKED(IDC_RADIO_RANGE, &CFormatPatchDlg::OnBnClickedRadio)\r
54 END_MESSAGE_MAP()\r
55 \r
56 BOOL CFormatPatchDlg::OnInitDialog()\r
57 {\r
58         CResizableStandAloneDialog::OnInitDialog();\r
59         \r
60         AddAnchor(IDC_GROUP_DIR, TOP_LEFT, TOP_RIGHT);\r
61         AddAnchor(IDC_COMBOBOXEX_DIR,TOP_LEFT, TOP_RIGHT);\r
62         AddAnchor(IDC_BUTTON_DIR, TOP_RIGHT);\r
63 \r
64         AddAnchor(IDC_GROUP_VERSION, TOP_LEFT, TOP_RIGHT);\r
65         AddAnchor(IDC_COMBOBOXEX_SINCE, TOP_LEFT, TOP_RIGHT);\r
66         AddAnchor(IDC_EDIT_NUM, TOP_LEFT, TOP_RIGHT);\r
67         AddAnchor(IDC_SPIN_NUM, TOP_RIGHT);\r
68 \r
69         AddAnchor(IDC_COMBOBOXEX_FROM, TOP_LEFT, TOP_RIGHT);\r
70         AddAnchor(IDC_COMBOBOXEX_TO, TOP_LEFT, TOP_RIGHT);\r
71 \r
72         AddAnchor(IDC_BUTTON_FROM,  TOP_RIGHT);\r
73         AddAnchor(IDC_BUTTON_TO,        TOP_RIGHT);\r
74         AddAnchor(IDC_CHECK_SENDMAIL,BOTTOM_LEFT);\r
75         AddAnchor(IDOK,BOTTOM_RIGHT);\r
76         AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
77 \r
78         this->AddOthersToAnchor();\r
79 \r
80         m_cDir.SetPathHistory(TRUE);\r
81         m_cDir.LoadHistory(_T("Software\\TortoiseGit\\History\\FormatPatchURLS"), _T("path"));\r
82         m_cDir.SetCurSel(0);\r
83 \r
84         STRING_VECTOR list;\r
85         g_Git.GetBranchList(list,NULL,CGit::BRANCH_ALL);\r
86         m_cSince.AddString(list);\r
87 \r
88         if(!m_Since.IsEmpty())\r
89                 m_cSince.SetWindowText(m_Since);\r
90 \r
91         m_cFrom.LoadHistory(_T("Software\\TortoiseGit\\History\\FormatPatchFromURLS"), _T("ver"));\r
92         m_cFrom.SetCurSel(0);\r
93 \r
94         if(!m_From.IsEmpty())\r
95                 m_cFrom.SetWindowText(m_From);\r
96 \r
97         m_cTo.LoadHistory(_T("Software\\TortoiseGit\\History\\FormatPatchToURLS"), _T("ver"));\r
98         m_cTo.SetCurSel(0);\r
99 \r
100         if(!m_To.IsEmpty())\r
101                 m_cTo.SetWindowText(m_To);\r
102 \r
103         this->CheckRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE,this->m_Radio);\r
104         \r
105         OnBnClickedRadio();\r
106 \r
107         EnableSaveRestore(_T("FormatPatchDlg"));\r
108         return TRUE;\r
109 }\r
110 // CFormatPatchDlg message handlers\r
111 \r
112 void CFormatPatchDlg::OnBnClickedButtonDir()\r
113 {\r
114         // TODO: Add your control notification handler code here\r
115         CBrowseFolder browseFolder;\r
116         browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;\r
117         CString strCloneDirectory;\r
118         this->UpdateData(TRUE);\r
119         strCloneDirectory=m_Dir;\r
120         if (browseFolder.Show(GetSafeHwnd(), strCloneDirectory) == CBrowseFolder::OK) \r
121         {\r
122                 m_Dir=strCloneDirectory;\r
123                 this->UpdateData(FALSE);\r
124         }\r
125 }\r
126 \r
127 void CFormatPatchDlg::OnBnClickedButtonFrom()\r
128 {\r
129         // TODO: Add your control notification handler code here\r
130 }\r
131 \r
132 void CFormatPatchDlg::OnBnClickedButtonTo()\r
133 {\r
134         // TODO: Add your control notification handler code here\r
135 }\r
136 \r
137 void CFormatPatchDlg::OnBnClickedOk()\r
138 {\r
139         // TODO: Add your control notification handler code here\r
140 \r
141         m_cDir.SaveHistory();\r
142         m_cFrom.SaveHistory();\r
143         m_cTo.SaveHistory();\r
144         this->UpdateData(TRUE);\r
145         this->m_Radio=GetCheckedRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE);\r
146 \r
147         m_regSendMail=this->m_bSendMail;\r
148         OnOK();\r
149 }\r
150 \r
151 void CFormatPatchDlg::OnBnClickedRadio()\r
152 {\r
153         // TODO: Add your control notification handler code here\r
154         int radio=this->GetCheckedRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE);\r
155         m_cSince.EnableWindow(FALSE);\r
156         m_cNum.EnableWindow(FALSE);\r
157         m_cFrom.EnableWindow(FALSE);\r
158         m_cTo.EnableWindow(FALSE);\r
159         switch(radio)\r
160         {\r
161         case IDC_RADIO_SINCE:\r
162                 m_cSince.EnableWindow(TRUE);\r
163                 break;\r
164         case IDC_RADIO_NUM:\r
165                 m_cNum.EnableWindow(TRUE);\r
166                 break;\r
167         case IDC_RADIO_RANGE:\r
168                 m_cFrom.EnableWindow(TRUE);\r
169                 m_cTo.EnableWindow(TRUE);\r
170         }\r
171 }\r