Commit b890f18a authored by shubham's avatar shubham

Testing data binding

parent 49c89e44
......@@ -12,6 +12,7 @@ namespace Personal_Insight.Models
private String productName;
private String productFolderPath;
private BitmapImage imageData;
private long dirSize;
public GoogleProductModel(string productName, string productFolderPath, BitmapImage imageResource)
{
......
......@@ -79,7 +79,11 @@ namespace Personal_Insight.Models
break;
case Chrome:
fileName = "Calendar";
fileName = "Chrome";
break;
case GPC:
fileName = "GPC";
break;
case Contacts:
......@@ -223,7 +227,7 @@ namespace Personal_Insight.Models
break;
default:
fileName = "Google";
fileName = "NotFound";
break;
}
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
namespace Personal_Insight.Models
{
class HelpfulMethods
{
public HelpfulMethods()
{
}
public static long DirSize(DirectoryInfo d)
{
try
{
long size = 0;
// Add file sizes.
FileInfo[] fis = d.GetFiles();
foreach (FileInfo fi in fis)
{
size += fi.Length;
}
// Add subdirectory sizes.
DirectoryInfo[] dis = d.GetDirectories();
foreach (DirectoryInfo di in dis)
{
size += DirSize(di);
}
return size;
}
catch(Exception e)
{
Console.WriteLine("ERROR: {0} Exception caught.", e);
return 0;
}
}
}
}
......@@ -28,8 +28,16 @@ namespace Personal_Insight
private void P1BtnClick_begin(object sender, RoutedEventArgs e)
{
IntroPage_2 page2 = new IntroPage_2();
NavigationService.Navigate(page2);
if (NavigationService.CanGoForward)
{
NavigationService.GoForward();
}
else
{
IntroPage_2 page2 = new IntroPage_2();
NavigationService.Navigate(page2);
}
}
}
}
......@@ -34,14 +34,29 @@ namespace Personal_Insight
private void P2BtnClick_back(object sender, RoutedEventArgs e)
{
IntroPage_1 page1 = new IntroPage_1();
NavigationService.Navigate(page1);
if (NavigationService.CanGoBack)
{
NavigationService.GoBack();
}
else
{
IntroPage_1 page1 = new IntroPage_1();
NavigationService.Navigate(page1);
}
}
private void P2BtnClick_next(object sender, RoutedEventArgs e)
{
IntroPage_3 page3 = new IntroPage_3();
NavigationService.Navigate(page3);
if (NavigationService.CanGoForward)
{
NavigationService.GoForward();
}
else
{
IntroPage_3 page3 = new IntroPage_3();
NavigationService.Navigate(page3);
}
}
}
......
......@@ -56,7 +56,8 @@
<Image x:Name="itemImage" Margin="200,5,20,5" Source="{Binding ImageResource}" Width="32" Height="32"/>
<TextBlock Text="{Binding ProductName}" TextWrapping="Wrap" FontFamily="Microsoft YaHei UI Light" FontSize="16" Foreground="#DDE2E2E2" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0" TextAlignment="Left" Width="400" Grid.Column="1" Height="Auto"/>
<TextBlock Text="{Binding ProductFolderPath}" TextWrapping="Wrap" FontFamily="Microsoft YaHei UI Light" FontSize="14" Foreground="#DDA4A4A4" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0" TextAlignment="Left" Width="500" Grid.Column="2" Height="Auto"/>
<CheckBox Grid.Column="3" Width="Auto" Height="Auto" HorizontalAlignment="Right" IsChecked="True" Background="#FF39D80B" VerticalAlignment="Center" Padding="0" Margin="0,0,200,0"/>
<Image Source="/Personal Insight;component/assets/icons/icons8-tick-box-48.png" Width="32" Height="32"/>
<TextBlock Text="Imported Successfully!" TextWrapping="Wrap" FontFamily="Microsoft YaHei UI Light" FontSize="14" Foreground="#DDA4A4A4" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,200,0" TextAlignment="Left" Width="Auto" Grid.Column="2" Height="Auto"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
......
......@@ -15,6 +15,7 @@ using System.Windows.Shapes;
using System.IO;
using Microsoft.WindowsAPICodePack.Dialogs;
using Personal_Insight.Models;
using Personal_Insight.Pages;
namespace Personal_Insight
{
......@@ -25,24 +26,51 @@ namespace Personal_Insight
public partial class IntroPage_3 : Page
{
private List<GoogleProductModel> googleProductList;
private bool isPopulated;
public IntroPage_3()
{
InitializeComponent();
InitializeComponent();
ShowsNavigationUI = false;
//Init the arraylist
googleProductList = new List<GoogleProductModel>();
isPopulated = false;
}
private void P3BtnClick_next(object sender, RoutedEventArgs e)
{
if (isPopulated)
{
if (NavigationService.CanGoForward)
{
NavigationService.GoForward();
}
else
{
IntroPage_4 page4 = new IntroPage_4(googleProductList);
NavigationService.Navigate(page4);
}
}
else
{
MessageBox.Show("Please mount the Takeout folder before proceeding!", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
private void P3BtnClick_back(object sender, RoutedEventArgs e)
{
IntroPage_2 page2 = new IntroPage_2();
NavigationService.Navigate(page2);
if (NavigationService.CanGoBack)
{
NavigationService.GoBack();
}
else
{
IntroPage_2 page2 = new IntroPage_2();
NavigationService.Navigate(page2);
}
}
private void btnClick_openFile(object sender, RoutedEventArgs e)
......@@ -77,8 +105,7 @@ namespace Personal_Insight
private void populateArrayList(String folderName)
{
//listView.Items.Clear();
googleProductList.Clear();
string[] files = Directory.GetFiles(folderName);
string[] dirs = Directory.GetDirectories(folderName);
......@@ -91,6 +118,7 @@ namespace Personal_Insight
}
listView.ItemsSource = googleProductList;
isPopulated = true;
}
private void populateListBox(String path)
......
<Page x:Class="Personal_Insight.Pages.IntroPage_4"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Personal_Insight"
xmlns:pageTransitions="clr-namespace:WpfPageTransitions;assembly=WpfPageTransitions"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920"
Title="Personal Insight"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
FontFamily="{DynamicResource MaterialDesignFont}">
<Page.Background>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.75,0">
<GradientStop Color="{DynamicResource Color2}" Offset="0"/>
<GradientStop Color="{DynamicResource Color1}" Offset="1" FrameworkElement.FlowDirection="LeftToRight"/>
</LinearGradientBrush>
</Page.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Margin="0,50" TextWrapping="Wrap" Text="Data Scan" FontSize="48" TextAlignment="Center" HorizontalAlignment="Center" Foreground="#DDFFFFFF" FontFamily="Microsoft YaHei UI Light" VerticalAlignment="Top"/>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="6*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1">
<TextBlock TextWrapping="Wrap" FontFamily="Microsoft YaHei UI Light" FontSize="20" Foreground="#DDE2E2E2" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,50" TextAlignment="Center" Grid.Row="1">
Whenever you are ready click the button begin the scan. Please be patient as it will take a while, feel free to grab a cup of coffee or watch a Friends episode.
</TextBlock>
<Button Content="Begin Takeout Scan" Height="Auto" Margin="0" Background="#FFD44B4B" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="22" FontFamily="Segoe UI" Click="P4BtnClick_next" Grid.Column="1" Padding="25" Grid.Row="2"/>
</StackPanel>
</Grid>
<Button Content="BACK" Height="50" Margin="0,0,0,100" Background="#FF2D7874" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="22" FontFamily="Segoe UI" Click="P4BtnClick_back" Padding="0" Width="200" Grid.Row="4"/>
</Grid>
</Page>
using Personal_Insight.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Personal_Insight.Pages
{
/// <summary>
/// Interaction logic for IntroPage_4.xaml
/// </summary>
public partial class IntroPage_4 : Page
{
private List<GoogleProductModel> googleProductList;
public IntroPage_4()
{
InitializeComponent();
ShowsNavigationUI = false;
}
public IntroPage_4(List<GoogleProductModel> googleProductList)
{
InitializeComponent();
ShowsNavigationUI = false;
this.googleProductList = googleProductList;
}
private void P4BtnClick_back(object sender, RoutedEventArgs e)
{
if (NavigationService.CanGoBack)
{
NavigationService.GoBack();
}
else
{
IntroPage_3 page3 = new IntroPage_3();
NavigationService.Navigate(page3);
}
}
private void P4BtnClick_next(object sender, RoutedEventArgs e)
{
if (NavigationService.CanGoForward)
{
NavigationService.GoForward();
}
else
{
IntroPage_5 page5 = new IntroPage_5(googleProductList);
NavigationService.Navigate(page5);
}
}
}
}
<Page x:Class="Personal_Insight.Pages.IntroPage_5"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Personal_Insight"
xmlns:pageTransitions="clr-namespace:WpfPageTransitions;assembly=WpfPageTransitions"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920"
Title="Personal Insight"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
FontFamily="{DynamicResource MaterialDesignFont}"
Loaded="Window_ContentRendered">
<Page.Background>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.75,0">
<GradientStop Color="{DynamicResource Color2}" Offset="0"/>
<GradientStop Color="{DynamicResource Color1}" Offset="1" FrameworkElement.FlowDirection="LeftToRight"/>
</LinearGradientBrush>
</Page.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Margin="0,50" TextWrapping="Wrap" Text="Processing Google Takeout ..." FontSize="48" TextAlignment="Center" HorizontalAlignment="Center" Foreground="#DDFFFFFF" FontFamily="Microsoft YaHei UI Light" VerticalAlignment="Top"/>
<ProgressBar x:Name="progressBar" Grid.Row="1" VerticalAlignment="Center" Margin="25" Height="10"/>
<TextBox Name="consoleBlock" Text="{Binding Path=ConsoleLogText, Mode=TwoWay}" Grid.Row="2" TextWrapping="Wrap" FontFamily="Microsoft YaHei UI Light" FontSize="20" Foreground="#DDE2E2E2" Background="#FF2E2E2E" Padding="25"/>
<Grid Grid.Row="3" Margin="0,50,0,44">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Content="BACK" Height="50" Margin="0" Background="#FF2D7874" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="22" FontFamily="Segoe UI" Padding="0" Width="200"/>
<Button x:Name="btn_next" Content="NEXT" Height="50" Margin="0" Width="200" Background="#FF2D7874" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="22" FontFamily="Segoe UI" Grid.Column="1" Padding="0"/>
</Grid>
</Grid>
</Page>
using Personal_Insight.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
namespace Personal_Insight.Pages
{
/// <summary>
/// Interaction logic for IntroPage_5.xaml
/// </summary>
public partial class IntroPage_5 : Page, INotifyPropertyChanged
{
private int percentageProgress;
private List<GoogleProductModel> googleProductList;
private String _consoleLogText;
public String ConsoleLogText {
get { return _consoleLogText; }
set
{
if (value != _consoleLogText)
{
_consoleLogText = value;
OnPropertyChanged("Name2");
}
}
}
public IntroPage_5(List<GoogleProductModel> googleProductList)
{
InitializeComponent();
percentageProgress = 0;
this.googleProductList = googleProductList;
}
private void Window_ContentRendered(object sender, EventArgs e)
{
ConsoleLogText = "Starting takeout scan...";
BackgroundWorker worker = new BackgroundWorker();
worker.WorkerReportsProgress = true;
worker.DoWork += worker_DoWork;
worker.ProgressChanged += worker_ProgressChanged;
worker.RunWorkerAsync();
}
private void worker_DoWork(object sender, DoWorkEventArgs e)
{
/*for (int i = 0; i <= 100; i++)
{
(sender as BackgroundWorker).ReportProgress(i);
Thread.Sleep(100);
}*/
for(int i=0; i< googleProductList.Count; i++)
{
product_worker(googleProductList.ElementAt(i));
(sender as BackgroundWorker).ReportProgress((i/googleProductList.Count)*100); // TODO Add a check if count==0
}
}
private void product_worker(GoogleProductModel product)
{
Console.WriteLine("The size is {0} bytes.", HelpfulMethods.DirSize(new DirectoryInfo(product.ProductFolderPath)));
enterLog(product.ProductFolderPath);
}
private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
progressBar.Value = e.ProgressPercentage;
}
private void enterLog(String log)
{
//ConsoleLogText += Environment.NewLine + log;
Console.WriteLine(log);
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
......@@ -86,6 +86,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\IntroPage_4.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\IntroPage_5.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -96,6 +104,7 @@
</Compile>
<Compile Include="Models\GoogleProductModel.cs" />
<Compile Include="Models\GoogleProductsList.cs" />
<Compile Include="Models\HelpfulMethods.cs" />
<Compile Include="Pages\IntroPage_1.xaml.cs">
<DependentUpon>IntroPage_1.xaml</DependentUpon>
</Compile>
......@@ -105,6 +114,12 @@
<Compile Include="Pages\IntroPage_3.xaml.cs">
<DependentUpon>IntroPage_3.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\IntroPage_4.xaml.cs">
<DependentUpon>IntroPage_4.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\IntroPage_5.xaml.cs">
<DependentUpon>IntroPage_5.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
......@@ -193,5 +208,14 @@
<Resource Include="assets\google_products\Voice.png" />
<Resource Include="assets\google_products\YouTube.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="assets\google_products\GPC.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="assets\icons\icons8-tick-box-48.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="assets\google_products\NotFound.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
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