| 237 | } |
| 238 | |
| 239 | bool WinMergeContextMenu::UpdateMenuState(const std::vector<std::wstring>& paths) |
| 240 | { |
| 241 | m_strPaths = paths; |
| 242 | |
| 243 | // Check if user wants to use context menu |
| 244 | CRegKeyEx reg; |
| 245 | if (reg.Open(HKEY_CURRENT_USER, f_RegDir) != ERROR_SUCCESS) |
| 246 | { |
| 247 | m_dwMenuState = MENU_HIDDEN; |
| 248 | return false; |
| 249 | } |
| 250 | |
| 251 | DWORD dwContextMenuEnabled = reg.ReadDword(f_RegValueEnabled, 0); |
| 252 | m_strPreviousPaths[0] = reg.ReadString(f_FirstSelection, _T("")).c_str(); |
| 253 | m_strPreviousPaths[1] = reg.ReadString(f_SecondSelection, _T("")).c_str(); |
| 254 | |
| 255 | if (dwContextMenuEnabled & EXT_ENABLED) // Context menu enabled |
| 256 | { |
| 257 | // Check if advanced menuitems enabled |
| 258 | if ((dwContextMenuEnabled & EXT_ADVANCED) == 0) |
| 259 | { |
| 260 | m_dwMenuState = MENU_SIMPLE; |
| 261 | } |
| 262 | else |
| 263 | { |
| 264 | if (m_strPaths.size() == 1 && m_strPreviousPaths[0].empty()) |
| 265 | m_dwMenuState = MENU_ONESEL_NOPREV; |
| 266 | else if (m_strPaths.size() == 1 && !m_strPreviousPaths[0].empty() && m_strPreviousPaths[1].empty()) |
| 267 | m_dwMenuState = MENU_ONESEL_PREV; |
| 268 | else if (m_strPaths.size() == 1 && !m_strPreviousPaths[0].empty() && !m_strPreviousPaths[1].empty()) |
| 269 | m_dwMenuState = MENU_ONESEL_TWO_PREV; |
| 270 | else if (m_strPaths.size() == 2) |
| 271 | m_dwMenuState = MENU_TWOSEL; |
| 272 | else if (m_strPaths.size() >= 3) |
| 273 | m_dwMenuState = MENU_THREESEL; |
| 274 | } |
| 275 | } |
| 276 | else |
| 277 | { |
| 278 | m_dwMenuState = MENU_HIDDEN; |
| 279 | } |
| 280 | return true; |
| 281 | } |
| 282 | |
| 283 | std::vector<MenuItem> WinMergeContextMenu::GetMenuItemList() const |
| 284 | { |
no test coverage detected