Skip to content
This repository has been archived by the owner on Nov 21, 2020. It is now read-only.

Commit

Permalink
Remove commented code; fix profiles being corrupted
Browse files Browse the repository at this point in the history
  • Loading branch information
kprinssu committed May 26, 2018
1 parent 62b5733 commit 0c8c8e4
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions AnneProKeyboard/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ public ObservableCollection<KeyboardProfileItem> KeyboardProfiles
private GattCharacteristic ReadGatt;
private DeviceInformation KeyboardDeviceInformation;

//private ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;

private AboutPage aboutPage;
private LayoutPage layoutPage;
private LightingPage lightingPage;
Expand All @@ -64,7 +62,6 @@ public MainPage()
initPages();
this._frame.Content = layoutPage;
FindKeyboard();
//CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = false;
lightingNavItem.Icon = new FontIcon { Glyph = "\uE706" };
LoadProfiles();
this._keyboardProfiles.CollectionChanged += KeyboardProfiles_CollectionChanged;
Expand All @@ -78,13 +75,6 @@ private void initPages()
lightingPage = new LightingPage();
}

//private void KeyboardProfiles_ItemClick(object sender, ItemClickEventArgs e)
//{
// //KeyboardProfileItem profile = (e.ClickedItem as KeyboardProfileItem);
// (this._frame.Content as IContentPage).ChangeSelectedProfile(profile);
// this.selectedProfile = ProfilesCombo.SelectedItem as KeyboardProfileItem;
//}

private void ProfileAddButton_Click(object sender, RoutedEventArgs e)
{
this.CreateNewKeyboardProfile();
Expand All @@ -95,8 +85,6 @@ private void ProfileAddButton_Click(object sender, RoutedEventArgs e)

private void ProfileEditButton_Click(object sender, RoutedEventArgs e)
{
//Button button = (Button)sender;
//FrameworkElement parent = (FrameworkElement)button.Parent;
TextBox textbox = ProfileNameTextbox;
textbox.IsEnabled = true;
textbox.Visibility = Visibility.Visible;
Expand Down Expand Up @@ -155,10 +143,6 @@ private void ProfileNameTextbox_LostFocus(object sender, RoutedEventArgs e)
TextBox textbox = (TextBox)sender;
textbox.Visibility = Visibility.Collapsed;
textbox.Text = "";
//FrameworkElement parent = (FrameworkElement)textbox.Parent;

//TextBlock textblock = (TextBlock)parent.FindName("ProfileNameTextblock");
//textblock.Visibility = Visibility.Collapsed;

this.RenamingProfile = null;
}
Expand All @@ -184,6 +168,12 @@ public async void SaveProfiles()

try
{
var profileFileItem = await ApplicationData.Current.LocalFolder.TryGetItemAsync("KeyboardProfilesData");
if(profileFileItem == null)
{
File.Create(ApplicationData.Current.LocalFolder.Path + "//KeyboardProfilesData").Close();
}

StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("KeyboardProfilesData", CreationCollisionOption.ReplaceExisting);
using (Stream file_stream = await file.OpenStreamForWriteAsync())
{
Expand Down Expand Up @@ -216,8 +206,9 @@ public async void LoadProfiles()
using (IInputStream inStream = await file.OpenSequentialReadAsync())
{
DataContractSerializer serialiser = new DataContractSerializer(typeof(ObservableCollection<KeyboardProfileItem>));
ObservableCollection<KeyboardProfileItem> saved_profiles = (ObservableCollection<KeyboardProfileItem>)serialiser.ReadObject(inStream.AsStreamForRead());

Stream rawStream = inStream.AsStreamForRead();
ObservableCollection<KeyboardProfileItem> saved_profiles = (ObservableCollection<KeyboardProfileItem>)serialiser.ReadObject(rawStream);

foreach (KeyboardProfileItem profile in saved_profiles)
{
if (!_keyboardProfiles.Contains(profile))
Expand Down Expand Up @@ -344,7 +335,7 @@ await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>

private void App_Suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e)
{
SaveProfiles();
// SaveProfiles();

if (this.BluetoothDeviceWatcher != null)
{
Expand Down

0 comments on commit 0c8c8e4

Please sign in to comment.