Ejemplo n.º 1
0
//right now this is equivalent to Job.cpp @ void MainFrame::OnStartJob(wxCommandEvent& event)
void MainFrame::QueryClusters(wxCommandEvent& event){
    wxString filtertext,itemtext;
    
    int id = event.GetId();
    m_queryThread->m_qp = new udefrag_query_parameters();
    WxTextCtrl1->Clear();
    
//Launched from Menu:
    if (id == ID_QueryClusters){
        itemtext = m_filesList->GetListItem().GetText();
        WxFilePickerCtrl1->SetPath(itemtext);
        
        ProcessCommandEvent(ID_SelectProperDrive);
        long i = m_filesList->GetFirstSelected();
        while(i != -1){
            wxString selitem = m_filesList->GetItemText(i);
            Utils::extendfiltertext(selitem,&filtertext);
            i = m_filesList->GetNextSelected(i);
        }
    }
//Launched from Tab
    else if (id == ID_PERFORMQUERY){
        itemtext = WxFilePickerCtrl1->GetPath();
        Utils::extendfiltertext(itemtext,&filtertext);
    }
   
    //set the Analysis Mode to SINGLE file mode.
    // This probably can't work for all queries, but is fast.
    wxSetEnv(L"UD_CUT_FILTER",filtertext);
    m_queryThread->singlefile = TRUE;
    m_queryThread->m_flags |= UD_JOB_CONTEXT_MENU_HANDLER;

    m_queryThread->m_querypath = (wchar_t *)itemtext.fn_str();
    m_queryThread->m_qp->path = m_queryThread->m_querypath;
    m_queryThread->m_letter = (char)(itemtext[0]); //find the drive-letter of the fragmented files tab.
        
    m_queryThread->m_mapSize = getmapsize();
    
    switch(id){
    case ID_QueryClusters:
    case ID_PERFORMQUERY:
        m_queryThread->m_qType = QUERY_GET_VCNLIST;
        break;
    case ID_QueryClusters+1:
        m_queryThread->m_qType = QUERY_GET_FREE_REGIONS;
        break;    
    default:
        break;
    }
    m_busy = true; m_paused = false; m_stopped = false;
    m_queryThread->m_startquery = true; //BEGIN LAUNCH.
    
}
Ejemplo n.º 2
0
/**
 * @brief Deinitializes main window.
 */
MainFrame::~MainFrame()
{
    // terminate threads
    ProcessCommandEvent(ID_Stop);
    ::SetEvent(g_synchEvent);
    delete m_btdThread;
    delete m_configThread;
    delete m_crashInfoThread;
    delete m_jobThread;
    delete m_listThread;

    // save configuration
    SaveAppConfiguration();
    delete m_upgradeThread;

    // remove system tray icon
    delete m_systemTrayIcon;

    // free resources
    ::CloseHandle(g_synchEvent);
    delete m_title;
}
Ejemplo n.º 3
0
/**
 * @brief Manages translation changes.
 */
