Commit 07a43dbc authored by shubham's avatar shubham

Layout dashboard changes

parent 919d8c05
......@@ -27,6 +27,17 @@ namespace Personal_Insight.ComputeProduct
//calculate_numFiles();
gatherDevices();
setStatInfo();
}
private void setStatInfo()
{
googleProduct.NumItems = devicesList.Count;
if (devicesList.Count > 0)
{
GoogleProduct.isProcessed = true;
}
}
private void gatherDevices()
......
......@@ -25,7 +25,16 @@ namespace Personal_Insight.ComputeProduct
calculate_numFiles();
gatherData();
setStatInfo();
}
private void setStatInfo()
{
googleProduct.NumItems = shoppingList_list.Count;
if (shoppingList_list.Count > 0)
{
GoogleProduct.isProcessed = true;
}
}
private void gatherData()
......
......@@ -27,8 +27,16 @@ namespace Personal_Insight.ComputeProduct
calculate_numFiles();
gatherData();
setStatInfo();
}
private void setStatInfo()
{
googleProduct.NumItems = blogList.Count;
if (blogList.Count > 0)
{
GoogleProduct.isProcessed = true;
}
}
private void gatherData()
......
......@@ -26,6 +26,16 @@ namespace Personal_Insight.ComputeProduct
page.enterLog("Starting work on Bookmarks");
gatherData();
setStatInfo();
}
private void setStatInfo()
{
googleProduct.NumItems = bookmarks.Count;
if (bookmarks.Count > 0)
{
GoogleProduct.isProcessed = true;
}
}
private void gatherData()
......
......@@ -30,7 +30,16 @@ namespace Personal_Insight.ComputeProduct
page.enterLog("Starting work on Calendar");
gatherData();
setStatInfo();
}
private void setStatInfo()
{
googleProduct.NumItems = calendarEvents.Count;
if (calendarEvents.Count > 0)
{
GoogleProduct.isProcessed = true;
}
}
private void gatherData()
......
......@@ -75,6 +75,26 @@ namespace Personal_Insight.ComputeProduct
}
}
setStatInfo();
}
private void setStatInfo()
{
googleProduct.NumItems = bookMarks.Count +
searchEnginesModel.SearchEngines.Count +
extensionsModel.Extensions.Count +
dictionaryWords.Count +
browserHistoryModel.BrowserHistory.Count +
autofillContent.Autofill.Count;
if (bookMarks.Count > 0 ||
searchEnginesModel.SearchEngines.Count > 0 ||
extensionsModel.Extensions.Count > 0 ||
dictionaryWords.Count > 0 ||
browserHistoryModel.BrowserHistory.Count > 0 ||
autofillContent.Autofill.Count > 0)
{
GoogleProduct.isProcessed = true;
}
}
private void gather_AutoFills(String jsonText)
......
......@@ -26,9 +26,19 @@ namespace Personal_Insight.ComputeProduct
page.enterLog("Starting work on Classic Sites");
gatherData(googleProduct.ProductFolderPath);
setStatInfo();
}
private void setStatInfo()
{
googleProduct.NumItems = siteList.Count;
if (siteList.Count > 0)
{
GoogleProduct.isProcessed = true;
}
}
private void gatherData(string productFolderPath)
{
siteList = new List<Site>();
......
......@@ -29,6 +29,16 @@ namespace Personal_Insight.ComputeProduct
page.enterLog("Starting work on Cloud Print");
gatherData(googleProduct.ProductFolderPath);
setStatInfo();
}
private void setStatInfo()
{
googleProduct.NumItems = printerJobsList.Count + printerList.Count;
if (printerJobsList.Count > 0 || printerList.Count > 0)
{
GoogleProduct.isProcessed = true;
}
}
private void gatherData(string productFolderPath)
......
......@@ -29,6 +29,16 @@ namespace Personal_Insight.ComputeProduct
page.enterLog("Starting work on Contacts");
gatherData(googleProduct.ProductFolderPath);
setStatInfo();
}
private void setStatInfo()
{
googleProduct.NumItems = contactsList.Count;
if (contactsList.Count > 0)
{
GoogleProduct.isProcessed = true;
}
}
private void gatherData(string productFolderPath)
......
......@@ -27,6 +27,16 @@ namespace Personal_Insight.ComputeProduct
gatherData(googleProduct.ProductFolderPath);
page.enterLog("Logged " + fileInfoList.Count + " files in Google Drive");
setStatInfo();
}
private void setStatInfo()
{
googleProduct.NumItems = fileInfoList.Count;
if (fileInfoList.Count > 0)
{
GoogleProduct.isProcessed = true;
}
}
private void gatherData(string productFolderPath)
......
......@@ -25,6 +25,16 @@ namespace Personal_Insight.ComputeProduct
page.enterLog("Starting work on YouTube");
gatherData(googleProduct.ProductFolderPath);
setStatInfo();
}
private void setStatInfo()
{
/*googleProduct.NumItems = fileInfoList.Count;
if (fileInfoList.Count > 0)
{
GoogleProduct.isProcessed = true;
}*/
}
private void gatherData(string productFolderPath)
......
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace Personal_Insight.Models
......@@ -16,8 +17,9 @@ namespace Personal_Insight.Models
private String verifyModuleText;
private Object productObject;
private long dirSize;
private long numItems;
private string isModuleDisabledText;
private double dirSize = 0;
private long numItems = 0;
public GoogleProductModel(string productName, string productFolderPath, BitmapImage imageResource, Object productObject)
......@@ -45,5 +47,16 @@ namespace Personal_Insight.Models
public String VerifyModuleText { get => verifyModuleText; set => verifyModuleText = value; }
public Object ProductObject { get => productObject; set => productObject = value; }
public long NumItems { get => numItems; set => numItems = value; }
public double DirSize { get => dirSize; set => dirSize = value; }
public bool isProcessed { get; set; }
public string IsModuleDisabledText {
get
{
if (numItems != 0)
return "";
else return "This module is disabled";
}
}
}
}
......@@ -15,12 +15,11 @@ namespace Personal_Insight.Models
}
public static long DirSize(DirectoryInfo d)
public static double DirSize(DirectoryInfo d)
{
double size = 0;
try
{
long size = 0;
// Add file sizes.
FileInfo[] fis = d.GetFiles();
foreach (FileInfo fi in fis)
......@@ -38,8 +37,27 @@ namespace Personal_Insight.Models
catch(Exception e)
{
//Console.WriteLine("ERROR: {0} Exception caught.", e);
return 0;
return size;
}
}
public static Tuple<double, string> ByteToString(double len)
{
string[] sizes = { "Bytes", "KB", "MB", "GB", "TB" };
int order = 0;
while (len >= 1024 && order < sizes.Length - 1)
{
order++;
len = len / 1024;
}
// Adjust the format string to your preferences. For example "{0:0.#}{1}" would
// show a single decimal place, and no space.
//string result = String.Format("{0:0.##} {1}", len, sizes[order]);
return Tuple.Create(len,sizes[order]);
}
}
}
This diff is collapsed.
......@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
......@@ -22,6 +23,9 @@ namespace Personal_Insight.Pages
public partial class Dashboard : Page
{
private List<GoogleProductModel> googleProductList;
private long loggedFiles = 0;
private double takeoutSize = 0;
private String takeoutSizeType;
public Dashboard(List<GoogleProductModel> googleProductList)
{
......@@ -36,5 +40,46 @@ namespace Personal_Insight.Pages
{
listBox.ItemsSource = googleProductList;
}
private void Window_ContentRendered(object sender, RoutedEventArgs e)
{
foreach(GoogleProductModel googleProduct in googleProductList)
{
loggedFiles += googleProduct.NumItems;
takeoutSize += googleProduct.DirSize;
}
Console.WriteLine("Logged files: " + loggedFiles);
Console.WriteLine("Takeout bytes: " + takeoutSize);
var tuple = HelpfulMethods.ByteToString(takeoutSize);
takeoutSizeType = tuple.Item2;
takeoutSize = tuple.Item1;
new Thread(CountUpText).Start();
}
public void CountUpText()
{
var watch = System.Diagnostics.Stopwatch.StartNew();
var elapsedMs = watch.ElapsedMilliseconds;
while (elapsedMs < 1000)
{
this.Dispatcher.Invoke(() => {
loggedText.Text = ((int) (loggedFiles*(elapsedMs/1000.0))).ToString();
takeoutSizeText.Text = ((int)(takeoutSize * (elapsedMs / 1000.0))) + " " + takeoutSizeType;
});
elapsedMs = watch.ElapsedMilliseconds;
}
watch.Stop();
this.Dispatcher.Invoke(() => {
loggedText.Text = loggedFiles.ToString();
//string result = String.Format("{0:0.##} {1}", len, sizes[order]);
takeoutSizeText.Text = (String.Format("{0:0.##} ", takeoutSize)) + takeoutSizeType;
});
}
}
}
......@@ -42,9 +42,6 @@ namespace Personal_Insight
private void Window_ContentRendered(object sender, EventArgs e)
{
open_folder_btn.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Primitives.ButtonBase.ClickEvent));
System.Threading.Thread.Sleep(1000);
SendKeys.SendWait("{ENTER}"); // How to press enter?
System.Threading.Thread.Sleep(1000);
next_btn.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Primitives.ButtonBase.ClickEvent));
}
......
......@@ -98,6 +98,7 @@ namespace Personal_Insight.Pages
for (int i = 0; i < googleProductList.Count; i++)
{
googleProductList.ElementAt(i).DirSize = HelpfulMethods.DirSize(new DirectoryInfo(googleProductList.ElementAt(i).ProductFolderPath));
product_worker(googleProductList.ElementAt(i));
decimal send = ( ((i + 1) / (decimal)googleProductList.Count) * 100);
(sender as BackgroundWorker).ReportProgress((int)send); // TODO Add a check if count==0
......@@ -112,7 +113,9 @@ namespace Personal_Insight.Pages
{
enterLog("Working on module: " + product.ProductName + " in path, " + product.ProductFolderPath);
enterLog("The size is " + HelpfulMethods.DirSize(new DirectoryInfo(product.ProductFolderPath)) + "bytes");
var tuple = HelpfulMethods.ByteToString(product.DirSize);
string result = String.Format("{0:0.##} {1}", tuple.Item1, tuple.Item2);
enterLog("The size is " + result);
//Starting worker
GoogleProductsList.StartWork(product,this);
......
......@@ -15,6 +15,8 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
......@@ -26,13 +28,11 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<AutorunEnabled>true</AutorunEnabled>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment