<commit_before>//
// RemotePhotoTool - remote camera control software
// Copyright (C) 2008-2020 <NAME>
//
/// \file RemotePhotoTool/MainFrame.cpp Main application frame
//

// includes
#include "stdafx.h"
#include "MainFrame.hpp"
#include "AboutDlg.hpp"
#include <ulib/Exception.hpp>
#include "BlankView.hpp"
#include "ConnectCameraDlg.hpp"
#include "SettingsDlg.hpp"
#include "SourceDevice.hpp"
#include "ShutterReleaseSettings.hpp"
#include "ShootingMode.hpp"
#include "ImageFormat.hpp"
#include "Viewfinder.hpp"
#include "CameraException.hpp"
#include "CameraErrorDlg.hpp"
#include "Logging.hpp"
#include "TimelapseVideoOptionsDlg.hpp"
#include "FfmpegInterface.hpp"
#include <ulib/Path.hpp>
#include <ulib/thread/Thread.hpp>

/// settings registry key (subkey "Ribbon" is used for menu band)
LPCTSTR c_pszSettingsRegkey = _T("Software\\RemotePhotoTool");

/// ctor
MainFrame::MainFrame()
   :m_hWndView(nullptr),
   m_settings(c_pszSettingsRegkey),
   m_dwUIThreadId(Thread::CurrentId()),
   m_enCurrentViewType(viewBlank),
   m_enPrevImagesSavedView(viewBlank),
   m_iStateEventHandlerId(-1),
   m_iDownloadEventHandlerId(-1),
   m_iImagePropertyHandlerId(-1)
{
   m_settings.Load();

   SetupLogging();

   m_upImageFileManager.reset(new ImageFileManager(m_settings));

   m_releaseSettings.SaveTarget(ShutterReleaseSettings::saveToBoth);
}

MainFrame::~MainFrame()
{
   CleanupImagePropertyManager();

   LOG_TRACE(_T("RemotePhotoTool finished.\n"));
   LOG_TRACE(_T("************************************************************\n"));
}

BOOL MainFrame::PreTranslateMessage(MSG* pMsg)
{
   if (m_upView != nullptr && m_upView->PreTranslateMessage(pMsg))
      return TRUE;

   return BaseClass::PreTranslateMessage(pMsg);
}

BOOL MainFrame::OnIdle()
{
   Instance::OnIdle();

   UIUpdateToolBar();

   // enable contextual tabs
   bool hasReleaseControl =
      m_enCurrentViewType != viewBlank &&
      m_enCurrentViewType != viewPreviousImages &&
      m_connection.HasReleaseControl();

   SetRibbonContextAvail(ID_TAB_GROUP_CONTEXT_CAMERA, hasReleaseControl ?
      UI_CONTEXTAVAILABILITY_AVAILABLE : UI_CONTEXTAVAILABILITY_NOTAVAILABLE);

   bool isViewfinderActive = m_upViewFinderView != nullptr;
   SetRibbonContextAvail(ID_TAB_GROUP_CONTEXT_VIEWFINDER, isViewfinderActive ?
      UI_CONTEXTAVAILABILITY_AVAILABLE : UI_CONTEXTAVAILABILITY_NOTAVAILABLE);

   return FALSE;
}

LRESULT MainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
   SetupCmdBar();
   SetupRibbonBar();
   SetupToolbar();
   SetupStatusBar();

   // create view
   {
      m_hWndClient = m_splitter.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);

      m_upView.reset(new BlankView);
<commit_msg>hide file system contextual tab when current view has changed<commit_after>//
// RemotePhotoTool - remote camera control software
// Copyright (C) 2008-2020 <NAME>
//
/// \file RemotePhotoTool/MainFrame.cpp Main application frame
//

// includes
#include "stdafx.h"
#include "MainFrame.hpp"
#include "AboutDlg.hpp"
#include <ulib/Exception.hpp>
#include "BlankView.hpp"
#include "ConnectCameraDlg.hpp"
#include "SettingsDlg.hpp"
#include "SourceDevice.hpp"
#include "ShutterReleaseSettings.hpp"
#include "ShootingMode.hpp"
#include "ImageFormat.hpp"
#include "Viewfinder.hpp"
#include "CameraException.hpp"
#include "CameraErrorDlg.hpp"
#include "Logging.hpp"
#include "TimelapseVideoOptionsDlg.hpp"
#include "FfmpegInterface.hpp"
#include <ulib/Path.hpp>
#include <ulib/thread/Thread.hpp>

/// settings registry key (subkey "Ribbon" is used for menu band)
LPCTSTR c_pszSettingsRegkey = _T("Software\\RemotePhotoTool");

/// ctor
MainFrame::MainFrame()
   :m_hWndView(nullptr),
   m_settings(c_pszSettingsRegkey),
   m_dwUIThreadId(Thread::CurrentId()),
   m_enCurrentViewType(viewBlank),
   m_enPrevImagesSavedView(viewBlank),
   m_iStateEventHandlerId(-1),
   m_iDownloadEventHandlerId(-1),
   m_iImagePropertyHandlerId(-1)
{
   m_settings.Load();

   SetupLogging();

   m_upImageFileManager.reset(new ImageFileManager(m_settings));

   m_releaseSettings.SaveTarget(ShutterReleaseSettings::saveToBoth);
}

MainFrame::~MainFrame()
{
   CleanupImagePropertyManager();

   LOG_TRACE(_T("RemotePhotoTool finished.\n"));
   LOG_TRACE(_T("************************************************************\n"));
}

BOOL MainFrame::PreTranslateMessage(MSG* pMsg)
{
   if (m_upView != nullptr && m_upView->PreTranslateMessage(pMsg))
      return TRUE;

   return BaseClass::PreTranslateMessage(pMsg);
}

BOOL MainFrame::OnIdle()
{
   Instance::OnIdle();

   UIUpdateToolBar();

   // enable contextual tabs
   bool hasReleaseControl =
      m_enCurrentViewType != viewBlank &&
      m_enCurrentViewType != viewPreviousImages &&
      m_connection.HasReleaseControl();

   SetRibbonContextAvail(ID_TAB_GROUP_CONTEXT_CAMERA, hasReleaseControl ?
      UI_CONTEXTAVAILABILITY_AVAILABLE : UI_CONTEXTAVAILABILITY_NOTAVAILABLE);

   bool isViewfinderActive = m_upViewFinderView != nullptr;
   SetRibbonContextAvail(ID_TAB_GROUP_CONTEXT_VIEWFINDER, isViewfinderActive ?
      UI_CONTEXTAVAILABILITY_AVAILABLE : UI_CONTEXTAVAILABILITY_NOTAVAILABLE);

   bool isFileSystemView = m_enCurrentViewType == viewCameraFileSystem;
   SetRibbonContextAvail(ID_TAB_GROUP_CONTEXT_FILESYSTEM,
      isFileSystemView ? UI_CONTEXTAVAILABILITY_ACTIVE : UI_CONTEXTAVAILABILITY_NOTAVAILABLE);

   return FALSE;
}

LRESULT MainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
   SetupCmdBar();
   SetupRibbonBar();
   SetupToolbar();
   SetupStatusBar();

   // create view
   {
      m_hWndClient = m_splitter.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);

      m_upView.reset(new BlankView);

{'fraction_non_alphanumeric': 0.13651994497936726, 'fraction_numerical': 0.003782668500687758, 'mean_word_length': 5.558060879368658, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7466392', 'n_tokens_mistral': 1980, 'n_tokens_neox': 1947, 'n_words': 319}