Exemplo n.º 1
0
        public void addToLayoutChooser(Keymap keymap)
        {
            if (this.isInLayoutChooser(keymap))
            {
                return;
            }

            JToken level1 = this.jsonObj.GetValue("LayoutChooser");

            if (level1 == null)
            {
                this.jsonObj.Add("LayoutChooser", new JArray());
            }
            level1 = this.jsonObj.GetValue("LayoutChooser");
            JArray array = (JArray)level1;

            JObject newObj = new JObject();

            newObj.Add("Title", keymap.getName());
            newObj.Add("Keymap", keymap.Filename);
            array.Add(newObj);

            this.jsonObj.Remove("LayoutChooser");
            this.jsonObj.Add("LayoutChooser", array);

            save();
        }
Exemplo n.º 2
0
        public void removeFromLayoutChooser(Keymap keymap)
        {
            if (!this.isInLayoutChooser(keymap))
            {
                return;
            }

            JToken level1 = this.jsonObj.GetValue("LayoutChooser");

            if (level1 != null && level1.Type == JTokenType.Array)
            {
                JArray array = (JArray)level1;

                foreach (JToken token in array)
                {
                    if (token.Type == JTokenType.Object)
                    {
                        string filename = ((JObject)token).GetValue("Keymap").ToString();

                        if (filename == keymap.Filename)
                        {
                            token.Remove();

                            this.jsonObj.Remove("LayoutChooser");
                            this.jsonObj.Add("LayoutChooser", array);

                            save();
                            return;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void addToApplicationSearch(Keymap keymap, string search)
        {
            if (this.isInApplicationSearch(keymap))
            {
                return;
            }

            JToken level1 = this.jsonObj.GetValue("Applications");

            if (level1 == null)
            {
                this.jsonObj.Add("Applications", new JArray());
            }
            level1 = this.jsonObj.GetValue("Applications");
            JArray array = (JArray)level1;

            JObject newObj = new JObject();

            newObj.Add("Search", search);
            newObj.Add("Keymap", keymap.Filename);
            array.Add(newObj);

            this.jsonObj.Remove("Applications");
            this.jsonObj.Add("Applications", array);

            save();
        }
Exemplo n.º 4
0
        public void addToApplicationSearch(Keymap keymap, string search)
        {
            if (this.isInApplicationSearch(keymap))
            {
                return;
            }

            JToken level1 = this.jsonObj.GetValue("Applications");
            if (level1 == null)
            {
                this.jsonObj.Add("Applications", new JArray());
            }
            level1 = this.jsonObj.GetValue("Applications");
            JArray array = (JArray)level1;

            JObject newObj = new JObject();
            newObj.Add("Search", search);
            newObj.Add("Keymap", keymap.Filename);
            array.Add(newObj);

            this.jsonObj.Remove("Applications");
            this.jsonObj.Add("Applications", array);

            save();
        }
Exemplo n.º 5
0
        public void setSearchStringFor(Keymap keymap, string search)
        {
            if (!isInApplicationSearch(keymap))
            {
                return;
            }

            JToken level1 = this.jsonObj.GetValue("Applications");

            if (level1 != null && level1.Type == JTokenType.Array)
            {
                JArray array = (JArray)level1;

                foreach (JToken token in array)
                {
                    if (token.Type == JTokenType.Object)
                    {
                        string filename = ((JObject)token).GetValue("Keymap").ToString();
                        if (filename == keymap.Filename)
                        {
                            ((JObject)token).Remove("Search");
                            ((JObject)token).Add("Search", search);

                            this.jsonObj.Remove("Applications");
                            this.jsonObj.Add("Applications", array);

                            save();

                            return;
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void selectKeymap(Keymap keymap)
        {
            this.currentKeymap = keymap;

            this.tbKeymapTitle.Text = keymap.getName();
            string searchstring = KeymapDatabase.Current.getKeymapSettings().getSearchStringFor(this.currentKeymap);

            if (searchstring != null && searchstring != "")
            {
                this.tbApplicationSearch.Text       = searchstring;
                this.tbApplicationSearch.Foreground = new SolidColorBrush(Colors.Black);
            }
            else
            {
                this.tbApplicationSearch.Text       = this.tbApplicationSearch.Tag.ToString();
                this.tbApplicationSearch.Foreground = new SolidColorBrush(Colors.Gray);
            }
            this.cbApplicationSearch.IsChecked = KeymapDatabase.Current.getKeymapSettings().isInApplicationSearch(this.currentKeymap);
            this.cbLayoutChooser.IsChecked     = KeymapDatabase.Current.getKeymapSettings().isInLayoutChooser(this.currentKeymap);

            this.tbDelete.Visibility = this.currentKeymap.Filename == KeymapDatabase.Current.getKeymapSettings().getDefaultKeymap() ? Visibility.Hidden : Visibility.Visible;

            this.fillConnectionLists(keymap, 0);

            this.fillKeymapList(KeymapDatabase.Current.getAllKeymaps());
        }
Exemplo n.º 7
0
 public bool deleteKeymap(Keymap keymap)
 {
     if (keymap.Filename == this.getKeymapSettings().getDefaultKeymap())
     {
         return(false);
     }
     this.getKeymapSettings().removeFromLayoutChooser(keymap);
     this.getKeymapSettings().removeFromApplicationSearch(keymap);
     File.Delete(Settings.Default.keymaps_path + keymap.Filename);
     return(true);
 }
Exemplo n.º 8
0
        public bool isInApplicationSearch(Keymap keymap)
        {
            List <ApplicationSearchSetting> allKeymaps = this.getApplicationSearchSettings();

            foreach (ApplicationSearchSetting setting in allKeymaps)
            {
                if (setting.Keymap == keymap.Filename)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 9
0
        private void fillConnectionLists(Keymap keymap, int wiimote)
        {
            bool defaultKeymap = wiimote == 0 && keymap.Filename == KeymapDatabase.Current.getDefaultKeymap().Filename;

            this.spWiimoteConnections.Children.Clear();
            this.spNunchukConnections.Children.Clear();
            this.spClassicConnections.Children.Clear();

            this.appendConnectionList(KeymapDatabase.Current.getAvailableInputs(KeymapInputSource.IR), keymap, wiimote, defaultKeymap, this.spWiimoteConnections);
            this.appendConnectionList(KeymapDatabase.Current.getAvailableInputs(KeymapInputSource.WIIMOTE), keymap, wiimote, defaultKeymap, this.spWiimoteConnections);
            this.appendConnectionList(KeymapDatabase.Current.getAvailableInputs(KeymapInputSource.NUNCHUK), keymap, wiimote, defaultKeymap, this.spNunchukConnections);
            this.appendConnectionList(KeymapDatabase.Current.getAvailableInputs(KeymapInputSource.CLASSIC), keymap, wiimote, defaultKeymap, this.spClassicConnections);
        }
Exemplo n.º 10
0
        public bool isInLayoutChooser(Keymap keymap)
        {
            List <LayoutChooserSetting> allKeymaps = this.getLayoutChooserSettings();

            foreach (LayoutChooserSetting setting in allKeymaps)
            {
                if (setting.Keymap == keymap.Filename)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 11
0
        public string getSearchStringFor(Keymap keymap)
        {
            List <ApplicationSearchSetting> allKeymaps = this.getApplicationSearchSettings();

            foreach (ApplicationSearchSetting setting in allKeymaps)
            {
                if (setting.Keymap == keymap.Filename)
                {
                    return(setting.Search);
                }
            }
            return(null);
        }
Exemplo n.º 12
0
 private void appendConnectionList(List <KeymapInput> list, Keymap keymap, int wiimote, bool defaultKeymap, Panel container)
 {
     foreach (KeymapInput input in list)
     {
         KeymapOutConfig config = keymap.getConfigFor(wiimote, input.Key);
         if (config != null)
         {
             KeymapConnectionRow row = new KeymapConnectionRow(input, config, defaultKeymap);
             row.OnConfigChanged += connectionRow_OnConfigChanged;
             row.OnDragStart     += output_OnDragStart;
             row.OnDragStop      += output_OnDragStop;
             container.Children.Add(row);
         }
     }
 }
Exemplo n.º 13
0
 public Keymap(Keymap parent, string filename)
 {
     this.Parent   = parent;
     this.Filename = filename;
     if (File.Exists(Settings.Default.keymaps_path + filename))
     {
         StreamReader reader = File.OpenText(Settings.Default.keymaps_path + filename);
         this.jsonObj = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
         reader.Close();
     }
     else
     {
         this.jsonObj = new JObject();
         this.jsonObj.Add("Title", "New Keymap");
         save();
     }
 }
Exemplo n.º 14
0
 public Keymap(Keymap parent, string filename)
 {
     this.Parent = parent;
     this.Filename = filename;
     if (File.Exists(Settings.Default.keymaps_path + filename))
     {
         StreamReader reader = File.OpenText(Settings.Default.keymaps_path + filename);
         this.jsonObj = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
         reader.Close();
     }
     else
     {
         this.jsonObj = new JObject();
         this.jsonObj.Add("Title", "New Keymap");
         save();
     }
 }
Exemplo n.º 15
0
        public Action <Keymap> OnClick; //filename

        public KeymapRow(Keymap keymap, bool active, bool defaultk)
        {
            InitializeComponent();
            this.keymap      = keymap;
            this.tbName.Text = keymap.getName();

            if (active)
            {
                this.border.Background = highlightBrush;
            }
            else
            {
                this.border.MouseUp += border_MouseUp;
                this.border.Cursor   = Cursors.Hand;
            }
            if (defaultk)
            {
                this.tbDefault.Visibility = Visibility.Visible;
            }
        }
Exemplo n.º 16
0
        public KeymapRow(Keymap keymap, bool active, bool defaultk)
        {
            InitializeComponent();
            this.keymap = keymap;
            this.tbName.Text = keymap.getName();

            if (active)
            {
                this.border.Background = highlightBrush;
            }
            else
            {
                this.border.MouseUp += border_MouseUp;
                this.border.Cursor = Cursors.Hand;
            }
            if (defaultk)
            {
                this.tbDefault.Visibility = Visibility.Visible;
            }
        }
Exemplo n.º 17
0
        public List <Keymap> getAllKeymaps()
        {
            List <Keymap> list = new List <Keymap>();

            string[] files = Directory.GetFiles(Settings.Default.keymaps_path, "*.json");
            string   defaultKeymapFilename = this.getKeymapSettings().getDefaultKeymap();

            Keymap defaultKeymap = new Keymap(null, defaultKeymapFilename);

            list.Add(defaultKeymap);

            foreach (string filepath in files)
            {
                string filename = Path.GetFileName(filepath);
                if (filename != Settings.Default.keymaps_config && filename != defaultKeymapFilename)
                {
                    list.Add(new Keymap(defaultKeymap, filename));
                }
            }
            return(list);
        }
Exemplo n.º 18
0
 private void rClear_MouseUp(object sender, MouseButtonEventArgs e)
 {
     if (this.config.Stack.Count == 1)
     {
         if (this.fromDefault)
         {
             this.SetConfig(new KeymapOutConfig(KeymapDatabase.Current.getDisableOutput(), false));
         }
         else
         {
             Keymap defaultKeymap = KeymapDatabase.Current.getDefaultKeymap();
             this.config.Stack     = defaultKeymap.getConfigFor(0, this.input.Key).Stack;
             this.config.Inherited = true;
             this.SetConfig(this.config);
         }
     }
     else if (this.config.Stack.Count > 1)
     {
         this.config.Stack.RemoveAt(this.config.Stack.Count - 1);
         this.SetConfig(this.config);
     }
 }
        private void selectKeymap(Keymap keymap)
        {
            this.currentKeymap = keymap;

            this.tbKeymapTitle.Text = keymap.getName();
            string searchstring = KeymapDatabase.Current.getKeymapSettings().getSearchStringFor(this.currentKeymap);
            if (searchstring != null && searchstring != "")
            {
                this.tbApplicationSearch.Text = searchstring;
                this.tbApplicationSearch.Foreground = new SolidColorBrush(Colors.Black);
            }
            else
            {
                this.tbApplicationSearch.Text = this.tbApplicationSearch.Tag.ToString();
                this.tbApplicationSearch.Foreground = new SolidColorBrush(Colors.Gray);
            }
            this.cbApplicationSearch.IsChecked = KeymapDatabase.Current.getKeymapSettings().isInApplicationSearch(this.currentKeymap);
            this.cbLayoutChooser.IsChecked = KeymapDatabase.Current.getKeymapSettings().isInLayoutChooser(this.currentKeymap);

            this.tbDelete.Visibility = this.currentKeymap.Filename == KeymapDatabase.Current.getKeymapSettings().getDefaultKeymap() ? Visibility.Hidden : Visibility.Visible;

            this.fillConnectionLists(keymap, 0);

            this.fillKeymapList(KeymapDatabase.Current.getAllKeymaps());
        }
Exemplo n.º 20
0
        public void addToLayoutChooser(Keymap keymap)
        {
            if (this.isInLayoutChooser(keymap))
            {
                return;
            }

            JToken level1 = this.jsonObj.GetValue("LayoutChooser");
            if (level1 == null)
            {
                this.jsonObj.Add("LayoutChooser",new JArray());
            }
            level1 = this.jsonObj.GetValue("LayoutChooser");
            JArray array = (JArray)level1;

            JObject newObj = new JObject();
            newObj.Add("Title", keymap.getName());
            newObj.Add("Keymap", keymap.Filename);
            array.Add(newObj);

            this.jsonObj.Remove("LayoutChooser");
            this.jsonObj.Add("LayoutChooser",array);

            save();
        }
Exemplo n.º 21
0
        public void setSearchStringFor(Keymap keymap, string search)
        {
            if (!isInApplicationSearch(keymap))
            {
                return;
            }

            JToken level1 = this.jsonObj.GetValue("Applications");
            if (level1 != null && level1.Type == JTokenType.Array)
            {
                JArray array = (JArray)level1;

                foreach (JToken token in array)
                {
                    if (token.Type == JTokenType.Object)
                    {
                        string filename = ((JObject)token).GetValue("Keymap").ToString();
                        if (filename == keymap.Filename)
                        {
                            ((JObject)token).Remove("Search");
                            ((JObject)token).Add("Search",search);

                            this.jsonObj.Remove("Applications");
                            this.jsonObj.Add("Applications", array);

                            save();

                            return;
                        }
                    }
                }

            }
        }
Exemplo n.º 22
0
        public void removeFromLayoutChooser(Keymap keymap)
        {
            if (!this.isInLayoutChooser(keymap))
            {
                return;
            }

            JToken level1 = this.jsonObj.GetValue("LayoutChooser");
            if (level1 != null && level1.Type == JTokenType.Array)
            {
                JArray array = (JArray)level1;

                foreach (JToken token in array)
                {
                    if (token.Type == JTokenType.Object)
                    {
                        string filename = ((JObject)token).GetValue("Keymap").ToString();

                        if (filename == keymap.Filename)
                        {
                            token.Remove();

                            this.jsonObj.Remove("LayoutChooser");
                            this.jsonObj.Add("LayoutChooser",array);

                            save();
                            return;
                        }
                    }
                }
            }
        }
Exemplo n.º 23
0
        public bool isInLayoutChooser(Keymap keymap)
        {
            List<LayoutChooserSetting> allKeymaps = this.getLayoutChooserSettings();

            foreach (LayoutChooserSetting setting in allKeymaps)
            {
                if (setting.Keymap == keymap.Filename)
                {
                    return true;
                }
            }
            return false;
        }
Exemplo n.º 24
0
        public bool isInApplicationSearch(Keymap keymap)
        {
            List<ApplicationSearchSetting> allKeymaps = this.getApplicationSearchSettings();

            foreach (ApplicationSearchSetting setting in allKeymaps)
            {
                if (setting.Keymap == keymap.Filename)
                {
                    return true;
                }
            }
            return false;
        }
Exemplo n.º 25
0
        public string getSearchStringFor(Keymap keymap)
        {
            List<ApplicationSearchSetting> allKeymaps = this.getApplicationSearchSettings();

            foreach (ApplicationSearchSetting setting in allKeymaps)
            {
                if (setting.Keymap == keymap.Filename)
                {
                    return setting.Search;
                }
            }
            return null;
        }
Exemplo n.º 26
0
        private void bAddKeymap_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Keymap newKeymap = KeymapDatabase.Current.createNewKeymap();

            selectKeymap(newKeymap);
        }
 private void appendConnectionList(List<KeymapInput> list, Keymap keymap, int wiimote, bool defaultKeymap, Panel container)
 {
     foreach (KeymapInput input in list)
     {
         KeymapOutConfig config = keymap.getConfigFor(wiimote, input.Key);
         if (config != null)
         {
             KeymapConnectionRow row = new KeymapConnectionRow(input, config, defaultKeymap);
             row.OnConfigChanged += connectionRow_OnConfigChanged;
             row.OnDragStart += output_OnDragStart;
             row.OnDragStop += output_OnDragStop;
             container.Children.Add(row);
         }
     }
 }
        private void fillConnectionLists(Keymap keymap, int wiimote)
        {
            bool defaultKeymap = wiimote == 0 && keymap.Filename == KeymapDatabase.Current.getDefaultKeymap().Filename;

            this.spWiimoteConnections.Children.Clear();
            this.spNunchukConnections.Children.Clear();
            this.spClassicConnections.Children.Clear();

            this.appendConnectionList(KeymapDatabase.Current.getAvailableInputs(KeymapInputSource.IR), keymap, wiimote, defaultKeymap, this.spWiimoteConnections);
            this.appendConnectionList(KeymapDatabase.Current.getAvailableInputs(KeymapInputSource.WIIMOTE), keymap, wiimote, defaultKeymap, this.spWiimoteConnections);
            this.appendConnectionList(KeymapDatabase.Current.getAvailableInputs(KeymapInputSource.NUNCHUK), keymap, wiimote, defaultKeymap, this.spNunchukConnections);
            this.appendConnectionList(KeymapDatabase.Current.getAvailableInputs(KeymapInputSource.CLASSIC), keymap, wiimote, defaultKeymap, this.spClassicConnections);
        }