Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change fontsize #23

Merged
merged 11 commits into from
May 24, 2019
28 changes: 9 additions & 19 deletions appLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,7 @@ sealed partial class App : Application
{
public static ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;

public static ThreadPoolTimer timer = ThreadPoolTimer.CreatePeriodicTimer(async (source) =>
{
if (!GlobalVariables.isSaving)
{
GlobalVariables.isSaving = true;
if (await GlobalVariables.SaveCollectionAsync())
{
GlobalVariables.isSaving = false;
}
}

},
TimeSpan.FromSeconds(90),
(source) =>
{

});
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
Expand All @@ -57,6 +41,7 @@ public App()
this.InitializeComponent();
this.Suspending += OnSuspending;


}

/// <summary>
Expand All @@ -66,8 +51,10 @@ public App()
/// <param name="e">Details about the launch request and process.</param>
protected async override void OnLaunched(LaunchActivatedEventArgs e)
{

//Extends view into status bar/title bar, depending on the device used.
GlobalVariables.bgimagesavailable = (App.localSettings.Values["bgImageAvailable"]==null)?false:true;
await GlobalVariables.LoadBackgroundImages();
await GlobalVariables.loadSettingImages();
//Extends view into status bar/title bar, depending on the device used.
var appView = ApplicationView.GetForCurrentView();
appView.SetPreferredMinSize(new Size(360, 360));
appView.SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);
Expand Down Expand Up @@ -192,9 +179,12 @@ void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
private async void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
await GlobalVariables.SaveCollectionAsync();
await GlobalVariables.SaveImageOrder();
await GlobalVariables.SaveImagePersistance();
//TODO: Save application state and stop any background activity
deferral.Complete();
}
Expand Down
15 changes: 9 additions & 6 deletions appLauncher/Control/appControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="using:appLauncher.Model"
xmlns:locals="using:appLauncher"
xmlns:xsa="using:Microsoft.Toolkit.Uwp.UI.Controls"
mc:Ignorable="d"
>
Expand All @@ -34,14 +35,16 @@
<GridView.Resources>
<DataTemplate x:Key="GridViewMainDataTemplate" x:DataType="local:finalAppItem">
<Grid Width="64" Height="84" Background="Transparent" Margin="12">
<StackPanel Height="84" Width="64" Background="LightGray">
<Image Height="50" Width="50" Source="{x:Bind appLogo}" />
<TextBlock Name="appName" Text="{x:Bind appEntry.DisplayInfo.DisplayName}"
FontSize="12"
<StackPanel Background="LightGray" Opacity=".35" />
<StackPanel Height="84" Width="64" Background="Transparent" Opacity="1">
<Image Height="50" Width="50" Source="{x:Bind appLogo}" Stretch="UniformToFill" VerticalAlignment="Center" HorizontalAlignment="Center" />
<TextBlock Name="appName" Text="{x:Bind appEntry.DisplayInfo.DisplayName}"
FontSize="{x:Bind locals:GlobalVariables.Fontsize}"
TextAlignment="Center"
MaxWidth="60"
MaxWidth="60"
Foreground="Black"
FontWeight="SemiBold"
TextTrimming="CharacterEllipsis"
TextTrimming="CharacterEllipsis"
TextWrapping="WrapWholeWords" />

</StackPanel>
Expand Down
3 changes: 2 additions & 1 deletion appLauncher/Control/appControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private void GridViewMain_Drop(object sender, DragEventArgs e)
AllApps.listOfApps.Move(GlobalVariables.oldindex,GlobalVariables.newindex);
GlobalVariables.pagenum = (int)this.DataContext;
SwitchedToThisPage();
//((Window.Current.Content as Frame).Content as MainPage).Frame.Navigate(typeof(MainPage));
((Window.Current.Content as Frame).Content as MainPage).UpdateIndicator(GlobalVariables.pagenum);

}

Expand Down Expand Up @@ -167,6 +167,7 @@ private void GridViewMain_DragOver(object sender, DragEventArgs e)
}
}
GlobalVariables.pagenum = c.SelectedIndex;
((Window.Current.Content as Frame).Content as MainPage).UpdateIndicator(GlobalVariables.pagenum);
}

