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);
            }

            this.SaveProfiles();
        }
 private void ProfileAddButton_Click(object sender, RoutedEventArgs e)
 {
     this.CreateNewKeyboardProfile();
     (this._frame.Content as IContentPage).ChangeSelectedProfile(_keyboardProfiles[_keyboardProfiles.Count - 1]);
     this.ProfilesCombo.SelectedIndex = this.ProfilesCombo.Items.Count - 1;
     this.selectedProfile             = _keyboardProfiles[_keyboardProfiles.Count - 1];
 }
Exemple #3
0
 private Boolean colour_wasd(KeyboardProfileItem profile)
 {
     return(
         profile.KeyboardColours[16] == profile.KeyboardColours[29] &&
         profile.KeyboardColours[29] == profile.KeyboardColours[30] &&
         profile.KeyboardColours[30] == profile.KeyboardColours[31]
         );
 }
Exemple #4
0
 private Boolean colour_ijkl(KeyboardProfileItem profile)
 {
     return(
         profile.KeyboardColours[22] == profile.KeyboardColours[35] &&
         profile.KeyboardColours[35] == profile.KeyboardColours[36] &&
         profile.KeyboardColours[36] == profile.KeyboardColours[37]
         );
 }
        private void ProfileNameTextbox_LostFocus(object sender, RoutedEventArgs e)
        {
            this.SaveProfiles();

            TextBox textbox = (TextBox)sender;

            textbox.Visibility = Visibility.Collapsed;
            textbox.Text       = "";

            this.RenamingProfile = null;
        }
Exemple #6
0
 private void KeyboardProfiles_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Remove)
     {
         // Really inefficient, we should consider re-implementing this later
         for (int i = 0; i < this._keyboardProfiles.Count; i++)
         {
             KeyboardProfileItem profile = this._keyboardProfiles[i];
             profile.ID = i;
         }
     }
 }
        private void ProfileEditButton_Click(object sender, RoutedEventArgs e)
        {
            TextBox textbox = ProfileNameTextbox;

            textbox.IsEnabled  = true;
            textbox.Visibility = Visibility.Visible;
            FocusState focus_state = FocusState.Keyboard;

            textbox.Focus(focus_state);

            this.RenamingProfile = selectedProfile;
            SaveProfiles();
        }
 private void ProfilesCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         SaveProfiles();
     } catch
     {
         this.SyncStatus.Text = "Profiles failed to save";
     }
     this.selectedProfile = ProfilesCombo.SelectedItem as KeyboardProfileItem;
     lightingPage.ChangeSelectedProfile((KeyboardProfileItem)ProfilesCombo.SelectedItem);
     layoutPage.ChangeSelectedProfile((KeyboardProfileItem)ProfilesCombo.SelectedItem);
 }
