2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-01-20 23:22:22 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2004-09-21 01:30:29 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2004-09-21 01:30:29 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-01-20 23:22:22 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
2004-09-21 01:30:29 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma implementation "ViewResources.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
|
|
|
#include "BOINCGUIApp.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "BOINCBaseFrame.h"
|
2004-09-21 01:30:29 +00:00
|
|
|
#include "MainDocument.h"
|
2009-12-22 01:22:11 +00:00
|
|
|
#include "AdvancedFrame.h"
|
2004-09-24 22:19:02 +00:00
|
|
|
#include "BOINCTaskCtrl.h"
|
|
|
|
#include "BOINCListCtrl.h"
|
2004-09-21 01:30:29 +00:00
|
|
|
#include "ViewResources.h"
|
|
|
|
#include "Events.h"
|
2006-10-17 00:18:04 +00:00
|
|
|
#include <wx/arrimpl.cpp>
|
2004-09-21 01:30:29 +00:00
|
|
|
#include "res/usage.xpm"
|
|
|
|
|
2016-09-01 16:20:08 +00:00
|
|
|
WX_DEFINE_OBJARRAY(wxArrayColour)
|
2006-10-17 00:18:04 +00:00
|
|
|
|
2004-09-24 22:19:02 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CViewResources, CBOINCBaseView)
|
2004-09-21 01:30:29 +00:00
|
|
|
|
2005-04-21 06:04:26 +00:00
|
|
|
BEGIN_EVENT_TABLE (CViewResources, CBOINCBaseView)
|
|
|
|
END_EVENT_TABLE ()
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
|
2005-09-02 18:40:06 +00:00
|
|
|
CViewResources::CViewResources()
|
|
|
|
{}
|
2004-09-21 01:30:29 +00:00
|
|
|
|
2008-05-13 19:52:35 +00:00
|
|
|
CViewResources::CViewResources(wxNotebook* pNotebook) :
|
2006-10-09 17:38:59 +00:00
|
|
|
CBOINCBaseView(pNotebook)
|
2005-04-21 06:04:26 +00:00
|
|
|
{
|
2007-07-19 01:29:57 +00:00
|
|
|
m_BOINCwasEmpty=false;
|
|
|
|
|
2007-01-19 00:59:31 +00:00
|
|
|
wxGridSizer* itemGridSizer = new wxGridSizer(2, 0, 3);
|
|
|
|
wxASSERT(itemGridSizer);
|
2006-10-12 12:52:19 +00:00
|
|
|
|
2006-10-09 17:38:59 +00:00
|
|
|
// create pie chart ctrl for total disk usage
|
2012-01-06 17:12:19 +00:00
|
|
|
m_pieCtrlTotal = new wxPieCtrl(this, ID_PIECTRL_RESOURCEUTILIZATIONVIEWTOTAL, wxDefaultPosition, wxDefaultSize);
|
2006-10-09 17:38:59 +00:00
|
|
|
wxASSERT(m_pieCtrlTotal);
|
2009-03-09 03:50:35 +00:00
|
|
|
|
|
|
|
// setup the legend
|
|
|
|
m_pieCtrlTotal->SetTransparent(true);
|
|
|
|
m_pieCtrlTotal->SetHorLegendBorder(10);
|
|
|
|
m_pieCtrlTotal->SetLabelFont(*wxSWISS_FONT);
|
|
|
|
m_pieCtrlTotal->SetLabelColour(wxColour(0,0,0));
|
|
|
|
m_pieCtrlTotal->SetLabel(_("Total disk usage"));
|
|
|
|
|
|
|
|
// initialize pie control
|
|
|
|
m_pieCtrlTotal->m_Series.Clear();
|
|
|
|
wxPiePart CtrlTotalPart;
|
|
|
|
CtrlTotalPart.SetLabel(wxEmptyString);
|
|
|
|
CtrlTotalPart.SetValue(1);
|
|
|
|
CtrlTotalPart.SetColour(wxColour(255,255,255));
|
|
|
|
m_pieCtrlTotal->m_Series.Add(CtrlTotalPart);
|
|
|
|
m_pieCtrlTotal->Refresh();
|
|
|
|
|
|
|
|
|
|
|
|
// create pie chart ctrl for BOINC disk usage
|
2012-01-06 17:12:19 +00:00
|
|
|
m_pieCtrlBOINC = new wxPieCtrl(this, ID_PIECTRL_RESOURCEUTILIZATIONVIEW, wxDefaultPosition, wxDefaultSize);
|
2006-10-09 17:38:59 +00:00
|
|
|
wxASSERT(m_pieCtrlBOINC);
|
2009-03-09 03:50:35 +00:00
|
|
|
|
|
|
|
//setup the legend
|
|
|
|
m_pieCtrlBOINC->SetTransparent(true);
|
|
|
|
m_pieCtrlBOINC->SetHorLegendBorder(10);
|
|
|
|
m_pieCtrlBOINC->SetLabelFont(*wxSWISS_FONT);
|
|
|
|
m_pieCtrlBOINC->SetLabelColour(wxColour(0,0,0));
|
|
|
|
m_pieCtrlBOINC->SetLabel(_("Disk usage by BOINC projects"));
|
|
|
|
|
|
|
|
// initialize pie control
|
|
|
|
m_pieCtrlBOINC->m_Series.Clear();
|
|
|
|
wxPiePart CtrlBOINCPart;
|
|
|
|
CtrlBOINCPart.SetLabel(wxEmptyString);
|
|
|
|
CtrlBOINCPart.SetValue(1);
|
|
|
|
CtrlBOINCPart.SetColour(wxColour(255,255,255));
|
|
|
|
m_pieCtrlBOINC->m_Series.Add(CtrlBOINCPart);
|
2021-02-20 20:31:18 +00:00
|
|
|
m_pieCtrlTotal->SetLayoutDirection(wxLayout_LeftToRight);
|
2021-02-21 02:15:35 +00:00
|
|
|
m_pieCtrlBOINC->SetLayoutDirection(wxLayout_LeftToRight);
|
2009-03-09 03:50:35 +00:00
|
|
|
m_pieCtrlBOINC->Refresh();
|
|
|
|
|
|
|
|
//init the flexGrid
|
|
|
|
itemGridSizer->Add(m_pieCtrlTotal, 1, wxGROW|wxALL,1);
|
|
|
|
itemGridSizer->Add(m_pieCtrlBOINC, 1, wxGROW|wxALL,1);
|
2006-10-09 17:38:59 +00:00
|
|
|
|
2012-01-06 17:12:19 +00:00
|
|
|
SetSizer(itemGridSizer);
|
2005-04-22 01:46:32 +00:00
|
|
|
|
|
|
|
UpdateSelection();
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
CViewResources::~CViewResources() {
|
2005-04-21 06:04:26 +00:00
|
|
|
EmptyTasks();
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-02 21:03:36 +00:00
|
|
|
wxString& CViewResources::GetViewName() {
|
2009-05-01 01:32:26 +00:00
|
|
|
static wxString strViewName(wxT("Disk"));
|
2005-09-02 20:56:08 +00:00
|
|
|
return strViewName;
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
- fixes #207 - HTML entities in BOINC Manager have to be decoded
BOINC Manager can now properly decode HTML entites for the
following elements:
Projects Tab:
Project Name
User Name
Team Name
Work Tab:
Project Name
Application Name
Transfers Tab:
Project Name
Messages Tab:
Project Name
Disk Tab:
Project Name
- fixes #212 - Info in columns misaligned on switching views
- Properly restore which tab view the user left from when going
to the advanced view from the simple view
- Fix the problem that caused the manager to wait for 7 seconds
to display anything on initial startup.
- Store the various Grid/List persisted data seperately so that
the different header sizes don't cause problems.
clientgui/
AdvancedFrame.cpp
BOINCBaseView.cpp, .h
BOINCGridCtrl.cpp
ViewMessages.cpp, .h
ViewMessagesGrid.cpp, .h
ViewProjects.cpp, .h
ViewProjectsGrid.cpp, .h
ViewResources.cpp, .h
ViewStatistics.cpp, .h
ViewTransfers.cpp, .h
ViewTransfersGrid.cpp, .h
ViewWork.cpp, .h
ViewWorkGrid.cpp, .h
lib/
gui_rpc_client_ops.C
svn path=/trunk/boinc/; revision=12761
2007-05-29 05:07:35 +00:00
|
|
|
wxString& CViewResources::GetViewDisplayName() {
|
|
|
|
static wxString strViewName(_("Disk"));
|
|
|
|
return strViewName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
const char** CViewResources::GetViewIcon() {
|
2004-09-21 01:30:29 +00:00
|
|
|
return usage_xpm;
|
|
|
|
}
|
|
|
|
|
2004-09-24 22:19:02 +00:00
|
|
|
|
2013-02-07 18:26:02 +00:00
|
|
|
int CViewResources::GetViewRefreshRate() {
|
2007-05-11 06:04:41 +00:00
|
|
|
return 10;
|
|
|
|
}
|
2009-12-22 01:22:11 +00:00
|
|
|
|
|
|
|
|
2013-02-07 18:26:02 +00:00
|
|
|
int CViewResources::GetViewCurrentViewPage() {
|
2009-12-22 01:22:11 +00:00
|
|
|
return VW_DISK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CViewResources::UpdateSelection() {
|
|
|
|
CBOINCBaseView::PreUpdateSelection();
|
|
|
|
}
|
2007-05-11 06:04:41 +00:00
|
|
|
|
|
|
|
|
2006-11-03 18:00:15 +00:00
|
|
|
wxInt32 CViewResources::FormatProjectName(PROJECT* project, wxString& strBuffer) const {
|
2005-06-13 08:47:51 +00:00
|
|
|
CMainDocument* doc = wxGetApp().GetDocument();
|
|
|
|
std::string project_name;
|
2004-10-22 22:37:11 +00:00
|
|
|
|
2005-06-13 08:47:51 +00:00
|
|
|
wxASSERT(doc);
|
|
|
|
wxASSERT(wxDynamicCast(doc, CMainDocument));
|
2004-10-22 22:37:11 +00:00
|
|
|
|
2006-11-03 17:08:49 +00:00
|
|
|
if (project) {
|
2006-11-03 18:00:15 +00:00
|
|
|
PROJECT* state_project = doc->state.lookup_project(project->master_url);
|
2005-06-13 08:47:51 +00:00
|
|
|
if (state_project) {
|
|
|
|
state_project->get_name(project_name);
|
- fixes #207 - HTML entities in BOINC Manager have to be decoded
BOINC Manager can now properly decode HTML entites for the
following elements:
Projects Tab:
Project Name
User Name
Team Name
Work Tab:
Project Name
Application Name
Transfers Tab:
Project Name
Messages Tab:
Project Name
Disk Tab:
Project Name
- fixes #212 - Info in columns misaligned on switching views
- Properly restore which tab view the user left from when going
to the advanced view from the simple view
- Fix the problem that caused the manager to wait for 7 seconds
to display anything on initial startup.
- Store the various Grid/List persisted data seperately so that
the different header sizes don't cause problems.
clientgui/
AdvancedFrame.cpp
BOINCBaseView.cpp, .h
BOINCGridCtrl.cpp
ViewMessages.cpp, .h
ViewMessagesGrid.cpp, .h
ViewProjects.cpp, .h
ViewProjectsGrid.cpp, .h
ViewResources.cpp, .h
ViewStatistics.cpp, .h
ViewTransfers.cpp, .h
ViewTransfersGrid.cpp, .h
ViewWork.cpp, .h
ViewWorkGrid.cpp, .h
lib/
gui_rpc_client_ops.C
svn path=/trunk/boinc/; revision=12761
2007-05-29 05:07:35 +00:00
|
|
|
strBuffer = HtmlEntityDecode(wxString(project_name.c_str(), wxConvUTF8));
|
2005-06-13 08:47:51 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-22 22:37:11 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-19 23:45:19 +00:00
|
|
|
bool CViewResources::OnSaveState(wxConfigBase* /*pConfig*/) {
|
2009-03-09 03:50:35 +00:00
|
|
|
return true;
|
2006-10-09 17:38:59 +00:00
|
|
|
}
|
|
|
|
|
2007-01-19 23:45:19 +00:00
|
|
|
bool CViewResources::OnRestoreState(wxConfigBase* /*pConfig*/) {
|
2009-03-09 03:50:35 +00:00
|
|
|
return true;
|
2006-10-09 17:38:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CViewResources::OnListRender( wxTimerEvent& WXUNUSED(event) ) {
|
2006-11-03 17:08:49 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-11-03 08:50:36 +00:00
|
|
|
wxString diskspace;
|
2008-05-14 17:26:15 +00:00
|
|
|
static double project_total=0.0;
|
2006-11-03 18:00:15 +00:00
|
|
|
unsigned int i;
|
2006-10-09 17:38:59 +00:00
|
|
|
|
2006-11-03 08:50:36 +00:00
|
|
|
wxASSERT(pDoc);
|
2006-11-03 17:08:49 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2008-05-13 19:52:35 +00:00
|
|
|
|
2006-10-09 17:38:59 +00:00
|
|
|
//get data for BOINC projects disk usage
|
2006-11-03 17:08:49 +00:00
|
|
|
pDoc->CachedDiskUsageUpdate();
|
|
|
|
pDoc->CachedStateUpdate();
|
2015-08-31 19:56:18 +00:00
|
|
|
bool refreshBOINC = false;
|
2006-11-03 18:00:15 +00:00
|
|
|
if (pDoc->disk_usage.projects.size()>0) {
|
2007-07-19 01:29:57 +00:00
|
|
|
m_BOINCwasEmpty=false;
|
2008-05-13 19:52:35 +00:00
|
|
|
//check for changes worth a refresh
|
2015-08-31 19:56:18 +00:00
|
|
|
if (pDoc->disk_usage.projects.size() != m_pieCtrlBOINC->m_Series.size()) {
|
|
|
|
refreshBOINC = true;
|
2008-05-13 19:52:35 +00:00
|
|
|
} else {
|
2007-07-19 01:29:57 +00:00
|
|
|
for (i=0; i<pDoc->disk_usage.projects.size(); i++) {
|
|
|
|
wxString oldValue;
|
|
|
|
wxString newValue;
|
|
|
|
FormatDiskSpace(pDoc->DiskUsageProject(i)->disk_usage, newValue);
|
|
|
|
FormatDiskSpace(m_pieCtrlBOINC->m_Series.Item(i).GetValue(), oldValue);
|
|
|
|
if(newValue.Cmp(oldValue)!=0) {
|
2015-08-31 19:56:18 +00:00
|
|
|
refreshBOINC = true;
|
2007-07-19 01:29:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-08-31 19:56:18 +00:00
|
|
|
// only refresh when worthy changes
|
|
|
|
if (refreshBOINC) {
|
2007-07-19 01:29:57 +00:00
|
|
|
m_pieCtrlBOINC->m_Series.Clear();
|
2008-05-14 17:26:15 +00:00
|
|
|
project_total = 0;
|
2007-07-19 01:29:57 +00:00
|
|
|
for (i=0; i<pDoc->disk_usage.projects.size(); i++) {
|
2008-05-13 19:52:35 +00:00
|
|
|
//update data for boinc projects pie chart
|
2007-07-19 01:29:57 +00:00
|
|
|
PROJECT* project = pDoc->DiskUsageProject(i);
|
2008-05-13 19:52:35 +00:00
|
|
|
wxString projectname;
|
2007-07-19 01:29:57 +00:00
|
|
|
FormatProjectName(project, projectname);
|
|
|
|
FormatDiskSpace(project->disk_usage, diskspace);
|
|
|
|
double usage = project->disk_usage;
|
2008-05-14 17:26:15 +00:00
|
|
|
project_total += usage;
|
2007-07-19 01:29:57 +00:00
|
|
|
wxPiePart part;
|
2008-10-21 17:26:21 +00:00
|
|
|
part.SetLabel(projectname + wxT(": ") + diskspace);
|
2007-07-19 01:29:57 +00:00
|
|
|
part.SetValue(usage);
|
2014-08-10 22:33:07 +00:00
|
|
|
wxColour color;
|
|
|
|
color_cycle(i, pDoc->disk_usage.projects.size(), color);
|
|
|
|
part.SetColour(color);
|
2007-07-19 01:29:57 +00:00
|
|
|
m_pieCtrlBOINC->m_Series.Add(part);
|
|
|
|
}
|
|
|
|
m_pieCtrlBOINC->Refresh();
|
2006-10-09 17:38:59 +00:00
|
|
|
}
|
2006-11-03 17:08:49 +00:00
|
|
|
} else {
|
2007-07-19 01:29:57 +00:00
|
|
|
if(!m_BOINCwasEmpty) {
|
2009-03-09 03:50:35 +00:00
|
|
|
//paint an empty black pie
|
2007-07-19 01:29:57 +00:00
|
|
|
m_pieCtrlBOINC->m_Series.Clear();
|
|
|
|
wxPiePart part;
|
2010-10-06 20:13:34 +00:00
|
|
|
part.SetLabel(_("no projects: 0 bytes used"));
|
2008-05-14 17:26:15 +00:00
|
|
|
part.SetValue(1);
|
2007-07-19 01:29:57 +00:00
|
|
|
part.SetColour(wxColour(0,0,0));
|
2008-05-13 19:52:35 +00:00
|
|
|
m_pieCtrlBOINC->m_Series.Add(part);
|
2007-07-19 01:29:57 +00:00
|
|
|
m_pieCtrlBOINC->Refresh();
|
|
|
|
m_BOINCwasEmpty=true;
|
|
|
|
refreshBOINC=true;
|
2009-03-09 03:50:35 +00:00
|
|
|
}
|
2006-10-09 17:38:59 +00:00
|
|
|
}
|
2009-03-09 03:50:35 +00:00
|
|
|
|
2015-08-31 19:56:18 +00:00
|
|
|
// pDoc->disk_usage.d_allowed = 0;
|
|
|
|
// data for pie chart 2 (total disk usage)
|
2006-11-28 00:54:48 +00:00
|
|
|
//
|
2007-07-19 01:29:57 +00:00
|
|
|
bool refreshTotal=false;
|
2006-11-03 18:00:15 +00:00
|
|
|
double free = pDoc->disk_usage.d_free;
|
2007-05-10 10:51:58 +00:00
|
|
|
double total = pDoc->disk_usage.d_total;
|
2015-08-31 19:56:18 +00:00
|
|
|
if (m_pieCtrlTotal->m_Series.size()>0) {
|
2007-07-19 01:29:57 +00:00
|
|
|
wxString oldFree;
|
|
|
|
wxString newFree;
|
2008-05-13 19:52:35 +00:00
|
|
|
FormatDiskSpace(free, newFree);
|
|
|
|
FormatDiskSpace(m_pieCtrlTotal->m_Series.Item(0).GetValue(), oldFree);
|
2007-07-19 01:29:57 +00:00
|
|
|
if(oldFree.Cmp(newFree)!=0) {
|
2008-05-13 19:52:35 +00:00
|
|
|
refreshTotal=true;
|
2007-07-19 01:29:57 +00:00
|
|
|
}
|
2008-05-13 19:52:35 +00:00
|
|
|
} else {
|
2007-07-19 01:29:57 +00:00
|
|
|
refreshTotal=true;
|
2008-05-13 19:52:35 +00:00
|
|
|
}
|
2015-08-31 19:56:18 +00:00
|
|
|
if (refreshBOINC || refreshTotal) {
|
2007-07-19 01:29:57 +00:00
|
|
|
m_pieCtrlTotal->m_Series.Clear();
|
2008-05-13 19:52:35 +00:00
|
|
|
wxPiePart part;
|
|
|
|
|
2008-05-13 20:39:42 +00:00
|
|
|
// used by BOINC
|
2008-05-14 17:26:15 +00:00
|
|
|
double boinc_total = project_total + pDoc->disk_usage.d_boinc;
|
2008-05-22 03:57:55 +00:00
|
|
|
FormatDiskSpace(boinc_total, diskspace);
|
2008-10-21 17:26:21 +00:00
|
|
|
part.SetLabel(_("used by BOINC: ") + diskspace);
|
2008-05-14 17:26:15 +00:00
|
|
|
part.SetValue(boinc_total);
|
2007-07-19 01:29:57 +00:00
|
|
|
part.SetColour(wxColour(0,0,0));
|
|
|
|
m_pieCtrlTotal->m_Series.Add(part);
|
2008-05-13 19:52:35 +00:00
|
|
|
|
2008-10-21 17:26:21 +00:00
|
|
|
if (pDoc->disk_usage.d_allowed > 0) {
|
|
|
|
double avail = pDoc->disk_usage.d_allowed - boinc_total;
|
2017-04-06 12:27:02 +00:00
|
|
|
if (avail < 0) avail = 0;
|
|
|
|
if (avail > free) avail = free;
|
|
|
|
FormatDiskSpace(avail, diskspace);
|
|
|
|
part.SetLabel(_("free, available to BOINC: ") + diskspace);
|
|
|
|
part.SetValue(avail == 0 ? 1 : avail);
|
|
|
|
part.SetColour(wxColour(128, 128, 128));
|
|
|
|
m_pieCtrlTotal->m_Series.Add(part);
|
|
|
|
|
2008-10-21 17:26:21 +00:00
|
|
|
double not_avail = free - avail;
|
2008-11-02 20:09:59 +00:00
|
|
|
if (not_avail > 0) {
|
|
|
|
FormatDiskSpace(not_avail, diskspace);
|
|
|
|
part.SetLabel(_("free, not available to BOINC: ") + diskspace);
|
|
|
|
part.SetValue(not_avail);
|
|
|
|
part.SetColour(wxColour(238,238,238));
|
|
|
|
m_pieCtrlTotal->m_Series.Add(part);
|
|
|
|
}
|
2008-05-13 20:39:42 +00:00
|
|
|
} else {
|
2008-10-21 17:26:21 +00:00
|
|
|
// if d_allowed is zero, we must be talking to a pre-6.3 client.
|
|
|
|
// Just show free space
|
|
|
|
//
|
|
|
|
FormatDiskSpace(free, diskspace);
|
|
|
|
part.SetLabel(_("free: ") + diskspace);
|
|
|
|
part.SetValue(free);
|
|
|
|
part.SetColour(wxColour(238,238,238));
|
|
|
|
m_pieCtrlTotal->m_Series.Add(part);
|
2008-05-13 20:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// used by others
|
2008-05-14 17:26:15 +00:00
|
|
|
double used_by_others = total-boinc_total-free;
|
|
|
|
FormatDiskSpace(used_by_others, diskspace);
|
2008-10-21 17:26:21 +00:00
|
|
|
part.SetLabel(_("used by other programs: ") + diskspace);
|
2008-05-14 17:26:15 +00:00
|
|
|
part.SetValue(used_by_others);
|
2007-07-19 01:29:57 +00:00
|
|
|
part.SetColour(wxColour(192,192,192));
|
|
|
|
m_pieCtrlTotal->m_Series.Add(part);
|
|
|
|
m_pieCtrlTotal->Refresh();
|
|
|
|
}
|
2006-10-09 17:38:59 +00:00
|
|
|
}
|
|
|
|
|
2006-11-03 18:00:15 +00:00
|
|
|
wxInt32 CViewResources::FormatDiskSpace(double bytes, wxString& strBuffer) const {
|
2004-10-22 22:37:11 +00:00
|
|
|
double xTera = 1099511627776.0;
|
|
|
|
double xGiga = 1073741824.0;
|
|
|
|
double xMega = 1048576.0;
|
|
|
|
double xKilo = 1024.0;
|
|
|
|
|
2006-11-09 17:18:32 +00:00
|
|
|
if (bytes >= xTera) {
|
|
|
|
strBuffer.Printf(wxT("%0.2f TB"), bytes/xTera);
|
|
|
|
} else if (bytes >= xGiga) {
|
|
|
|
strBuffer.Printf(wxT("%0.2f GB"), bytes/xGiga);
|
|
|
|
} else if (bytes >= xMega) {
|
|
|
|
strBuffer.Printf(wxT("%0.2f MB"), bytes/xMega);
|
2005-04-07 07:04:50 +00:00
|
|
|
} else {
|
2010-10-28 20:37:50 +00:00
|
|
|
strBuffer.Printf(wxT("%0.2f KB"), bytes/xKilo);
|
2004-10-22 22:37:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|