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

Commit

Permalink
Fixed delete logic. Added edit functionality.
Browse files Browse the repository at this point in the history
FIXED DELETE FINALLY. You can also edit again and moved some themeing into mainpage.xaml
  • Loading branch information
Unknown committed Apr 12, 2018
1 parent 23b70c7 commit 345b59e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 23 deletions.
2 changes: 1 addition & 1 deletion AnneProKeyboard/LayoutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
</Style>
</Page.Resources>
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Width="Auto">
<Grid Background="#000" Width="Auto">
<Grid Background="Transparent" Width="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
Expand Down
2 changes: 1 addition & 1 deletion AnneProKeyboard/LightingPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
mc:Ignorable="d" >

<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<Grid Background="#000" Height="876">
<Grid Background="Transparent" Height="876">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*" />
Expand Down
16 changes: 10 additions & 6 deletions AnneProKeyboard/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,26 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.Resources>
<converters:BooleanToVisibilityConverter x:Key="Bool2VisibilityConverter" />
<SolidColorBrush x:Key="FrameBackground" Color="{StaticResource SystemAltMediumColor}"/>
<SolidColorBrush x:Key="StatusBarBackground" Color="{StaticResource SystemAltLowColor}"/>
</Grid.Resources>
<ComboBox x:Name="ProfilesCombo" Height="35" Width="270" Grid.Row="0"
<StackPanel Grid.Row="0">
<ComboBox x:Name="ProfilesCombo" Height="35" Width="270"
ItemsSource="{x:Bind KeyboardProfiles}" HorizontalAlignment="Right" Margin="0,-41,262,0" SelectionChanged="ProfilesCombo_SelectionChanged" Loaded="ProfilesCombo_Loaded">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Grid.Row="3">
<TextBlock x:Name="ProfileNameTextblock" Text="{Binding Label, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" Width="140"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Frame Name="_frame" Grid.Row="0" Margin="0" Grid.RowSpan="2"/>
<Grid Grid.Row="2" Background="#FF111111" Height="30">
<TextBox x:Name="ProfileNameTextbox" Visibility="Collapsed" IsEnabled="False" Text="{Binding Label, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Canvas.ZIndex="999" LostFocus="ProfileNameTextbox_LostFocus" Margin="0,-41,263,0" Background="Transparent" BorderThickness="0" Height="35" Width="270" TextChanged="ProfileNameChangedEvent_TextChanged" HorizontalAlignment="Right" />
</StackPanel>
<Frame Name="_frame" Grid.Row="0" Margin="0" Grid.RowSpan="2" Background="{ThemeResource FrameBackground}"/>
<Grid Grid.Row="2" Background="{ThemeResource StatusBarBackground}" Height="30">
<StackPanel Orientation="Horizontal" Grid.Row="2" DataContext="{Binding ElementName=main}" Height="30px" >
<StackPanel Background="#FF111111" Orientation="Horizontal" DataContext="{Binding ElementName=main}" Height="30px" >
<StackPanel Background="Transparent" Orientation="Horizontal" DataContext="{Binding ElementName=main}" Height="30px" >
<TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE702;" Foreground="White" VerticalAlignment="Center" FontSize="20" />
<TextBlock x:Name="connectionStatusLabel" Text="Not Connected" VerticalAlignment="Center" Foreground="Red" />
</StackPanel>
Expand Down
52 changes: 37 additions & 15 deletions AnneProKeyboard/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public MainPage()
lightingNavItem.Icon = new FontIcon { Glyph = "\uE706" };
Color systemAccentColor = (Color)App.Current.Resources["SystemAccentColor"];
LoadProfiles();
this.selectedProfile = _keyboardProfiles[0];
this._keyboardProfiles.CollectionChanged += KeyboardProfiles_CollectionChanged;
Application.Current.Suspending += new SuspendingEventHandler(App_Suspending);
}
Expand All @@ -82,12 +83,12 @@ 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 = profile;
}
//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)
{
Expand All @@ -101,22 +102,40 @@ private void ProfileEditButton_Click(object sender, RoutedEventArgs e)
{
//Button button = (Button)sender;
//FrameworkElement parent = (FrameworkElement)button.Parent;
//TextBox textbox = (TextBox)parent.FindName("ProfileNameTextbox");
//textbox.IsEnabled = true;
//textbox.Visibility = Visibility.Visible;
//FocusState focus_state = FocusState.Keyboard;
//textbox.Focus(focus_state);

//TextBlock textblock = (TextBlock)parent.FindName("ProfileNameTextblock");
//textblock.Visibility = Visibility.Collapsed;
TextBox textbox = ProfileNameTextbox;
textbox.IsEnabled = true;
textbox.Visibility = Visibility.Visible;
FocusState focus_state = FocusState.Keyboard;
textbox.Focus(focus_state);

//this.RenamingProfile = this._keyboardProfiles[(int)button.Tag];
this.RenamingProfile = selectedProfile;
SaveProfiles();
}

private void ProfileDeleteButton_Click(object sender, RoutedEventArgs e)
{
//// always make sure that the keyboard profiles list has 1 element in it
int idx = ProfilesCombo.SelectedIndex;
KeyboardProfileItem kbp = ProfilesCombo.SelectedItem as KeyboardProfileItem;
if(ProfilesCombo.Items.Count > 2)
{
//set the selected index to 0 if it is not the first element, else set it to the second
if (idx != 0)
ProfilesCombo.SelectedIndex = 0;
else
ProfilesCombo.SelectedIndex = 1;
this._keyboardProfiles.Remove(kbp);
}
else if(ProfilesCombo.Items.Count == 2)
{
if (idx == 0)
ProfilesCombo.SelectedIndex = 1;
else
ProfilesCombo.SelectedIndex = 0;
this._keyboardProfiles.Remove(kbp);
}

/*
if (this._keyboardProfiles.Count != 1)
{
int curr = this._keyboardProfiles.IndexOf(selectedProfile);
Expand All @@ -141,6 +160,7 @@ private void ProfileDeleteButton_Click(object sender, RoutedEventArgs e)
this.selectedProfile = this._keyboardProfiles[0];
}
}
*/
//ensure not deleting the selected one or vice versa
//delete
//// Change the chosen profile to the first element
Expand Down Expand Up @@ -169,6 +189,7 @@ 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");
Expand Down Expand Up @@ -658,6 +679,7 @@ private void ProfilesCombo_SelectionChanged(object sender, SelectionChangedEvent
{
this.SyncStatus.Text = "Profiles failed to save";
}
this.selectedProfile = ProfilesCombo.SelectedItem as KeyboardProfileItem;
lightingPage.ChangeSelectedProfile((KeyboardProfileItem)ProfilesCombo.SelectedItem);
layoutPage.ChangeSelectedProfile((KeyboardProfileItem)ProfilesCombo.SelectedItem);
}
Expand Down

0 comments on commit 345b59e

Please sign in to comment.