void MainFrame::OnLocaleChange(wxCommandEvent& event)
{
    App::SetLocale(event.GetId() - ID_LocaleChange);

    // update menu labels and tool bar tool-tips

    // main menu
    m_menuBar->SetMenuLabel(0, _("&Action"));
    m_menuBar->SetMenuLabel(1, _("&Settings"));
    m_menuBar->SetMenuLabel(2, _("&Help"));

    // action menu
    UD_UpdateMenuItemLabel(ID_Analyze    , "&Analyze"              , "F5");
    UD_UpdateMenuItemLabel(ID_Defrag     , "&Defragment"           , "F6");
    UD_UpdateMenuItemLabel(ID_QuickOpt   , "&Quick optimization"   , "F7");
    UD_UpdateMenuItemLabel(ID_FullOpt    , "&Full optimization"    , "Ctrl+F7");
    UD_UpdateMenuItemLabel(ID_MftOpt     , "&Optimize MFT"         , "Shift+F7");
    UD_UpdateMenuItemLabel(ID_Pause      , "Pa&use"                , "Space");
    UD_UpdateMenuItemLabel(ID_Stop       , "&Stop"                 , "Ctrl+C");
    UD_UpdateMenuItemLabel(ID_ShowReport , "&Show report"          , "F8");
    UD_UpdateMenuItemLabel(ID_Repeat     , "Re&peat action"        , "Shift+R");
    UD_UpdateMenuItemLabel(ID_SkipRem    , "Skip removable &media" , "Ctrl+M");
    UD_UpdateMenuItemLabel(ID_Rescan     , "&Rescan drives"        , "Ctrl+D");
    UD_UpdateMenuItemLabel(ID_Repair     , "Repair dri&ves"        , "");
    UD_UpdateMenuItemLabel(ID_Exit       , "E&xit"                 , "Alt+F4");

    // when done sub-menu
    m_subMenuWhenDone->SetItemLabel(_("&When done"));
    UD_UpdateMenuItemLabel(ID_WhenDoneNone      , "&None"      , "");
    UD_UpdateMenuItemLabel(ID_WhenDoneExit      , "E&xit"      , "");
    UD_UpdateMenuItemLabel(ID_WhenDoneStandby   , "Stan&dby"   , "");
    UD_UpdateMenuItemLabel(ID_WhenDoneHibernate , "&Hibernate" , "");
    UD_UpdateMenuItemLabel(ID_WhenDoneLogoff    , "&Logoff"    , "");
    UD_UpdateMenuItemLabel(ID_WhenDoneReboot    , "&Reboot"    , "");
    UD_UpdateMenuItemLabel(ID_WhenDoneShutdown  , "&Shutdown"  , "");

    // settings menu
    m_subMenuLanguage->SetItemLabel(_("&Language"));
    UD_UpdateMenuItemLabel(ID_GuiOptions , "&Options" , "F10");
    m_subMenuSortingConfig->SetItemLabel(_("&Sorting"));
    m_subMenuBootConfig->SetItemLabel(_("&Boot time scan"));

    // language sub-menu
    UD_UpdateMenuItemLabel(ID_LangTranslateOnline  , "Translate &online"    , "");
    UD_UpdateMenuItemLabel(ID_LangTranslateOffline , "Translate o&ffline"   , "");
    UD_UpdateMenuItemLabel(ID_LangOpenFolder       , "&Translations folder" , "");

    // boot time scan sub-menu
    UD_UpdateMenuItemLabel(ID_BootEnable , "&Enable" , "F11");
    UD_UpdateMenuItemLabel(ID_BootScript , "&Script" , "F12");

    // sorting sub-menu
    UD_UpdateMenuItemLabel(ID_SortByPath             , "By &path"                   , "");
    UD_UpdateMenuItemLabel(ID_SortBySize             , "By &size"                   , "");
    UD_UpdateMenuItemLabel(ID_SortByCreationDate     , "By &creation time"          , "");
    UD_UpdateMenuItemLabel(ID_SortByModificationDate , "By last &modification time" , "");
    UD_UpdateMenuItemLabel(ID_SortByLastAccessDate   , "By &last access time"       , "");
    UD_UpdateMenuItemLabel(ID_SortAscending          , "In &ascending order"        , "");
    UD_UpdateMenuItemLabel(ID_SortDescending         , "In &descending order"       , "");

    // help menu
    UD_UpdateMenuItemLabel(ID_HelpContents     , "&Contents"                   , "F1");
    UD_UpdateMenuItemLabel(ID_HelpBestPractice , "Best &practice"              , "F2");
    UD_UpdateMenuItemLabel(ID_HelpFaq          , "&Frequently asked questions" , "F3");
    UD_UpdateMenuItemLabel(ID_HelpLegend       , "Cluster map &legend"         , "");

    // upgrade sub-menu
    m_subMenuUpgrade->SetItemLabel(_("&Upgrade"));
    UD_UpdateMenuItemLabel(ID_HelpUpgradeNone   , "&Never check"                , "");
    UD_UpdateMenuItemLabel(ID_HelpUpgradeStable , "Check &stable releases only" , "");
    UD_UpdateMenuItemLabel(ID_HelpUpgradeAll    , "Check &all releases"         , "");
    UD_UpdateMenuItemLabel(ID_HelpUpgradeCheck  , "&Check now"                  , "");
    UD_UpdateMenuItemLabel(ID_HelpAbout         , "&About"                      , "F4");

    // debug sub-menu
    m_subMenuDebug->SetItemLabel(_("&Debug"));
    UD_UpdateMenuItemLabel(ID_DebugLog  , "Open &log"        , "Alt+L");
    UD_UpdateMenuItemLabel(ID_DebugSend , "Send bug &report" , "");

    // update tool-tips that differ from menu labels
    wxString label = _("&Boot time scan"); label << wxT(" (F11)");
    m_toolBar->SetToolShortHelp(ID_BootEnable,label);
    label = _("Boot time script"); label << wxT(" (F12)");
    m_toolBar->SetToolShortHelp(ID_BootScript,label);
    label = _("&Help"); label << wxT(" (F1)");
    m_toolBar->SetToolShortHelp(ID_HelpContents,label);

    // update list column labels
    wxListItem item; item.SetMask(wxLIST_MASK_TEXT);
    item.SetText(_("Drive"));         m_vList->SetColumn(0,item);
    item.SetText(_("Status"));        m_vList->SetColumn(1,item);
    item.SetText(_("Fragmentation")); m_vList->SetColumn(2,item);
    item.SetText(_("Total space"));   m_vList->SetColumn(3,item);
    item.SetText(_("Free space"));    m_vList->SetColumn(4,item);
    //xgettext:no-c-format
    item.SetText(_("% free"));        m_vList->SetColumn(5,item);

    // set mono-space font for the list unless Burmese translation is selected
    if(g_locale->GetCanonicalName().Left(2) != wxT("my")){
        wxFont font = m_vList->GetFont();
        if(font.SetFaceName(wxT("Courier New")))
            m_vList->SetFont(font);
    } else {
        m_vList->SetFont(*m_vListFont);
    }

    // update list status fields
    for(int i = 0; i < m_vList->GetItemCount(); i++){
        int letter = (int)m_vList->GetItemText(i)[0];
        wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED,ID_UpdateVolumeStatus);
        event.SetInt(letter); ProcessEvent(event);
    }

    // update task-bar icon overlay
    ProcessCommandEvent(ID_AdjustTaskbarIconOverlay);

    // update progress counters
    ProcessCommandEvent(ID_UpdateStatusBar);

    // update report translation
    App::SaveReportTranslation();
}
Ejemplo n.º 4
0
/**
 * @brief Initializes main window.
 */