private async void GridViewMain_ItemClick(object sender, ItemClickEventArgs e)
Expand Down
211 changes: 181 additions & 30 deletions appLauncher/Helpers/GlobalVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
using System.Collections.ObjectModel;
using appLauncher.Helpers;
using Windows.Foundation;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Nito.AsyncEx;
using System.IO;

namespace appLauncher
{
Expand All @@ -20,20 +25,30 @@ public static class GlobalVariables
public static int newindex { get; set; }
public static int pagenum { get; set; }
public static bool isdragging { get; set; }
public static bool isSaving { get; set; }
public static bool bgimagesavailable { get; set; }
public static BackgroundImages currentimage { get; set; }


private static StorageFolder localFolder = ApplicationData.Current.LocalFolder;
public static ObservableCollection<BackgroundImages> backgroundImage { get; set; } = new ObservableCollection<BackgroundImages>();
public static ObservableCollection<BackgroundImages> settingslist { get; set; } = new ObservableCollection<BackgroundImages>();
public static Point startingpoint { get; set; }
public static async Task Logging(string texttolog)
{
StorageFolder stors = ApplicationData.Current.LocalFolder;
await FileIO.AppendTextAsync(await stors.CreateFileAsync("logfile.txt", CreationCollisionOption.OpenIfExists), texttolog);
await FileIO.AppendTextAsync(await stors.CreateFileAsync("logfile.txt", CreationCollisionOption.OpenIfExists), Environment.NewLine);
}
public static int NumofRoworColumn(int padding,int objectsize,int sizetofit)
public static int Fontsize { get; set; } = 12;



public static async Task Logging(string texttolog)
{
StorageFolder stors = ApplicationData.Current.LocalFolder;
await FileIO.AppendTextAsync(await stors.CreateFileAsync("logfile.txt", CreationCollisionOption.OpenIfExists), texttolog);
await FileIO.AppendTextAsync(await stors.CreateFileAsync("logfile.txt", CreationCollisionOption.OpenIfExists), Environment.NewLine);
}
public static int NumofRoworColumn(int padding, int objectsize, int sizetofit)
{
int amount = 0;
int intsize = objectsize + (padding + padding);
int intsize = objectsize + (padding + padding);
int size = intsize;
while (size+intsize<sizetofit)
while (size + intsize < sizetofit)
{
amount += 1;
size += intsize;
Expand All @@ -43,45 +58,181 @@ public static int NumofRoworColumn(int padding,int objectsize,int sizetofit)
}
public static async Task LoadCollectionAsync()
{
List<finalAppItem> oc1 = AllApps.listOfApps.ToList();
ObservableCollection<finalAppItem> oc = new ObservableCollection<finalAppItem>();
StorageFile item = (StorageFile) await ApplicationData.Current.LocalFolder.TryGetItemAsync("collection.txt");
var apps = await FileIO.ReadLinesAsync(item);
if (apps.Count()>1)

List<finalAppItem> oc1 = AllApps.listOfApps.ToList();
ObservableCollection<finalAppItem> oc = new ObservableCollection<finalAppItem>();
if (await IsFilePresent("collection.txt"))
{
foreach (string y in apps)

StorageFile item = (StorageFile)await ApplicationData.Current.LocalFolder.TryGetItemAsync("collection.txt");
var apps = await FileIO.ReadLinesAsync(item);
if (apps.Count() > 1)
{
foreach (finalAppItem items in oc1)
foreach (string y in apps)
{
if (items.appEntry.DisplayInfo.DisplayName == y)
foreach (finalAppItem items in oc1)
{
oc.Add(items);
if (items.appEntry.DisplayInfo.DisplayName == y)
{
oc.Add(items);
}
}
}
}
AllApps.listOfApps = (oc.Count > 0) ? oc : new ObservableCollection<finalAppItem>(oc1);
}









}
public static async Task<bool> SaveCollectionAsync()
public static async Task SaveCollectionAsync()
{
List<finalAppItem> finals = AllApps.listOfApps.ToList();


List<finalAppItem> finals = AllApps.listOfApps.ToList();
var te = from x in finals select x.appEntry.DisplayInfo.DisplayName;
StorageFile item = (StorageFile)await ApplicationData.Current.LocalFolder.CreateFileAsync("collection.txt",CreationCollisionOption.ReplaceExisting);
await FileIO.WriteLinesAsync(item, te);
return true;
StorageFile item = (StorageFile)await ApplicationData.Current.LocalFolder.CreateFileAsync("collection.txt", CreationCollisionOption.ReplaceExisting);
await FileIO.WriteLinesAsync(item, te);


}
public static async Task<bool> IsFilePresent(string fileName)
{
var item = await ApplicationData.Current.LocalFolder.TryGetItemAsync(fileName);
return item != null;
}
public static async Task LoadBackgroundImages()
{
if (bgimagesavailable)
{
if (await IsFilePresent("persistimage.txt"))
{
try
{
StorageFile item = (StorageFile)await ApplicationData.Current.LocalFolder.TryGetItemAsync("persistimage.txt");
var images = await FileIO.ReadLinesAsync(item);

StorageFolder localFolder = ApplicationData.Current.LocalFolder;
var backgroundImageFolder = await localFolder.CreateFolderAsync("backgroundImage", CreationCollisionOption.OpenIfExists);
var filesInFolder = await backgroundImageFolder.GetFilesAsync();
if (images.Count() > 0)
{
foreach (string y in images)
{
foreach (var items in filesInFolder)
{
if (items.DisplayName == y)
{
BackgroundImages bi = new BackgroundImages();
bi.Filename = items.DisplayName;
bi.Bitmapimage = new BitmapImage(new Uri(items.Path));
backgroundImage.Add(bi);
}
}
}
}
else
{
foreach (var items in filesInFolder)
{
BackgroundImages bi = new BackgroundImages();
bi.Filename = items.DisplayName;
bi.Bitmapimage = new BitmapImage(new Uri(items.Path));
backgroundImage.Add(bi);

}
}
}
catch (Exception e)
{
await Logging(e.ToString());
}
}
else
{
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
var backgroundImageFolder = await localFolder.CreateFolderAsync("backgroundImage", CreationCollisionOption.OpenIfExists);
var filesInFolder = await backgroundImageFolder.GetFilesAsync();
foreach (var items in filesInFolder)
{
BackgroundImages bi = new BackgroundImages();
bi.Filename = items.DisplayName;
bi.Bitmapimage = new BitmapImage(new Uri(items.Path));
backgroundImage.Add(bi);


}
}
}

}

public static async Task loadSettingImages()
{
if (bgimagesavailable)
{

StorageFolder localFolder = ApplicationData.Current.LocalFolder;
var backgroundImageFolder = await localFolder.CreateFolderAsync("backgroundImage", CreationCollisionOption.OpenIfExists);
var filesInFolder = await backgroundImageFolder.GetFilesAsync();
try
{
if (await IsFilePresent("settingsimages.txt"))
{
StorageFile item = (StorageFile)await ApplicationData.Current.LocalFolder.TryGetItemAsync("settingsimages.txt");
var images = await FileIO.ReadLinesAsync(item);
if (images.Count() > 0)
{
foreach (var y in images)
{
foreach (var items in filesInFolder)
{
if (items.DisplayName == y)
{
BackgroundImages bi = new BackgroundImages();
bi.Filename = items.DisplayName;
bi.Bitmapimage = new BitmapImage(new Uri(items.Path));
settingslist.Add(bi);
}
}
}
}
}
}
catch (Exception e)
{
await Logging(e.ToString());
}
}
}

public static async Task SaveImageOrder()
{
List<string> imageorder = new List<string>();
imageorder = (from x in settingslist select x.Filename).ToList();
StorageFile item = (StorageFile)await ApplicationData.Current.LocalFolder.CreateFileAsync("settingsimages.txt", CreationCollisionOption.ReplaceExisting);
await FileIO.WriteLinesAsync(item, imageorder);



}
public static async Task SaveImagePersistance()
{


int currentimagelocation = backgroundImage.IndexOf(currentimage);
int movetoloc = 0;
for (int i = currentimagelocation; i < backgroundImage.Count(); i++)
{
backgroundImage.Move(i, movetoloc);
movetoloc += 1;
}
List<string> persistance = (from x in backgroundImage select x.Filename).ToList();
StorageFile item = (StorageFile)await ApplicationData.Current.LocalFolder.CreateFileAsync("persistimage.txt", CreationCollisionOption.ReplaceExisting);
await FileIO.WriteLinesAsync(item, persistance);
}
}
}

}

Loading