コード例 #1
0
ファイル: KeymapSettings.cs プロジェクト: unknownnf/Touchmote
        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();
        }
コード例 #2
0
ファイル: KeymapSettings.cs プロジェクト: unknownnf/Touchmote
        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;
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: KeymapSettings.cs プロジェクト: unknownnf/Touchmote
        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();
        }
コード例 #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();
        }
コード例 #5
0
ファイル: KeymapSettings.cs プロジェクト: unknownnf/Touchmote
        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;
                        }
                    }
                }
            }
        }
コード例 #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());
        }
コード例 #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);
 }
コード例 #8
0
ファイル: KeymapSettings.cs プロジェクト: unknownnf/Touchmote
        public bool isInApplicationSearch(Keymap keymap)
        {
            List <ApplicationSearchSetting> allKeymaps = this.getApplicationSearchSettings();

            foreach (ApplicationSearchSetting setting in allKeymaps)
            {
                if (setting.Keymap == keymap.Filename)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #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);
        }
コード例 #10
0
ファイル: KeymapSettings.cs プロジェクト: unknownnf/Touchmote
        public bool isInLayoutChooser(Keymap keymap)
        {
            List <LayoutChooserSetting> allKeymaps = this.getLayoutChooserSettings();

            foreach (LayoutChooserSetting setting in allKeymaps)
            {
                if (setting.Keymap == keymap.Filename)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #11
0
ファイル: KeymapSettings.cs プロジェクト: unknownnf/Touchmote
        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);
        }
コード例 #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);
         }
     }
 }
コード例 #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();
     }
 }
コード例 #14
0
ファイル: Keymap.cs プロジェクト: joshreve/Touchmote
 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();
     }
 }
コード例 #15
0
ファイル: KeymapRow.xaml.cs プロジェクト: unknownnf/Touchmote
        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;
            }
        }
コード例 #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;
            }
        }
コード例 #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);
        }
コード例 #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);
     }
 }
コード例 #19
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());
        }
コード例 #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();
        }
コード例 #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;
                        }
                    }
                }

            }
        }
コード例 #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;
                        }
                    }
                }
            }
        }
コード例 #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;
        }
コード例 #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;
        }
コード例 #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;
        }
コード例 #26
0
        private void bAddKeymap_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Keymap newKeymap = KeymapDatabase.Current.createNewKeymap();

            selectKeymap(newKeymap);
        }
コード例 #27
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);
         }
     }
 }
コード例 #28
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);
        }