MainFrame::MainFrame()
    :wxFrame(NULL,wxID_ANY,wxT("UltraDefrag"))
{
    g_mainFrame = this;
    m_vList = NULL;
    m_cMap = NULL;
    m_currentJob = NULL;
    m_busy = false;
    m_paused = false;

    // set main window icon
    SetIcons(wxICON(appicon));

    // read configuration
    ReadAppConfiguration();
    ProcessCommandEvent(ID_ReadUserPreferences);

    // set main window title
    wxString *instdir = new wxString();
    //genBTC re-arranged the below, A LOT.
    wxStandardPaths stdpaths;
    wxFileName exepath(stdpaths.GetExecutablePath());
    wxString cd = exepath.GetPath();
    if((wxGetEnv(wxT("UD_INSTALL_DIR"),instdir))&&(cd.CmpNoCase(*instdir) == 0)) {
        itrace("current directory matches installation location, so it isn't portable");
        itrace("installation location: %ls",instdir->wc_str());
        m_title = new wxString(wxT(VERSIONINTITLE));
    } else {
        itrace("current directory differs from installation location, so it is portable");
        itrace("current directory: %ls",cd.wc_str());
        wxSetEnv(wxT("UD_IS_PORTABLE"),wxT("1"));
        m_title = new wxString(wxT(VERSIONINTITLE_PORTABLE));
    }
    //genBTC re-arranged the above, A LOT.
    ProcessCommandEvent(ID_SetWindowTitle);
    delete instdir;

    // set main window size and position
    SetSize(m_width,m_height);
    if(!m_saved){
        CenterOnScreen();
        GetPosition(&m_x,&m_y);
    }
    Move(m_x,m_y);
    if(m_maximized) Maximize(true);

    SetMinSize(wxSize(DPI(MAIN_WINDOW_MIN_WIDTH),DPI(MAIN_WINDOW_MIN_HEIGHT)));

    // create menu, tool and status bars
    InitMenu(); InitToolbar(); InitStatusBar();

	//make sizer1 to hold the the tabbed "notebook". And make the notebook
	wxBoxSizer* bSizer1;
	bSizer1 = new wxBoxSizer( wxVERTICAL );
	m_notebook1 = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );

	//make a panel inside the notebook to hold the m_splitter
	m_panel1 = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );

    // create list of volumes and cluster map (with splitter as parent)
    m_splitter = new wxSplitterWindow(m_panel1,wxID_ANY, wxDefaultPosition,wxDefaultSize, 
                                      wxSP_3D | wxCLIP_CHILDREN);
    m_splitter->SetMinimumPaneSize(DPI(MIN_PANEL_HEIGHT));

    m_vList = new DrivesList(m_splitter,wxLC_REPORT | wxLC_NO_SORT_HEADER | 
                             wxLC_HRULES | wxLC_VRULES | wxBORDER_NONE);

    m_cMap = new ClusterMap(m_splitter);

    m_splitter->SplitHorizontally(m_vList,m_cMap);

    int height = GetClientSize().GetHeight();
    int maxPanelHeight = height - DPI(MIN_PANEL_HEIGHT) - m_splitter->GetSashSize();
    if(m_separatorPosition < DPI(MIN_PANEL_HEIGHT)) m_separatorPosition = DPI(MIN_PANEL_HEIGHT);
    else if(m_separatorPosition > maxPanelHeight) m_separatorPosition = maxPanelHeight;
    m_splitter->SetSashPosition(m_separatorPosition);

    // update frame layout so we'll be able to initialize
    // list of volumes and cluster map properly
    wxSizeEvent evt(wxSize(m_width,m_height));
    ProcessEvent(evt); m_splitter->UpdateSize();

    InitVolList();
    m_vList->SetFocus();

    // populate list of volumes
    m_listThread = new ListThread();

    //make sizer2 to Fit the splitter, and initialize it.
	wxBoxSizer* bSizer2;
	bSizer2 = new wxBoxSizer( wxVERTICAL );
	bSizer2->Add( m_splitter, 1, wxEXPAND, 1 );
	m_panel1->SetSizer( bSizer2 );

	//Finish Tab1 - Add the Panel1(Splitter+sizer2) to the notebook.
	m_notebook1->AddPage( m_panel1, wxT("Drives"), false );

	//make a 2nd panel inside the notebook to hold the 2nd page(a grid)
	m_panel2 = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );

    m_filesList = new FilesList(m_panel2,wxLC_REPORT /* | wxLC_SINGLE_SEL  | wxLC_NO_SORT_HEADER*/ \
                                        | wxLC_VIRTUAL | wxLC_HRULES | wxLC_VRULES | wxBORDER_NONE);
    InitFilesList();

	//make sizer3 to Fit the page2list, and initialize it.
	wxBoxSizer* bSizer3;
	bSizer3 = new wxBoxSizer( wxVERTICAL );
	bSizer3->Add( m_filesList, 1, wxEXPAND, 1 );
	m_panel2->SetSizer( bSizer3 );
    bSizer3->Fit( m_panel2 );

	//Finish Tab 2 - Add the Panel2(page2list+sizer3) to the notebook.
	m_notebook1->AddPage( m_panel2, wxT("Files"), false );

    //Finish Notebook & initialize
	bSizer1->Add( m_notebook1, 1, wxEXPAND, 1 );
	this->SetSizer( bSizer1 );

    // check the boot time defragmenter presence
    wxFileName btdFile(wxT("%SystemRoot%\\system32\\defrag_native.exe"));
    btdFile.Normalize();
    bool btd = btdFile.FileExists();
    m_menuBar->FindItem(ID_BootEnable)->Enable(btd);
    m_menuBar->FindItem(ID_BootScript)->Enable(btd);
    m_toolBar->EnableTool(ID_BootEnable,btd);
    m_toolBar->EnableTool(ID_BootScript,btd);
    if(btd && ::winx_bootex_check(L"defrag_native") > 0){
        m_menuBar->FindItem(ID_BootEnable)->Check(true);
        m_toolBar->ToggleTool(ID_BootEnable,true);
        m_btdEnabled = true;
    } else {
        m_btdEnabled = false;
    }

    // launch threads for time consuming operations
    m_btdThread = btd ? new BtdThread() : NULL;
    m_configThread = new ConfigThread();
    m_crashInfoThread = new CrashInfoThread();

    wxConfigBase *cfg = wxConfigBase::Get();
    int ulevel = (int)cfg->Read(wxT("/Upgrade/Level"),1);
    wxMenuItem *item = m_menuBar->FindItem(ID_HelpUpgradeNone + ulevel);
    if(item) item->Check();

    m_upgradeThread = new UpgradeThread(ulevel);

    // set system tray icon
    m_systemTrayIcon = new SystemTrayIcon();
    if(!m_systemTrayIcon->IsOk()){
        etrace("system tray icon initialization failed");
        wxSetEnv(wxT("UD_MINIMIZE_TO_SYSTEM_TRAY"),wxT("0"));
    }
    SetSystemTrayIcon(wxT("tray"),wxT("UltraDefrag"));

    // set localized text
    ProcessCommandEvent(ID_LocaleChange + g_locale->GetLanguage());

    // allow disk processing
    m_jobThread = new JobThread();

    //create query thread to perform queries without blocking the GUI
    //(sort of like jobs) - may not be good to have both possibly running at once.
    //Create Query Tab, Tab #3.
    InitQueryMenu();
    
    UD_DisableTool(ID_Stop);    //change stop icon to be not always enabled.
}
Ejemplo n.º 5
0
void SystemTrayIcon::OnLeftButtonUp(wxTaskBarIconEvent& WXUNUSED(event))
{
    ProcessCommandEvent(ID_ShowHideMenu);
}