Exemple #9
0
        private Boolean colour_num_row(KeyboardProfileItem profile)
        {
            int colour = profile.KeyboardColours[1];

            for (int i = 2; i < 11; i++)
            {
                if (profile.KeyboardColours[i] != colour)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #10
0
        private void ChangeSelectedProfile(KeyboardProfileItem profile)
        {
            this.EditingProfile     = profile;
            chosenProfileName.Title = profile.Label;

            // set up the background colours for the keyboard lights
            byte alpha = 255;

            for (int i = 0; i < 70; i++)
            {
                // set the standard layout keys
                if (i < 61)
                {
                    string layout_id     = "keyboardStandardLayoutButton" + i;
                    Button layout_button = (this.FindName(layout_id) as Button);

                    if (layout_button != null)
                    {
                        layout_button.Content = profile.NormalKeys[i].KeyShortLabel;
                    }

                    string fn_layout_id     = "keyboardFNLayoutButton" + i;
                    Button fn_layout_button = (this.FindName(fn_layout_id) as Button);

                    if (fn_layout_id != null)
                    {
                        fn_layout_button.Content = profile.FnKeys[i].KeyShortLabel;
                    }
                }

                string s      = "keyboardButton" + i;
                Button button = (this.FindName(s) as Button);

                // NOTE: last 4 keys (RALT, FN, Anne, Ctrl) are identify as 66,67,68,69
                if (button == null)
                {
                    continue;
                }

                int coloured_int = profile.KeyboardColours[i];

                int red   = (coloured_int >> 16) & 0xff;
                int green = (coloured_int >> 8) & 0xff;
                int blue  = (coloured_int >> 0) & 0xff;

                Color colour = Color.FromArgb(alpha, (byte)red, (byte)green, (byte)blue);

                button.BorderBrush     = new SolidColorBrush(colour);
                button.BorderThickness = new Thickness(1);
            }
        }
Exemple #11
0
        public void ChangeSelectedProfile(KeyboardProfileItem profile)
        {
            if (profile == null)
            {
                return;
            }
            this.editingProfile = profile;

            // set up the background colours for the keyboard lights
            for (int i = 0; i < 70; i++)
            {
                // set the standard layout keys
                if (i < 61)
                {
                    string layout_id     = "keyboardStandardLayoutButton" + i;
                    Button layout_button = (this.FindName(layout_id) as Button);

                    if (layout_button != null)
                    {
                        layout_button.Content = profile.NormalKeys[i].KeyShortLabel;
                    }

                    string fn_layout_id     = "keyboardFNLayoutButton" + i;
                    Button fn_layout_button = (this.FindName(fn_layout_id) as Button);

                    if (fn_layout_id != null)
                    {
                        if (profile.FnKeys[i].KeyShortLabel == "None")
                        {
                            fn_layout_button.Content = "";
                        }
                        else
                        {
                            fn_layout_button.Content = profile.FnKeys[i].KeyShortLabel;
                        }
                    }
                }

                string s      = "keyboardButton" + i;
                Button button = (this.FindName(s) as Button);

                // NOTE: last 4 keys (RALT, FN, Anne, Ctrl) are identify as 66,67,68,69
                if (button == null)
                {
                    continue;
                }
                int coloured_int = profile.KeyboardColours[i];
            }
        }
        public override Boolean Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj.GetType() == typeof(KeyboardProfileItem))
            {
                KeyboardProfileItem that = obj as KeyboardProfileItem;
                return(this.ID == that.ID && this.Label == that.Label);
            }

            return(false);
        }
Exemple #13
0
        protected override async void OnFileActivated(FileActivatedEventArgs args)
        {
            // TODO: Handle file activation
            // The number of files received is args.Files.Size
            // The name of the first file is args.Files[0].Name
            Frame       rootFrame = Window.Current.Content as Frame;
            MainPage    content   = rootFrame.Content as MainPage;
            StorageFile profile   = args.Files[0] as StorageFile;

            using (IInputStream inStream = await profile.OpenSequentialReadAsync())
            {
                DataContractSerializer serialiser = new DataContractSerializer(typeof(KeyboardProfileItem));
                KeyboardProfileItem    kpi        = (KeyboardProfileItem)serialiser.ReadObject(inStream.AsStreamForRead());
                content.KeyboardProfiles.Add(kpi);
            }
        }
Exemple #14
0
        private void ProfileNameTextbox_LostFocus(object sender, RoutedEventArgs e)
        {
            this.SaveProfiles();

            TextBox textbox = (TextBox)sender;

            textbox.IsEnabled  = false;
            textbox.Visibility = Visibility.Collapsed;

            FrameworkElement parent    = (FrameworkElement)textbox.Parent;
            TextBlock        textblock = (TextBlock)parent.FindName("ProfileNameTextblock");

            textblock.Visibility = Visibility.Visible;

            this.RenamingProfile = null;
        }
Exemple #15
0
        private Boolean colour_modifiers(KeyboardProfileItem profile)
        {
            int[] modifiers = new int[14] {
                14, 28, 42, 56, 57, 58, 66, 67, 68, 69, 55, 41, 13, 27
            };                                                                                        //Tab->LCtrl->RCtrl->Bkspc: 14,28,42,56,57,58,66,67,68,69,55,41,13,27

            int colour = profile.KeyboardColours[14];

            foreach (int i in modifiers)
            {
                if (profile.KeyboardColours[i] != colour)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #16
0
        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;

            this.RenamingProfile = this._keyboardProfiles[(int)button.Tag];
        }
Exemple #17
0
        private void ProfileDeleteButton_Click(object sender, RoutedEventArgs e)
        {
            Button              button           = (Button)sender;
            FrameworkElement    parent           = (FrameworkElement)button.Parent;
            TextBox             textbox          = (TextBox)parent.FindName("ProfileNameTextbox");
            KeyboardProfileItem selected_profile = this._keyboardProfiles[(int)button.Tag];

            this._keyboardProfiles.Remove(selected_profile);

            // always make sure that the keyboard profiles list has 1 element in it
            if (this._keyboardProfiles.Count == 0)
            {
                this.CreateNewKeyboardProfile();
            }

            // Change the chosen profile to the first element
            ChangeSelectedProfile(this._keyboardProfiles[0]);

            this.SaveProfiles();
        }
Exemple #18
0
        private void CreateNewKeyboardProfile()
        {
            KeyboardProfileItem profile_item = new KeyboardProfileItem(this._keyboardProfiles.Count, "Profile " + (this._keyboardProfiles.Count + 1));

            this._keyboardProfiles.Add(profile_item);
        }
Exemple #19
0
        private void KeyboardProfiles_ItemClick(object sender, ItemClickEventArgs e)
        {
            KeyboardProfileItem profile = (e.ClickedItem as KeyboardProfileItem);

            ChangeSelectedProfile(profile);
        }
 public void SyncProfile(KeyboardProfileItem EditingProfile)
 {
     EditingProfile.SyncProfile(this.WriteGatt);
 }
Exemple #21
0
        public static void InitaliseKeyboardProfile(KeyboardProfileItem profile)
        {
            // This is a straight copy from obins app
            profile.NormalKeys = new List <KeyboardKey>();
            profile.FnKeys     = new List <KeyboardKey>();

            // Normal keys
            profile.NormalKeys.Add(IntKeyboardKeys[41]);
            profile.NormalKeys.Add(IntKeyboardKeys[30]);
            profile.NormalKeys.Add(IntKeyboardKeys[31]);
            profile.NormalKeys.Add(IntKeyboardKeys[32]);
            profile.NormalKeys.Add(IntKeyboardKeys[33]);
            profile.NormalKeys.Add(IntKeyboardKeys[34]);
            profile.NormalKeys.Add(IntKeyboardKeys[35]);
            profile.NormalKeys.Add(IntKeyboardKeys[36]);
            profile.NormalKeys.Add(IntKeyboardKeys[37]);
            profile.NormalKeys.Add(IntKeyboardKeys[38]);
            profile.NormalKeys.Add(IntKeyboardKeys[39]);
            profile.NormalKeys.Add(IntKeyboardKeys[45]);
            profile.NormalKeys.Add(IntKeyboardKeys[46]);
            profile.NormalKeys.Add(IntKeyboardKeys[42]);
            profile.NormalKeys.Add(IntKeyboardKeys[43]);
            profile.NormalKeys.Add(IntKeyboardKeys[20]);
            profile.NormalKeys.Add(IntKeyboardKeys[26]);
            profile.NormalKeys.Add(IntKeyboardKeys[8]);
            profile.NormalKeys.Add(IntKeyboardKeys[21]);
            profile.NormalKeys.Add(IntKeyboardKeys[23]);
            profile.NormalKeys.Add(IntKeyboardKeys[28]);
            profile.NormalKeys.Add(IntKeyboardKeys[24]);
            profile.NormalKeys.Add(IntKeyboardKeys[12]);
            profile.NormalKeys.Add(IntKeyboardKeys[18]);
            profile.NormalKeys.Add(IntKeyboardKeys[19]);
            profile.NormalKeys.Add(IntKeyboardKeys[47]);
            profile.NormalKeys.Add(IntKeyboardKeys[48]);
            profile.NormalKeys.Add(IntKeyboardKeys[49]);
            profile.NormalKeys.Add(IntKeyboardKeys[57]);
            profile.NormalKeys.Add(IntKeyboardKeys[4]);
            profile.NormalKeys.Add(IntKeyboardKeys[22]);
            profile.NormalKeys.Add(IntKeyboardKeys[7]);
            profile.NormalKeys.Add(IntKeyboardKeys[9]);
            profile.NormalKeys.Add(IntKeyboardKeys[10]);
            profile.NormalKeys.Add(IntKeyboardKeys[11]);
            profile.NormalKeys.Add(IntKeyboardKeys[13]);
            profile.NormalKeys.Add(IntKeyboardKeys[14]);
            profile.NormalKeys.Add(IntKeyboardKeys[15]);
            profile.NormalKeys.Add(IntKeyboardKeys[51]);
            profile.NormalKeys.Add(IntKeyboardKeys[52]);
            profile.NormalKeys.Add(IntKeyboardKeys[40]);
            profile.NormalKeys.Add(IntKeyboardKeys[225]);
            profile.NormalKeys.Add(IntKeyboardKeys[29]);
            profile.NormalKeys.Add(IntKeyboardKeys[27]);
            profile.NormalKeys.Add(IntKeyboardKeys[6]);
            profile.NormalKeys.Add(IntKeyboardKeys[25]);
            profile.NormalKeys.Add(IntKeyboardKeys[5]);
            profile.NormalKeys.Add(IntKeyboardKeys[17]);
            profile.NormalKeys.Add(IntKeyboardKeys[16]);
            profile.NormalKeys.Add(IntKeyboardKeys[54]);
            profile.NormalKeys.Add(IntKeyboardKeys[55]);
            profile.NormalKeys.Add(IntKeyboardKeys[56]);
            profile.NormalKeys.Add(IntKeyboardKeys[229]);
            profile.NormalKeys.Add(IntKeyboardKeys[224]);
            profile.NormalKeys.Add(IntKeyboardKeys[227]);
            profile.NormalKeys.Add(IntKeyboardKeys[226]);
            profile.NormalKeys.Add(IntKeyboardKeys[44]);
            profile.NormalKeys.Add(IntKeyboardKeys[230]);
            profile.NormalKeys.Add(IntKeyboardKeys[254]);
            profile.NormalKeys.Add(IntKeyboardKeys[250]);
            profile.NormalKeys.Add(IntKeyboardKeys[228]);

            // Function keys (Fn + X)
            profile.FnKeys.Add(IntKeyboardKeys[53]);
            profile.FnKeys.Add(IntKeyboardKeys[58]);
            profile.FnKeys.Add(IntKeyboardKeys[59]);
            profile.FnKeys.Add(IntKeyboardKeys[60]);
            profile.FnKeys.Add(IntKeyboardKeys[61]);
            profile.FnKeys.Add(IntKeyboardKeys[62]);
            profile.FnKeys.Add(IntKeyboardKeys[63]);
            profile.FnKeys.Add(IntKeyboardKeys[64]);
            profile.FnKeys.Add(IntKeyboardKeys[65]);
            profile.FnKeys.Add(IntKeyboardKeys[66]);
            profile.FnKeys.Add(IntKeyboardKeys[67]);
            profile.FnKeys.Add(IntKeyboardKeys[68]);
            profile.FnKeys.Add(IntKeyboardKeys[69]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[82]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[82]);
            profile.FnKeys.Add(IntKeyboardKeys[71]);
            profile.FnKeys.Add(IntKeyboardKeys[72]);
            profile.FnKeys.Add(IntKeyboardKeys[74]);
            profile.FnKeys.Add(IntKeyboardKeys[77]);
            profile.FnKeys.Add(IntKeyboardKeys[70]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[80]);
            profile.FnKeys.Add(IntKeyboardKeys[81]);
            profile.FnKeys.Add(IntKeyboardKeys[79]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[80]);
            profile.FnKeys.Add(IntKeyboardKeys[81]);
            profile.FnKeys.Add(IntKeyboardKeys[79]);
            profile.FnKeys.Add(IntKeyboardKeys[75]);
            profile.FnKeys.Add(IntKeyboardKeys[78]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[73]);
            profile.FnKeys.Add(IntKeyboardKeys[76]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[227]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
            profile.FnKeys.Add(IntKeyboardKeys[254]);
            profile.FnKeys.Add(IntKeyboardKeys[250]);
            profile.FnKeys.Add(IntKeyboardKeys[0]);
        }
Exemple #22
0
        private void ChangeSelectedProfile(KeyboardProfileItem profile)
        {
            this.EditingProfile     = profile;
            chosenProfileName.Title = profile.Label;

            // set up the background colours for the keyboard lights
            for (int i = 0; i < 70; i++)
            {
                // set the standard layout keys
                if (i < 61)
                {
                    string layout_id     = "keyboardStandardLayoutButton" + i;
                    Button layout_button = (this.FindName(layout_id) as Button);

                    if (layout_button != null)
                    {
                        layout_button.Content = profile.NormalKeys[i].KeyShortLabel;
                    }

                    string fn_layout_id     = "keyboardFNLayoutButton" + i;
                    Button fn_layout_button = (this.FindName(fn_layout_id) as Button);

                    if (fn_layout_id != null)
                    {
                        fn_layout_button.Content = profile.FnKeys[i].KeyShortLabel;
                    }
                }

                string s      = "keyboardButton" + i;
                Button button = (this.FindName(s) as Button);

                // NOTE: last 4 keys (RALT, FN, Anne, Ctrl) are identify as 66,67,68,69
                if (button == null)
                {
                    continue;
                }

                int coloured_int = profile.KeyboardColours[i];

                Color colour = ConvertIntToColour(coloured_int);

                button.BorderBrush     = new SolidColorBrush(colour);
                button.BorderThickness = new Thickness(1);
                button.Background      = new SolidColorBrush(colour);
            }

            //colour the multi selection buttons
            //check the WASD keys. If all same, color WASD button
            Color  multi_colour   = ConvertIntToColour(profile.KeyboardColours[16]); //W key idx
            Button multi_button   = (this.FindName("WASDKeys") as Button);
            Color  default_colour = Color.FromArgb(255, 75, 75, 75);

            if (colour_wasd(profile))
            {
                setButtonColour(multi_button, multi_colour);
            }
            else
            {
                setButtonColour(multi_button, default_colour);
            }

            //check IJKL keys
            if (colour_ijkl(profile))
            {
                multi_colour = ConvertIntToColour(profile.KeyboardColours[22]); //I key idx
                multi_button = (this.FindName("IJKLKeys") as Button);
                setButtonColour(multi_button, multi_colour);
            }
            else
            {
                setButtonColour(multi_button, default_colour);
            }

            //check Modifier Keys
            if (colour_modifiers(profile))
            {
                multi_colour = ConvertIntToColour(profile.KeyboardColours[14]); //Tab key idx
                multi_button = (this.FindName("ModifierKeys") as Button);
                setButtonColour(multi_button, multi_colour);
            }
            else
            {
                setButtonColour(multi_button, default_colour);
            }

            //check num row
            if (colour_num_row(profile))
            {
                multi_colour = ConvertIntToColour(profile.KeyboardColours[1]); //1 key idx
                multi_button = (this.FindName("NumKeys") as Button);
                setButtonColour(multi_button, multi_colour);
            }
            else
            {
                setButtonColour(multi_button, default_colour);
            }

            //set all buttons colour to default colour. Easy to see if all buttons are the same colour
            multi_button = (this.FindName("AllKeys") as Button);
            setButtonColour(multi_button, default_colour);
        }